mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-26 17:36:05 -05:00
move Addresser::followThunkFunction to source
This commit is contained in:
parent
cb9c26b597
commit
37361269ec
2 changed files with 14 additions and 12 deletions
|
@ -163,18 +163,7 @@ namespace geode::addresser {
|
|||
return addressOfNonVirtual(reinterpret_cast<R (T::*)(Ps...)>(func));
|
||||
}
|
||||
|
||||
static inline intptr_t 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);
|
||||
}
|
||||
#endif
|
||||
return address;
|
||||
}
|
||||
static intptr_t followThunkFunction(intptr_t address);
|
||||
|
||||
template <typename R, typename T, typename... Ps>
|
||||
static intptr_t addressOfNonVirtual(R (T::*func)(Ps...)) {
|
||||
|
|
|
@ -65,3 +65,16 @@ namespace {
|
|||
Addresser::MultipleInheritance* Addresser::instance() {
|
||||
return reinterpret_cast<Addresser::MultipleInheritance*>(&TableTable::table);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
return address;
|
||||
}
|
Loading…
Reference in a new issue