将例程的内容复制到内存中的另一个位置
我想将内存中的例程代码复制到另一个位置。例如,假设
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 指令,我可能无法使用旧例程中提供的功能。
我上一个问题的参考是此处
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您阅读了 Detours 实际工作原理的技术细节,您将请注意,您可以通过使用
蹦床
作为绕行的一部分来利用旧例行程序。然后,只要您想调用旧例程,就可以调用蹦床。If you read up on the technical details of how Detours actually work, you will see that you can make use of the old routine by utilizing a
trampoline
as part of your detour. You can then call the trampoline whenever you want to invoke the old routine.