From fca9c2d2344947eac22fb8a5e4dfb570b3866028 Mon Sep 17 00:00:00 2001 From: Edo Date: Wed, 11 Jan 2023 19:37:35 +0000 Subject: [PATCH] [QuickPatch]: Cleanup (#717) --- src/Components/Modules/Ceg.cpp | 4 +++ src/Components/Modules/Network.cpp | 50 ++++++++++++++++++--------- src/Components/Modules/QuickPatch.cpp | 36 +++++-------------- src/Components/Modules/QuickPatch.hpp | 2 ++ src/Game/Dvars.cpp | 1 + src/Game/Dvars.hpp | 3 ++ 6 files changed, 52 insertions(+), 44 deletions(-) diff --git a/src/Components/Modules/Ceg.cpp b/src/Components/Modules/Ceg.cpp index 835e729e..f6fb5a33 100644 --- a/src/Components/Modules/Ceg.cpp +++ b/src/Components/Modules/Ceg.cpp @@ -36,6 +36,10 @@ namespace Components // Removed on IW5 MP (unprotected) but present on IW5 SP (protected) - CEG uninitialization / Steam Shutdown Utils::Hook::Set(0x4F6370, 0xC3); + // Remove 'Steam Start' checking for DRM IPC + Utils::Hook::Nop(0x451145, 5); + Utils::Hook::Set(0x45114C, 0xEB); + // Disable some checks on certain game events Utils::Hook::Nop(0x43EC96, 9); Utils::Hook::Nop(0x4675C6, 9); diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index 9e415552..edc26200 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -331,22 +331,22 @@ namespace Components { AssertSize(Game::netadr_t, 20); - // maximum size in NET_OutOfBandPrint - Utils::Hook::Set(0x4AEF08, 0x1FFFC); - Utils::Hook::Set(0x4AEFA3, 0x1FFFC); + // Maximum size in NET_OutOfBandPrint + Utils::Hook::Set(0x4AEF08, 0x1FFFC); + Utils::Hook::Set(0x4AEFA3, 0x1FFFC); - // increase max port binding attempts from 10 to 100 - Utils::Hook::Set(0x4FD48A, 100); + // Increase max port binding attempts from 10 to 100 + Utils::Hook::Set(0x4FD48A, 100); - // increase cl_maxpackets limit - Utils::Hook::Set(0x4050A1, 125); + // Increase cl_maxpackets dvar limit + Utils::Hook::Set(0x4050A1, 125); - // increase snaps + // Increase snaps (disabled for unknown reasons) //Utils::Hook::Set(0x405357, 40); - // default maxpackets and snaps - Utils::Hook::Set(0x40535B, 30); - Utils::Hook::Set(0x4050A5, 125); + // Set default value of snaps and cl_maxpackets dvar + Utils::Hook::Set(0x40535B, 30); + Utils::Hook::Set(0x4050A5, 125); // Parse port as short in Net_AddrToString Utils::Hook::Set(0x4698E3, "%u.%u.%u.%u:%hu"); @@ -364,11 +364,29 @@ namespace Components Utils::Hook(0x5AA703, CL_HandleCommandStub, HOOK_JUMP).install()->quick(); // Disable unused OOB packets handlers just to be sure - Utils::Hook::Set(0x5AA5B6, 0xEB); // CL_SteamServerAuth - Utils::Hook::Set(0x5AA69F, 0xEB); // echo - Utils::Hook::Set(0x5AAA82, 0xEB); // SP - Utils::Hook::Set(0x5A9F18, 0xEB); // CL_VoiceConnectionTestPacket - Utils::Hook::Set(0x5A9FF3, 0xEB); // CL_HandleRelayPacket + Utils::Hook::Set(0x5AA5B6, 0xEB); // CL_SteamServerAuth + Utils::Hook::Set(0x5AA69F, 0xEB); // echo + Utils::Hook::Set(0x5AAA82, 0xEB); // SP + Utils::Hook::Set(0x5A9F18, 0xEB); // CL_VoiceConnectionTestPacket + Utils::Hook::Set(0x5A9FF3, 0xEB); // CL_HandleRelayPacket + + // Com_GetProtocol + Utils::Hook::Set(0x4FB501, PROTOCOL); + + // Set the default, min and max of the protocol dvar + Utils::Hook::Set(0x4D36A9, PROTOCOL); + Utils::Hook::Set(0x4D36AE, PROTOCOL); + Utils::Hook::Set(0x4D36B3, PROTOCOL); + + // Internal version is 99, most servers should accept it + Utils::Hook::Set(0x463C61, 208); // getBuildNumberAsInt + + // LSP disabled + Utils::Hook::Set(0x435950, 0xC3); // LSP HELLO + Utils::Hook::Set(0x49C220, 0xC3); // We wanted to send a logging packet, but we haven't connected to LSP! + Utils::Hook::Set(0x4BD900, 0xC3); // main LSP response func + Utils::Hook::Set(0x682170, 0xC3); // Telling LSP that we're playing a private match + Utils::Hook::Nop(0x4FD448, 5); // Don't create lsp_socket OnClientPacket("resolveAddress", [](const Address& address, [[maybe_unused]] const std::string& data) { diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 286ac544..b07c53bb 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -5,6 +5,8 @@ namespace Components { + Dvar::Var QuickPatch::UIMousePitch; + Dvar::Var QuickPatch::r_customAspectRatio; void QuickPatch::UnlockStats() @@ -248,7 +250,7 @@ namespace Components using namespace Game; static const char* msg = "SND_GetAliasOffset: Could not find sound alias '%s'"; - static const DWORD func = 0x4B22D0; // Com_Error + using namespace Game; __asm { @@ -270,7 +272,7 @@ namespace Components push [esi] // alias->aliasName push msg push ERR_DROP - call func // Going to longjmp back to safety + call Com_Error // Going to longjmp back to safety add esp, 0xC xor eax, eax @@ -318,31 +320,9 @@ namespace Components // Fix crash as nullptr goes unchecked Utils::Hook(0x437CAD, QuickPatch::SND_GetAliasOffset_Stub, HOOK_JUMP).install()->quick(); - // protocol version (workaround for hacks) - Utils::Hook::Set(0x4FB501, PROTOCOL); - - // protocol command - Utils::Hook::Set(0x4D36A9, PROTOCOL); - Utils::Hook::Set(0x4D36AE, PROTOCOL); - Utils::Hook::Set(0x4D36B3, PROTOCOL); - - // internal version is 99, most servers should accept it - Utils::Hook::Set(0x463C61, 208); - // remove system pre-init stuff (improper quit, disk full) Utils::Hook::Set(0x411350, 0xC3); - // remove STEAMSTART checking for DRM IPC - Utils::Hook::Nop(0x451145, 5); - Utils::Hook::Set(0x45114C, 0xEB); - - // LSP disabled - Utils::Hook::Set(0x435950, 0xC3); // LSP HELLO - Utils::Hook::Set(0x49C220, 0xC3); // We wanted to send a logging packet, but we haven't connected to LSP! - Utils::Hook::Set(0x4BD900, 0xC3); // main LSP response func - Utils::Hook::Set(0x682170, 0xC3); // Telling LSP that we're playing a private match - Utils::Hook::Nop(0x4FD448, 5); // Don't create lsp_socket - // Don't delete config files if corrupted Utils::Hook::Set(0x47DCB3, 0xEB); Utils::Hook::Set(0x4402B6, 0); @@ -519,16 +499,16 @@ namespace Components }, Scheduler::Pipeline::RENDERER); // Fix mouse pitch adjustments - Dvar::Register("ui_mousePitch", false, Game::DVAR_ARCHIVE, ""); + UIMousePitch = Dvar::Register("ui_mousePitch", false, Game::DVAR_ARCHIVE, ""); UIScript::Add("updateui_mousePitch", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info) { - if (Dvar::Var("ui_mousePitch").get()) + if (UIMousePitch.get()) { - Dvar::Var("m_pitch").set(-0.022f); + Game::Dvar_SetFloatByName("m_pitch", -0.022f); } else { - Dvar::Var("m_pitch").set(0.022f); + Game::Dvar_SetFloatByName("m_pitch", 0.022f); } }); diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index 58679706..8f18c838 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -12,6 +12,8 @@ namespace Components static void UnlockStats(); private: + static Dvar::Var UIMousePitch; + static Dvar::Var r_customAspectRatio; static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description); static void SetAspectRatio_Stub(); diff --git a/src/Game/Dvars.cpp b/src/Game/Dvars.cpp index 029fe756..1fa87f3b 100644 --- a/src/Game/Dvars.cpp +++ b/src/Game/Dvars.cpp @@ -29,6 +29,7 @@ namespace Game Dvar_SetBool_t Dvar_SetBool = Dvar_SetBool_t(0x4A9510); Dvar_SetBoolByName_t Dvar_SetBoolByName = Dvar_SetBoolByName_t(0x45C4D0); Dvar_SetFloat_t Dvar_SetFloat = Dvar_SetFloat_t(0x40BB20); + Dvar_SetFloatByName_t Dvar_SetFloatByName = Dvar_SetFloatByName_t(0x466320); Dvar_SetInt_t Dvar_SetInt = Dvar_SetInt_t(0x421DA0); const dvar_t** com_developer = reinterpret_cast(0x1AD78E8); diff --git a/src/Game/Dvars.hpp b/src/Game/Dvars.hpp index 3372579a..ba5fafc9 100644 --- a/src/Game/Dvars.hpp +++ b/src/Game/Dvars.hpp @@ -54,6 +54,9 @@ namespace Game typedef void(*Dvar_SetFloat_t)(const dvar_t* dvar, float value); extern Dvar_SetFloat_t Dvar_SetFloat; + typedef void(*Dvar_SetFloatByName_t)(const char* dvarName, float value); + extern Dvar_SetFloatByName_t Dvar_SetFloatByName; + typedef void(*Dvar_SetInt_t)(const dvar_t* dvar, int integer); extern Dvar_SetInt_t Dvar_SetInt;