From d53fc404b218054b15a3a0f06576d93faba7d32e Mon Sep 17 00:00:00 2001 From: Edo Date: Sun, 16 Apr 2023 11:05:51 +0200 Subject: [PATCH] [Auth]: Undo this (#929) --- src/Components/Modules/Auth.cpp | 34 +++++++++++++++++++++++++-------- src/Components/Modules/Auth.hpp | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 98372d44..f150b107 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -273,16 +273,33 @@ namespace Components return value; } - int Auth::NET_IsLocalAddressStub(Game::netadr_t adr) + __declspec(naked) void Auth::DirectConnectPrivateClientStub() { - if (HasAccessToReservedSlot) + __asm { - // Bypass sv_privateClients if client has the password - return 1; - } + push eax - // Only bypass if address is local. Original behaviour - return Utils::Hook::Call(0x402BD0)(adr); + mov al, HasAccessToReservedSlot + test al, al + + pop eax + + je noAccess + + // Set the number of private clients to 0 if the client has the right password + xor eax, eax + jmp safeContinue + + noAccess: + mov eax, dword ptr [edx + 0x10] + + safeContinue: + // Game code skipped by hook + add esp, 0xC + + push 0x460FB3 + ret + } } unsigned __int64 Auth::GetKeyHash(const std::string& key) @@ -467,7 +484,8 @@ namespace Components // Install registration hook Utils::Hook(0x6265F9, DirectConnectStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x460EF5, Info_ValueForKeyStub, HOOK_CALL).install()->quick(); - Utils::Hook(0x460F89, NET_IsLocalAddressStub, HOOK_CALL).install()->quick(); + Utils::Hook(0x460FAD, DirectConnectPrivateClientStub, HOOK_JUMP).install()->quick(); + Utils::Hook::Nop(0x460FAD + 5, 1); Utils::Hook(0x41D3E3, SendConnectDataStub, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Auth.hpp b/src/Components/Modules/Auth.hpp index 9f10db42..5ab438ce 100644 --- a/src/Components/Modules/Auth.hpp +++ b/src/Components/Modules/Auth.hpp @@ -51,7 +51,7 @@ namespace Components static void ParseConnectData(Game::msg_t* msg, Game::netadr_t* addr); static void DirectConnectStub(); static char* Info_ValueForKeyStub(const char* s, const char* key); - static int NET_IsLocalAddressStub(Game::netadr_t adr); + static void DirectConnectPrivateClientStub(); static void Frame(); };