From 27cc07b547e4ca7da1bc3fec06cb3d9fb8177378 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 17 Jan 2023 00:32:08 +0100 Subject: [PATCH] Remove unused patterns No longer used. --- r5dev/server/vengineserver_impl.cpp | 6 ++--- r5dev/server/vengineserver_impl.h | 34 +++++------------------------ 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/r5dev/server/vengineserver_impl.cpp b/r5dev/server/vengineserver_impl.cpp index 038ccd97..d7b955c2 100644 --- a/r5dev/server/vengineserver_impl.cpp +++ b/r5dev/server/vengineserver_impl.cpp @@ -13,7 +13,7 @@ //----------------------------------------------------------------------------- // Purpose: sets the persistence var in the CClient instance to 'ready' //----------------------------------------------------------------------------- -bool HIVEngineServer__PersistenceAvailable(void* entidx, int clienthandle) +bool CVEngineServer::PersistenceAvailable(void* entidx, int clienthandle) { CClient* pClient = g_pClient->GetClient(clienthandle); // Get client instance. pClient->SetPersistenceState(PERSISTENCE::PERSISTENCE_READY); // Set the client instance to 'ready'. @@ -42,12 +42,12 @@ bool HIVEngineServer__PersistenceAvailable(void* entidx, int clienthandle) void IVEngineServer_Attach() { - DetourAttach((LPVOID*)&IVEngineServer__PersistenceAvailable, &HIVEngineServer__PersistenceAvailable); + DetourAttach((LPVOID*)&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable); } void IVEngineServer_Detach() { - DetourDetach((LPVOID*)&IVEngineServer__PersistenceAvailable, &HIVEngineServer__PersistenceAvailable); + DetourDetach((LPVOID*)&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable); } /////////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/server/vengineserver_impl.h b/r5dev/server/vengineserver_impl.h index 9a3ee422..04bd127b 100644 --- a/r5dev/server/vengineserver_impl.h +++ b/r5dev/server/vengineserver_impl.h @@ -6,26 +6,12 @@ inline CMemory p_IVEngineServer__PersistenceAvailable; inline auto IVEngineServer__PersistenceAvailable = p_IVEngineServer__PersistenceAvailable.RCast(); -inline CMemory p_IVEngineServer__IsDedicatedServer; -inline auto IVEngineServer__IsDedicatedServer = p_IVEngineServer__IsDedicatedServer.RCast(); - -inline CMemory p_IVEngineServer__GetNumHumanPlayers; -inline auto IVEngineServer__GetNumHumanPlayers = p_IVEngineServer__GetNumHumanPlayers.RCast(); - -inline CMemory p_IVEngineServer__GetNumFakeClients; -inline auto IVEngineServer__GetNumFakeClients = p_IVEngineServer__GetNumFakeClients.RCast(); - -inline CMemory p_IVEngineServer__CreateFakeClient; -inline auto IVEngineServer__CreateFakeClient = p_IVEngineServer__CreateFakeClient.RCast(); - //inline CMemory p_RunFrameServer; //inline auto v_RunFrameServer = p_RunFrameServer.RCast(); inline bool* g_bDedicated = nullptr; /////////////////////////////////////////////////////////////////////////////// -bool HIVEngineServer__PersistenceAvailable(void* entidx, int clientidx); - void IVEngineServer_Attach(); void IVEngineServer_Detach(); @@ -60,6 +46,8 @@ extern ServerPlayer_t g_ServerPlayer[MAX_PLAYERS]; class CVEngineServer : public IVEngineServer { +public: + static bool PersistenceAvailable(void* entidx, int clientidx); // Implementation in GameDLL. }; extern CVEngineServer* g_pEngineServer; @@ -71,10 +59,6 @@ class HVEngineServer : public IDetour virtual void GetAdr(void) const { spdlog::debug("| FUN: CVEngineServer::PersistenceAvailable : {:#18x} |\n", p_IVEngineServer__PersistenceAvailable.GetPtr()); - spdlog::debug("| FUN: CVEngineServer::IsDedicatedServer : {:#18x} |\n", p_IVEngineServer__IsDedicatedServer.GetPtr()); - spdlog::debug("| FUN: CVEngineServer::GetNumHumanPlayers : {:#18x} |\n", p_IVEngineServer__GetNumHumanPlayers.GetPtr()); - spdlog::debug("| FUN: CVEngineServer::GetNumFakeClients : {:#18x} |\n", p_IVEngineServer__GetNumFakeClients.GetPtr()); - spdlog::debug("| FUN: CVEngineServer::CreateFakeClient : {:#18x} |\n", p_IVEngineServer__CreateFakeClient.GetPtr()); //spdlog::debug("| FUN: RunFrameServer : {:#18x} |\n", p_RunFrameServer.GetPtr()); spdlog::debug("| VAR: g_bDedicated : {:#18x} |\n", reinterpret_cast(g_bDedicated)); spdlog::debug("| VAR: g_pEngineServerVFTable : {:#18x} |\n", reinterpret_cast(g_pEngineServerVFTable)); @@ -83,23 +67,17 @@ class HVEngineServer : public IDetour virtual void GetFun(void) const { p_IVEngineServer__PersistenceAvailable = g_GameDll.FindPatternSIMD("3B 15 ?? ?? ?? ?? 7D 33"); - p_IVEngineServer__IsDedicatedServer = g_GameDll.FindPatternSIMD("0F B6 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 40 53"); - p_IVEngineServer__GetNumHumanPlayers = g_GameDll.FindPatternSIMD("8B 15 ?? ?? ?? ?? 33 C0 85 D2 7E 24"); - p_IVEngineServer__GetNumFakeClients = g_GameDll.FindPatternSIMD("8B 05 ?? ?? ?? ?? 33 C9 85 C0 7E 2D"); - p_IVEngineServer__CreateFakeClient = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F2 41 8B F8"); // p_RunFrameServer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 30 0F 29 74 24 ?? 48 8D 0D ?? ?? ?? ??"); IVEngineServer__PersistenceAvailable = p_IVEngineServer__PersistenceAvailable.RCast(); /*3B 15 ?? ?? ?? ?? 7D 33*/ - IVEngineServer__IsDedicatedServer = p_IVEngineServer__IsDedicatedServer.RCast(); /*0F B6 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 40 53*/ - IVEngineServer__GetNumHumanPlayers = p_IVEngineServer__GetNumHumanPlayers.RCast(); /*8B 15 ?? ?? ?? ?? 33 C0 85 D2 7E 24*/ - IVEngineServer__GetNumFakeClients = p_IVEngineServer__GetNumFakeClients.RCast(); /*8B 05 ?? ?? ?? ?? 33 C9 85 C0 7E 2D*/ - IVEngineServer__CreateFakeClient = p_IVEngineServer__CreateFakeClient.RCast();/*48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F2 41 8B F8*/ // v_RunFrameServer = p_RunFrameServer.RCast(); /*48 89 5C 24 ?? 57 48 83 EC 30 0F 29 74 24 ?? 48 8D 0D ?? ?? ?? ??*/ } virtual void GetVar(void) const { - g_bDedicated = p_IVEngineServer__IsDedicatedServer.ResolveRelativeAddress(0x3, 0x7).RCast(); - g_pEngineServerVFTable = g_GameDll.GetVirtualMethodTable(".?AVCVEngineServer@@", 0).RCast(); + CMemory pEngineServerVFTable = g_GameDll.GetVirtualMethodTable(".?AVCVEngineServer@@", 0); + + g_pEngineServerVFTable = pEngineServerVFTable.RCast(); + g_bDedicated = pEngineServerVFTable.WalkVTableSelf(3).DerefSelf().ResolveRelativeAddress(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { }