From 37361269ec18749ecf2911fd4c149320cb39074c Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Tue, 14 Feb 2023 18:15:13 -0300 Subject: [PATCH] move Addresser::followThunkFunction to source --- loader/include/Geode/utils/addresser.hpp | 13 +------------ loader/src/utils/addresser.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/loader/include/Geode/utils/addresser.hpp b/loader/include/Geode/utils/addresser.hpp index eb458ffa..7b4a5adb 100644 --- a/loader/include/Geode/utils/addresser.hpp +++ b/loader/include/Geode/utils/addresser.hpp @@ -163,18 +163,7 @@ namespace geode::addresser { return addressOfNonVirtual(reinterpret_cast(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(address) == 0xFF && *reinterpret_cast(address + 1) == 0x25) { - // read where the jmp reads from - address = *reinterpret_cast(address + 2); - // that then contains the actual address of the func - address = *reinterpret_cast(address); - } -#endif - return address; - } + static intptr_t followThunkFunction(intptr_t address); template static intptr_t addressOfNonVirtual(R (T::*func)(Ps...)) { diff --git a/loader/src/utils/addresser.cpp b/loader/src/utils/addresser.cpp index d9a4c9b8..9fd65c2f 100644 --- a/loader/src/utils/addresser.cpp +++ b/loader/src/utils/addresser.cpp @@ -65,3 +65,16 @@ namespace { Addresser::MultipleInheritance* Addresser::instance() { return reinterpret_cast(&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(address) == 0xFF && *reinterpret_cast(address + 1) == 0x25) { + // read where the jmp reads from + address = *reinterpret_cast(address + 2); + // that then contains the actual address of the func + address = *reinterpret_cast(address); + } +#endif + return address; +} \ No newline at end of file