From d0932060b408cade9e9f138a76106411c104d818 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Wed, 31 Aug 2022 16:40:17 +0200 Subject: [PATCH] Fix bug in localized strings code --- src/Components/Modules/Security.cpp | 8 ++++++++ src/Components/Modules/Security.hpp | 2 ++ src/DllMain.cpp | 1 + 3 files changed, 11 insertions(+) diff --git a/src/Components/Modules/Security.cpp b/src/Components/Modules/Security.cpp index 07193220..e0565e24 100644 --- a/src/Components/Modules/Security.cpp +++ b/src/Components/Modules/Security.cpp @@ -120,6 +120,11 @@ namespace Components InterlockedIncrement(&Game::deferredQueue->send); } + void Security::SEH_LocalizeTextMessageStub(char* dest, const char* src, [[maybe_unused]] int destsize) + { + Game::I_strncpyz(dest, src, 1024); + } + Security::Security() { // Exploit fixes @@ -147,5 +152,8 @@ namespace Components // Fix packets causing buffer overflow Utils::Hook(0x6267E3, NET_DeferPacketToClientStub, HOOK_CALL).install()->quick(); + + // Use the correct size for the destination buffer + Utils::Hook(0x49D548, SEH_LocalizeTextMessageStub, HOOK_CALL).install()->quick(); } } diff --git a/src/Components/Modules/Security.hpp b/src/Components/Modules/Security.hpp index 23ceb4d6..b0270bbe 100644 --- a/src/Components/Modules/Security.hpp +++ b/src/Components/Modules/Security.hpp @@ -22,5 +22,7 @@ namespace Components static void G_LogPrintfStub(const char* fmt); static void NET_DeferPacketToClientStub(Game::netadr_t* net_from, Game::msg_t* net_message); + + static void SEH_LocalizeTextMessageStub(char* dest, const char* src, int destsize); }; } diff --git a/src/DllMain.cpp b/src/DllMain.cpp index fa4d6498..5860b701 100644 --- a/src/DllMain.cpp +++ b/src/DllMain.cpp @@ -48,6 +48,7 @@ BOOL APIENTRY DllMain(HINSTANCE /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpvReser { if (fdwReason == DLL_PROCESS_ATTACH) { + SetProcessDEPPolicy(PROCESS_DEP_ENABLE); Steam::Proxy::RunMod(); #ifndef DISABLE_BINARY_CHECK