I want to copy the routine code in memory to another location. For e.g.
procedure OldShowMessage;
begin
ShowMessage('Old message..');
end;
Say i want to copy the routine to another location in memory. I have declared something like
var
lopShowMessage : procedure; // procedural pointer.
Some pseudo code would be like
// VirtualProtect(@OldShowMessage, <length of routine>, ..., ...);
// Allocate memory
// lopShowMessage := AllocMem(<length of routine>);
// Move(@OldMessage, Pointer(lopShowMessage)^, <length of routine>);
// FlushInstructioncache.....
I just want to know if there is any possibility of doing this. I have patched a routine to call a new routine, but since we place a JMP instruction using code detours, i may not be able to use the functionality provided in the old routine.
A reference for my previous question is here