mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -05:00
(urgent) fix followThunkFunction
it was following hooks for cocos functions, causing bad crashes. instead, now only follow jmp and then jmp dword ptr
This commit is contained in:
parent
2077a238d3
commit
4b7663015a
3 changed files with 20 additions and 14 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.3.8
|
1.3.9
|
||||||
|
|
|
@ -48,7 +48,7 @@ gd::string decompressString2(unsigned char* data, bool decrypt, int size, int de
|
||||||
|
|
||||||
// Modify doesnt want to work for some reason!
|
// Modify doesnt want to work for some reason!
|
||||||
$execute {
|
$execute {
|
||||||
Mod::get()->addHook(
|
(void) Mod::get()->addHook(
|
||||||
reinterpret_cast<void*>(
|
reinterpret_cast<void*>(
|
||||||
geode::addresser::getNonVirtual(
|
geode::addresser::getNonVirtual(
|
||||||
&cocos2d::ZipUtils::decompressString2
|
&cocos2d::ZipUtils::decompressString2
|
||||||
|
|
|
@ -68,20 +68,26 @@ Addresser::MultipleInheritance* Addresser::instance() {
|
||||||
|
|
||||||
intptr_t Addresser::followThunkFunction(intptr_t address) {
|
intptr_t Addresser::followThunkFunction(intptr_t address) {
|
||||||
#ifdef GEODE_IS_WINDOWS
|
#ifdef GEODE_IS_WINDOWS
|
||||||
for (int limit = 0; limit < 100; ++limit) {
|
// if theres a jmp at the start
|
||||||
// check if first instruction is a jmp dword ptr [....], i.e. if the func is a thunk
|
if (*reinterpret_cast<uint8_t*>(address) == 0xE9) {
|
||||||
if (*reinterpret_cast<uint8_t*>(address) == 0xFF && *reinterpret_cast<uint8_t*>(address + 1) == 0x25) {
|
auto relative = *reinterpret_cast<uint32_t*>(address + 1);
|
||||||
// read where the jmp reads from
|
auto newAddress = address + relative + 5;
|
||||||
address = *reinterpret_cast<uint32_t*>(address + 2);
|
// and if that jmp leads to a jmp dword ptr, only then follow it,
|
||||||
// that then contains the actual address of the func
|
// because otherwise its just a hook.
|
||||||
address = *reinterpret_cast<uintptr_t*>(address);
|
// For some reason this [jmp -> jmp dword ptr] chain happens with a few cocos functions,
|
||||||
} else if (*reinterpret_cast<uint8_t*>(address) == 0xE9) {
|
// but not all. For example: cocos2d::ZipUtils::decompressString2
|
||||||
auto relative = *reinterpret_cast<uint32_t*>(address + 1);
|
if (*reinterpret_cast<uint8_t*>(newAddress) == 0xFF && *reinterpret_cast<uint8_t*>(newAddress + 1) == 0x25) {
|
||||||
address = address + relative + 5;
|
address = newAddress;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
Loading…
Reference in a new issue