diff --git a/r5dev/client/client.h b/r5dev/client/client.h index bb759ff3..c3e15e05 100644 --- a/r5dev/client/client.h +++ b/r5dev/client/client.h @@ -1,23 +1,11 @@ #ifndef CLIENT_H #define CLIENT_H -inline CMemory CClientState__RunFrame; /////////////////////////////////////////////////////////////////////////////// class VClient : public IDetour { - virtual void GetAdr(void) const - { - spdlog::debug("| FUN: CClientState::RunFrame : {:#18x} |\n", CClientState__RunFrame.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - } - virtual void GetFun(void) const - { -#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - CClientState__RunFrame = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x83\xB9\x00\x00\x00\x00\x00"), "xxxx?xxxx????xx?????"); -#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - CClientState__RunFrame = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x81\xEC\x00\x00\x00\x00\x83\xB9\x00\x00\x00\x00\x00\x48\x8B\xD9\x7D\x0B"), "xxxxx????xx?????xxxxx"); -#endif - } + virtual void GetAdr(void) const { } + virtual void GetFun(void) const { } virtual void GetVar(void) const { } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/common/opcodes.cpp b/r5dev/common/opcodes.cpp index a5e54d6d..c0ca7fa7 100644 --- a/r5dev/common/opcodes.cpp +++ b/r5dev/common/opcodes.cpp @@ -15,6 +15,7 @@ #include "engine/cl_main.h" #include "engine/sv_main.h" #include "engine/sys_getmodes.h" +#include "engine/baseclientstate.h" #include "game/server/ai_networkmanager.h" #include "game/server/fairfight_impl.h" #include "rtech/rtech_game.h" @@ -62,7 +63,8 @@ void Dedicated_Init() //------------------------------------------------------------------------- { /*MOV EAX, 0*/ - CClientState__RunFrame.Patch({ 0xB8, 0x00, 0x00, 0x00, 0x00, 0xC3 }); // FUN --> RET | Always return false for pending client snapshots (inline CClientState call in '_Host_RunFrame()') + p_CClientState__RunFrame.Patch({ 0xB8, 0x00, 0x00, 0x00, 0x00, 0xC3 }); // FUN --> RET | Always return false for pending client snapshots (inline CClientState call in '_Host_RunFrame()') + p_CClientState__Disconnect.Patch({ 0xB8, 0x00, 0x00, 0x00, 0x00, 0xC3 }); // FUN --> RET | Always return false for keeping client persistent data after disconnect (CLIENT ONLY). } //------------------------------------------------------------------------- diff --git a/r5dev/engine/baseclientstate.h b/r5dev/engine/baseclientstate.h index 29b2aab1..f3f6032c 100644 --- a/r5dev/engine/baseclientstate.h +++ b/r5dev/engine/baseclientstate.h @@ -173,28 +173,54 @@ public: extern CBaseClientState* g_pBaseClientState; /* ==== CCLIENTSTATE ==================================================================================================================================================== */ -#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) -//inline CMemory p_CClientState__CheckForResend = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x56\x57\x41\x57\x00\x81\xEC\x20\x04\x00\x00\x45\x0F\xB6\xF9\x00\x00\x00\x00\x8B\xF1\x48"), "xxxx?xxxx?xxxx?xxxxx????xxx"); /*48 89 5C 24 ?? 56 57 41 57 ?? 81 EC 20 04 ?? 00 45 0F B6 F9 ?? ?? ?? ?? 8B F1 48*/ -//inline auto CClientState__CheckForResend = p_CClientState__CheckForResend.RCast(); -#elif defined (GAMEDLL_S2) -//inline CMemory p_CClientState__CheckForResend = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x45\x0F\xB6"), "xxxx?xxxx?xxxx?xxxxx????xxx"); /*48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 81 EC ?? ?? ?? ?? 45 0F B6*/ -//inline auto CClientState__CheckForResend = p_CClientState__CheckForResend.RCast(); -#elif defined (GAMEDLL_S3) -//inline CMemory p_CClientState__CheckForResend = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x32"), "xxxx?xxxx?xxxx?xxxxx????xxx"); /*48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 81 EC ?? ?? ?? ?? 48 8B 32*/ -//inline auto CClientState__CheckForResend = p_CClientState__CheckForResend.RCast(); -#endif +inline CMemory p_CClientState__RunFrame; +inline auto CClientState__RunFrame = p_CClientState__RunFrame.RCast(); + +inline CMemory p_CClientState__CheckForResend; /*48 89 5C 24 ?? 56 57 41 57 ?? 81 EC 20 04 ?? 00 45 0F B6 F9 ?? ?? ?? ?? 8B F1 48*/ +inline auto CClientState__CheckForResend = p_CClientState__CheckForResend.RCast(); + +inline CMemory p_CClientState__Disconnect; /*48 89 5C 24 ?? 55 57 41 56 48 83 EC 30 0F B6 EA*/ +inline auto CClientState__Disconnect = p_CClientState__Disconnect.RCast(); + /////////////////////////////////////////////////////////////////////////////// class VBaseClientState : public IDetour { virtual void GetAdr(void) const { - //spdlog::debug("| FUN: CClientState::CheckForResend : {:#18x} |\n", p_CClientState__CheckForResend.GetPtr()); + spdlog::debug("| FUN: CClientState::RunFrame : {:#18x} |\n", p_CClientState__RunFrame.GetPtr()); + spdlog::debug("| FUN: CClientState::Disconnect : {:#18x} |\n", p_CClientState__Disconnect.GetPtr()); + spdlog::debug("| FUN: CClientState::CheckForResend : {:#18x} |\n", p_CClientState__CheckForResend.GetPtr()); spdlog::debug("| VAR: cl_m_bPaused : {:#18x} |\n", reinterpret_cast(cl_m_bPaused)); spdlog::debug("| VAR: cl_host_tickcount : {:#18x} |\n", reinterpret_cast(cl_host_tickcount)); spdlog::debug("+----------------------------------------------------------------+\n"); } - virtual void GetFun(void) const { } + virtual void GetFun(void) const + { +#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) + p_CClientState__RunFrame = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x4C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x83\xB9\x00\x00\x00\x00\x00"), "xxxx?xxxx????xx?????"); + CClientState__RunFrame = p_CClientState__RunFrame.RCast(); + + p_CClientState__CheckForResend = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x56\x57\x41\x57\x00\x81\xEC\x20\x04\x00\x00\x45\x0F\xB6\xF9\x00\x00\x00\x00\x8B\xF1\x48"), "xxxx?xxxx?xxxx?xxxxx????xxx"); + CClientState__CheckForResend = p_CClientState__CheckForResend.RCast(); /*48 89 5C 24 ?? 56 57 41 57 ?? 81 EC 20 04 ?? 00 45 0F B6 F9 ?? ?? ?? ?? 8B F1 48*/ + + p_CClientState__Disconnect = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x57\x41\x56\x48\x83\xEC\x30\x0F\xB6\xEA"), "xxxx?xxxxxxxxxxx"); + CClientState__Disconnect = p_CClientState__Disconnect.RCast(); /*48 89 5C 24 ?? 55 57 41 56 48 83 EC 30 0F B6 EA*/ +#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) + p_CClientState__RunFrame = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x81\xEC\x00\x00\x00\x00\x83\xB9\x00\x00\x00\x00\x00\x48\x8B\xD9\x7D\x0B"), "xxxxx????xx?????xxxxx"); + CClientState__RunFrame = p_CClientState__RunFrame.RCast(); + + p_CClientState__Disconnect = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x57\x41\x54\x41\x55\x41\x57\x48\x83\xEC\x30\x44\x0F\xB6\xFA"), "xxxxxxxxxxxxxxxxx"); + CClientState__Disconnect = p_CClientState__Disconnect.RCast(); /*40 56 57 41 54 41 55 41 57 48 83 EC 30 44 0F B6 FA*/ +#endif +#if defined (GAMEDLL_S2) + p_CClientState__CheckForResend = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x45\x0F\xB6"), "xxxx?xxxx?xxxx?xxxxx????xxx"); + CClientState__CheckForResend = p_CClientState__CheckForResend.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 81 EC ?? ?? ?? ?? 45 0F B6*/ +#elif defined (GAMEDLL_S3) + p_CClientState__CheckForResend = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x32"), "xxxx?xxxx?xxxx?xxxxx????xxx"); + CClientState__CheckForResend = p_CClientState__CheckForResend.RCast(); /*48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 81 EC ?? ?? ?? ?? 48 8B 32*/ +#endif + } virtual void GetVar(void) const {