C++ mid-function hook: get register values and jump back [x86 assembly on windows]

我只是一个虾纸丫 提交于 2019-12-05 22:24:07

You can get the value of the last EBP from the stack.

It is the first value that is pushed on the stack when you call your function. If I am not mistaken it will be at [EBP].

As for the jump, can you make it so that instead of jumping to the hook, you call it? After the function returns the code will continue from the next address.

The reason you are getting an error is because you never reach the end of the function. Normally a function contains a prologue and an epilogue, where stack pointers are saved and retrieved.

Prologue:

push ebp
mov  ebp, esp

Epilogue:

pop ebp

Since you never reach the end of the function, the pop is not called, and your stack is corrupted.

The error you are getting with the jump is because you are jumping to a location pointed to by the memory in the address 0x46AA87. You probably wanted to jump to the address, so the brackets are unnecessary.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!