mirror of
https://github.com/geode-sdk/geode.git
synced 2025-02-17 00:30:26 -05:00
recursively follow jumps in followThunkFunction
This commit is contained in:
parent
e8a326f7cb
commit
44a018cdf9
1 changed files with 13 additions and 6 deletions
|
@ -68,12 +68,19 @@ Addresser::MultipleInheritance* Addresser::instance() {
|
|||
|
||||
intptr_t Addresser::followThunkFunction(intptr_t address) {
|
||||
#ifdef GEODE_IS_WINDOWS
|
||||
// check if first instruction is a jmp dword ptr [....], i.e. if the func is a thunk
|
||||
if (*reinterpret_cast<uint8_t*>(address) == 0xFF && *reinterpret_cast<uint8_t*>(address + 1) == 0x25) {
|
||||
// read where the jmp reads from
|
||||
address = *reinterpret_cast<uint32_t*>(address + 2);
|
||||
// that then contains the actual address of the func
|
||||
address = *reinterpret_cast<uintptr_t*>(address);
|
||||
for (int limit = 0; limit < 100; ++limit) {
|
||||
// check if first instruction is a jmp dword ptr [....], i.e. if the func is a thunk
|
||||
if (*reinterpret_cast<uint8_t*>(address) == 0xFF && *reinterpret_cast<uint8_t*>(address + 1) == 0x25) {
|
||||
// read where the jmp reads from
|
||||
address = *reinterpret_cast<uint32_t*>(address + 2);
|
||||
// that then contains the actual address of the func
|
||||
address = *reinterpret_cast<uintptr_t*>(address);
|
||||
} else if (*reinterpret_cast<uint8_t*>(address) == 0xE9) {
|
||||
auto relative = *reinterpret_cast<uint32_t*>(address + 1);
|
||||
address = address + relative + 5;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return address;
|
||||
|
|
Loading…
Reference in a new issue