diff options
Diffstat (limited to 'primedev/client')
-rw-r--r-- | primedev/client/audio.cpp | 84 | ||||
-rw-r--r-- | primedev/client/clientauthhooks.cpp | 26 | ||||
-rw-r--r-- | primedev/client/clientruihooks.cpp | 13 | ||||
-rw-r--r-- | primedev/client/clientvideooverrides.cpp | 20 | ||||
-rw-r--r-- | primedev/client/debugoverlay.cpp | 25 | ||||
-rw-r--r-- | primedev/client/languagehooks.cpp | 15 | ||||
-rw-r--r-- | primedev/client/latencyflex.cpp | 13 | ||||
-rw-r--r-- | primedev/client/modlocalisation.cpp | 43 | ||||
-rw-r--r-- | primedev/client/rejectconnectionfixes.cpp | 13 |
9 files changed, 139 insertions, 113 deletions
diff --git a/primedev/client/audio.cpp b/primedev/client/audio.cpp index 63501414..4a759cda 100644 --- a/primedev/client/audio.cpp +++ b/primedev/client/audio.cpp @@ -11,8 +11,6 @@ namespace fs = std::filesystem; -AUTOHOOK_INIT() - static const char* pszAudioEventName; ConVar* Cvar_mileslog_enable; @@ -389,14 +387,12 @@ bool ShouldPlayAudioEvent(const char* eventName, const std::shared_ptr<EventOver return true; // good to go } -// clang-format off -AUTOHOOK(LoadSampleMetadata, mileswin64.dll + 0xF110, -bool, __fastcall, (void* sample, void* audioBuffer, unsigned int audioBufferLength, int audioType)) -// clang-format on +static bool(__fastcall* o_pLoadSampleMetadata)(void* sample, void* audioBuffer, unsigned int audioBufferLength, int audioType) = nullptr; +static bool __fastcall h_LoadSampleMetadata(void* sample, void* audioBuffer, unsigned int audioBufferLength, int audioType) { // Raw source, used for voice data only if (audioType == 0) - return LoadSampleMetadata(sample, audioBuffer, audioBufferLength, audioType); + return o_pLoadSampleMetadata(sample, audioBuffer, audioBufferLength, audioType); const char* eventName = pszAudioEventName; @@ -423,7 +419,7 @@ bool, __fastcall, (void* sample, void* audioBuffer, unsigned int audioBufferLeng if (!overrideData) // not found either - return LoadSampleMetadata(sample, audioBuffer, audioBufferLength, audioType); + return o_pLoadSampleMetadata(sample, audioBuffer, audioBufferLength, audioType); else { // cache found pattern to improve performance @@ -437,7 +433,7 @@ bool, __fastcall, (void* sample, void* audioBuffer, unsigned int audioBufferLeng overrideData = iter->second; if (!ShouldPlayAudioEvent(eventName, overrideData)) - return LoadSampleMetadata(sample, audioBuffer, audioBufferLength, audioType); + return o_pLoadSampleMetadata(sample, audioBuffer, audioBufferLength, audioType); void* data = 0; unsigned int dataLength = 0; @@ -479,7 +475,7 @@ bool, __fastcall, (void* sample, void* audioBuffer, unsigned int audioBufferLeng if (!data) { spdlog::warn("Could not fetch override sample data for event {}! Using original data instead.", eventName); - return LoadSampleMetadata(sample, audioBuffer, audioBufferLength, audioType); + return o_pLoadSampleMetadata(sample, audioBuffer, audioBufferLength, audioType); } audioBuffer = data; @@ -490,26 +486,22 @@ bool, __fastcall, (void* sample, void* audioBuffer, unsigned int audioBufferLeng *(unsigned int*)((uintptr_t)sample + 0xF0) = audioBufferLength; // 64 - Auto-detect sample type - bool res = LoadSampleMetadata(sample, audioBuffer, audioBufferLength, 64); + bool res = o_pLoadSampleMetadata(sample, audioBuffer, audioBufferLength, 64); if (!res) spdlog::error("LoadSampleMetadata failed! The game will crash :("); return res; } -// clang-format off -AUTOHOOK(sub_1800294C0, mileswin64.dll + 0x294C0, -void*, __fastcall, (void* a1, void* a2)) -// clang-format on +static void*(__fastcall* o_pSub_1800294C0)(void* a1, void* a2) = nullptr; +static void* __fastcall h_Sub_1800294C0(void* a1, void* a2) { pszAudioEventName = reinterpret_cast<const char*>((*((__int64*)a2 + 6))); - return sub_1800294C0(a1, a2); + return o_pSub_1800294C0(a1, a2); } -// clang-format off -AUTOHOOK(MilesLog, client.dll + 0x57DAD0, -void, __fastcall, (int level, const char* string)) -// clang-format on +static void(__fastcall* o_pMilesLog)(int level, const char* string) = nullptr; +static void __fastcall h_MilesLog(int level, const char* string) { if (!Cvar_mileslog_enable->GetBool()) return; @@ -517,6 +509,55 @@ void, __fastcall, (int level, const char* string)) spdlog::info("[MSS] {} - {}", level, string); } +static void(__fastcall* o_pSub_18003EBD0)(DWORD dwThreadID, const char* threadName) = nullptr; +static void __fastcall h_Sub_18003EBD0(DWORD dwThreadID, const char* threadName) +{ + HANDLE hThread = OpenThread(THREAD_SET_LIMITED_INFORMATION, FALSE, dwThreadID); + + if (hThread != NULL) + { + // TODO: This "method" of "charset conversion" from string to wstring is abhorrent. Change it to a proper one + // as soon as Northstar has some helper function to do proper charset conversions. + auto tmp = std::string(threadName); + HRESULT WINAPI _SetThreadDescription(HANDLE hThread, PCWSTR lpThreadDescription); + _SetThreadDescription(hThread, std::wstring(tmp.begin(), tmp.end()).c_str()); + + CloseHandle(hThread); + } + + o_pSub_18003EBD0(dwThreadID, threadName); +} + +static char*(__fastcall* o_pSub_18003BC10)(void* a1, void* a2, void* a3, void* a4, void* a5, int a6) = nullptr; +static char* __fastcall h_Sub_18003BC10(void* a1, void* a2, void* a3, void* a4, void* a5, int a6) +{ + HANDLE hThread; + char* ret = o_pSub_18003BC10(a1, a2, a3, a4, a5, a6); + + if (ret != NULL && (hThread = reinterpret_cast<HANDLE>(*((uint64_t*)ret + 55))) != NULL) + { + HRESULT WINAPI _SetThreadDescription(HANDLE hThread, PCWSTR lpThreadDescription); + _SetThreadDescription(hThread, L"[Miles] WASAPI Service Thread"); + } + + return ret; +} + +ON_DLL_LOAD("mileswin64.dll", MilesWin64_Audio, (CModule module)) +{ + o_pLoadSampleMetadata = module.Offset(0xF110).RCast<decltype(o_pLoadSampleMetadata)>(); + HookAttach(&(PVOID&)o_pLoadSampleMetadata, (PVOID)h_LoadSampleMetadata); + + o_pSub_1800294C0 = module.Offset(0x294C0).RCast<decltype(o_pSub_1800294C0)>(); + HookAttach(&(PVOID&)o_pSub_1800294C0, (PVOID)h_Sub_1800294C0); + + o_pSub_18003EBD0 = module.Offset(0x3EBD0).RCast<decltype(o_pSub_18003EBD0)>(); + HookAttach(&(PVOID&)o_pSub_18003EBD0, (PVOID)h_Sub_18003EBD0); + + o_pSub_18003BC10 = module.Offset(0x3BC10).RCast<decltype(o_pSub_18003BC10)>(); + HookAttach(&(PVOID&)o_pSub_18003BC10, (PVOID)h_Sub_18003BC10); +} + ON_DLL_LOAD_RELIESON("engine.dll", MilesLogFuncHooks, ConVar, (CModule module)) { Cvar_mileslog_enable = new ConVar("mileslog_enable", "0", FCVAR_NONE, "Enables/disables whether the mileslog func should be logged"); @@ -524,7 +565,8 @@ ON_DLL_LOAD_RELIESON("engine.dll", MilesLogFuncHooks, ConVar, (CModule module)) ON_DLL_LOAD_CLIENT_RELIESON("client.dll", AudioHooks, ConVar, (CModule module)) { - AUTOHOOK_DISPATCH() + o_pMilesLog = module.Offset(0x57DAD0).RCast<decltype(o_pMilesLog)>(); + HookAttach(&(PVOID&)o_pMilesLog, (PVOID)h_MilesLog); Cvar_ns_print_played_sounds = new ConVar("ns_print_played_sounds", "0", FCVAR_NONE, ""); MilesStopAll = module.Offset(0x580850).RCast<MilesStopAll_Type>(); diff --git a/primedev/client/clientauthhooks.cpp b/primedev/client/clientauthhooks.cpp index 35ae3aa7..ceb648a5 100644 --- a/primedev/client/clientauthhooks.cpp +++ b/primedev/client/clientauthhooks.cpp @@ -3,8 +3,6 @@ #include "client/r2client.h" #include "core/vanilla.h" -AUTOHOOK_INIT() - ConVar* Cvar_ns_has_agreed_to_send_token; // mirrored in script @@ -12,16 +10,14 @@ const int NOT_DECIDED_TO_SEND_TOKEN = 0; const int AGREED_TO_SEND_TOKEN = 1; const int DISAGREED_TO_SEND_TOKEN = 2; -// clang-format off -AUTOHOOK(AuthWithStryder, engine.dll + 0x1843A0, -void, __fastcall, (void* a1)) -// clang-format on +static void (*__fastcall o_pAuthWithStryder)(void* a1) = nullptr; +static void __fastcall h_AuthWithStryder(void* a1) { // don't attempt to do Atlas auth if we are in vanilla compatibility mode // this prevents users from joining untrustworthy servers (unless they use a concommand or something) if (g_pVanillaCompatibility->GetVanillaCompatibility()) { - AuthWithStryder(a1); + o_pAuthWithStryder(a1); return; } @@ -38,15 +34,13 @@ void, __fastcall, (void* a1)) *g_pLocalPlayerOriginToken = 0; } - AuthWithStryder(a1); + o_pAuthWithStryder(a1); } char* p3PToken; -// clang-format off -AUTOHOOK(Auth3PToken, engine.dll + 0x183760, -char*, __fastcall, ()) -// clang-format on +static char* (*__fastcall o_pAuth3PToken)() = nullptr; +static char* __fastcall h_Auth3PToken() { if (!g_pVanillaCompatibility->GetVanillaCompatibility() && g_pMasterServerManager->m_sOwnClientAuthToken[0]) { @@ -54,12 +48,16 @@ char*, __fastcall, ()) strcpy(p3PToken, "Protocol 3: Protect the Pilot"); } - return Auth3PToken(); + return o_pAuth3PToken(); } ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", ClientAuthHooks, ConVar, (CModule module)) { - AUTOHOOK_DISPATCH() + o_pAuthWithStryder = module.Offset(0x1843A0).RCast<decltype(o_pAuthWithStryder)>(); + HookAttach(&(PVOID&)o_pAuthWithStryder, (PVOID)h_AuthWithStryder); + + o_pAuth3PToken = module.Offset(0x183760).RCast<decltype(o_pAuth3PToken)>(); + HookAttach(&(PVOID&)o_pAuth3PToken, (PVOID)h_Auth3PToken); p3PToken = module.Offset(0x13979D80).RCast<char*>(); diff --git a/primedev/client/clientruihooks.cpp b/primedev/client/clientruihooks.cpp index ad50d11a..e49e6f63 100644 --- a/primedev/client/clientruihooks.cpp +++ b/primedev/client/clientruihooks.cpp @@ -1,23 +1,20 @@ #include "core/convar/convar.h" -AUTOHOOK_INIT() - ConVar* Cvar_rui_drawEnable; -// clang-format off -AUTOHOOK(DrawRUIFunc, engine.dll + 0xFC500, -bool, __fastcall, (void* a1, float* a2)) -// clang-format on +static bool (*__fastcall o_pDrawRUIFunc)(void* a1, float* a2) = nullptr; +static bool __fastcall h_DrawRUIFunc(void* a1, float* a2) { if (!Cvar_rui_drawEnable->GetBool()) return 0; - return DrawRUIFunc(a1, a2); + return o_pDrawRUIFunc(a1, a2); } ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", RUI, ConVar, (CModule module)) { - AUTOHOOK_DISPATCH() + o_pDrawRUIFunc = module.Offset(0xFC500).RCast<decltype(o_pDrawRUIFunc)>(); + HookAttach(&(PVOID&)o_pDrawRUIFunc, (PVOID)h_DrawRUIFunc); Cvar_rui_drawEnable = new ConVar("rui_drawEnable", "1", FCVAR_CLIENTDLL, "Controls whether RUI should be drawn"); } diff --git a/primedev/client/clientvideooverrides.cpp b/primedev/client/clientvideooverrides.cpp index d8aa2754..54bb6469 100644 --- a/primedev/client/clientvideooverrides.cpp +++ b/primedev/client/clientvideooverrides.cpp @@ -1,11 +1,7 @@ #include "mods/modmanager.h" -AUTOHOOK_INIT() - -// clang-format off -AUTOHOOK_PROCADDRESS(BinkOpen, bink2w64.dll, BinkOpen, -void*, __fastcall, (const char* path, uint32_t flags)) -// clang-format on +static void* (*__fastcall o_pBinkOpen)(const char* path, uint32_t flags) = nullptr; +static void* __fastcall h_BinkOpen(const char* path, uint32_t flags) { std::string filename(fs::path(path).filename().string()); spdlog::info("BinkOpen {}", filename); @@ -25,16 +21,20 @@ void*, __fastcall, (const char* path, uint32_t flags)) { // create new path fs::path binkPath(fileOwner->m_ModDirectory / "media" / filename); - return BinkOpen(binkPath.string().c_str(), flags); + return o_pBinkOpen(binkPath.string().c_str(), flags); } else - return BinkOpen(path, flags); + return o_pBinkOpen(path, flags); } -ON_DLL_LOAD_CLIENT("engine.dll", BinkVideo, (CModule module)) +ON_DLL_LOAD_CLIENT("bink2w64.dll", BinkRead, (CModule module)) { - AUTOHOOK_DISPATCH() + o_pBinkOpen = module.GetExportedFunction("BinkOpen").RCast<decltype(o_pBinkOpen)>(); + HookAttach(&(PVOID&)o_pBinkOpen, (PVOID)h_BinkOpen); +} +ON_DLL_LOAD_CLIENT("engine.dll", BinkVideo, (CModule module)) +{ // remove engine check for whether the bik we're trying to load exists in r2/media, as this will fail for biks in mods // note: the check in engine is actually unnecessary, so it's just useless in practice and we lose nothing by removing it module.Offset(0x459AD).NOP(6); diff --git a/primedev/client/debugoverlay.cpp b/primedev/client/debugoverlay.cpp index 7f2e0901..9cfc1612 100644 --- a/primedev/client/debugoverlay.cpp +++ b/primedev/client/debugoverlay.cpp @@ -5,8 +5,6 @@ #include "core/math/vector.h" #include "server/ai_helper.h" -AUTOHOOK_INIT() - enum OverlayType_t { OVERLAY_BOX = 0, @@ -122,10 +120,8 @@ OverlayBase_t** s_pOverlays; int* g_nRenderTickCount; int* g_nOverlayTickCount; -// clang-format off -AUTOHOOK(DrawOverlay, engine.dll + 0xABCB0, -void, __fastcall, (OverlayBase_t * pOverlay)) -// clang-format on +static void(__fastcall* o_pDrawOverlay)(OverlayBase_t* pOverlay) = nullptr; +static void __fastcall h_DrawOverlay(OverlayBase_t* pOverlay) { EnterCriticalSection(s_OverlayMutex); @@ -205,10 +201,8 @@ void, __fastcall, (OverlayBase_t * pOverlay)) LeaveCriticalSection(s_OverlayMutex); } -// clang-format off -AUTOHOOK(DrawAllOverlays, engine.dll + 0xAB780, -void, __fastcall, (bool bRender)) -// clang-format on +static void(__fastcall* o_pDrawAllOverlays)(bool bRender) = nullptr; +static void __fastcall h_DrawAllOverlays(bool bRender) { EnterCriticalSection(s_OverlayMutex); @@ -259,10 +253,7 @@ void, __fastcall, (bool bRender)) if (bShouldDraw && bRender && (Cvar_enable_debug_overlays->GetBool() || pCurrOverlay->m_Type == OVERLAY_SMARTAMMO)) { - // call the new function, not the original - // note: if there is a beter way to call the hooked version of an - // autohook func then that would be better than this - __autohookfuncDrawOverlay(pCurrOverlay); + h_DrawOverlay(pCurrOverlay); } pPrevOverlay = pCurrOverlay; @@ -280,7 +271,11 @@ void, __fastcall, (bool bRender)) ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", DebugOverlay, ConVar, (CModule module)) { - AUTOHOOK_DISPATCH() + o_pDrawOverlay = module.Offset(0xABCB0).RCast<decltype(o_pDrawOverlay)>(); + HookAttach(&(PVOID&)o_pDrawOverlay, (PVOID)h_DrawOverlay); + + o_pDrawAllOverlays = module.Offset(0xAB780).RCast<decltype(o_pDrawAllOverlays)>(); + HookAttach(&(PVOID&)o_pDrawAllOverlays, (PVOID)h_DrawAllOverlays); OverlayBase_t__IsDead = module.Offset(0xACAC0).RCast<decltype(OverlayBase_t__IsDead)>(); OverlayBase_t__DestroyOverlay = module.Offset(0xAB680).RCast<decltype(OverlayBase_t__DestroyOverlay)>(); diff --git a/primedev/client/languagehooks.cpp b/primedev/client/languagehooks.cpp index 36b5d5ae..80d3c31d 100644 --- a/primedev/client/languagehooks.cpp +++ b/primedev/client/languagehooks.cpp @@ -5,8 +5,6 @@ namespace fs = std::filesystem; -AUTOHOOK_INIT() - typedef LANGID (*Tier0_DetectDefaultLanguageType)(); bool CheckLangAudioExists(char* lang) @@ -48,10 +46,8 @@ std::string GetAnyInstalledAudioLanguage() return "NO LANGUAGE DETECTED"; } -// clang-format off -AUTOHOOK(GetGameLanguage, tier0.dll + 0xF560, -char*, __fastcall, ()) -// clang-format on +static char*(__fastcall* o_pGetGameLanguage)() = nullptr; +static char* __fastcall h_GetGameLanguage() { auto tier0Handle = GetModuleHandleA("tier0.dll"); auto Tier0_DetectDefaultLanguageType = GetProcAddress(tier0Handle, "Tier0_DetectDefaultLanguage"); @@ -78,7 +74,7 @@ char*, __fastcall, ()) canOriginDictateLang = true; // let it try { - auto lang = GetGameLanguage(); + auto lang = o_pGetGameLanguage(); if (!CheckLangAudioExists(lang)) { if (strcmp(lang, "russian") != @@ -96,7 +92,7 @@ char*, __fastcall, ()) Tier0_DetectDefaultLanguageType(); // force the global in tier0 to be populated with language inferred from user's system rather than // defaulting to Russian canOriginDictateLang = false; // Origin has no say anymore, we will fallback to user's system setup language - auto lang = GetGameLanguage(); + auto lang = o_pGetGameLanguage(); spdlog::info("Detected system language: {}", lang); if (!CheckLangAudioExists(lang)) { @@ -113,5 +109,6 @@ char*, __fastcall, ()) ON_DLL_LOAD_CLIENT("tier0.dll", LanguageHooks, (CModule module)) { - AUTOHOOK_DISPATCH() + o_pGetGameLanguage = module.Offset(0xF560).RCast<decltype(o_pGetGameLanguage)>(); + HookAttach(&(PVOID&)o_pGetGameLanguage, (PVOID)h_GetGameLanguage); } diff --git a/primedev/client/latencyflex.cpp b/primedev/client/latencyflex.cpp index 39557870..be93fabd 100644 --- a/primedev/client/latencyflex.cpp +++ b/primedev/client/latencyflex.cpp @@ -1,20 +1,16 @@ #include "core/convar/convar.h" -AUTOHOOK_INIT() - ConVar* Cvar_r_latencyflex; void (*m_winelfx_WaitAndBeginFrame)(); -// clang-format off -AUTOHOOK(OnRenderStart, client.dll + 0x1952C0, -void, __fastcall, ()) -// clang-format on +void(__fastcall* o_pOnRenderStart)() = nullptr; +void __fastcall h_OnRenderStart() { if (Cvar_r_latencyflex->GetBool() && m_winelfx_WaitAndBeginFrame) m_winelfx_WaitAndBeginFrame(); - OnRenderStart(); + o_pOnRenderStart(); } ON_DLL_LOAD_CLIENT_RELIESON("client.dll", LatencyFlex, ConVar, (CModule module)) @@ -36,7 +32,8 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", LatencyFlex, ConVar, (CModule module)) return; } - AUTOHOOK_DISPATCH() + o_pOnRenderStart = module.Offset(0x1952C0).RCast<decltype(o_pOnRenderStart)>(); + HookAttach(&(PVOID&)o_pOnRenderStart, (PVOID)h_OnRenderStart); spdlog::info("LatencyFleX initialized."); Cvar_r_latencyflex = new ConVar("r_latencyflex", "1", FCVAR_ARCHIVE, "Whether or not to use LatencyFleX input latency reduction."); diff --git a/primedev/client/modlocalisation.cpp b/primedev/client/modlocalisation.cpp index 2b73876b..e5efa074 100644 --- a/primedev/client/modlocalisation.cpp +++ b/primedev/client/modlocalisation.cpp @@ -1,55 +1,58 @@ #include "mods/modmanager.h" -AUTOHOOK_INIT() - void* g_pVguiLocalize; -// clang-format off -AUTOHOOK(CLocalize__AddFile, localize.dll + 0x6D80, -bool, __fastcall, (void* pVguiLocalize, const char* path, const char* pathId, bool bIncludeFallbackSearchPaths)) -// clang-format on +static bool(__fastcall* o_pCLocalise__AddFile)( + void* pVguiLocalize, const char* path, const char* pathId, bool bIncludeFallbackSearchPaths) = nullptr; +static bool __fastcall h_CLocalise__AddFile(void* pVguiLocalize, const char* path, const char* pathId, bool bIncludeFallbackSearchPaths) { // save this for later g_pVguiLocalize = pVguiLocalize; - bool ret = CLocalize__AddFile(pVguiLocalize, path, pathId, bIncludeFallbackSearchPaths); + bool ret = o_pCLocalise__AddFile(pVguiLocalize, path, pathId, bIncludeFallbackSearchPaths); if (ret) spdlog::info("Loaded localisation file {} successfully", path); return true; } -// clang-format off -AUTOHOOK(CLocalize__ReloadLocalizationFiles, localize.dll + 0xB830, -void, __fastcall, (void* pVguiLocalize)) -// clang-format on +static void(__fastcall* o_pCLocalize__ReloadLocalizationFiles)(void* pVguiLocalize) = nullptr; +static void __fastcall h_CLocalize__ReloadLocalizationFiles(void* pVguiLocalize) { // load all mod localization manually, so we keep track of all files, not just previously loaded ones for (Mod mod : g_pModManager->m_LoadedMods) if (mod.m_bEnabled) for (std::string& localisationFile : mod.LocalisationFiles) - CLocalize__AddFile(g_pVguiLocalize, localisationFile.c_str(), nullptr, false); + o_pCLocalise__AddFile(g_pVguiLocalize, localisationFile.c_str(), nullptr, false); spdlog::info("reloading localization..."); - CLocalize__ReloadLocalizationFiles(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 for (Mod mod : g_pModManager->m_LoadedMods) if (mod.m_bEnabled) for (std::string& localisationFile : mod.LocalisationFiles) - CLocalize__AddFile(g_pVguiLocalize, localisationFile.c_str(), nullptr, false); + 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() + o_pCLocalise__AddFile = module.Offset(0x6D80).RCast<decltype(o_pCLocalise__AddFile)>(); + HookAttach(&(PVOID&)o_pCLocalise__AddFile, (PVOID)h_CLocalise__AddFile); + + o_pCLocalize__ReloadLocalizationFiles = module.Offset(0xB830).RCast<decltype(o_pCLocalize__ReloadLocalizationFiles)>(); + HookAttach(&(PVOID&)o_pCLocalize__ReloadLocalizationFiles, (PVOID)h_CLocalize__ReloadLocalizationFiles); } diff --git a/primedev/client/rejectconnectionfixes.cpp b/primedev/client/rejectconnectionfixes.cpp index 1b326a3c..adfd772c 100644 --- a/primedev/client/rejectconnectionfixes.cpp +++ b/primedev/client/rejectconnectionfixes.cpp @@ -1,12 +1,8 @@ #include "engine/r2engine.h"
-AUTOHOOK_INIT()
-
// this is called from when our connection is rejected, this is the only case we're hooking this for
-// clang-format off
-AUTOHOOK(COM_ExplainDisconnection, engine.dll + 0x1342F0,
-void,, (bool a1, const char* fmt, ...))
-// clang-format on
+static void (*o_pCOM_ExplainDisconnection)(bool a1, const char* fmt, ...) = nullptr;
+static void h_COM_ExplainDisconnection(bool a1, const char* fmt, ...)
{
va_list va;
va_start(va, fmt);
@@ -25,10 +21,11 @@ void,, (bool a1, const char* fmt, ...)) Cbuf_AddText(Cbuf_GetCurrentPlayer(), "disconnect", cmd_source_t::kCommandSrcCode);
}
- return COM_ExplainDisconnection(a1, "%s", buf);
+ return o_pCOM_ExplainDisconnection(a1, "%s", buf);
}
ON_DLL_LOAD_CLIENT("engine.dll", RejectConnectionFixes, (CModule module))
{
- AUTOHOOK_DISPATCH()
+ o_pCOM_ExplainDisconnection = module.Offset(0x1342F0).RCast<decltype(o_pCOM_ExplainDisconnection)>();
+ HookAttach(&(PVOID&)o_pCOM_ExplainDisconnection, (PVOID)h_COM_ExplainDisconnection);
}
|