-
-
Notifications
You must be signed in to change notification settings - Fork 172
Relocation of conditional jumps: x64 MessageBox #3
Comments
Its my test code
It can jump into hooked func,but when return to original func,it crashed |
use the same code , run the x86 bin , it goes well. |
it's failing to relocate the je opcode, you can see that just before the push rax line. This is an error specific to x64. The reason this happens is because the address space x64 is much larger than the +-2GB of x86 so opcodes that have small offsets (31 bytes in this JE case) cannot be properly moved as the trampoline copies them significanly farther than their opcode supports a jump to. The only possible way to fix this would be to re-encode the instruction itself into one that supports a farther jump but that is significantly more work and i am willing to do at this moment. You can notice that i have already documented this bug under #1. You will be hard pressed to find any x64 hooking library that properly supports this case, i may decide to fix it waaaaay down the road but like i said it's alot of work so it will be a long time if i ever do. On the bright side this is also a not very common case so if you hook another function chances are it would work properly |
I decided to spend the day and fix this, the working code can now be found under my "development" branch, please check this out and get back to me if this fixes your issue. It's been fixed by building up a jump table at the end of the trampoline, the conditional jumps are re-encoded to point to an absolute jump that then points to the final destination, so je->jmp->destination |
wait a moment , I'll check it , thx |
the testing is ok. |
if you could get back to me on how your additional tests went that would be great, i would like to close this issue if it's been properly fixed |
How can use this lib to hook windows api ,
can you give a example plz?~
The text was updated successfully, but these errors were encountered: