From 6c258e331883d61510f5d2e8b6890c51c92f220a Mon Sep 17 00:00:00 2001 From: pv Date: Wed, 27 Sep 2023 08:23:13 +0300 Subject: [PATCH] Fix RTTI initialization --- ida/patterns.py | 2 +- src/reverse/Addresses.h | 2 +- src/scripting/LuaVM.h | 4 ++-- src/scripting/LuaVM_Hooks.cpp | 12 +++--------- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ida/patterns.py b/ida/patterns.py index 38bf2169..ece6e785 100644 --- a/ida/patterns.py +++ b/ida/patterns.py @@ -48,7 +48,7 @@ def get_groups() -> List[Group]: Item(name='LogChannel', pattern='48 89 5C 24 08 48 89 74 24 18 55 48 8B EC 48 83 EC 70 48 8B 02 48 8D 35 ? ? ? ? 48 83 65 18 00 4C 8D 45 18 48 83 62 30 00 45 33 C9 48 83 62 38 00', expected=2, index=0), # ok Item(name='LogChannelWarning', pattern='48 89 5C 24 08 48 89 74 24 18 55 48 8B EC 48 83 EC 70 48 8B 02 48 8D 35 ? ? ? ? 48 83 65 18 00 4C 8D 45 18 48 83 62 30 00 45 33 C9 48 83 62 38 00', expected=2, index=1), # ok Item(name='TDBIDConstructorDerive', pattern='48 89 5C 24 10 48 89 6C 24 18 48 89 74 24 20 57 45 33 C9 48 8B FA', expected=1), # ok - Item(name='TranslateBytecode', pattern='40 53 55 56 57 41 54 41 56 41 57 48 83 EC 60 48 8B 1A 48 8B E9 8B 42 0C 4C 8D 24 C3'), # ok + Item(name='TranslateBytecode', pattern='48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B 1A 48 8B E9 8B 42 0C', expected=2), # ok Item(name='TweakDBLoad', pattern='48 89 5C 24 10 48 89 7C 24 18 55 48 8B EC 48 83 EC 70 48 8B F9 48 8B DA 48 8B 0D ? ? ? ? 48 8B 01 FF 90 B8 00 00 00', expected=1), # ok Item(name='RegisterMemberFunction', pattern='40 53 48 83 EC 20 49 8B C1 4D 8B D0 44 8B 4C 24 58 4C 8B DA 41 83 C9 03 4C 8B C0 49 8B D2 48 8B D9 E8', expected=1) # ok ]), diff --git a/src/reverse/Addresses.h b/src/reverse/Addresses.h index fa922502..c47414ac 100644 --- a/src/reverse/Addresses.h +++ b/src/reverse/Addresses.h @@ -71,7 +71,7 @@ constexpr uintptr_t CScript_LogChannelWarning = 0x141F9E2F8 - ImageBase; // 48 8 // 18 48 83 62 30 00 45 33 C9 48 83 62 38 00, expected: 2, index: 1 constexpr uintptr_t CScript_TDBIDConstructorDerive = 0x1405981F8 - ImageBase; // 48 89 5C 24 10 48 89 6C 24 18 48 89 74 24 20 57 45 33 C9 48 8B FA, expected: 1, index: 0 constexpr uintptr_t CScript_TranslateBytecode = - 0x140601D84 - ImageBase; // 40 53 55 56 57 41 54 41 56 41 57 48 83 EC 60 48 8B 1A 48 8B E9 8B 42 0C 4C 8D 24 C3, expected: 1, index: 0 + 0x14021CA60 - ImageBase; // 48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B 1A 48 8B E9 8B 42 0C, expected: 2, index: 0 constexpr uintptr_t CScript_TweakDBLoad = 0x141410CBC - ImageBase; // 48 89 5C 24 10 48 89 7C 24 18 55 48 8B EC 48 83 EC 70 48 8B F9 48 8B DA 48 8B 0D ? ? ? ? 48 8B 01 FF 90 B8 00 00 00, expected: 1, index: 0 constexpr uintptr_t CScript_RegisterMemberFunction = diff --git a/src/scripting/LuaVM.h b/src/scripting/LuaVM.h index 5ee9af16..c0881ac6 100644 --- a/src/scripting/LuaVM.h +++ b/src/scripting/LuaVM.h @@ -13,7 +13,7 @@ using TRunningStateRun = bool(uintptr_t, uintptr_t); using TShutdownStateRun = bool(uintptr_t, uintptr_t); using TSetLoadingState = uintptr_t(uintptr_t, int); using TTweakDBLoad = uint64_t(uintptr_t, uintptr_t); -using TTranslateBytecode = bool(uintptr_t, uintptr_t); +using TTranslateBytecode = void(uintptr_t, uintptr_t); using TPlayerSpawned = uint64_t(uint64_t, uint64_t, uint64_t, uint64_t); struct TDBIDLookupEntry @@ -70,7 +70,7 @@ struct LuaVM static TDBID* HookTDBIDCtorDerive(TDBID* apBase, TDBID* apThis, const char* acpName); static uintptr_t HookSetLoadingState(uintptr_t aThis, int aState); static uint64_t HookTweakDBLoad(uintptr_t aThis, uintptr_t aParam); - static bool HookTranslateBytecode(uintptr_t aBinder, uintptr_t aData); + static void HookTranslateBytecode(uintptr_t aBinder, uintptr_t aData); static uint64_t HookPlayerSpawned(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4); private: diff --git a/src/scripting/LuaVM_Hooks.cpp b/src/scripting/LuaVM_Hooks.cpp index f6790b27..fdaa176a 100644 --- a/src/scripting/LuaVM_Hooks.cpp +++ b/src/scripting/LuaVM_Hooks.cpp @@ -309,16 +309,10 @@ void LuaVM::HookTDBIDToStringDEBUG(RED4ext::IScriptable*, RED4ext::CStackFrame* } } -bool LuaVM::HookTranslateBytecode(uintptr_t aBinder, uintptr_t aData) +void LuaVM::HookTranslateBytecode(uintptr_t aBinder, uintptr_t aData) { - const auto ret = s_vm->m_realTranslateBytecode(aBinder, aData); - - if (ret) - { - s_vm->PostInitializeScripting(); - } - - return ret; + s_vm->m_realTranslateBytecode(aBinder, aData); + s_vm->PostInitializeScripting(); } uint64_t LuaVM::HookPlayerSpawned(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4)