Skip to content

Commit

Permalink
Fix RTTI initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Sep 27, 2023
1 parent f097d9b commit 6c258e3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ida/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]),
Expand Down
2 changes: 1 addition & 1 deletion src/reverse/Addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions src/scripting/LuaVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 3 additions & 9 deletions src/scripting/LuaVM_Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6c258e3

Please sign in to comment.