relativeToAbsolute #3424
-
I've been looking at the hooking method Osiris uses on Linux to hook SDL_SwapWindow and SDL_PollEvent and I just have a few questions. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In your example bytes:
Absolute address is calculated by adding the offset to the address of the next instruction after rel jmp (which is the address of the offset + 4). You can also remove the
Bonus: |
Beta Was this translation helpful? Give feedback.
In your example bytes:
FF 25
is the opcode of a relative jump with 4-byte offsetCAFC3200
- is the offsetAbsolute address is calculated by adding the offset to the address of the next instruction after rel jmp (which is the address of the offset + 4).
You can also remove the
+ 2
and then (pointer
being std::uintptr_t):*(int*)(pointer + 2)
pointer + 6
relativeToAbsolute
requires input address to point to the offset, not to the opcode, because it also has to support call instruction with relative offset whose opcode (E8) is a single byte.Bonus:
The offset in relative jump is a signed integer so you can jump backwards. I've seen some source…