Skip to content

Commit

Permalink
Manually hook CEngineVGui__Init
Browse files Browse the repository at this point in the history
  • Loading branch information
ASpoonPlaysGames committed Aug 29, 2024
1 parent b01751d commit 185d5d2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions primedev/client/modlocalisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ static void __fastcall h_CLocalize__ReloadLocalizationFiles(void* pVguiLocalize)
o_pCLocalize__ReloadLocalizationFiles(pVguiLocalize);
}

// clang-format off
AUTOHOOK(CEngineVGui__Init, engine.dll + 0x247E10,
void, __fastcall, (void* self))
// clang-format on
static void(__fastcall* o_pCEngineVGui__Init)(void* self) = nullptr;
static void __fastcall h_CEngineVGui__Init(void* self)
{
CEngineVGui__Init(self); // this loads r1_english, valve_english, dev_english
o_pCEngineVGui__Init(self); // this loads r1_english, valve_english, dev_english

// previously we did this in CLocalize::AddFile, but for some reason it won't properly overwrite localization from
// files loaded previously if done there, very weird but this works so whatever
Expand All @@ -46,6 +44,12 @@ void, __fastcall, (void* self))
o_pCLocalise__AddFile(g_pVguiLocalize, localisationFile.c_str(), nullptr, false);
}

ON_DLL_LOAD_CLIENT("engine.dll", VGuiInit, (CModule module))
{
o_pCEngineVGui__Init = module.Offset(0x247E10).RCast<decltype(o_pCEngineVGui__Init)>();
HookAttach(&(PVOID&)o_pCEngineVGui__Init, (PVOID)h_CEngineVGui__Init);
}

ON_DLL_LOAD_CLIENT("localize.dll", Localize, (CModule module))
{
AUTOHOOK_DISPATCH()
Expand Down

0 comments on commit 185d5d2

Please sign in to comment.