将例程的内容复制到内存中的另一个位置
问题描述:
我想将内存中的例程代码复制到另一个位置。对于例如将例程的内容复制到内存中的另一个位置
procedure OldShowMessage;
begin
ShowMessage('Old message..');
end;
说我想复制例程到内存中的另一个位置。我宣布类似
var
lopShowMessage : procedure; // procedural pointer.
一些伪代码会像
// VirtualProtect(@OldShowMessage, <length of routine>, ..., ...);
// Allocate memory
// lopShowMessage := AllocMem(<length of routine>);
// Move(@OldMessage, Pointer(lopShowMessage)^, <length of routine>);
// FlushInstructioncache.....
我只是想知道是否有这样做的可能性。我修补了一个例程来调用一个新的例程,但是由于我们使用代码绕道来放置JMP指令,因此我可能无法使用旧例程中提供的功能。
一种我刚才的问题引用here
为什么这会降低投票率?这是一个有效的答案。 – 2012-03-02 23:38:04