Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Commit 14b7b25

Browse files
committed
earlier hooking, log archive loads
1 parent 11621f4 commit 14b7b25

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎src/experiments/Game.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ inline void SetPattern(TFn& func, const char(&pattern)[Len], int offset = 0)
88
}
99

1010
AddLocalizationEntry_t AddLocalizationEntry;
11+
GetArchiveName_t GetArchiveName;
1112

1213
void AddGameFunctions()
1314
{
1415
SetPattern(AddLocalizationEntry, "48 85 D2 74 10 48 C7 C0 FF", -21);
16+
SetPattern(GetArchiveName, "81 79 14 00 00 00 40 48 8B C1");
1517
//SetPattern(Name2Hash, "48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC ? 4C 8B F1 48 8B F2 48 8B CA E8 ? ? ? ? 48");
1618
//SetPattern(Hash2Name, "48 83 EC ? 33 C0 48 89 54 24 ? 48 85 D2 74 ? 38 02 74 ? 48");
1719
}

‎src/experiments/Game.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
typedef void(__cdecl* AddLocalizationEntry_t)(const char* text, const char* locKey);
2-
extern AddLocalizationEntry_t AddLocalizationEntry;
2+
extern AddLocalizationEntry_t AddLocalizationEntry;
3+
4+
typedef const char* (__cdecl* GetArchiveName_t)(void* archive);
5+
extern GetArchiveName_t GetArchiveName;

‎src/experiments/Main.cpp‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,22 @@ __int64 Hook_SomeLogFunc(__int64 a1, const char** a2)
5959
return Orig_SomeLogFunc(a1, a2);
6060
}
6161

62+
static void(__cdecl* Orig_LoadArchive)(void* a1, __int64* a2);
63+
void Hook_LoadArchive(void* a1, __int64* a2)
64+
{
65+
auto an = GetArchiveName(a2);
66+
logger::write("Loading archive %s", an);
67+
Orig_LoadArchive(a1, a2);
68+
}
69+
6270
// Game.cpp
6371
void AddGameFunctions();
6472

6573
DWORD WINAPI OnAttach(LPVOID lpParameter)
6674
{
6775
logger::write("[+] OnAttach");
6876

69-
//AddGameFunctions();
77+
AddGameFunctions();
7078

7179
hashes = fopen("hashes.txt", "w");
7280

@@ -79,6 +87,7 @@ DWORD WINAPI OnAttach(LPVOID lpParameter)
7987
MH_CreateHook(hook::get_pattern("48 83 EC 38 33 C0 48 89 54 24 20"), Hook_RegisterHashString, (void**)&Orig_RegisterHashString);
8088
MH_CreateHook(hook::get_pattern("48 83 EC 38 33 C0 48 89 54 24 20"), Hook_RegisterHashString, (void**)&Orig_RegisterHashString);
8189
//MH_CreateHook(hook::get_pattern("48 89 5C 24 08 57 48 83 EC 20 41 B9 40"), Hook_SomeLogFunc, (void**)Orig_SomeLogFunc);
90+
MH_CreateHook(hook::get_pattern("48 8D 54 24 20 E8 ? ? ? ? EB 05", -0x47), Hook_LoadArchive, (void**)&Orig_LoadArchive);
8291

8392
if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK)
8493
{
@@ -132,7 +141,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
132141
freopen("CON", "w", stdout);
133142
freopen("CONIN$", "r", stdin);
134143

135-
CreateThread(nullptr, 0, OnAttach, hModule, 0, nullptr);
144+
OnAttach(hModule);
145+
//CreateThread(nullptr, 0, OnAttach, hModule, 0, nullptr);
136146
}
137147

138148
if (ul_reason_for_call == DLL_PROCESS_DETACH)

0 commit comments

Comments
 (0)