Skip to content

Commit

Permalink
add missing ToStringDEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamashi committed Feb 15, 2022
1 parent c42c7f7 commit be28b93
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
1 change: 1 addition & 0 deletions ida/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_groups() -> List[Group]:
Item(name='RunPureScript', pattern='40 55 48 81 EC D0 00 00 00 48 8D 6C 24 40 8B', expected=1),
Item(name='AllocateFunction', pattern='BA B8 00 00 00 48 8D 4D D7 E8', expected=3, index=0, offset=10),
Item(name='Log', pattern='40 53 48 83 EC ? 48 8D 4C 24 20 48 8B DA E8 ? ? ? ? 33 D2 48 8D 4C 24 40 E8', expected=1),
Item(name='ToStringDEBUG', pattern='48 89 5C 24 08 57 48 83 EC 20 FE 42 62 4C 8D 15 ? ? ? ? 33 C9 33 C0', expected=4, index=2),
Item(name='LogChannel', pattern='4C 8B DC 49 89 5B 08 49 89 73 18 57 48 83 EC 70 48 8B 02 ? ? ? ? ? ? ? FE 42 62 4D 8D 43 10 33 FF 45 33 C9 49 89 7B 10 48 8B DA 48 89 7A', expected=1),
Item(name='TDBIDConstructorDerive', pattern='40 53 48 83 EC 30 33 C0 4C 89 44 24 20 48 8B DA', expected=1),
Item(name='ProcessRunningState', pattern='40 53 48 83 EC 20 48 8B 0D ? ? ? ? 48 8B DA E8 ? ? ? ? 84 C0', expected=1),
Expand Down
1 change: 1 addition & 0 deletions src/reverse/Addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ constexpr uintptr_t CRenderNode_Present_DoInternal = 0x142C860B0 - ImageBase; //
constexpr uintptr_t CScript_RunPureScript = 0x140206E70 - ImageBase; // 40 55 48 81 EC D0 00 00 00 48 8D 6C 24 40 8B, expected: 1, index: 0
constexpr uintptr_t CScript_AllocateFunction = 0x1401A7720 - ImageBase; // BA B8 00 00 00 48 8D 4D D7 E8, expected: 3, index: 0
constexpr uintptr_t CScript_Log = 0x1401E90F0 - ImageBase; // 40 53 48 83 EC ? 48 8D 4C 24 20 48 8B DA E8 ? ? ? ? 33 D2 48 8D 4C 24 40 E8, expected: 1, index: 0
constexpr uintptr_t CScript_ToStringDEBUG = 0x140BCA760 - ImageBase; // 48 89 5C 24 08 57 48 83 EC 20 FE 42 62 4C 8D 15 ? ? ? ? 33 C9 33 C0, expected: 4, index: 2
constexpr uintptr_t CScript_LogChannel = 0x1401E9190 - ImageBase; // 4C 8B DC 49 89 5B 08 49 89 73 18 57 48 83 EC 70 48 8B 02 ? ? ? ? ? ? ? FE 42 62 4D 8D 43 10 33 FF 45 33 C9 49 89 7B 10 48 8B DA 48 89 7A, expected: 1, index: 0
constexpr uintptr_t CScript_TDBIDConstructorDerive = 0x142B8E8E0 - ImageBase; // 40 53 48 83 EC 30 33 C0 4C 89 44 24 20 48 8B DA, expected: 1, index: 0
constexpr uintptr_t CScript_ProcessRunningState = 0x140A68BD0 - ImageBase; // 40 53 48 83 EC 20 48 8B 0D ? ? ? ? 48 8B DA E8 ? ? ? ? 84 C0, expected: 1, index: 0
Expand Down
28 changes: 10 additions & 18 deletions src/scripting/LuaVM_Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,19 @@ void LuaVM::Hook(Options& aOptions)
}

{
const mem::pattern cPattern("48 BF 58 D1 78 A0 18 09 BA EC 75 16 48 8D 15 ? ? ? ? 48 8B CF E8 ? ? ? ? C6 05 ?? "
"?? ?? ?? 01 41 8B 06 39 05 ? ? ? ? 7F");
const mem::default_scanner cScanner(cPattern);
uint8_t* pLocation = cScanner(gameImage.TextRegion).as<uint8_t*>();
RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CScript_ToStringDEBUG);
uint8_t* pLocation = func.GetAddr();

if (pLocation)
{
pLocation = &pLocation[45] + static_cast<int8_t>(pLocation[44]);
mem::region reg(pLocation, 45);
const mem::pattern cSecondaryPattern(
"48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 3D ?? ?? ?? ?? FF 75 ?? 48 8D 05");
const mem::default_scanner cSecondaryScanner(cSecondaryPattern);
pLocation = cSecondaryScanner(reg).as<uint8_t*>();
if (pLocation)
if (MH_CreateHook(pLocation, &HookTDBIDToStringDEBUG,
reinterpret_cast<void**>(&m_realTDBIDToStringDEBUG)) !=
MH_OK ||
MH_EnableHook(pLocation) != MH_OK)
Log::Error("Could not hook RunningState::Run function!");
else
{
pLocation = &pLocation[28] + *reinterpret_cast<int32_t*>(&pLocation[24]);
if (MH_CreateHook(pLocation, &HookTDBIDToStringDEBUG,
reinterpret_cast<void**>(&m_realTDBIDToStringDEBUG)) != MH_OK ||
MH_EnableHook(pLocation) != MH_OK)
Log::Error("Could not hook TDBID::ToStringDEBUG function!");
else
Log::Info("TDBID::ToStringDEBUG function hook complete!");
Log::Info("RunningState::Run function hook complete!");
}
}
}
Expand Down

0 comments on commit be28b93

Please sign in to comment.