diff --git a/r5dev/bsplib/bsplib.cpp b/r5dev/bsplib/bsplib.cpp index 2df36bbc..926da8c6 100644 --- a/r5dev/bsplib/bsplib.cpp +++ b/r5dev/bsplib/bsplib.cpp @@ -432,14 +432,14 @@ void* __fastcall BuildPropStaticFrustumCullMap(int64_t a1, int64_t a2, unsigned return v_BuildPropStaticFrustumCullMap(a1, a2, a3, a4, a5, a6, a7); } -void BspLib_Attach() +void VBspLib::Attach() const { #ifndef DEDICATED DetourAttach((LPVOID*)&v_BuildPropStaticFrustumCullMap, &BuildPropStaticFrustumCullMap); #endif // !DEDICATED } -void BspLib_Detach() +void VBspLib::Detach() const { #ifndef DEDICATED DetourDetach((LPVOID*)&v_BuildPropStaticFrustumCullMap, &BuildPropStaticFrustumCullMap); diff --git a/r5dev/bsplib/bsplib.h b/r5dev/bsplib/bsplib.h index 0ba9e83e..edd6483e 100644 --- a/r5dev/bsplib/bsplib.h +++ b/r5dev/bsplib/bsplib.h @@ -24,28 +24,25 @@ inline auto v_BuildPropStaticFrustumCullMap = p_BuildPropStaticFrustumCullMap.RC void* __fastcall BuildPropStaticFrustumCullMap(int64_t a1, int64_t a2, unsigned int a3, unsigned int a4, int64_t a5, int64_t a6, int64_t a7); -void BspLib_Attach(); -void BspLib_Detach(); /////////////////////////////////////////////////////////////////////////////// class VBspLib : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: BuildPropStaticFrustumCullMap : {:#18x} |\n", p_BuildPropStaticFrustumCullMap.GetPtr()); - //spdlog::debug("| FUN: sub_1404365A0 : {:#18x} |\n", reinterpret_cast(sub_1404365A0)); - //spdlog::debug("| FUN: sub_140270130 : {:#18x} |\n", reinterpret_cast(sub_140270130)); - //spdlog::debug("| FUN: sub_14028F170 : {:#18x} |\n", reinterpret_cast(sub_14028F170)); - //spdlog::debug("| FUN: sub_140257F20 : {:#18x} |\n", reinterpret_cast(sub_140257F20)); - //spdlog::debug("| VAR: dword_1696A9D20 : {:#18x} |\n", reinterpret_cast(dword_1696A9D20)); - //spdlog::debug("| VAR: dword_141744EBC : {:#18x} |\n", reinterpret_cast(dword_141744EBC)); - //spdlog::debug("| VAR: dword_141744EE8 : {:#18x} |\n", reinterpret_cast(dword_141744EE8)); - //spdlog::debug("| VAR: qword_141744EA8 : {:#18x} |\n", reinterpret_cast(qword_141744EA8)); - //spdlog::debug("| VAR: qword_141744EA0 : {:#18x} |\n", reinterpret_cast(qword_141744EA0)); - //spdlog::debug("| VAR: qword_141744E88 : {:#18x} |\n", reinterpret_cast(qword_141744E88)); - //spdlog::debug("| VAR: xmmword_1415BD270 : {:#18x} |\n", reinterpret_cast(xmmword_1415BD270)); - //spdlog::debug("| VAR: off_141744E70 : {:#18x} |\n", reinterpret_cast(off_141744E70)); - //spdlog::debug("| VAR: off_141731448 : {:#18x} |\n", reinterpret_cast(off_141731448)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("BuildPropStaticFrustumCullMap", p_BuildPropStaticFrustumCullMap.GetPtr()); + //LogFunAdr("sub_1404365A0", reinterpret_cast(sub_1404365A0)); + //LogFunAdr("sub_140270130", reinterpret_cast(sub_140270130)); + //LogFunAdr("sub_14028F170", reinterpret_cast(sub_14028F170)); + //LogFunAdr("sub_140257F20", reinterpret_cast(sub_140257F20)); + //LogVarAdr("dword_1696A9D20", reinterpret_cast(dword_1696A9D20)); + //LogVarAdr("dword_141744EBC", reinterpret_cast(dword_141744EBC)); + //LogVarAdr("dword_141744EE8", reinterpret_cast(dword_141744EE8)); + //LogVarAdr("qword_141744EA8", reinterpret_cast(qword_141744EA8)); + //LogVarAdr("qword_141744EA0", reinterpret_cast(qword_141744EA0)); + //LogVarAdr("qword_141744E88", reinterpret_cast(qword_141744E88)); + //LogVarAdr("xmmword_1415BD270", reinterpret_cast(xmmword_1415BD270)); + //LogVarAdr("off_141744E70", reinterpret_cast(off_141744E70)); + //LogVarAdr("off_141731448", reinterpret_cast(off_141731448)); } virtual void GetFun(void) const { @@ -77,9 +74,7 @@ class VBspLib : public IDetour //#endif } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VBspLib); diff --git a/r5dev/client/cdll_engine_int.cpp b/r5dev/client/cdll_engine_int.cpp index e50a726c..7b234a36 100644 --- a/r5dev/client/cdll_engine_int.cpp +++ b/r5dev/client/cdll_engine_int.cpp @@ -35,12 +35,16 @@ ClientClass* CHLClient::GetAllClasses() } /////////////////////////////////////////////////////////////////////////////// -void CHLClient_Attach() +void VDll_Engine_Int::Attach() const { - //DetourAttach((LPVOID*)&CHLClient_FrameStageNotify, &CHLClient::FrameStageNotify); +#ifndef DEDICATED + DetourAttach((LPVOID*)&CHLClient_FrameStageNotify, &CHLClient::FrameStageNotify); +#endif // !DEDICATED } -void CHLClient_Detach() +void VDll_Engine_Int::Detach() const { - //DetourDetach((LPVOID*)&CHLClient_FrameStageNotify, &CHLClient::FrameStageNotify); +#ifndef DEDICATED + DetourDetach((LPVOID*)&CHLClient_FrameStageNotify, &CHLClient::FrameStageNotify); +#endif // !DEDICATED } diff --git a/r5dev/client/cdll_engine_int.h b/r5dev/client/cdll_engine_int.h index b109597a..b7779494 100644 --- a/r5dev/client/cdll_engine_int.h +++ b/r5dev/client/cdll_engine_int.h @@ -63,27 +63,22 @@ inline auto CHLClient_GetAllClasses = p_CHLClient_GetAllClasses.RCast(gHLClient)); - spdlog::debug("| VAR: g_pHLClient : {:#18x} |\n", reinterpret_cast(g_pHLClient)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("gHLClient", reinterpret_cast(gHLClient)); + LogVarAdr("g_pHLClient", reinterpret_cast(g_pHLClient)); } virtual void GetFun(void) const { @@ -120,9 +115,7 @@ class VDll_Engine_Int : public IDetour .FindPatternSelf("4C 8B", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VDll_Engine_Int); diff --git a/r5dev/client/vengineclient_impl.h b/r5dev/client/vengineclient_impl.h index 72e7cfae..8ee40f24 100644 --- a/r5dev/client/vengineclient_impl.h +++ b/r5dev/client/vengineclient_impl.h @@ -20,8 +20,7 @@ class HVEngineClient : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| CON: g_pEngineClientVFTable : {:#18x} |\n", g_pEngineClientVFTable.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogConAdr("g_pEngineClientVFTable", g_pEngineClientVFTable.GetPtr()); } virtual void GetFun(void) const { } virtual void GetVar(void) const { } @@ -34,5 +33,3 @@ class HVEngineClient : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(HVEngineClient); \ No newline at end of file diff --git a/r5dev/codecs/Miles/miles_impl.cpp b/r5dev/codecs/Miles/miles_impl.cpp index cf493d36..de373ef7 100644 --- a/r5dev/codecs/Miles/miles_impl.cpp +++ b/r5dev/codecs/Miles/miles_impl.cpp @@ -44,7 +44,7 @@ void MilesBankPatch(Miles::Bank* bank, char* streamPatch, char* localizedStreamP } /////////////////////////////////////////////////////////////////////////////// -void MilesCore_Attach() +void MilesCore::Attach() const { DetourAttach(&v_AIL_LogFunc, &AIL_LogFunc); DetourAttach(&v_Miles_Initialize, &Miles_Initialize); @@ -52,7 +52,7 @@ void MilesCore_Attach() DetourAttach(&v_MilesBankPatch, &MilesBankPatch); } -void MilesCore_Detach() +void MilesCore::Detach() const { DetourDetach(&v_AIL_LogFunc, &AIL_LogFunc); DetourDetach(&v_Miles_Initialize, &Miles_Initialize); diff --git a/r5dev/codecs/Miles/miles_impl.h b/r5dev/codecs/Miles/miles_impl.h index 07dbd741..f74e8451 100644 --- a/r5dev/codecs/Miles/miles_impl.h +++ b/r5dev/codecs/Miles/miles_impl.h @@ -14,17 +14,13 @@ inline auto v_MilesQueueEventRun = p_MilesQueueEventRun.RCast(); -void MilesCore_Attach(); -void MilesCore_Detach(); - /////////////////////////////////////////////////////////////////////////////// class MilesCore : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: AIL_LogFunc : {:#18x} |\n", p_AIL_LogFunc.GetPtr()); - spdlog::debug("| FUN: Miles_Initialize : {:#18x} |\n", p_Miles_Initialize.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("AIL_LogFunc", p_AIL_LogFunc.GetPtr()); + LogFunAdr("Miles_Initialize", p_Miles_Initialize.GetPtr()); } virtual void GetFun(void) const { @@ -45,9 +41,7 @@ class MilesCore : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(MilesCore); diff --git a/r5dev/codecs/Miles/radshal_wasapi.h b/r5dev/codecs/Miles/radshal_wasapi.h index 8d38014a..a3578b59 100644 --- a/r5dev/codecs/Miles/radshal_wasapi.h +++ b/r5dev/codecs/Miles/radshal_wasapi.h @@ -8,8 +8,7 @@ class VRadShal : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: WASAPI_GetAudioDevice : {:#18x} |\n", p_WASAPI_GetAudioDevice.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("WASAPI_GetAudioDevice", p_WASAPI_GetAudioDevice.GetPtr()); } virtual void GetFun(void) const { @@ -22,5 +21,3 @@ class VRadShal : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VRadShal); diff --git a/r5dev/codecs/bink/bink_impl.cpp b/r5dev/codecs/bink/bink_impl.cpp index 9abab80e..64985a53 100644 --- a/r5dev/codecs/bink/bink_impl.cpp +++ b/r5dev/codecs/bink/bink_impl.cpp @@ -20,12 +20,12 @@ void* BinkOpen(HANDLE hBinkFile, UINT32 nFlags) } /////////////////////////////////////////////////////////////////////////////// -void BinkImpl_Attach() +void BinkCore::Attach() const { DetourAttach(&v_BinkOpen, &BinkOpen); } -void BinkImpl_Detach() +void BinkCore::Detach() const { DetourDetach(&v_BinkOpen, &BinkOpen); } \ No newline at end of file diff --git a/r5dev/codecs/bink/bink_impl.h b/r5dev/codecs/bink/bink_impl.h index df081794..ceef7a27 100644 --- a/r5dev/codecs/bink/bink_impl.h +++ b/r5dev/codecs/bink/bink_impl.h @@ -9,18 +9,14 @@ inline auto v_BinkClose = p_BinkClose.RCast(); inline CMemory p_BinkGetError; inline auto v_BinkGetError = p_BinkGetError.RCast(); -void BinkImpl_Attach(); -void BinkImpl_Detach(); - /////////////////////////////////////////////////////////////////////////////// class BinkCore : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: BinkOpen : {:#18x} |\n", p_BinkOpen.GetPtr()); - spdlog::debug("| FUN: BinkClose : {:#18x} |\n", p_BinkClose.GetPtr()); - spdlog::debug("| FUN: BinkGetError : {:#18x} |\n", p_BinkGetError.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("BinkOpen", p_BinkOpen.GetPtr()); + LogFunAdr("BinkClose", p_BinkClose.GetPtr()); + LogFunAdr("BinkGetError", p_BinkGetError.GetPtr()); } virtual void GetFun(void) const { @@ -33,9 +29,8 @@ class BinkCore : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(BinkCore); diff --git a/r5dev/common/netmessages.cpp b/r5dev/common/netmessages.cpp index 574d7ecc..44b00c8d 100644 --- a/r5dev/common/netmessages.cpp +++ b/r5dev/common/netmessages.cpp @@ -41,17 +41,21 @@ bool SVC_UserMessage::ProcessImpl() return SVC_UserMessage_Process(this); // Need to return original. } -void CNetMessages_Attach() +void V_NetMessages::Attach() const { +#if !defined(DEDICATED) auto SVCPrint = &SVC_Print::ProcessImpl; auto SVCUserMessage = &SVC_UserMessage::ProcessImpl; CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VFTable, (LPVOID&)SVCPrint, 3, (LPVOID*)&SVC_Print_Process); CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VFTable, (LPVOID&)SVCUserMessage, 3, (LPVOID*)&SVC_UserMessage_Process); +#endif // DEDICATED } -void CNetMessages_Detach() +void V_NetMessages::Detach() const { +#if !defined(DEDICATED) void* hkRestore = nullptr; CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VFTable, (LPVOID)SVC_Print_Process, 3, (LPVOID*)&hkRestore); CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VFTable, (LPVOID)SVC_UserMessage_Process, 3, (LPVOID*)&hkRestore); +#endif // DEDICATED } \ No newline at end of file diff --git a/r5dev/common/netmessages.h b/r5dev/common/netmessages.h index 02ca6747..7a459b37 100644 --- a/r5dev/common/netmessages.h +++ b/r5dev/common/netmessages.h @@ -111,18 +111,14 @@ inline void* g_pSVC_Print_VFTable = nullptr; inline auto SVC_UserMessage_Process = CMemory().RCast(); inline void* g_pSVC_UserMessage_VFTable = nullptr; -void CNetMessages_Attach(); -void CNetMessages_Detach(); - /////////////////////////////////////////////////////////////////////////////// -class HMM_Heartbeat : public IDetour +class V_NetMessages : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: MM_Heartbeat::ToString : {:#18x} |\n", MM_Heartbeat__ToString.GetPtr()); - spdlog::debug("| CON: SVC_Print (VFTable) : {:#18x} |\n", reinterpret_cast(g_pSVC_Print_VFTable)); - spdlog::debug("| CON: SVC_UserMessage (VFTable) : {:#18x} |\n", reinterpret_cast(g_pSVC_UserMessage_VFTable)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("MM_Heartbeat::ToString", MM_Heartbeat__ToString.GetPtr()); + LogConAdr("SVC_Print (VFTable)", reinterpret_cast(g_pSVC_Print_VFTable)); + LogConAdr("SVC_UserMessage (VFTable)", reinterpret_cast(g_pSVC_UserMessage_VFTable)); } virtual void GetFun(void) const { @@ -136,9 +132,8 @@ class HMM_Heartbeat : public IDetour g_pSVC_Print_VFTable = g_GameDll.GetVirtualMethodTable(".?AVSVC_Print@@"); g_pSVC_UserMessage_VFTable = g_GameDll.GetVirtualMethodTable(".?AVSVC_UserMessage@@"); } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(HMM_Heartbeat); diff --git a/r5dev/common/opcodes.h b/r5dev/common/opcodes.h index da73884f..2f9dfec3 100644 --- a/r5dev/common/opcodes.h +++ b/r5dev/common/opcodes.h @@ -80,33 +80,24 @@ class VOpcodes : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CShaderSystem::Init : {:#18x} |\n", CShaderSystem__Init.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: CVGui::RunFrame : {:#18x} |\n", CVGui__RunFrame.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: CEngineVGui::Shutdown : {:#18x} |\n", CEngineVGui__Shutdown.GetPtr()); - spdlog::debug("| FUN: CEngineVGui::ActivateGameUI : {:#18x} |\n", CEngineVGui__ActivateGameUI.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: CInputSystem::RunFrameIME : {:#18x} |\n", CInputSystem__RunFrameIME.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: Sys_InitGame : {:#18x} |\n", Sys_InitGame.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: Host_Init_1 : {:#18x} |\n", gHost_Init_1.GetPtr()); - spdlog::debug("| FUN: Host_Init_2 : {:#18x} |\n", gHost_Init_2.GetPtr()); - spdlog::debug("| FUN: Host_Disconnect : {:#18x} |\n", Host_Disconnect.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CShaderSystem::Init", CShaderSystem__Init.GetPtr()); + LogFunAdr("CVGui::RunFrame", CVGui__RunFrame.GetPtr()); + LogFunAdr("CEngineVGui::Shutdown", CEngineVGui__Shutdown.GetPtr()); + LogFunAdr("CEngineVGui::ActivateGameUI", CEngineVGui__ActivateGameUI.GetPtr()); + LogFunAdr("CInputSystem::RunFrameIME", CInputSystem__RunFrameIME.GetPtr()); + LogFunAdr("Sys_InitGame", Sys_InitGame.GetPtr()); + LogFunAdr("Host_Init_1", gHost_Init_1.GetPtr()); + LogFunAdr("Host_Init_2", gHost_Init_2.GetPtr()); + LogFunAdr("Host_Disconnect", Host_Disconnect.GetPtr()); #ifndef CLIENT_DLL - spdlog::debug("| FUN: Server_S2C_CONNECT_1 : {:#18x} |\n", Server_S2C_CONNECT_1.GetPtr()); + LogFunAdr("Server_S2C_CONNECT_1", Server_S2C_CONNECT_1.GetPtr()); #endif // !CLIENT_DLL - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: GetEngineClientThread : {:#18x} |\n", GetEngineClientThread.GetPtr()); - spdlog::debug("| FUN: MatchMaking_Frame : {:#18x} |\n", MatchMaking_Frame.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("GetEngineClientThread", GetEngineClientThread.GetPtr()); + LogFunAdr("MatchMaking_Frame", MatchMaking_Frame.GetPtr()); #if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1) - spdlog::debug("| FUN: CWin32Surface::initStaticData : {:#18x} |\n", CWin32Surface_initStaticData.GetPtr()); + LogFunAdr("CWin32Surface::initStaticData", CWin32Surface_initStaticData.GetPtr()); #endif - spdlog::debug("| FUN: KeyboardLayout_Init : {:#18x} |\n", KeyboardLayout_Init.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("KeyboardLayout_Init", KeyboardLayout_Init.GetPtr()); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -199,5 +190,3 @@ class VOpcodes : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VOpcodes); diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index 1d5261c8..57a61977 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -71,9 +71,11 @@ #include "engine/client/cl_main.h" #include "engine/client/client.h" #include "engine/client/clientstate.h" +#include "engine/enginetrace.h" #include "engine/traceinit.h" #include "engine/common.h" #include "engine/cmodel_bsp.h" +#include "engine/modelinfo.h" #include "engine/host.h" #include "engine/host_cmd.h" #include "engine/host_state.h" @@ -90,6 +92,7 @@ #include "engine/sys_utils.h" #include "engine/sys_getmodes.h" #ifndef DEDICATED +#include "engine/gl_rmain.h" #include "engine/sys_mainwind.h" #endif // !DEDICATED #include "engine/matsys_interface.h" @@ -99,6 +102,8 @@ #include "engine/gl_rsurf.h" #include "engine/debugoverlay.h" #endif // !DEDICATED +#include "game/shared/util_shared.h" +#include "game/shared/usercmd.h" #include "game/shared/animation.h" #ifndef CLIENT_DLL #include "game/server/ai_node.h" @@ -113,6 +118,7 @@ #endif // !CLIENT_DLL #ifndef DEDICATED #include "game/client/viewrender.h" +#include "game/client/movehelper_client.h" #endif // !DEDICATED #include "public/edict.h" #include "public/utility/binstream.h" @@ -155,100 +161,11 @@ void Systems_Init() DetourUpdateThread(GetCurrentThread()); // Hook functions - //TSList_Attach(); + for (const IDetour* pDetour : vDetour) + { + pDetour->Attach(); + } - Launcher_Attach(); - IApplication_Attach(); -#ifdef DEDICATED - //PRX_Attach(); -#endif // DEDICATED -#ifndef DEDICATED - CL_Ents_Parse_Attach(); -#endif // !DEDICATED - CBaseClient_Attach(); - CBaseFileSystem_Attach(); - - MDLCache_Attach(); - -#ifndef DEDICATED - BinkImpl_Attach(); - MilesCore_Attach(); - - CMaterialSystem_Attach(); -#endif // !DEDICATED - - QHull_Attach(); - BspLib_Attach(); - -#ifndef DEDICATED - CEngineVGui_Attach(); - //CFPSPanel_Attach(); - CHLClient_Attach(); -#endif // !DEDICATED - -#if !defined(CLIENT_DLL) && defined (GAMEDLL_S3) - CServer_Attach(); // S1 and S2 CServer functions require work. -#endif // !CLIENT_DLL && GAMEDLL_S3 - - Host_Attach(); - HostCmd_Attach(); - - CHostState_Attach(); - - CModelBsp_Attach(); - CModelLoader_Attach(); - -#if !defined(DEDICATED) && defined (GAMEDLL_S3) - CNetMessages_Attach(); // S1 and S2 require certification. -#endif // !DEDICATED && GAMEDLL_S3 - - NET_Attach(); - NetChan_Attach(); - - ConCommand_Attach(); - IConVar_Attach(); - CKeyValueSystem_Attach(); - -#ifndef CLIENT_DLL - Persistence_Attach(); - IVEngineServer_Attach(); - CServerGameDLL_Attach(); - - Physics_Main_Attach(); -#endif // !CLIENT_DLL - - SQAPI_Attach(); - SQVM_Attach(); - SQScript_Attach(); - SQAUX_Attach(); - - RTech_Game_Attach(); - RTech_Utils_Attach(); -#ifndef DEDICATED - Rui_Attach(); -#endif // !DEDICATED - - SysDll_Attach(); - SysDll2_Attach(); - SysUtils_Attach(); -#ifndef DEDICATED - SysGame_Attach(); -#endif // !DEDICATED - -#ifndef DEDICATED - HCVideoMode_Common_Attach(); - DebugOverlays_Attach(); - - MatSys_Iface_Attach(); - RSurf_Attach(); -#endif // !DEDICATED - - Animation_Attach(); -#ifndef CLIENT_DLL - CAI_Utility_Attach(); - CAI_Network_Attach(); - CAI_NetworkManager_Attach(); -#endif // !#ifndef CLIENT_DLL // Patch instructions RuntimePtc_Init(); @@ -292,99 +209,10 @@ void Systems_Shutdown() DetourUpdateThread(GetCurrentThread()); // Unhook functions - //TSList_Detach(); - - Launcher_Detach(); - IApplication_Detach(); -#ifdef DEDICATED - //PRX_Detach(); -#endif // DEDICATED -#ifndef DEDICATED - CL_Ents_Parse_Detach(); -#endif // !DEDICATED - CBaseClient_Detach(); - CBaseFileSystem_Detach(); - - MDLCache_Detach(); - -#ifndef DEDICATED - BinkImpl_Detach(); - MilesCore_Detach(); - - CMaterialSystem_Detach(); -#endif // !DEDICATED - - QHull_Detach(); - BspLib_Detach(); - -#ifndef DEDICATED - CEngineVGui_Detach(); - //CFPSPanel_Detach(); - CHLClient_Detach(); -#endif // !DEDICATED - -#if !defined(CLIENT_DLL) && defined (GAMEDLL_S3) - CServer_Detach(); // S1 and S2 CServer functions require work. -#endif // !CLIENT_DLL && GAMEDLL_S3 - - Host_Detach(); - HostCmd_Detach(); - - CHostState_Detach(); - - CModelBsp_Detach(); - CModelLoader_Detach(); - -#if !defined(DEDICATED) && defined (GAMEDLL_S3) - CNetMessages_Detach(); // S1 and S2 require certification. -#endif // !DEDICATED && GAMEDLL_S3 - - NET_Detach(); - NetChan_Detach(); - - ConCommand_Detach(); - IConVar_Detach(); - CKeyValueSystem_Detach(); - -#ifndef CLIENT_DLL - Persistence_Detach(); - IVEngineServer_Detach(); - CServerGameDLL_Detach(); - - Physics_Main_Detach(); -#endif // !CLIENT_DLL - SQAPI_Detach(); - SQVM_Detach(); - SQScript_Detach(); - SQAUX_Detach(); - - RTech_Game_Detach(); - RTech_Utils_Detach(); -#ifndef DEDICATED - Rui_Detach(); -#endif // !DEDICATED - - SysDll_Detach(); - SysDll2_Detach(); - SysUtils_Detach(); -#ifndef DEDICATED - SysGame_Detach(); -#endif // DEDICATED - -#ifndef DEDICATED - HCVideoMode_Common_Detach(); - DebugOverlays_Detach(); - - MatSys_Iface_Detach(); - RSurf_Detach(); -#endif // !DEDICATED - - Animation_Detach(); -#ifndef CLIENT_DLL - CAI_Utility_Detach(); - CAI_Network_Detach(); - CAI_NetworkManager_Detach(); -#endif // !CLIENT_DLL + for (const IDetour* pDetour : vDetour) + { + pDetour->Detach(); + } // Commit the transaction DetourTransactionCommit(); @@ -517,9 +345,10 @@ void DetourInit() // Run the sigscan if (!bInitDivider) { bInitDivider = true; - spdlog::debug("+----------------------------------------------------------------+\n"); + spdlog::debug("+---------------------------------------------------------------------+\n"); } pDetour->GetAdr(); + spdlog::debug("+---------------------------------------------------------------------+\n"); } } @@ -534,9 +363,194 @@ void DetourInit() // Run the sigscan void DetourAddress() // Test the sigscan results { - spdlog::debug("+----------------------------------------------------------------+\n"); + spdlog::debug("+---------------------------------------------------------------------+\n"); for (const IDetour* pDetour : vDetour) { pDetour->GetAdr(); + spdlog::debug("+---------------------------------------------------------------------+\n"); } } + +// Tier0 +REGISTER(VPlatform); +REGISTER(VJobThread); +REGISTER(VThreadTools); +REGISTER(VTSListBase); +REGISTER(VMemStd); + +// Tier1 +REGISTER(VCommandLine); +REGISTER(VConCommand); +REGISTER(VConVar); +REGISTER(VCVar); + +// VPC +REGISTER(VAppSystem); +REGISTER(VKeyValues); +REGISTER(VFactory); + +// VstdLib +REGISTER(VCallback); +REGISTER(VCompletion); +REGISTER(HKeyValuesSystem); + +// Common +REGISTER(VOpcodes); +REGISTER(V_NetMessages); + +// Launcher +REGISTER(VPRX); +REGISTER(VLauncher); +REGISTER(VApplication); + +// FileSystem +REGISTER(VBaseFileSystem); +REGISTER(VFileSystem_Stdio); + +// DataCache +REGISTER(VMDLCache); + +// Ebisu +REGISTER(VEbisuSDK); + +#ifndef DEDICATED + +// Codecs +REGISTER(BinkCore); // REGISTER CLIENT ONLY! +REGISTER(MilesCore); // REGISTER CLIENT ONLY! +REGISTER(VRadShal); + +#endif // !DEDICATED + +// VPhysics +REGISTER(VQHull); + +// BspLib +REGISTER(VBspLib); + +// MaterialSystem +REGISTER(VMaterialSystem); +REGISTER(VMaterialGlue); + +#ifndef DEDICATED +REGISTER(VShaderGlue); + +// VGui +REGISTER(VEngineVGui); // REGISTER CLIENT ONLY! +REGISTER(VFPSPanel); // REGISTER CLIENT ONLY! +REGISTER(VMatSystemSurface); + +// Client +REGISTER(HVEngineClient); +#endif // !DEDICATED + +REGISTER(VDll_Engine_Int); + +#ifndef CLIENT_DLL + +// Server +REGISTER(VServer); // REGISTER SERVER ONLY! +REGISTER(VPersistence); // REGISTER SERVER ONLY! +REGISTER(HVEngineServer); // REGISTER SERVER ONLY! + +#endif // !CLIENT_DLL + +// Squirrel +REGISTER(VSqInit); +REGISTER(VSqapi); +REGISTER(HSQVM); +REGISTER(VSquirrelVM); +REGISTER(VSqStdAux); + +// Studio +REGISTER(VStudioRenderContext); + +// RTech +REGISTER(V_RTechGame); +REGISTER(V_RTechUtils); +REGISTER(VStryder); + +REGISTER(V_Rui); // Should this be client dll only??? + +#ifndef DEDICATED +REGISTER(V_CL_Ents_Parse); // REGISTER CLIENT ONLY! +#endif // !DEDICATED + +// Engine/client +REGISTER(VCL_Main); +REGISTER(VClient); +REGISTER(VClientState); + +// Engine +REGISTER(VTraceInit); +REGISTER(VCommon); +REGISTER(VModel_BSP); +REGISTER(VHost); +REGISTER(VHostCmd); +REGISTER(VHostState); +REGISTER(VModelLoader); +REGISTER(VNet); +REGISTER(VNetChannel); + +REGISTER(VSys_Dll); +REGISTER(VSys_Dll2); +REGISTER(VSys_Utils); +REGISTER(VEngine); +REGISTER(VEngineTrace); +REGISTER(VModelInfo); + +REGISTER(HVideoMode_Common); + +#ifndef DEDICATED +REGISTER(VGL_RMain); // Client only? +#endif // !DEDICATED + +REGISTER(VMatSys_Interface); // Should this be client dll only??? +REGISTER(VGL_MatSysIFace); +REGISTER(VGL_Screen); + + +// !!! SERVER DLL ONLY !!! +REGISTER(HSV_Main); +// !!! END SERVER DLL ONLY !!! + +#ifndef DEDICATED +REGISTER(VGame); // REGISTER CLIENT ONLY! +REGISTER(VGL_RSurf); +#endif // !DEDICATED + +REGISTER(VDebugOverlay); // !TODO: This also needs to be exposed to server dll!!! + +// Game/shared +REGISTER(VUserCmd); +REGISTER(VAnimation); +REGISTER(VUtil_Shared); + +#ifndef CLIENT_DLL + +// Game/server +REGISTER(VAI_Network); +REGISTER(VAI_NetworkManager); +REGISTER(VRecast); +REGISTER(VFairFight); +REGISTER(VServerGameDLL); +REGISTER(VMoveHelperServer); +REGISTER(VPhysics_Main); // REGISTER SERVER ONLY +REGISTER(VBaseEntity); +REGISTER(VBaseAnimating); +REGISTER(VPlayer); + +#endif // !CLIENT_DLL + +#ifndef DEDICATED +REGISTER(V_ViewRender); +REGISTER(VMoveHelperClient); +#endif // !DEDICATED + +// Public +REGISTER(VEdict); + +#ifndef DEDICATED +REGISTER(VInputSystem); +REGISTER(VDXGI); +#endif // !DEDICATED \ No newline at end of file diff --git a/r5dev/core/stdafx.h b/r5dev/core/stdafx.h index fa165b57..5639b3f8 100644 --- a/r5dev/core/stdafx.h +++ b/r5dev/core/stdafx.h @@ -130,4 +130,17 @@ ReturnType CallVFunc(int index, void* thisPtr, Args... args) { return (*reinterpret_cast(thisPtr))[index](thisPtr, args...); } + +inline void LogFunAdr(const char* szFun, uintptr_t nAdr) // Logging function addresses. +{ + spdlog::debug("| FUN: {:42s}: {:#18x} |\n", szFun, nAdr); +} +inline void LogVarAdr(const char* szVar, uintptr_t nAdr) // Logging variable addresses. +{ + spdlog::debug("| VAR: {:42s}: {:#18x} |\n", szVar, nAdr); +} +inline void LogConAdr(const char* szCon, uintptr_t nAdr) // Logging constant addresses. +{ + spdlog::debug("| CON: {:42s}: {:#18x} |\n", szCon, nAdr); +} #endif // !SDKLAUNCHER && !NETCONSOLE && !PLUGINSDK \ No newline at end of file diff --git a/r5dev/datacache/mdlcache.cpp b/r5dev/datacache/mdlcache.cpp index b15cb7bb..64309b35 100644 --- a/r5dev/datacache/mdlcache.cpp +++ b/r5dev/datacache/mdlcache.cpp @@ -357,7 +357,7 @@ bool CMDLCache::IsKnownBadModel(MDLHandle_t handle) return std::find(g_vBadMDLHandles.begin(), g_vBadMDLHandles.end(), handle) != g_vBadMDLHandles.end(); } -void MDLCache_Attach() +void VMDLCache::Attach() const { DetourAttach((LPVOID*)&v_CMDLCache__FindMDL, &CMDLCache::FindMDL); #ifdef GAMEDLL_S3 // !!! DECLARED INLINE WITH FINDMDL IN < S3 !!! @@ -370,7 +370,7 @@ void MDLCache_Attach() #endif } -void MDLCache_Detach() +void VMDLCache::Detach() const { DetourDetach((LPVOID*)&v_CMDLCache__FindMDL, &CMDLCache::FindMDL); #ifdef GAMEDLL_S3 // !!! DECLARED INLINE WITH FINDMDL IN < S3 !!! diff --git a/r5dev/datacache/mdlcache.h b/r5dev/datacache/mdlcache.h index 1da43644..5313e8e7 100644 --- a/r5dev/datacache/mdlcache.h +++ b/r5dev/datacache/mdlcache.h @@ -105,29 +105,25 @@ inline LPCRITICAL_SECTION* m_MDLMutex = nullptr; inline PSRWLOCK* m_MDLLock = nullptr; inline CMDLCache* g_MDLCache = nullptr; - -void MDLCache_Attach(); -void MDLCache_Detach(); /////////////////////////////////////////////////////////////////////////////// class VMDLCache : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CMDLCache::FindMDL : {:#18x} |\n", p_CMDLCache__FindMDL.GetPtr()); + LogFunAdr("CMDLCache::FindMDL", p_CMDLCache__FindMDL.GetPtr()); #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2) - spdlog::debug("| FUN: CMDLCache::FindCachedMDL : {:#18x} |\n", p_CMDLCache__FindCachedMDL.GetPtr()); - spdlog::debug("| FUN: CMDLCache::FindUncachedMDL : {:#18x} |\n", p_CMDLCache__FindUncachedMDL.GetPtr()); + LogFunAdr("CMDLCache::FindCachedMDL", p_CMDLCache__FindCachedMDL.GetPtr()); + LogFunAdr("CMDLCache::FindUncachedMDL", p_CMDLCache__FindUncachedMDL.GetPtr()); #endif - spdlog::debug("| FUN: CMDLCache::GetStudioHDR : {:#18x} |\n", p_CMDLCache__GetStudioHDR.GetPtr()); - spdlog::debug("| FUN: CMDLCache::GetHardwareData : {:#18x} |\n", p_CMDLCache__GetHardwareData.GetPtr()); + LogFunAdr("CMDLCache::GetStudioHDR", p_CMDLCache__GetStudioHDR.GetPtr()); + LogFunAdr("CMDLCache::GetHardwareData", p_CMDLCache__GetHardwareData.GetPtr()); #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2) - spdlog::debug("| FUN: CStudioHWDataRef::SetFlags : {:#18x} |\n", p_CStudioHWDataRef__SetFlags.GetPtr()); + LogFunAdr("CStudioHWDataRef::SetFlags", p_CStudioHWDataRef__SetFlags.GetPtr()); #endif - spdlog::debug("| VAR: m_MDLMutex : {:#18x} |\n", reinterpret_cast(m_MDLMutex)); - spdlog::debug("| VAR: m_MDLLock : {:#18x} |\n", reinterpret_cast(m_MDLLock)); - spdlog::debug("| VAR: m_MDLDict : {:#18x} |\n", reinterpret_cast(m_MDLDict)); - spdlog::debug("| VAR: g_MDLCache : {:#18x} |\n", reinterpret_cast(g_MDLCache)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("m_MDLMutex", reinterpret_cast(m_MDLMutex)); + LogVarAdr("m_MDLLock", reinterpret_cast(m_MDLLock)); + LogVarAdr("m_MDLDict", reinterpret_cast(m_MDLDict)); + LogVarAdr("g_MDLCache", reinterpret_cast(g_MDLCache)); } virtual void GetFun(void) const { @@ -178,10 +174,9 @@ class VMDLCache : public IDetour .ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VMDLCache); #endif // MDLCACHE_H diff --git a/r5dev/ebisusdk/EbisuSDK.h b/r5dev/ebisusdk/EbisuSDK.h index 165f076f..3135ebc4 100644 --- a/r5dev/ebisusdk/EbisuSDK.h +++ b/r5dev/ebisusdk/EbisuSDK.h @@ -33,16 +33,15 @@ class VEbisuSDK : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: EbisuSDK_Tier0_Init : {:#18x} |\n", p_EbisuSDK_Tier0_Init.GetPtr()); - spdlog::debug("| FUN: EbisuSDK_CVar_Init : {:#18x} |\n", p_EbisuSDK_CVar_Init.GetPtr()); - spdlog::debug("| FUN: EbisuSDK_SetState : {:#18x} |\n", p_EbisuSDK_SetState.GetPtr()); - spdlog::debug("| VAR: g_NucleusID : {:#18x} |\n", reinterpret_cast(g_NucleusID)); - spdlog::debug("| VAR: g_OriginErrorLevel : {:#18x} |\n", reinterpret_cast(g_OriginErrorLevel)); - spdlog::debug("| VAR: g_OriginAuthCode : {:#18x} |\n", reinterpret_cast(g_OriginAuthCode)); - spdlog::debug("| VAR: g_OriginNucleusToken : {:#18x} |\n", reinterpret_cast(g_OriginNucleusToken)); - spdlog::debug("| VAR: g_bEbisuSDKInitialized : {:#18x} |\n", reinterpret_cast(g_bEbisuSDKInitialized)); - spdlog::debug("| VAR: g_bEbisuSDKCvarInitialized : {:#18x} |\n", reinterpret_cast(g_bEbisuSDKCvarInitialized)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("EbisuSDK_Tier0_Init", p_EbisuSDK_Tier0_Init.GetPtr()); + LogFunAdr("EbisuSDK_CVar_Init", p_EbisuSDK_CVar_Init.GetPtr()); + LogFunAdr("EbisuSDK_SetState", p_EbisuSDK_SetState.GetPtr()); + LogVarAdr("g_NucleusID", reinterpret_cast(g_NucleusID)); + LogVarAdr("g_OriginErrorLevel", reinterpret_cast(g_OriginErrorLevel)); + LogVarAdr("g_OriginAuthCode", reinterpret_cast(g_OriginAuthCode)); + LogVarAdr("g_OriginNucleusToken", reinterpret_cast(g_OriginNucleusToken)); // TODO: rename to g_NucleusToken. + LogVarAdr("g_bEbisuSDKInitialized", reinterpret_cast(g_bEbisuSDKInitialized)); + LogVarAdr("g_bEbisuSDKCvarInitialized", reinterpret_cast(g_bEbisuSDKCvarInitialized)); } virtual void GetFun(void) const { @@ -73,5 +72,3 @@ class VEbisuSDK : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VEbisuSDK); diff --git a/r5dev/engine/client/cl_ents_parse.cpp b/r5dev/engine/client/cl_ents_parse.cpp index 090249cf..eb8d58ad 100644 --- a/r5dev/engine/client/cl_ents_parse.cpp +++ b/r5dev/engine/client/cl_ents_parse.cpp @@ -24,12 +24,3 @@ bool CL_CopyExistingEntity(__int64 a1, unsigned int* a2, char* a3) } return v_CL_CopyExistingEntity(a1, a2, a3); } - -void CL_Ents_Parse_Attach() -{ - DetourAttach((LPVOID*)&v_CL_CopyExistingEntity, &CL_CopyExistingEntity); -} -void CL_Ents_Parse_Detach() -{ - DetourDetach((LPVOID*)&v_CL_CopyExistingEntity, &CL_CopyExistingEntity); -} \ No newline at end of file diff --git a/r5dev/engine/client/cl_ents_parse.h b/r5dev/engine/client/cl_ents_parse.h index 5e1fc492..07d362d3 100644 --- a/r5dev/engine/client/cl_ents_parse.h +++ b/r5dev/engine/client/cl_ents_parse.h @@ -4,14 +4,13 @@ inline CMemory p_CL_CopyExistingEntity; inline auto v_CL_CopyExistingEntity = p_CL_CopyExistingEntity.RCast(); - +bool CL_CopyExistingEntity(__int64 a1, unsigned int* a2, char* a3); /////////////////////////////////////////////////////////////////////////////// class V_CL_Ents_Parse : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CL_CopyExistingEntity : {:#18x} |\n", p_CL_CopyExistingEntity.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CL_CopyExistingEntity", p_CL_CopyExistingEntity.GetPtr()); } virtual void GetFun(void) const { @@ -20,13 +19,15 @@ class V_CL_Ents_Parse : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const + { + DetourAttach((LPVOID*)&v_CL_CopyExistingEntity, &CL_CopyExistingEntity); + } + virtual void Detach(void) const + { + DetourDetach((LPVOID*)&v_CL_CopyExistingEntity, &CL_CopyExistingEntity); + } }; /////////////////////////////////////////////////////////////////////////////// -void CL_Ents_Parse_Attach(); -void CL_Ents_Parse_Detach(); - -REGISTER(V_CL_Ents_Parse); #endif // !CL_ENTS_PARSE_H diff --git a/r5dev/engine/client/cl_main.h b/r5dev/engine/client/cl_main.h index caa5d5a6..4a10efe8 100644 --- a/r5dev/engine/client/cl_main.h +++ b/r5dev/engine/client/cl_main.h @@ -15,9 +15,8 @@ class VCL_Main : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CL_EndMovie : {:#18x} |\n", p_CL_EndMovie.GetPtr()); - spdlog::debug("| FUN: CL_ClearState : {:#18x} |\n", p_CL_ClearState.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CL_EndMovie", p_CL_EndMovie.GetPtr()); + LogFunAdr("CL_ClearState", p_CL_ClearState.GetPtr()); } virtual void GetFun(void) const { @@ -37,5 +36,3 @@ class VCL_Main : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VCL_Main); diff --git a/r5dev/engine/client/client.cpp b/r5dev/engine/client/client.cpp index be2e0b50..e6688b5f 100644 --- a/r5dev/engine/client/client.cpp +++ b/r5dev/engine/client/client.cpp @@ -332,19 +332,5 @@ bool CClient::VProcessStringCmd(CClient* pClient, NET_StringCmd* pMsg) return v_CClient_ProcessStringCmd(pClient, pMsg); } -/////////////////////////////////////////////////////////////////////////////////// -void CBaseClient_Attach() -{ - DetourAttach((LPVOID*)&v_CClient_Clear, &CClient::VClear); - DetourAttach((LPVOID*)&v_CClient_Connect, &CClient::VConnect); - DetourAttach((LPVOID*)&v_CClient_ProcessStringCmd, &CClient::VProcessStringCmd); -} -void CBaseClient_Detach() -{ - DetourDetach((LPVOID*)&v_CClient_Clear, &CClient::VClear); - DetourDetach((LPVOID*)&v_CClient_Connect, &CClient::VConnect); - DetourDetach((LPVOID*)&v_CClient_ProcessStringCmd, &CClient::VProcessStringCmd); -} - /////////////////////////////////////////////////////////////////////////////// CClient* g_pClient = nullptr; \ No newline at end of file diff --git a/r5dev/engine/client/client.h b/r5dev/engine/client/client.h index 7b3e21b2..444c5330 100644 --- a/r5dev/engine/client/client.h +++ b/r5dev/engine/client/client.h @@ -114,22 +114,17 @@ inline auto v_CClient_ProcessStringCmd = p_CClient_ProcessStringCmd.RCast(); -/////////////////////////////////////////////////////////////////////////////// -void CBaseClient_Attach(); -void CBaseClient_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VClient : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CClient::Connect : {:#18x} |\n", p_CClient_Connect.GetPtr()); - spdlog::debug("| FUN: CClient::Disconnect : {:#18x} |\n", p_CClient_Disconnect.GetPtr()); - spdlog::debug("| FUN: CClient::Clear : {:#18x} |\n", p_CClient_Clear.GetPtr()); - spdlog::debug("| FUN: CClient::ProcessStringCmd : {:#18x} |\n", p_CClient_ProcessStringCmd.GetPtr()); - spdlog::debug("| FUN: CClient::SetSignonState : {:#18x} |\n", p_CClient_SetSignonState.GetPtr()); - spdlog::debug("| VAR: g_pClient[128] : {:#18x} |\n", reinterpret_cast(g_pClient)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CClient::Connect", p_CClient_Connect.GetPtr()); + LogFunAdr("CClient::Disconnect", p_CClient_Disconnect.GetPtr()); + LogFunAdr("CClient::Clear", p_CClient_Clear.GetPtr()); + LogFunAdr("CClient::ProcessStringCmd", p_CClient_ProcessStringCmd.GetPtr()); + LogFunAdr("CClient::SetSignonState", p_CClient_SetSignonState.GetPtr()); + LogVarAdr("g_pClient[128]", reinterpret_cast(g_pClient)); } virtual void GetFun(void) const { @@ -159,9 +154,18 @@ class VClient : public IDetour .FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const + { + DetourAttach((LPVOID*)&v_CClient_Clear, &CClient::VClear); + DetourAttach((LPVOID*)&v_CClient_Connect, &CClient::VConnect); + DetourAttach((LPVOID*)&v_CClient_ProcessStringCmd, &CClient::VProcessStringCmd); + } + virtual void Detach(void) const + { + DetourDetach((LPVOID*)&v_CClient_Clear, &CClient::VClear); + DetourDetach((LPVOID*)&v_CClient_Connect, &CClient::VConnect); + DetourDetach((LPVOID*)&v_CClient_ProcessStringCmd, &CClient::VProcessStringCmd); + } }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VClient); diff --git a/r5dev/engine/client/clientstate.h b/r5dev/engine/client/clientstate.h index f18b6e1d..43d2126d 100644 --- a/r5dev/engine/client/clientstate.h +++ b/r5dev/engine/client/clientstate.h @@ -195,13 +195,12 @@ class VClientState : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CClientState::RunFrame : {:#18x} |\n", p_CClientState__RunFrame.GetPtr()); - spdlog::debug("| FUN: CClientState::Disconnect : {:#18x} |\n", p_CClientState__Disconnect.GetPtr()); + LogFunAdr("CClientState::RunFrame", p_CClientState__RunFrame.GetPtr()); + LogFunAdr("CClientState::Disconnect", p_CClientState__Disconnect.GetPtr()); #ifndef DEDICATED - spdlog::debug("| VAR: g_pClientState : {:#18x} |\n", reinterpret_cast(g_pClientState)); - spdlog::debug("| VAR: g_pClientState_Shifted : {:#18x} |\n", reinterpret_cast(g_pClientState_Shifted)); + LogVarAdr("g_pClientState", reinterpret_cast(g_pClientState)); + LogVarAdr("g_pClientState_Shifted", reinterpret_cast(g_pClientState_Shifted)); #endif // DEDICATED - spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { @@ -231,5 +230,3 @@ class VClientState : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VClientState); diff --git a/r5dev/engine/cmodel_bsp.cpp b/r5dev/engine/cmodel_bsp.cpp index 70a1eda9..866fc982 100644 --- a/r5dev/engine/cmodel_bsp.cpp +++ b/r5dev/engine/cmodel_bsp.cpp @@ -437,13 +437,13 @@ void Mod_UnloadPakFile(void) g_vBadMDLHandles.clear(); } -void CModelBsp_Attach() +void VModel_BSP::Attach() const { DetourAttach((LPVOID*)&v_Mod_LoadPakForMap, &Mod_LoadPakForMap); DetourAttach((LPVOID*)&v_Mod_ProcessPakQueue, &Mod_ProcessPakQueue); } -void CModelBsp_Detach() +void VModel_BSP::Detach() const { DetourDetach((LPVOID*)&v_Mod_LoadPakForMap, &Mod_LoadPakForMap); DetourDetach((LPVOID*)&v_Mod_ProcessPakQueue, &Mod_ProcessPakQueue); diff --git a/r5dev/engine/cmodel_bsp.h b/r5dev/engine/cmodel_bsp.h index c374f641..b9bfe473 100644 --- a/r5dev/engine/cmodel_bsp.h +++ b/r5dev/engine/cmodel_bsp.h @@ -37,31 +37,28 @@ KeyValues* Mod_GetLevelSettings(const char* pszLevelName); void Mod_PreloadLevelPaks(const char* pszLevelName); void Mod_UnloadPakFile(void); -void CModelBsp_Attach(); -void CModelBsp_Detach(); + /////////////////////////////////////////////////////////////////////////////// class VModel_BSP : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Mod_LoadPakForMap : {:#18x} |\n", p_Mod_LoadPakForMap.GetPtr()); - spdlog::debug("| FUN: Mod_ProcessPakQueue : {:#18x} |\n", p_Mod_ProcessPakQueue.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: sub_14045BAC0 : {:#18x} |\n", reinterpret_cast(sub_14045BAC0)); - spdlog::debug("| FUN: sub_14045A1D0 : {:#18x} |\n", reinterpret_cast(sub_14045A1D0)); - spdlog::debug("| FUN: sub_140441220 : {:#18x} |\n", reinterpret_cast(sub_140441220)); - spdlog::debug("| VAR: dword_14B383420 : {:#18x} |\n", reinterpret_cast(dword_14B383420)); - spdlog::debug("| VAR: dword_1634F445C : {:#18x} |\n", reinterpret_cast(dword_1634F445C)); - spdlog::debug("| VAR: qword_167ED7BB8 : {:#18x} |\n", reinterpret_cast(qword_167ED7BB8)); - spdlog::debug("| VAR: qword_14180A098 : {:#18x} |\n", reinterpret_cast(qword_14180A098)); - spdlog::debug("| VAR: byte_16709DDDF : {:#18x} |\n", reinterpret_cast(byte_16709DDDF)); - spdlog::debug("| VAR: off_141874660 : {:#18x} |\n", reinterpret_cast(off_141874660)); - spdlog::debug("| VAR: unk_141874555 : {:#18x} |\n", reinterpret_cast(unk_141874555)); - spdlog::debug("| VAR: unk_1418749B0 : {:#18x} |\n", reinterpret_cast(unk_1418749B0)); - spdlog::debug("| VAR: unk_141874550 : {:#18x} |\n", reinterpret_cast(unk_141874550)); - spdlog::debug("| VAR: qword_167ED7BC0 : {:#18x} |\n", reinterpret_cast(qword_167ED7BC0)); - spdlog::debug("| VAR: qword_167ED7C68 : {:#18x} |\n", reinterpret_cast(qword_167ED7C68)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("Mod_LoadPakForMap", p_Mod_LoadPakForMap.GetPtr()); + LogFunAdr("Mod_ProcessPakQueue", p_Mod_ProcessPakQueue.GetPtr()); + LogFunAdr("sub_14045BAC0", reinterpret_cast(sub_14045BAC0)); + LogFunAdr("sub_14045A1D0", reinterpret_cast(sub_14045A1D0)); + LogFunAdr("sub_140441220", reinterpret_cast(sub_140441220)); + LogVarAdr("dword_14B383420", reinterpret_cast(dword_14B383420)); + LogVarAdr("dword_1634F445C", reinterpret_cast(dword_1634F445C)); + LogVarAdr("qword_167ED7BB8", reinterpret_cast(qword_167ED7BB8)); + LogVarAdr("qword_14180A098", reinterpret_cast(qword_14180A098)); + LogVarAdr("byte_16709DDDF", reinterpret_cast(byte_16709DDDF)); + LogVarAdr("off_141874660", reinterpret_cast(off_141874660)); + LogVarAdr("unk_141874555", reinterpret_cast(unk_141874555)); + LogVarAdr("unk_1418749B0", reinterpret_cast(unk_1418749B0)); + LogVarAdr("unk_141874550", reinterpret_cast(unk_141874550)); + LogVarAdr("qword_167ED7BC0", reinterpret_cast(qword_167ED7BC0)); + LogVarAdr("qword_167ED7C68", reinterpret_cast(qword_167ED7C68)); } virtual void GetFun(void) const { @@ -100,9 +97,7 @@ class VModel_BSP : public IDetour (*((char**)(&qword_167ED7C68))) -= 6; } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VModel_BSP); diff --git a/r5dev/engine/common.h b/r5dev/engine/common.h index 6644ee43..352319d2 100644 --- a/r5dev/engine/common.h +++ b/r5dev/engine/common.h @@ -12,9 +12,8 @@ class VCommon : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: COM_InitFilesystem : {:#18x} |\n", p_COM_InitFilesystem.GetPtr()); - spdlog::debug("| FUN: COM_ExplainDisconnection : {:#18x} |\n", p_COM_ExplainDisconnection.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("COM_InitFilesystem", p_COM_InitFilesystem.GetPtr()); + LogFunAdr("COM_ExplainDisconnection", p_COM_ExplainDisconnection.GetPtr()); } virtual void GetFun(void) const { @@ -30,5 +29,3 @@ class VCommon : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VCommon); diff --git a/r5dev/engine/debugoverlay.cpp b/r5dev/engine/debugoverlay.cpp index ad59ce94..6ab12bd2 100644 --- a/r5dev/engine/debugoverlay.cpp +++ b/r5dev/engine/debugoverlay.cpp @@ -324,12 +324,12 @@ void DrawAllOverlays(bool bDraw) } /////////////////////////////////////////////////////////////////////////////// -void DebugOverlays_Attach() +void VDebugOverlay::Attach() const { DetourAttach(&v_DrawAllOverlays, &DrawAllOverlays); } -void DebugOverlays_Detach() +void VDebugOverlay::Detach() const { DetourDetach(&v_DrawAllOverlays, &DrawAllOverlays); } diff --git a/r5dev/engine/debugoverlay.h b/r5dev/engine/debugoverlay.h index f07b94aa..52704fac 100644 --- a/r5dev/engine/debugoverlay.h +++ b/r5dev/engine/debugoverlay.h @@ -157,8 +157,6 @@ struct OverlayCapsule_t : public OverlayBase_t void DestroyOverlay(OverlayBase_t* pOverlay); void DrawOverlay(OverlayBase_t* pOverlay); -void DebugOverlays_Attach(); -void DebugOverlays_Detach(); inline CMemory p_DrawAllOverlays; inline auto v_DrawAllOverlays = p_DrawAllOverlays.RCast(); @@ -186,16 +184,15 @@ class VDebugOverlay : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: DrawAllOverlays : {:#18x} |\n", p_DrawAllOverlays.GetPtr()); - spdlog::debug("| FUN: DestroyOverlay : {:#18x} |\n", p_DestroyOverlay.GetPtr()); - spdlog::debug("| FUN: RenderLine : {:#18x} |\n", p_RenderLine.GetPtr()); - spdlog::debug("| FUN: RenderBox : {:#18x} |\n", p_RenderBox.GetPtr()); - spdlog::debug("| FUN: RenderWireframeSphere : {:#18x} |\n", p_RenderWireframeSphere.GetPtr()); - spdlog::debug("| VAR: s_pOverlays : {:#18x} |\n", reinterpret_cast(s_pOverlays)); - spdlog::debug("| VAR: s_OverlayMutex : {:#18x} |\n", reinterpret_cast(s_OverlayMutex)); - spdlog::debug("| VAR: g_nOverlayTickCount : {:#18x} |\n", reinterpret_cast(g_nOverlayTickCount)); - spdlog::debug("| VAR: g_nRenderTickCount : {:#18x} |\n", reinterpret_cast(g_nRenderTickCount)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("DrawAllOverlays", p_DrawAllOverlays.GetPtr()); + LogFunAdr("DestroyOverlay", p_DestroyOverlay.GetPtr()); + LogFunAdr("RenderLine", p_RenderLine.GetPtr()); + LogFunAdr("RenderBox", p_RenderBox.GetPtr()); + LogFunAdr("RenderWireframeSphere", p_RenderWireframeSphere.GetPtr()); + LogVarAdr("s_pOverlays", reinterpret_cast(s_pOverlays)); + LogVarAdr("s_OverlayMutex", reinterpret_cast(s_OverlayMutex)); + LogVarAdr("g_nOverlayTickCount", reinterpret_cast(g_nOverlayTickCount)); + LogVarAdr("g_nRenderTickCount", reinterpret_cast(g_nRenderTickCount)); } virtual void GetFun(void) const { @@ -230,9 +227,7 @@ class VDebugOverlay : public IDetour #endif } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VDebugOverlay); diff --git a/r5dev/engine/enginetrace.h b/r5dev/engine/enginetrace.h index 2027d841..033138ec 100644 --- a/r5dev/engine/enginetrace.h +++ b/r5dev/engine/enginetrace.h @@ -32,12 +32,11 @@ class VEngineTrace : public IDetour virtual void GetAdr(void) const { #ifndef CLIENT_DLL - spdlog::debug("| VAR: g_pEngineTraceServer : {:#18x} |\n", reinterpret_cast(g_pEngineTraceServer)); + LogVarAdr("g_pEngineTraceServer", reinterpret_cast(g_pEngineTraceServer)); #endif // CLIENT_DLL #ifndef DEDICATED - spdlog::debug("| VAR: g_pEngineTraceClient : {:#18x} |\n", reinterpret_cast(g_pEngineTraceClient)); + LogVarAdr("g_pEngineTraceClient", reinterpret_cast(g_pEngineTraceClient)); #endif // DEDICATED - spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { } virtual void GetVar(void) const { } @@ -52,5 +51,3 @@ class VEngineTrace : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VEngineTrace); \ No newline at end of file diff --git a/r5dev/engine/gl_matsysiface.h b/r5dev/engine/gl_matsysiface.h index 75aecc13..2867737c 100644 --- a/r5dev/engine/gl_matsysiface.h +++ b/r5dev/engine/gl_matsysiface.h @@ -10,8 +10,7 @@ class VGL_MatSysIFace : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: InitMaterialSystem : {:#18x} |\n", p_InitMaterialSystem.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("InitMaterialSystem", p_InitMaterialSystem.GetPtr()); } virtual void GetFun(void) const { @@ -24,5 +23,3 @@ class VGL_MatSysIFace : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VGL_MatSysIFace); diff --git a/r5dev/engine/gl_rmain.h b/r5dev/engine/gl_rmain.h index 35fcc896..3f0103a9 100644 --- a/r5dev/engine/gl_rmain.h +++ b/r5dev/engine/gl_rmain.h @@ -29,6 +29,4 @@ class VGL_RMain : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VGL_RMain); - #endif \ No newline at end of file diff --git a/r5dev/engine/gl_rsurf.cpp b/r5dev/engine/gl_rsurf.cpp index bbfbf727..8a1a0af6 100644 --- a/r5dev/engine/gl_rsurf.cpp +++ b/r5dev/engine/gl_rsurf.cpp @@ -32,16 +32,16 @@ void* R_DrawWorldMeshesDepthAtTheEnd(void* ptr1, void* ptr2, void* ptr3, DrawWor return nullptr; } -void RSurf_Attach() +void VGL_RSurf::Attach() const { - DetourAttach((LPVOID*)&V_DrawWorldMeshes, &R_DrawWorldMeshes); - DetourAttach((LPVOID*)&V_DrawWorldMeshesDepthOnly, &R_DrawWorldMeshesDepthOnly); - DetourAttach((LPVOID*)&V_DrawWorldMeshesDepthAtTheEnd, &R_DrawWorldMeshesDepthAtTheEnd); + DetourAttach(&V_DrawWorldMeshes, &R_DrawWorldMeshes); + DetourAttach(&V_DrawWorldMeshesDepthOnly, &R_DrawWorldMeshesDepthOnly); + DetourAttach(&V_DrawWorldMeshesDepthAtTheEnd, &R_DrawWorldMeshesDepthAtTheEnd); } -void RSurf_Detach() +void VGL_RSurf::Detach() const { - DetourDetach((LPVOID*)&V_DrawWorldMeshes, &R_DrawWorldMeshes); - DetourDetach((LPVOID*)&V_DrawWorldMeshesDepthOnly, &R_DrawWorldMeshesDepthOnly); - DetourDetach((LPVOID*)&V_DrawWorldMeshesDepthAtTheEnd, &R_DrawWorldMeshesDepthAtTheEnd); + DetourDetach(&V_DrawWorldMeshes, &R_DrawWorldMeshes); + DetourDetach(&V_DrawWorldMeshesDepthOnly, &R_DrawWorldMeshesDepthOnly); + DetourDetach(&V_DrawWorldMeshesDepthAtTheEnd, &R_DrawWorldMeshesDepthAtTheEnd); } \ No newline at end of file diff --git a/r5dev/engine/gl_rsurf.h b/r5dev/engine/gl_rsurf.h index 9db7bb37..26e4b6b7 100644 --- a/r5dev/engine/gl_rsurf.h +++ b/r5dev/engine/gl_rsurf.h @@ -10,17 +10,14 @@ inline auto V_DrawWorldMeshesDepthOnly = P_DrawWorldMeshesDepthOnly.RCast(); -void RSurf_Attach(); -void RSurf_Detach(); /////////////////////////////////////////////////////////////////////////////// class VGL_RSurf : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: R_DrawWorldMeshes : {:#18x} |\n", P_DrawWorldMeshes.GetPtr()); - spdlog::debug("| FUN: R_DrawWorldMeshesDepthOnly : {:#18x} |\n", P_DrawWorldMeshesDepthOnly.GetPtr()); - spdlog::debug("| FUN: R_DrawWorldMeshesDepthAtTheEnd : {:#18x} |\n", P_DrawWorldMeshesDepthAtTheEnd.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("R_DrawWorldMeshes", P_DrawWorldMeshes.GetPtr()); + LogFunAdr("R_DrawWorldMeshesDepthOnly", P_DrawWorldMeshesDepthOnly.GetPtr()); + LogFunAdr("R_DrawWorldMeshesDepthAtTheEnd", P_DrawWorldMeshesDepthAtTheEnd.GetPtr()); } virtual void GetFun(void) const { @@ -38,9 +35,7 @@ class VGL_RSurf : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VGL_RSurf); \ No newline at end of file diff --git a/r5dev/engine/gl_screen.h b/r5dev/engine/gl_screen.h index d0438516..cd116d64 100644 --- a/r5dev/engine/gl_screen.h +++ b/r5dev/engine/gl_screen.h @@ -14,10 +14,9 @@ class VGL_Screen : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: SCR_BeginLoadingPlaque : {:#18x} |\n", SCR_BeginLoadingPlaque.GetPtr()); - spdlog::debug("| VAR: scr_drawloading : {:#18x} |\n", reinterpret_cast(scr_drawloading)); - spdlog::debug("| VAR: scr_engineevent_loadingstarted : {:#18x} |\n", reinterpret_cast(scr_engineevent_loadingstarted)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("SCR_BeginLoadingPlaque", SCR_BeginLoadingPlaque.GetPtr()); + LogVarAdr("scr_drawloading", reinterpret_cast(scr_drawloading)); + LogVarAdr("scr_engineevent_loadingstarted", reinterpret_cast(scr_engineevent_loadingstarted)); } virtual void GetFun(void) const { @@ -44,5 +43,3 @@ class VGL_Screen : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VGL_Screen); diff --git a/r5dev/engine/host.cpp b/r5dev/engine/host.cpp index 663384b3..bf43997d 100644 --- a/r5dev/engine/host.cpp +++ b/r5dev/engine/host.cpp @@ -39,12 +39,12 @@ void _Host_RunFrame(void* unused, float time) } /////////////////////////////////////////////////////////////////////////////// -void Host_Attach() +void VHost::Attach() const { DetourAttach((LPVOID*)&v_Host_RunFrame, &_Host_RunFrame); } -void Host_Detach() +void VHost::Detach() const { DetourDetach((LPVOID*)&v_Host_RunFrame, &_Host_RunFrame); } \ No newline at end of file diff --git a/r5dev/engine/host.h b/r5dev/engine/host.h index f7cab5fa..8b3c800e 100644 --- a/r5dev/engine/host.h +++ b/r5dev/engine/host.h @@ -17,22 +17,18 @@ inline jmp_buf* host_abortserver = nullptr; inline float* interval_per_tick = nullptr; - -void Host_Attach(); -void Host_Detach(); /////////////////////////////////////////////////////////////////////////////// class VHost : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: _Host_RunFrame : {:#18x} |\n", p_Host_RunFrame.GetPtr()); - spdlog::debug("| FUN: _Host_RunFrame_Render : {:#18x} |\n", p_Host_RunFrame_Render.GetPtr()); - spdlog::debug("| FUN: Host_Error : {:#18x} |\n", p_Host_Error.GetPtr()); - spdlog::debug("| FUN: VCR_EnterPausedState : {:#18x} |\n", p_VCR_EnterPausedState.GetPtr()); - spdlog::debug("| VAR: interval_per_tick : {:#18x} |\n", reinterpret_cast(interval_per_tick)); - spdlog::debug("| VAR: host_abortserver : {:#18x} |\n", reinterpret_cast(host_abortserver)); - spdlog::debug("| VAR: g_bAbortServerSet : {:#18x} |\n", reinterpret_cast(g_bAbortServerSet)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("_Host_RunFrame", p_Host_RunFrame.GetPtr()); + LogFunAdr("_Host_RunFrame_Render", p_Host_RunFrame_Render.GetPtr()); + LogFunAdr("Host_Error", p_Host_Error.GetPtr()); + LogFunAdr("VCR_EnterPausedState", p_VCR_EnterPausedState.GetPtr()); + LogVarAdr("interval_per_tick", reinterpret_cast(interval_per_tick)); + LogVarAdr("host_abortserver", reinterpret_cast(host_abortserver)); + LogVarAdr("g_bAbortServerSet", reinterpret_cast(g_bAbortServerSet)); } virtual void GetFun(void) const { @@ -62,9 +58,7 @@ class VHost : public IDetour #endif } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VHost); \ No newline at end of file diff --git a/r5dev/engine/host_cmd.cpp b/r5dev/engine/host_cmd.cpp index 01e99028..30fc0c4c 100644 --- a/r5dev/engine/host_cmd.cpp +++ b/r5dev/engine/host_cmd.cpp @@ -11,12 +11,12 @@ bool DFS_InitializeFeatureFlagDefinitions(const char* pszFeatureFlags) } /////////////////////////////////////////////////////////////////////////////// -void HostCmd_Attach() +void VHostCmd::Attach() const { DetourAttach(&v_DFS_InitializeFeatureFlagDefinitions, &DFS_InitializeFeatureFlagDefinitions); } -void HostCmd_Detach() +void VHostCmd::Detach() const { DetourDetach(&v_DFS_InitializeFeatureFlagDefinitions, &DFS_InitializeFeatureFlagDefinitions); } diff --git a/r5dev/engine/host_cmd.h b/r5dev/engine/host_cmd.h index 05eff770..ba4a6a55 100644 --- a/r5dev/engine/host_cmd.h +++ b/r5dev/engine/host_cmd.h @@ -32,22 +32,19 @@ inline auto v_DFS_InitializeFeatureFlagDefinitions = p_DFS_InitializeFeatureFlag extern EngineParms_t* g_pEngineParms; -void HostCmd_Attach(); -void HostCmd_Detach(); /////////////////////////////////////////////////////////////////////////////// class VHostCmd : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Host_Init : {:#18x} |\n", p_Host_Init.GetPtr()); - spdlog::debug("| FUN: Host_NewGame : {:#18x} |\n", p_Host_NewGame.GetPtr()); - spdlog::debug("| FUN: Host_ChangeLevel : {:#18x} |\n", p_Host_ChangeLevel.GetPtr()); - spdlog::debug("| FUN: SetLaunchOptions : {:#18x} |\n", p_SetLaunchOptions.GetPtr()); + LogFunAdr("Host_Init", p_Host_Init.GetPtr()); + LogFunAdr("Host_NewGame", p_Host_NewGame.GetPtr()); + LogFunAdr("Host_ChangeLevel", p_Host_ChangeLevel.GetPtr()); + LogFunAdr("SetLaunchOptions", p_SetLaunchOptions.GetPtr()); #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2) - spdlog::debug("| FUN: DFS_InitializeFeatureFlagDefinitions : {:#18x} |\n", p_DFS_InitializeFeatureFlagDefinitions.GetPtr()); + LogFunAdr("DFS_InitializeFeatureFlagDefinitions", p_DFS_InitializeFeatureFlagDefinitions.GetPtr()); #endif // !(GAMEDLL_S0) || !(GAMEDLL_S1) || !(GAMEDLL_S2) - spdlog::debug("| VAR: g_pEngineParms : {:#18x} |\n", reinterpret_cast(g_pEngineParms)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pEngineParms", reinterpret_cast(g_pEngineParms)); } virtual void GetFun(void) const { @@ -80,9 +77,7 @@ class VHostCmd : public IDetour #endif } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VHostCmd); diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp index ee2e9800..a49296e7 100644 --- a/r5dev/engine/host_state.cpp +++ b/r5dev/engine/host_state.cpp @@ -459,13 +459,11 @@ FORCEINLINE void CHostState::ResetLevelName(void) Q_snprintf(const_cast(m_levelName), sizeof(m_levelName), szNoMap); } -/////////////////////////////////////////////////////////////////////////////// -void CHostState_Attach() +void VHostState::Attach(void) const { DetourAttach(&CHostState_FrameUpdate, &CHostState::FrameUpdate); } - -void CHostState_Detach() +void VHostState::Detach(void) const { DetourDetach(&CHostState_FrameUpdate, &CHostState::FrameUpdate); } diff --git a/r5dev/engine/host_state.h b/r5dev/engine/host_state.h index fff6fcb0..361d61ad 100644 --- a/r5dev/engine/host_state.h +++ b/r5dev/engine/host_state.h @@ -61,10 +61,6 @@ inline auto CHostState_State_GameShutDown = p_CHostState_State_GameShutDown.RCas inline CMemory p_HostState_ChangeLevelMP; inline auto v_HostState_ChangeLevelMP = p_HostState_ChangeLevelMP.RCast(); -/////////////////////////////////////////////////////////////////////////////// -void CHostState_Attach(); -void CHostState_Detach(); - /////////////////////////////////////////////////////////////////////////////// extern CHostState* g_pHostState; @@ -73,12 +69,11 @@ class VHostState : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CHostState::FrameUpdate : {:#18x} |\n", p_CHostState_FrameUpdate.GetPtr()); - spdlog::debug("| FUN: CHostState::State_Run : {:#18x} |\n", p_CHostState_State_Run.GetPtr()); - spdlog::debug("| FUN: CHostState::State_GameShutDown : {:#18x} |\n", p_CHostState_State_GameShutDown.GetPtr()); - spdlog::debug("| FUN: HostState_ChangeLevelMP : {:#18x} |\n", p_HostState_ChangeLevelMP.GetPtr()); - spdlog::debug("| VAR: g_pHostState : {:#18x} |\n", reinterpret_cast(g_pHostState)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CHostState::FrameUpdate", p_CHostState_FrameUpdate.GetPtr()); + LogFunAdr("CHostState::State_Run", p_CHostState_State_Run.GetPtr()); + LogFunAdr("CHostState::State_GameShutDown", p_CHostState_State_GameShutDown.GetPtr()); + LogFunAdr("HostState_ChangeLevelMP", p_HostState_ChangeLevelMP.GetPtr()); + LogVarAdr("g_pHostState", reinterpret_cast(g_pHostState)); } virtual void GetFun(void) const { @@ -103,9 +98,7 @@ class VHostState : public IDetour g_pHostState = p_CHostState_FrameUpdate.FindPattern("48 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VHostState); diff --git a/r5dev/engine/matsys_interface.cpp b/r5dev/engine/matsys_interface.cpp index 979d54a6..bb752c49 100644 --- a/r5dev/engine/matsys_interface.cpp +++ b/r5dev/engine/matsys_interface.cpp @@ -26,12 +26,12 @@ bool UpdateCurrentVideoConfig(MaterialSystem_Config_t* pConfig) */ /////////////////////////////////////////////////////////////////////////////// -void MatSys_Iface_Attach() +void VMatSys_Interface::Attach() const { //DetourAttach(&v_UpdateCurrentVideoConfig, &UpdateCurrentVideoConfig); } -void MatSys_Iface_Detach() +void VMatSys_Interface::Detach() const { //DetourDetach(&v_UpdateCurrentVideoConfig, &UpdateCurrentVideoConfig); } \ No newline at end of file diff --git a/r5dev/engine/matsys_interface.h b/r5dev/engine/matsys_interface.h index ce56202a..af6b82a4 100644 --- a/r5dev/engine/matsys_interface.h +++ b/r5dev/engine/matsys_interface.h @@ -15,19 +15,16 @@ inline CMemory p_LoadPlayerConfig; inline auto v_UpdateCurrentVideoConfig = p_UpdateCurrentVideoConfig.RCast(); -void MatSys_Iface_Attach(); -void MatSys_Iface_Detach(); /////////////////////////////////////////////////////////////////////////////// class VMatSys_Interface : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: UpdateMaterialSystemConfig : {:#18x} |\n", p_UpdateMaterialSystemConfig.GetPtr()); - spdlog::debug("| FUN: UpdateCurrentVideoConfig : {:#18x} |\n", p_UpdateCurrentVideoConfig.GetPtr()); - spdlog::debug("| FUN: HandleConfigFile : {:#18x} |\n", p_HandleConfigFile.GetPtr()); - spdlog::debug("| FUN: ResetPreviousGameState : {:#18x} |\n", p_ResetPreviousGameState.GetPtr()); - spdlog::debug("| FUN: LoadPlayerConfig : {:#18x} |\n", p_LoadPlayerConfig.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("UpdateMaterialSystemConfig", p_UpdateMaterialSystemConfig.GetPtr()); + LogFunAdr("UpdateCurrentVideoConfig", p_UpdateCurrentVideoConfig.GetPtr()); + LogFunAdr("HandleConfigFile", p_HandleConfigFile.GetPtr()); + LogFunAdr("ResetPreviousGameState", p_ResetPreviousGameState.GetPtr()); + LogFunAdr("LoadPlayerConfig", p_LoadPlayerConfig.GetPtr()); } virtual void GetFun(void) const { @@ -45,11 +42,9 @@ class VMatSys_Interface : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VMatSys_Interface); - #endif // MATSYS_INTERFACE_H diff --git a/r5dev/engine/modelinfo.h b/r5dev/engine/modelinfo.h index b111c3de..5a5bbea6 100644 --- a/r5dev/engine/modelinfo.h +++ b/r5dev/engine/modelinfo.h @@ -41,12 +41,11 @@ class VModelInfo : public IDetour virtual void GetAdr(void) const { #ifndef CLIENT_DLL - spdlog::debug("| FUN: g_pModelInfoServer : {:#18x} |\n", reinterpret_cast(g_pModelInfoServer)); + LogFunAdr("g_pModelInfoServer", reinterpret_cast(g_pModelInfoServer)); #endif // CLIENT_DLL #ifndef DEDICATED - spdlog::debug("| FUN: g_pModelInfoClient : {:#18x} |\n", reinterpret_cast(g_pModelInfoClient)); + LogFunAdr("g_pModelInfoClient", reinterpret_cast(g_pModelInfoClient)); #endif // DEDICATED - spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -66,6 +65,4 @@ class VModelInfo : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VModelInfo); - #endif // ENGINE_MODELINFO_H diff --git a/r5dev/engine/modelloader.cpp b/r5dev/engine/modelloader.cpp index 8157da05..04e06749 100644 --- a/r5dev/engine/modelloader.cpp +++ b/r5dev/engine/modelloader.cpp @@ -56,13 +56,13 @@ uint64_t CModelLoader::Map_LoadModelGuts(CModelLoader* loader, model_t* model) } /////////////////////////////////////////////////////////////////////////////// -void CModelLoader_Attach() +void VModelLoader::Attach() const { DetourAttach((LPVOID*)&CModelLoader__LoadModel, &CModelLoader::LoadModel); DetourAttach((LPVOID*)&CModelLoader__Map_LoadModelGuts, &CModelLoader::Map_LoadModelGuts); } -void CModelLoader_Detach() +void VModelLoader::Detach() const { DetourDetach((LPVOID*)&CModelLoader__LoadModel, &CModelLoader::LoadModel); DetourDetach((LPVOID*)&CModelLoader__Map_LoadModelGuts, &CModelLoader::Map_LoadModelGuts); diff --git a/r5dev/engine/modelloader.h b/r5dev/engine/modelloader.h index 27239220..3d6993f8 100644 --- a/r5dev/engine/modelloader.h +++ b/r5dev/engine/modelloader.h @@ -76,24 +76,20 @@ inline auto BuildSpriteLoadName = p_BuildSpriteLoadName.RCast(g_pModelLoader)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CModelLoader::FindModel", p_CModelLoader__FindModel.GetPtr()); + LogFunAdr("CModelLoader::LoadModel", p_CModelLoader__LoadModel.GetPtr()); + LogFunAdr("CModelLoader::UnloadModel", p_CModelLoader__UnloadModel.GetPtr()); + LogFunAdr("CModelLoader::Map_LoadModelGuts", p_CModelLoader__Map_LoadModelGuts.GetPtr()); + LogFunAdr("CModelLoader::Map_IsValid", p_CModelLoader__Map_IsValid.GetPtr()); + LogFunAdr("CModelLoader::Studio_LoadModel", p_CModelLoader__Studio_LoadModel.GetPtr()); + LogFunAdr("GetSpriteInfo", p_GetSpriteInfo.GetPtr()); + LogFunAdr("BuildSpriteLoadName", p_BuildSpriteLoadName.GetPtr()); + LogVarAdr("g_pModelLoader", reinterpret_cast(g_pModelLoader)); } virtual void GetFun(void) const { @@ -131,9 +127,7 @@ class VModelLoader : public IDetour "48 89 4C 24 ?? 53 55 56 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ??").FindPatternSelf("48 ?? 0D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(3, 7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VModelLoader); diff --git a/r5dev/engine/net.cpp b/r5dev/engine/net.cpp index 5ba281a8..774258cd 100644 --- a/r5dev/engine/net.cpp +++ b/r5dev/engine/net.cpp @@ -281,7 +281,7 @@ const char* NET_ErrorString(int iCode) #ifndef NETCONSOLE /////////////////////////////////////////////////////////////////////////////// -void NET_Attach() +void VNet::Attach() const { DetourAttach((LPVOID*)&v_NET_ReceiveDatagram, &NET_ReceiveDatagram); DetourAttach((LPVOID*)&v_NET_SendDatagram, &NET_SendDatagram); @@ -291,7 +291,7 @@ void NET_Attach() #endif } -void NET_Detach() +void VNet::Detach() const { DetourDetach((LPVOID*)&v_NET_ReceiveDatagram, &NET_ReceiveDatagram); DetourDetach((LPVOID*)&v_NET_SendDatagram, &NET_SendDatagram); diff --git a/r5dev/engine/net.h b/r5dev/engine/net.h index da87af3d..d216998e 100644 --- a/r5dev/engine/net.h +++ b/r5dev/engine/net.h @@ -45,9 +45,6 @@ void NET_PrintFunc(const char* fmt, ...); void NET_Shutdown(void* thisptr, const char* szReason, uint8_t bBadRep, bool bRemoveNow); void NET_RemoveChannel(CClient* pClient, int nIndex, const char* szReason, uint8_t bBadRep, bool bRemoveNow); -void NET_Attach(); -void NET_Detach(); - /////////////////////////////////////////////////////////////////////////////// extern string g_svNetKey; extern uintptr_t g_pNetKey; @@ -58,14 +55,13 @@ class VNet : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: NET_Init : {:#18x} |\n", p_NET_Init.GetPtr()); - spdlog::debug("| FUN: NET_Shutdown : {:#18x} |\n", p_NET_Shutdown.GetPtr()); - spdlog::debug("| FUN: NET_SetKey : {:#18x} |\n", p_NET_SetKey.GetPtr()); - spdlog::debug("| FUN: NET_ReceiveDatagram : {:#18x} |\n", p_NET_ReceiveDatagram.GetPtr()); - spdlog::debug("| FUN: NET_SendDatagram : {:#18x} |\n", p_NET_SendDatagram.GetPtr()); - spdlog::debug("| FUN: NET_PrintFunc : {:#18x} |\n", p_NET_PrintFunc.GetPtr()); - spdlog::debug("| VAR: g_pNetKey : {:#18x} |\n", g_pNetKey); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("NET_Init", p_NET_Init.GetPtr()); + LogFunAdr("NET_Shutdown", p_NET_Shutdown.GetPtr()); + LogFunAdr("NET_SetKey", p_NET_SetKey.GetPtr()); + LogFunAdr("NET_ReceiveDatagram", p_NET_ReceiveDatagram.GetPtr()); + LogFunAdr("NET_SendDatagram", p_NET_SendDatagram.GetPtr()); + LogFunAdr("NET_PrintFunc", p_NET_PrintFunc.GetPtr()); + LogVarAdr("g_pNetKey", g_pNetKey); } virtual void GetFun(void) const { @@ -94,11 +90,10 @@ class VNet : public IDetour g_pNetKey = g_GameDll.FindString("client:NetEncryption_NewKey").FindPatternSelf("48 8D ? ? ? ? ? 48 3B", CMemory::Direction::UP, 300).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VNet); #endif // !NETCONSOLE const char* NET_ErrorString(int iCode); diff --git a/r5dev/engine/net_chan.cpp b/r5dev/engine/net_chan.cpp index a498aa32..5175ffc5 100644 --- a/r5dev/engine/net_chan.cpp +++ b/r5dev/engine/net_chan.cpp @@ -254,11 +254,11 @@ bool CNetChan::ProcessMessages(CNetChan* pChan, bf_read* pMsg) } /////////////////////////////////////////////////////////////////////////////// -void NetChan_Attach() +void VNetChannel::Attach() const { - DetourAttach((LPVOID*)&v_NetChan_ProcessMessages, &CNetChan::ProcessMessages); + DetourAttach(&v_NetChan_ProcessMessages, &CNetChan::ProcessMessages); } -void NetChan_Detach() +void VNetChannel::Detach() const { - DetourDetach((LPVOID*)&v_NetChan_ProcessMessages, &CNetChan::ProcessMessages); + DetourDetach(&v_NetChan_ProcessMessages, &CNetChan::ProcessMessages); } diff --git a/r5dev/engine/net_chan.h b/r5dev/engine/net_chan.h index 5710ec95..f60026a3 100644 --- a/r5dev/engine/net_chan.h +++ b/r5dev/engine/net_chan.h @@ -185,9 +185,8 @@ class VNetChannel : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CNetChan::Clear : {:#18x} |\n", p_NetChan_Clear.GetPtr()); - spdlog::debug("| FUN: CNetChan::ProcessMessages : {:#18x} |\n", p_NetChan_ProcessMessages.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CNetChan::Clear", p_NetChan_Clear.GetPtr()); + LogFunAdr("CNetChan::ProcessMessages", p_NetChan_ProcessMessages.GetPtr()); } virtual void GetFun(void) const { @@ -199,13 +198,9 @@ class VNetChannel : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VNetChannel); - -void NetChan_Attach(); -void NetChan_Detach(); #endif // NET_CHAN_H diff --git a/r5dev/engine/server/server.cpp b/r5dev/engine/server/server.cpp index 8fece3aa..ea323318 100644 --- a/r5dev/engine/server/server.cpp +++ b/r5dev/engine/server/server.cpp @@ -143,16 +143,20 @@ void CServer::FrameJob(double flFrameTime, bool bRunOverlays, bool bUniformSnaps } /////////////////////////////////////////////////////////////////////////////// -void CServer_Attach() +void VServer::Attach() const { +#if defined(GAMEDLL_S3) DetourAttach((LPVOID*)&v_CServer_ConnectClient, &CServer::ConnectClient); DetourAttach((LPVOID*)&v_CServer_FrameJob, &CServer::FrameJob); +#endif // !TODO: S1 and S2 CServer functions require work. } -void CServer_Detach() +void VServer::Detach() const { +#if defined(GAMEDLL_S3) DetourDetach((LPVOID*)&v_CServer_ConnectClient, &CServer::ConnectClient); DetourDetach((LPVOID*)&v_CServer_FrameJob, &CServer::FrameJob); +#endif // !TODO: S1 and S2 CServer functions require work. } /////////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/engine/server/server.h b/r5dev/engine/server/server.h index aaefc07c..fcdcf360 100644 --- a/r5dev/engine/server/server.h +++ b/r5dev/engine/server/server.h @@ -93,9 +93,6 @@ inline auto v_CServer_ConnectClient = p_CServer_Authenticate.RCast(); -void CServer_Attach(); -void CServer_Detach(); - extern bool g_bCheckCompBanDB; /////////////////////////////////////////////////////////////////////////////// @@ -104,11 +101,10 @@ class VServer : public IDetour virtual void GetAdr(void) const { #ifndef CLIENT_DLL - spdlog::debug("| FUN: CServer::FrameJob : {:#18x} |\n", p_CServer_FrameJob.GetPtr()); - spdlog::debug("| FUN: CServer::ConnectClient : {:#18x} |\n", p_CServer_Authenticate.GetPtr()); - spdlog::debug("| FUN: CServer::RejectConnection : {:#18x} |\n", p_CServer_RejectConnection.GetPtr()); - spdlog::debug("| VAR: g_pServer[128] : {:#18x} |\n", reinterpret_cast(g_pServer)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CServer::FrameJob", p_CServer_FrameJob.GetPtr()); + LogFunAdr("CServer::ConnectClient", p_CServer_Authenticate.GetPtr()); + LogFunAdr("CServer::RejectConnection", p_CServer_RejectConnection.GetPtr()); + LogVarAdr("g_pServer[128]", reinterpret_cast(g_pServer)); #endif // !CLIENT_DLL } virtual void GetFun(void) const @@ -136,9 +132,7 @@ class VServer : public IDetour #endif // !CLIENT_DLL } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VServer); diff --git a/r5dev/engine/server/sv_main.h b/r5dev/engine/server/sv_main.h index 0ff70d14..4a02ab79 100644 --- a/r5dev/engine/server/sv_main.h +++ b/r5dev/engine/server/sv_main.h @@ -29,12 +29,11 @@ class HSV_Main : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: SV_InitGameDLL : {:#18x} |\n", p_SV_InitGameDLL.GetPtr()); - spdlog::debug("| FUN: SV_ShutdownGameDLL : {:#18x} |\n", p_SV_ShutdownGameDLL.GetPtr()); - spdlog::debug("| FUN: SV_CreateBaseline : {:#18x} |\n", p_SV_CreateBaseline.GetPtr()); - spdlog::debug("| FUN: CGameServer::SpawnServer : {:#18x} |\n", p_CGameServer__SpawnServer.GetPtr()); - spdlog::debug("| VAR: s_bDedicated : {:#18x} |\n", reinterpret_cast(s_bDedicated)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("SV_InitGameDLL", p_SV_InitGameDLL.GetPtr()); + LogFunAdr("SV_ShutdownGameDLL", p_SV_ShutdownGameDLL.GetPtr()); + LogFunAdr("SV_CreateBaseline", p_SV_CreateBaseline.GetPtr()); + LogFunAdr("CGameServer::SpawnServer", p_CGameServer__SpawnServer.GetPtr()); + LogVarAdr("s_bDedicated", reinterpret_cast(s_bDedicated)); } virtual void GetFun(void) const { @@ -62,5 +61,3 @@ class HSV_Main : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(HSV_Main); diff --git a/r5dev/engine/sys_dll.cpp b/r5dev/engine/sys_dll.cpp index b1b6698a..ac93a9ab 100644 --- a/r5dev/engine/sys_dll.cpp +++ b/r5dev/engine/sys_dll.cpp @@ -17,12 +17,12 @@ int HSys_Error_Internal(char* fmt, va_list args) return Sys_Error_Internal(fmt, args); } -void SysDll_Attach() +void VSys_Dll::Attach() const { - DetourAttach((LPVOID*)&Sys_Error_Internal, &HSys_Error_Internal); + DetourAttach(&Sys_Error_Internal, &HSys_Error_Internal); } -void SysDll_Detach() +void VSys_Dll::Detach() const { - DetourDetach((LPVOID*)&Sys_Error_Internal, &HSys_Error_Internal); + DetourDetach(&Sys_Error_Internal, &HSys_Error_Internal); } diff --git a/r5dev/engine/sys_dll.h b/r5dev/engine/sys_dll.h index 009640eb..165037d9 100644 --- a/r5dev/engine/sys_dll.h +++ b/r5dev/engine/sys_dll.h @@ -10,17 +10,13 @@ inline bool* gfExtendedError = nullptr; /////////////////////////////////////////////////////////////////////////////// int HSys_Error_Internal(char* fmt, va_list args); -void SysDll_Attach(); -void SysDll_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VSys_Dll : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Sys_Error_Internal : {:#18x} |\n", p_Sys_Error_Internal.GetPtr()); - spdlog::debug("| VAR: gfExtendedError : {:#18x} |\n", reinterpret_cast(gfExtendedError)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("Sys_Error_Internal", p_Sys_Error_Internal.GetPtr()); + LogVarAdr("gfExtendedError", reinterpret_cast(gfExtendedError)); } virtual void GetFun(void) const { @@ -32,9 +28,7 @@ class VSys_Dll : public IDetour gfExtendedError = p_COM_ExplainDisconnection.Offset(0x0).FindPatternSelf("C6 05", CMemory::Direction::DOWN, 300).ResolveRelativeAddressSelf(0x2, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VSys_Dll); \ No newline at end of file diff --git a/r5dev/engine/sys_dll2.cpp b/r5dev/engine/sys_dll2.cpp index c7dce89b..70c6e6fb 100644 --- a/r5dev/engine/sys_dll2.cpp +++ b/r5dev/engine/sys_dll2.cpp @@ -145,14 +145,14 @@ void CEngineAPI::VSetStartupInfo(CEngineAPI* pEngineAPI, StartupInfo_t* pStartup } /////////////////////////////////////////////////////////////////////////////// -void SysDll2_Attach() +void VSys_Dll2::Attach() const { - DetourAttach((LPVOID*)&CEngineAPI_ModInit, &CEngineAPI::VModInit); - DetourAttach((LPVOID*)&v_CEngineAPI_SetStartupInfo, &CEngineAPI::VSetStartupInfo); + DetourAttach(&CEngineAPI_ModInit, &CEngineAPI::VModInit); + DetourAttach(&v_CEngineAPI_SetStartupInfo, &CEngineAPI::VSetStartupInfo); } -void SysDll2_Detach() +void VSys_Dll2::Detach() const { - DetourDetach((LPVOID*)&CEngineAPI_ModInit, &CEngineAPI::VModInit); - DetourDetach((LPVOID*)&v_CEngineAPI_SetStartupInfo, &CEngineAPI::VSetStartupInfo); + DetourDetach(&CEngineAPI_ModInit, &CEngineAPI::VModInit); + DetourDetach(&v_CEngineAPI_SetStartupInfo, &CEngineAPI::VSetStartupInfo); } \ No newline at end of file diff --git a/r5dev/engine/sys_dll2.h b/r5dev/engine/sys_dll2.h index 35441755..6d6e9dcd 100644 --- a/r5dev/engine/sys_dll2.h +++ b/r5dev/engine/sys_dll2.h @@ -62,27 +62,23 @@ inline char* g_szBaseDir = nullptr; // static size = 260 inline int64_t* g_pMTVFTaskItem = nullptr; // struct. inline char* g_szMTVFItemName = nullptr; - -void SysDll2_Attach(); -void SysDll2_Detach(); /////////////////////////////////////////////////////////////////////////////// class VSys_Dll2 : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CEngineAPI::Connect : {:#18x} |\n", p_CEngineAPI_Connect.GetPtr()); - spdlog::debug("| FUN: CEngineAPI::ModInit : {:#18x} |\n", p_CEngineAPI_ModInit.GetPtr()); - spdlog::debug("| FUN: CEngineAPI::MainLoop : {:#18x} |\n", p_CEngineAPI_MainLoop.GetPtr()); + LogFunAdr("CEngineAPI::Connect", p_CEngineAPI_Connect.GetPtr()); + LogFunAdr("CEngineAPI::ModInit", p_CEngineAPI_ModInit.GetPtr()); + LogFunAdr("CEngineAPI::MainLoop", p_CEngineAPI_MainLoop.GetPtr()); #if defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - spdlog::debug("| FUN: CEngineAPI::SetStartupInfo : {:#18x} |\n", p_CEngineAPI_SetStartupInfo.GetPtr()); + LogFunAdr("CEngineAPI::SetStartupInfo", p_CEngineAPI_SetStartupInfo.GetPtr()); #endif - spdlog::debug("| FUN: ResetMTVFTaskItem : {:#18x} |\n", p_ResetMTVFTaskItem.GetPtr()); - spdlog::debug("| FUN: PakFile_Init : {:#18x} |\n", p_PakFile_Init.GetPtr()); - spdlog::debug("| VAR: g_bTextMode : {:#18x} |\n", reinterpret_cast(g_bTextMode)); - spdlog::debug("| VAR: g_szBaseDir : {:#18x} |\n", reinterpret_cast(g_szBaseDir)); - spdlog::debug("| VAR: g_pMTVFTaskItem : {:#18x} |\n", reinterpret_cast(g_pMTVFTaskItem)); - spdlog::debug("| VAR: g_szMTVFItemName : {:#18x} |\n", reinterpret_cast(g_szMTVFItemName)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("ResetMTVFTaskItem", p_ResetMTVFTaskItem.GetPtr()); + LogFunAdr("PakFile_Init", p_PakFile_Init.GetPtr()); + LogVarAdr("g_bTextMode", reinterpret_cast(g_bTextMode)); + LogVarAdr("g_szBaseDir", reinterpret_cast(g_szBaseDir)); + LogVarAdr("g_pMTVFTaskItem", reinterpret_cast(g_pMTVFTaskItem)); + LogVarAdr("g_szMTVFItemName", reinterpret_cast(g_szMTVFItemName)); } virtual void GetFun(void) const { @@ -114,9 +110,7 @@ class VSys_Dll2 : public IDetour g_szMTVFItemName = p_ResetMTVFTaskItem.FindPattern("C6 05", CMemory::Direction::DOWN, 250).ResolveRelativeAddressSelf(0x2, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VSys_Dll2); \ No newline at end of file diff --git a/r5dev/engine/sys_engine.h b/r5dev/engine/sys_engine.h index 17ef3428..71a661f4 100644 --- a/r5dev/engine/sys_engine.h +++ b/r5dev/engine/sys_engine.h @@ -30,8 +30,7 @@ class VEngine : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pEngine : {:#18x} |\n", reinterpret_cast(g_pEngine)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pEngine", reinterpret_cast(g_pEngine)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -47,5 +46,3 @@ class VEngine : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VEngine); \ No newline at end of file diff --git a/r5dev/engine/sys_getmodes.cpp b/r5dev/engine/sys_getmodes.cpp index 0d8825f8..5e19e234 100644 --- a/r5dev/engine/sys_getmodes.cpp +++ b/r5dev/engine/sys_getmodes.cpp @@ -17,12 +17,12 @@ bool HCVideoMode_Common__CreateGameWindow(int* pnRect) return CVideoMode_Common__CreateGameWindow(pnRect); } -void HCVideoMode_Common_Attach() +void HVideoMode_Common::Attach() const { - DetourAttach((LPVOID*)&CVideoMode_Common__CreateGameWindow, &HCVideoMode_Common__CreateGameWindow); + DetourAttach(&CVideoMode_Common__CreateGameWindow, &HCVideoMode_Common__CreateGameWindow); } -void HCVideoMode_Common_Detach() +void HVideoMode_Common::Detach() const { - DetourDetach((LPVOID*)&CVideoMode_Common__CreateGameWindow, &HCVideoMode_Common__CreateGameWindow); + DetourDetach(&CVideoMode_Common__CreateGameWindow, &HCVideoMode_Common__CreateGameWindow); } diff --git a/r5dev/engine/sys_getmodes.h b/r5dev/engine/sys_getmodes.h index 4bfbf825..aab323f0 100644 --- a/r5dev/engine/sys_getmodes.h +++ b/r5dev/engine/sys_getmodes.h @@ -9,17 +9,13 @@ inline auto CVideoMode_Common__CreateGameWindow = p_CVideoMode_Common__CreateGam inline CMemory p_CVideoMode_Common__CreateWindowClass; inline auto CVideoMode_Common__CreateWindowClass = p_CVideoMode_Common__CreateWindowClass.RCast(); -void HCVideoMode_Common_Attach(); -void HCVideoMode_Common_Detach(); - /////////////////////////////////////////////////////////////////////////////// class HVideoMode_Common : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CVideoMode_Common::CreateGameWindow : {:#18x} |\n", p_CVideoMode_Common__CreateGameWindow.GetPtr()); - spdlog::debug("| FUN: CVideoMode_Common::CreateWindowClass : {:#18x} |\n", p_CVideoMode_Common__CreateWindowClass.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CVideoMode_Common::CreateGameWindow", p_CVideoMode_Common__CreateGameWindow.GetPtr()); + LogFunAdr("CVideoMode_Common::CreateWindowClass", p_CVideoMode_Common__CreateWindowClass.GetPtr()); } virtual void GetFun(void) const { @@ -35,9 +31,7 @@ class HVideoMode_Common : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(HVideoMode_Common); diff --git a/r5dev/engine/sys_mainwind.cpp b/r5dev/engine/sys_mainwind.cpp index d058cfc2..b7218e80 100644 --- a/r5dev/engine/sys_mainwind.cpp +++ b/r5dev/engine/sys_mainwind.cpp @@ -19,12 +19,12 @@ void CGame::PlayStartupVideos(void) } /////////////////////////////////////////////////////////////////////////////// -void SysGame_Attach() +void VGame::Attach() const { - DetourAttach((LPVOID*)&v_CGame__PlayStartupVideos, &CGame::PlayStartupVideos); + DetourAttach(&v_CGame__PlayStartupVideos, &CGame::PlayStartupVideos); } -void SysGame_Detach() +void VGame::Detach() const { - DetourDetach((LPVOID*)&v_CGame__PlayStartupVideos, &CGame::PlayStartupVideos); + DetourDetach(&v_CGame__PlayStartupVideos, &CGame::PlayStartupVideos); } \ No newline at end of file diff --git a/r5dev/engine/sys_mainwind.h b/r5dev/engine/sys_mainwind.h index eb1488aa..98221623 100644 --- a/r5dev/engine/sys_mainwind.h +++ b/r5dev/engine/sys_mainwind.h @@ -16,16 +16,12 @@ public: static void PlayStartupVideos(void); }; -void SysGame_Attach(); -void SysGame_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VGame : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CGame::PlayStartupVideos : {:#18x} |\n", p_CGame__PlayStartupVideos.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CGame::PlayStartupVideos", p_CGame__PlayStartupVideos.GetPtr()); } virtual void GetFun(void) const { @@ -38,9 +34,7 @@ class VGame : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VGame); \ No newline at end of file diff --git a/r5dev/engine/sys_utils.cpp b/r5dev/engine/sys_utils.cpp index 228719cc..8214728b 100644 --- a/r5dev/engine/sys_utils.cpp +++ b/r5dev/engine/sys_utils.cpp @@ -99,20 +99,20 @@ int Sys_GetProcessUpTime(char* szBuffer) return v_Sys_GetProcessUpTime(szBuffer); } -void SysUtils_Attach() +void VSys_Utils::Attach() const { - //DetourAttach((LPVOID*)&Sys_Error, &HSys_Error); - DetourAttach((LPVOID*)&v_Sys_Warning, &HSys_Warning); + //DetourAttach(&Sys_Error, &HSys_Error); + DetourAttach(&v_Sys_Warning, &HSys_Warning); #ifndef DEDICATED - DetourAttach((LPVOID*)&v_Con_NPrintf, &HCon_NPrintf); + DetourAttach(&v_Con_NPrintf, &HCon_NPrintf); #endif // !DEDICATED } -void SysUtils_Detach() +void VSys_Utils::Detach() const { - //DetourDetach((LPVOID*)&Sys_Error, &HSys_Error); - DetourDetach((LPVOID*)&v_Sys_Warning, &HSys_Warning); + //DetourDetach(&Sys_Error, &HSys_Error); + DetourDetach(&v_Sys_Warning, &HSys_Warning); #ifndef DEDICATED - DetourDetach((LPVOID*)&v_Con_NPrintf, &HCon_NPrintf); + DetourDetach(&v_Con_NPrintf, &HCon_NPrintf); #endif // !DEDICATED } diff --git a/r5dev/engine/sys_utils.h b/r5dev/engine/sys_utils.h index 771d130b..5d30f970 100644 --- a/r5dev/engine/sys_utils.h +++ b/r5dev/engine/sys_utils.h @@ -19,21 +19,17 @@ inline auto v_Con_NPrintf = p_Con_NPrintf.RCast(g_pFileSystem)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CBaseFileSystem::Warning", p_CBaseFileSystem_Warning.GetPtr()); + LogFunAdr("CBaseFileSystem::LoadFromVPK", p_CBaseFileSystem_LoadFromVPK.GetPtr()); + LogFunAdr("CBaseFileSystem::LoadFromCache", p_CBaseFileSystem_LoadFromCache.GetPtr()); + LogFunAdr("CBaseFileSystem::MountVPKFile", p_CBaseFileSystem_MountVPKFile.GetPtr()); + LogFunAdr("CBaseFileSystem::UnmountVPKFile", p_CBaseFileSystem_UnmountVPKFile.GetPtr()); + LogFunAdr("CBaseFileSystem::GetMountedVPKHandle", p_CBaseFileSystem_GetMountedVPKHandle.GetPtr()); + LogVarAdr("g_pFileSystem", reinterpret_cast(g_pFileSystem)); } virtual void GetFun(void) const { @@ -102,9 +97,7 @@ class VBaseFileSystem : public IDetour .FindPattern("48 89", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VBaseFileSystem); diff --git a/r5dev/filesystem/filesystem.h b/r5dev/filesystem/filesystem.h index 855fa4e0..540b2ab5 100644 --- a/r5dev/filesystem/filesystem.h +++ b/r5dev/filesystem/filesystem.h @@ -39,9 +39,8 @@ class VFileSystem_Stdio : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pFullFileSystem : {:#18x} |\n", reinterpret_cast(g_pFullFileSystem)); - spdlog::debug("| VAR: g_pFileSystem_Stdio : {:#18x} |\n", reinterpret_cast(g_pFileSystem_Stdio)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pFullFileSystem", reinterpret_cast(g_pFullFileSystem)); + LogVarAdr("g_pFileSystem_Stdio", reinterpret_cast(g_pFileSystem_Stdio)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -57,5 +56,4 @@ class VFileSystem_Stdio : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VFileSystem_Stdio); #endif // !FILESYSTEM_H diff --git a/r5dev/game/client/movehelper_client.h b/r5dev/game/client/movehelper_client.h index 70f9f316..03a18071 100644 --- a/r5dev/game/client/movehelper_client.h +++ b/r5dev/game/client/movehelper_client.h @@ -35,8 +35,7 @@ class VMoveHelperClient : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: s_MoveHelperClient : {:#18x} |\n", reinterpret_cast(s_MoveHelperClient)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("s_MoveHelperClient", reinterpret_cast(s_MoveHelperClient)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -50,6 +49,4 @@ class VMoveHelperClient : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VMoveHelperClient); - #endif // MOVEHELPER_CLIENT_H \ No newline at end of file diff --git a/r5dev/game/client/viewrender.h b/r5dev/game/client/viewrender.h index 1ae468f7..9e6cd4fe 100644 --- a/r5dev/game/client/viewrender.h +++ b/r5dev/game/client/viewrender.h @@ -29,12 +29,11 @@ class V_ViewRender : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CViewRender::GetWorldMatrixForView : {:#18x} |\n", p_CViewRender_GetWorldMatrixForView.GetPtr()); - spdlog::debug("| VAR: g_vecRenderOrigin : {:#18x} |\n", reinterpret_cast(g_vecRenderOrigin)); - spdlog::debug("| VAR: g_vecRenderAngles : {:#18x} |\n", reinterpret_cast(g_vecRenderAngles)); - spdlog::debug("| VAR: g_pViewRender : {:#18x} |\n", reinterpret_cast(g_pViewRender)); - spdlog::debug("| CON: CViewRender (VFTable) : {:#18x} |\n", g_pViewRender_VFTable.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CViewRender::GetWorldMatrixForView", p_CViewRender_GetWorldMatrixForView.GetPtr()); + LogVarAdr("g_vecRenderOrigin", reinterpret_cast(g_vecRenderOrigin)); + LogVarAdr("g_vecRenderAngles", reinterpret_cast(g_vecRenderAngles)); + LogVarAdr("g_pViewRender", reinterpret_cast(g_pViewRender)); + LogConAdr("CViewRender (VFTable)", g_pViewRender_VFTable.GetPtr()); } virtual void GetFun(void) const { @@ -57,5 +56,3 @@ class V_ViewRender : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(V_ViewRender); \ No newline at end of file diff --git a/r5dev/game/server/ai_network.cpp b/r5dev/game/server/ai_network.cpp index a0e50846..be14ea2d 100644 --- a/r5dev/game/server/ai_network.cpp +++ b/r5dev/game/server/ai_network.cpp @@ -124,12 +124,12 @@ CAI_Node** CAI_Network::GetPathNodes(void) const } //----------------------------------------------------------------------------- -void CAI_Network_Attach() +void VAI_Network::Attach() const { - DetourAttach((LPVOID*)&v_CAI_Network__DebugConnectMsg, &CAI_Network::DebugConnectMsg); + DetourAttach(&v_CAI_Network__DebugConnectMsg, &CAI_Network::DebugConnectMsg); } -void CAI_Network_Detach() +void VAI_Network::Detach() const { - DetourDetach((LPVOID*)&v_CAI_Network__DebugConnectMsg, &CAI_Network::DebugConnectMsg); + DetourDetach(&v_CAI_Network__DebugConnectMsg, &CAI_Network::DebugConnectMsg); } diff --git a/r5dev/game/server/ai_network.h b/r5dev/game/server/ai_network.h index b4d111e6..62692f85 100644 --- a/r5dev/game/server/ai_network.h +++ b/r5dev/game/server/ai_network.h @@ -45,9 +45,6 @@ public: }; inline CAI_Network** g_pAINetwork = nullptr; -void CAI_Network_Attach(); -void CAI_Network_Detach(); - inline CMemory p_CAI_Network__DebugConnectMsg; inline auto v_CAI_Network__DebugConnectMsg = p_CAI_Network__DebugConnectMsg.RCast(); @@ -56,9 +53,8 @@ class VAI_Network : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CAI_Network::DebugConnectMsg : {:#18x} |\n", p_CAI_Network__DebugConnectMsg.GetPtr()); - spdlog::debug("| VAR: g_pAINetwork : {:#18x} |\n", reinterpret_cast(g_pAINetwork)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CAI_Network::DebugConnectMsg", p_CAI_Network__DebugConnectMsg.GetPtr()); + LogVarAdr("g_pAINetwork", reinterpret_cast(g_pAINetwork)); } virtual void GetFun(void) const { @@ -70,9 +66,7 @@ class VAI_Network : public IDetour g_pAINetwork = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 4C 63 91 ?? ?? ?? ??").FindPatternSelf("48 8B").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VAI_Network); diff --git a/r5dev/game/server/ai_networkmanager.cpp b/r5dev/game/server/ai_networkmanager.cpp index 1fb2dc7e..2bd4336c 100644 --- a/r5dev/game/server/ai_networkmanager.cpp +++ b/r5dev/game/server/ai_networkmanager.cpp @@ -415,13 +415,13 @@ void CAI_NetworkBuilder::Build(CAI_NetworkBuilder* pBuilder, CAI_Network* pAINet CAI_NetworkBuilder::SaveNetworkGraph(pAINetwork); } -void CAI_NetworkManager_Attach() +void VAI_NetworkManager::Attach() const { DetourAttach((LPVOID*)&CAI_NetworkManager__LoadNetworkGraph, &CAI_NetworkManager::LoadNetworkGraph); DetourAttach((LPVOID*)&CAI_NetworkBuilder__Build, &CAI_NetworkBuilder::Build); } -void CAI_NetworkManager_Detach() +void VAI_NetworkManager::Detach() const { DetourDetach((LPVOID*)&CAI_NetworkManager__LoadNetworkGraph, &CAI_NetworkManager::LoadNetworkGraph); DetourDetach((LPVOID*)&CAI_NetworkBuilder__Build, &CAI_NetworkBuilder::Build); diff --git a/r5dev/game/server/ai_networkmanager.h b/r5dev/game/server/ai_networkmanager.h index 86849396..5f8e4113 100644 --- a/r5dev/game/server/ai_networkmanager.h +++ b/r5dev/game/server/ai_networkmanager.h @@ -32,9 +32,6 @@ inline AINodeClusters *** g_pppAiNodeClusters = nullptr; inline int * g_nAiNodeClusterLinks = nullptr; inline AINodeClusterLinks*** g_pppAiNodeClusterLinks = nullptr; -void CAI_NetworkManager_Attach(); -void CAI_NetworkManager_Detach(); - //----------------------------------------------------------------------------- // CAI_NetworkBuilder // @@ -68,14 +65,13 @@ class VAI_NetworkManager : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CAI_NetworkManager::LoadNetworkGraph : {:#18x} |\n", p_CAI_NetworkManager__LoadNetworkGraph.GetPtr()); - spdlog::debug("| FUN: CAI_NetworkManager::ShouldRebuild : {:#18x} |\n", p_CAI_NetworkManager__ShouldRebuild.GetPtr()); - spdlog::debug("| FUN: CAI_NetworkBuilder::Build : {:#18x} |\n", p_CAI_NetworkBuilder__Build.GetPtr() ); - spdlog::debug("| VAR: g_nAiNodeClusters : {:#18x} |\n", reinterpret_cast(g_nAiNodeClusters )); - spdlog::debug("| VAR: g_pppAiNodeClusters : {:#18x} |\n", reinterpret_cast(g_pppAiNodeClusters )); - spdlog::debug("| VAR: g_nAiNodeClusterLinks : {:#18x} |\n", reinterpret_cast(g_nAiNodeClusterLinks )); - spdlog::debug("| VAR: g_pppAiNodeClusterLinks : {:#18x} |\n", reinterpret_cast(g_pppAiNodeClusterLinks)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CAI_NetworkManager::LoadNetworkGraph", p_CAI_NetworkManager__LoadNetworkGraph.GetPtr()); + LogFunAdr("CAI_NetworkManager::ShouldRebuild", p_CAI_NetworkManager__ShouldRebuild.GetPtr()); + LogFunAdr("CAI_NetworkBuilder::Build", p_CAI_NetworkBuilder__Build.GetPtr()); + LogVarAdr("g_nAiNodeClusters", reinterpret_cast(g_nAiNodeClusters)); + LogVarAdr("g_pppAiNodeClusters", reinterpret_cast(g_pppAiNodeClusters)); + LogVarAdr("g_nAiNodeClusterLinks", reinterpret_cast(g_nAiNodeClusterLinks)); + LogVarAdr("g_pppAiNodeClusterLinks", reinterpret_cast(g_pppAiNodeClusterLinks)); } virtual void GetFun(void) const { @@ -107,9 +103,7 @@ class VAI_NetworkManager : public IDetour .FindPatternSelf("4C 8B 1D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VAI_NetworkManager); diff --git a/r5dev/game/server/ai_utility.cpp b/r5dev/game/server/ai_utility.cpp index f8929391..1d6a18e0 100644 --- a/r5dev/game/server/ai_utility.cpp +++ b/r5dev/game/server/ai_utility.cpp @@ -117,13 +117,13 @@ void Detour_HotSwap() } /////////////////////////////////////////////////////////////////////////////// -void CAI_Utility_Attach() +void VRecast::Attach() const { DetourAttach((LPVOID*)&v_dtNavMesh__isPolyReachable, &IsGoalPolyReachable); DetourAttach((LPVOID*)&v_Detour_LevelInit, &Detour_LevelInit); } -void CAI_Utility_Detach() +void VRecast::Detach() const { DetourDetach((LPVOID*)&v_dtNavMesh__isPolyReachable, &IsGoalPolyReachable); DetourDetach((LPVOID*)&v_Detour_LevelInit, &Detour_LevelInit); diff --git a/r5dev/game/server/ai_utility.h b/r5dev/game/server/ai_utility.h index 763dd12d..6f70f09b 100644 --- a/r5dev/game/server/ai_utility.h +++ b/r5dev/game/server/ai_utility.h @@ -1,4 +1 @@ #pragma once - -void CAI_Utility_Attach(); -void CAI_Utility_Detach(); \ No newline at end of file diff --git a/r5dev/game/server/baseanimating.h b/r5dev/game/server/baseanimating.h index ff0111eb..2645f005 100644 --- a/r5dev/game/server/baseanimating.h +++ b/r5dev/game/server/baseanimating.h @@ -147,8 +147,7 @@ class VBaseAnimating : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CBaseAnimating::LockStudioHdr : {:#18x} |\n", p_CBaseAnimating__LockStudioHdr.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CBaseAnimating::LockStudioHdr", p_CBaseAnimating__LockStudioHdr.GetPtr()); } virtual void GetFun(void) const { @@ -162,7 +161,4 @@ class VBaseAnimating : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VBaseAnimating); - #endif // BASEANIMATING_H - diff --git a/r5dev/game/server/baseentity.h b/r5dev/game/server/baseentity.h index 9077557f..4ea9c04c 100644 --- a/r5dev/game/server/baseentity.h +++ b/r5dev/game/server/baseentity.h @@ -261,9 +261,8 @@ class VBaseEntity : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CBaseEntity::GetBaseEntity : {:#18x} |\n", p_CBaseEntity__GetBaseEntity.GetPtr()); - spdlog::debug("| VAR: g_pEntityList : {:#18x} |\n", reinterpret_cast(g_pEntityList)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CBaseEntity::GetBaseEntity", p_CBaseEntity__GetBaseEntity.GetPtr()); + LogVarAdr("g_pEntityList", reinterpret_cast(g_pEntityList)); } virtual void GetFun(void) const { @@ -280,6 +279,4 @@ class VBaseEntity : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VBaseEntity); - #endif // BASEENTITY_H diff --git a/r5dev/game/server/detour_impl.h b/r5dev/game/server/detour_impl.h index 538fa2ed..4e174afa 100644 --- a/r5dev/game/server/detour_impl.h +++ b/r5dev/game/server/detour_impl.h @@ -58,14 +58,13 @@ class VRecast : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Detour_LevelInit : {:#18x} |\n", p_Detour_LevelInit.GetPtr()); - spdlog::debug("| FUN: Detour_FreeNavMesh : {:#18x} |\n", p_Detour_FreeNavMesh.GetPtr()); - spdlog::debug("| FUN: dtNavMesh::Init : {:#18x} |\n", p_dtNavMesh__Init.GetPtr()); - spdlog::debug("| FUN: dtNavMesh::addTile : {:#18x} |\n", p_dtNavMesh__addTile.GetPtr()); - spdlog::debug("| FUN: dtNavMesh::isPolyReachable : {:#18x} |\n", p_dtNavMesh__isPolyReachable.GetPtr()); - spdlog::debug("| VAR: g_pNavMesh[5] : {:#18x} |\n", reinterpret_cast(g_pNavMesh)); - spdlog::debug("| VAR: g_pNavMeshQuery : {:#18x} |\n", reinterpret_cast(g_pNavMeshQuery)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("Detour_LevelInit", p_Detour_LevelInit.GetPtr()); + LogFunAdr("Detour_FreeNavMesh", p_Detour_FreeNavMesh.GetPtr()); + LogFunAdr("dtNavMesh::Init", p_dtNavMesh__Init.GetPtr()); + LogFunAdr("dtNavMesh::addTile", p_dtNavMesh__addTile.GetPtr()); + LogFunAdr("dtNavMesh::isPolyReachable", p_dtNavMesh__isPolyReachable.GetPtr()); + LogVarAdr("g_pNavMesh[5]", reinterpret_cast(g_pNavMesh)); + LogVarAdr("g_pNavMeshQuery", reinterpret_cast(g_pNavMeshQuery)); } virtual void GetFun(void) const { @@ -95,9 +94,7 @@ class VRecast : public IDetour .FindPatternSelf("48 89 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VRecast); diff --git a/r5dev/game/server/fairfight_impl.h b/r5dev/game/server/fairfight_impl.h index 76ddf6c9..2498aaaf 100644 --- a/r5dev/game/server/fairfight_impl.h +++ b/r5dev/game/server/fairfight_impl.h @@ -10,8 +10,7 @@ class VFairFight : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: FairFight_Init : {:#18x} |\n", FairFight_Init.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("FairFight_Init", FairFight_Init.GetPtr()); } virtual void GetFun(void) const { @@ -27,5 +26,3 @@ class VFairFight : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VFairFight); diff --git a/r5dev/game/server/gameinterface.cpp b/r5dev/game/server/gameinterface.cpp index eb76ddfd..476b31c8 100644 --- a/r5dev/game/server/gameinterface.cpp +++ b/r5dev/game/server/gameinterface.cpp @@ -120,7 +120,7 @@ void RunFrameServer(double flFrameTime, bool bRunOverlays, bool bUniformUpdate) v_RunFrameServer(flFrameTime, bRunOverlays, bUniformUpdate); } -void CServerGameDLL_Attach() +void VServerGameDLL::Attach() const { #if defined(GAMEDLL_S3) DetourAttach((LPVOID*)&CServerGameDLL__OnReceivedSayTextMessage, &CServerGameDLL::OnReceivedSayTextMessage); @@ -128,7 +128,7 @@ void CServerGameDLL_Attach() DetourAttach(&v_RunFrameServer, &RunFrameServer); } -void CServerGameDLL_Detach() +void VServerGameDLL::Detach() const { #if defined(GAMEDLL_S3) DetourDetach((LPVOID*)&CServerGameDLL__OnReceivedSayTextMessage, &CServerGameDLL::OnReceivedSayTextMessage); diff --git a/r5dev/game/server/gameinterface.h b/r5dev/game/server/gameinterface.h index c9b9ecd1..31f84075 100644 --- a/r5dev/game/server/gameinterface.h +++ b/r5dev/game/server/gameinterface.h @@ -55,21 +55,17 @@ extern CServerGameEnts* g_pServerGameEntities; extern CGlobalVars** g_pGlobals; -void CServerGameDLL_Attach(); -void CServerGameDLL_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VServerGameDLL : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: OnReceivedSayTextMessage : {:#18x} |\n", p_CServerGameDLL__OnReceivedSayTextMessage.GetPtr()); - spdlog::debug("| FUN: RunFrameServer : {:#18x} |\n", p_RunFrameServer.GetPtr()); - spdlog::debug("| VAR: g_pServerGameDLL : {:#18x} |\n", reinterpret_cast(g_pServerGameDLL)); - spdlog::debug("| VAR: g_pServerGameClients : {:#18x} |\n", reinterpret_cast(g_pServerGameClients)); - spdlog::debug("| VAR: g_pServerGameEntities : {:#18x} |\n", reinterpret_cast(g_pServerGameEntities)); - spdlog::debug("| VAR: g_pGlobals : {:#18x} |\n", reinterpret_cast(g_pGlobals)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CServerGameDLL::OnReceivedSayTextMessage", p_CServerGameDLL__OnReceivedSayTextMessage.GetPtr()); + LogFunAdr("RunFrameServer", p_RunFrameServer.GetPtr()); + LogVarAdr("g_pServerGameDLL", reinterpret_cast(g_pServerGameDLL)); + LogVarAdr("g_pServerGameClients", reinterpret_cast(g_pServerGameClients)); + LogVarAdr("g_pServerGameEntities", reinterpret_cast(g_pServerGameEntities)); + LogVarAdr("g_pGlobals", reinterpret_cast(g_pGlobals)); } virtual void GetFun(void) const { @@ -86,11 +82,9 @@ class VServerGameDLL : public IDetour g_pGlobals = g_GameDll.FindPatternSIMD("4C 8B 0D ?? ?? ?? ?? 48 8B D1").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VServerGameDLL); - #endif // GAMEINTERFACE_H \ No newline at end of file diff --git a/r5dev/game/server/movehelper_server.h b/r5dev/game/server/movehelper_server.h index da7014be..83604fe8 100644 --- a/r5dev/game/server/movehelper_server.h +++ b/r5dev/game/server/movehelper_server.h @@ -34,8 +34,7 @@ class VMoveHelperServer : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: s_MoveHelperServer : {:#18x} |\n", reinterpret_cast(s_MoveHelperServer)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("s_MoveHelperServer", reinterpret_cast(s_MoveHelperServer)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -49,6 +48,4 @@ class VMoveHelperServer : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VMoveHelperServer); - #endif // MOVEHELPER_SERVER_H diff --git a/r5dev/game/server/physics_main.cpp b/r5dev/game/server/physics_main.cpp index 4eb665ee..f45f4063 100644 --- a/r5dev/game/server/physics_main.cpp +++ b/r5dev/game/server/physics_main.cpp @@ -44,12 +44,12 @@ void* Physics_RunThinkFunctions(bool bSimulating) } /////////////////////////////////////////////////////////////////////////////// -void Physics_Main_Attach() +void VPhysics_Main::Attach() const { DetourAttach(&v_Physics_RunThinkFunctions, &Physics_RunThinkFunctions); } -void Physics_Main_Detach() +void VPhysics_Main::Detach() const { DetourDetach(&v_Physics_RunThinkFunctions, &Physics_RunThinkFunctions); } \ No newline at end of file diff --git a/r5dev/game/server/physics_main.h b/r5dev/game/server/physics_main.h index 4cb3b0fe..f6fba56d 100644 --- a/r5dev/game/server/physics_main.h +++ b/r5dev/game/server/physics_main.h @@ -10,15 +10,12 @@ inline CMemory p_Physics_RunThinkFunctions; inline auto v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast(); -void Physics_Main_Attach(); -void Physics_Main_Detach(); /////////////////////////////////////////////////////////////////////////////// class VPhysics_Main : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Physics_RunThinkFunctions : {:#18x} |\n", p_Physics_RunThinkFunctions.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("Physics_RunThinkFunctions", p_Physics_RunThinkFunctions.GetPtr()); } virtual void GetFun(void) const { @@ -27,10 +24,9 @@ class VPhysics_Main : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VPhysics_Main); #endif // PHYSICS_MAIN_H diff --git a/r5dev/game/server/player.h b/r5dev/game/server/player.h index d75e006f..9722e2c3 100644 --- a/r5dev/game/server/player.h +++ b/r5dev/game/server/player.h @@ -800,9 +800,8 @@ class VPlayer : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CPlayer::EyeAngles : {:#18x} |\n", p_CPlayer__EyeAngles.GetPtr()); - spdlog::debug("| FUN: CPlayer::PlayerRunCommand : {:#18x} |\n", p_CPlayer__PlayerRunCommand.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CPlayer::EyeAngles", p_CPlayer__EyeAngles.GetPtr()); + LogFunAdr("CPlayer::PlayerRunCommand", p_CPlayer__PlayerRunCommand.GetPtr()); } virtual void GetFun(void) const { @@ -819,6 +818,4 @@ class VPlayer : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VPlayer); - #endif // PLAYER_H diff --git a/r5dev/game/shared/animation.cpp b/r5dev/game/shared/animation.cpp index 7439f196..f9199e7a 100644 --- a/r5dev/game/shared/animation.cpp +++ b/r5dev/game/shared/animation.cpp @@ -19,12 +19,12 @@ int CStudioHdr::LookupSequence(CStudioHdr* pStudio, const char* pszName) return v_CStudioHdr__LookupSequence(pStudio, pszName); } -void Animation_Attach() +void VAnimation::Attach() const { - DetourAttach((LPVOID*)&v_CStudioHdr__LookupSequence, &CStudioHdr::LookupSequence); + DetourAttach(&v_CStudioHdr__LookupSequence, &CStudioHdr::LookupSequence); } -void Animation_Detach() +void VAnimation::Detach() const { - DetourDetach((LPVOID*)&v_CStudioHdr__LookupSequence, &CStudioHdr::LookupSequence); + DetourDetach(&v_CStudioHdr__LookupSequence, &CStudioHdr::LookupSequence); } diff --git a/r5dev/game/shared/animation.h b/r5dev/game/shared/animation.h index 9fb6e81b..58fddeb2 100644 --- a/r5dev/game/shared/animation.h +++ b/r5dev/game/shared/animation.h @@ -83,15 +83,12 @@ struct Player_AnimViewEntityData inline CMemory p_CStudioHdr__LookupSequence; inline auto v_CStudioHdr__LookupSequence = p_CStudioHdr__LookupSequence.RCast(); -void Animation_Attach(); -void Animation_Detach(); /////////////////////////////////////////////////////////////////////////////// class VAnimation : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CStudioHdr::LookupSequence : {:#18x} |\n", p_CStudioHdr__LookupSequence.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CStudioHdr::LookupSequence", p_CStudioHdr__LookupSequence.GetPtr()); } virtual void GetFun(void) const { @@ -100,11 +97,9 @@ class VAnimation : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VAnimation); - #endif // ANIMATION_H diff --git a/r5dev/game/shared/usercmd.h b/r5dev/game/shared/usercmd.h index 52e89aa6..0490f495 100644 --- a/r5dev/game/shared/usercmd.h +++ b/r5dev/game/shared/usercmd.h @@ -64,9 +64,8 @@ class VUserCmd : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CUserCmd::Reset : {:#18x} |\n", p_CUserCmd__Reset.GetPtr()); - spdlog::debug("| FUN: CUserCmd::Copy : {:#18x} |\n", p_CUserCmd__Copy.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CUserCmd::Reset", p_CUserCmd__Reset.GetPtr()); + LogFunAdr("CUserCmd::Copy", p_CUserCmd__Copy.GetPtr()); } virtual void GetFun(void) const { @@ -83,6 +82,4 @@ class VUserCmd : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VUserCmd); - #endif // USERCMD_H diff --git a/r5dev/game/shared/util_shared.h b/r5dev/game/shared/util_shared.h index c187c177..e85e3bcb 100644 --- a/r5dev/game/shared/util_shared.h +++ b/r5dev/game/shared/util_shared.h @@ -48,8 +48,7 @@ class VUtil_Shared : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pTraceFilterSimpleVFTable : {:#18x} |\n", reinterpret_cast(g_pTraceFilterSimpleVFTable)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pTraceFilterSimpleVFTable", reinterpret_cast(g_pTraceFilterSimpleVFTable)); } virtual void GetFun(void) const { } virtual void GetVar(void) const { } @@ -62,6 +61,4 @@ class VUtil_Shared : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VUtil_Shared); - #endif // !UTIL_SHARED_H diff --git a/r5dev/inputsystem/inputsystem.h b/r5dev/inputsystem/inputsystem.h index 1a2f1714..60833501 100644 --- a/r5dev/inputsystem/inputsystem.h +++ b/r5dev/inputsystem/inputsystem.h @@ -26,8 +26,7 @@ class VInputSystem : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pInputSystem : {:#18x} |\n", reinterpret_cast(g_pInputSystem)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pInputSystem", reinterpret_cast(g_pInputSystem)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -40,5 +39,3 @@ class VInputSystem : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VInputSystem); diff --git a/r5dev/launcher/IApplication.cpp b/r5dev/launcher/IApplication.cpp index 08dca395..ddb0ac12 100644 --- a/r5dev/launcher/IApplication.cpp +++ b/r5dev/launcher/IApplication.cpp @@ -125,16 +125,3 @@ void CModAppSystemGroup::InitPluginSystem(CModAppSystemGroup* pModAppSystemGroup Warning(eDLL_T::ENGINE, "Failed loading plugin: '%s'\n", it.m_svPluginName.c_str()); } } - -/////////////////////////////////////////////////////////////////////////////// -void IApplication_Attach() -{ - DetourAttach((LPVOID*)&CModAppSystemGroup_Main, &CModAppSystemGroup::Main); - DetourAttach((LPVOID*)&CModAppSystemGroup_Create, &CModAppSystemGroup::Create); -} - -void IApplication_Detach() -{ - DetourDetach((LPVOID*)&CModAppSystemGroup_Main, &CModAppSystemGroup::Main); - DetourDetach((LPVOID*)&CModAppSystemGroup_Create, &CModAppSystemGroup::Create); -} diff --git a/r5dev/launcher/IApplication.h b/r5dev/launcher/IApplication.h index 9d1f839a..09f19aee 100644 --- a/r5dev/launcher/IApplication.h +++ b/r5dev/launcher/IApplication.h @@ -40,10 +40,6 @@ inline auto CSourceAppSystemGroup__PreInit = p_CSourceAppSystemGroup__PreInit.RC inline CMemory p_CSourceAppSystemGroup__Create; inline auto CSourceAppSystemGroup__Create = p_CSourceAppSystemGroup__Create.RCast(); -/////////////////////////////////////////////////////////////////////////////// -void IApplication_Attach(); -void IApplication_Detach(); - inline bool g_bAppSystemInit = false; /////////////////////////////////////////////////////////////////////////////// @@ -51,11 +47,10 @@ class VApplication : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CModAppSystemGroup::Main : {:#18x} |\n", p_CModAppSystemGroup_Main.GetPtr()); - spdlog::debug("| FUN: CModAppSystemGroup::Create : {:#18x} |\n", p_CModAppSystemGroup_Create.GetPtr()); - spdlog::debug("| FUN: CSourceAppSystemGroup::Create : {:#18x} |\n", p_CSourceAppSystemGroup__Create.GetPtr()); - spdlog::debug("| FUN: CSourceAppSystemGroup::PreInit : {:#18x} |\n", p_CSourceAppSystemGroup__PreInit.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CModAppSystemGroup::Main", p_CModAppSystemGroup_Main.GetPtr()); + LogFunAdr("CModAppSystemGroup::Create", p_CModAppSystemGroup_Create.GetPtr()); + LogFunAdr("CSourceAppSystemGroup::Create", p_CSourceAppSystemGroup__Create.GetPtr()); + LogFunAdr("CSourceAppSystemGroup::PreInit", p_CSourceAppSystemGroup__PreInit.GetPtr()); } virtual void GetFun(void) const { @@ -80,9 +75,15 @@ class VApplication : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const + { + DetourAttach((LPVOID*)&CModAppSystemGroup_Main, &CModAppSystemGroup::Main); + DetourAttach((LPVOID*)&CModAppSystemGroup_Create, &CModAppSystemGroup::Create); + } + virtual void Detach(void) const + { + DetourDetach((LPVOID*)&CModAppSystemGroup_Main, &CModAppSystemGroup::Main); + DetourDetach((LPVOID*)&CModAppSystemGroup_Create, &CModAppSystemGroup::Create); + } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VApplication); diff --git a/r5dev/launcher/launcher.cpp b/r5dev/launcher/launcher.cpp index 81236908..1a5642e0 100644 --- a/r5dev/launcher/launcher.cpp +++ b/r5dev/launcher/launcher.cpp @@ -169,7 +169,7 @@ LONG WINAPI TopLevelExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) return v_TopLevelExceptionFilter(pExceptionPointers); } -void Launcher_Attach() +void VLauncher::Attach(void) const { DetourAttach((LPVOID*)&v_WinMain, &HWinMain); DetourAttach((LPVOID*)&v_LauncherMain, &LauncherMain); @@ -178,8 +178,7 @@ void Launcher_Attach() DetourAttach((LPVOID*)&v_RemoveSpuriousGameParameters, &RemoveSpuriousGameParameters); #endif } - -void Launcher_Detach() +void VLauncher::Detach(void) const { DetourDetach((LPVOID*)&v_WinMain, &HWinMain); DetourDetach((LPVOID*)&v_LauncherMain, &LauncherMain); diff --git a/r5dev/launcher/launcher.h b/r5dev/launcher/launcher.h index 66375d6a..57346f5a 100644 --- a/r5dev/launcher/launcher.h +++ b/r5dev/launcher/launcher.h @@ -20,21 +20,17 @@ string LoadConfigFile(const string& svConfig); void ParseAndApplyConfigFile(const string& svConfig); const char* ExitCodeToString(int nCode); -void Launcher_Attach(); -void Launcher_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VLauncher : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: WinMain : {:#18x} |\n", p_WinMain.GetPtr()); - spdlog::debug("| FUN: LauncherMain : {:#18x} |\n", p_LauncherMain.GetPtr()); - spdlog::debug("| FUN: TopLevelExceptionFilter : {:#18x} |\n", p_TopLevelExceptionFilter.GetPtr()); + LogFunAdr("WinMain", p_WinMain.GetPtr()); + LogFunAdr("LauncherMain", p_LauncherMain.GetPtr()); + LogFunAdr("TopLevelExceptionFilter", p_TopLevelExceptionFilter.GetPtr()); #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) - spdlog::debug("| FUN: RemoveSpuriousGameParameters : {:#18x} |\n", p_RemoveSpuriousGameParameters.GetPtr()); + LogFunAdr("RemoveSpuriousGameParameters", p_RemoveSpuriousGameParameters.GetPtr()); #endif // !GAMEDLL_S0 || !GAMEDLL_S1 - spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { @@ -54,10 +50,9 @@ class VLauncher : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VLauncher); #endif // LAUNCHER_H \ No newline at end of file diff --git a/r5dev/launcher/prx.cpp b/r5dev/launcher/prx.cpp index 93498f44..5694ae28 100644 --- a/r5dev/launcher/prx.cpp +++ b/r5dev/launcher/prx.cpp @@ -13,12 +13,16 @@ void h_exit_or_terminate_process(UINT uExitCode) TerminateProcess(h, uExitCode); } -void PRX_Attach() +void VPRX::Attach() const { - DetourAttach((LPVOID*)&v_exit_or_terminate_process, &h_exit_or_terminate_process); +#ifdef DEDICATED + //DetourAttach(&v_exit_or_terminate_process, &h_exit_or_terminate_process); +#endif // DEDICATED } -void PRX_Detach() +void VPRX::Detach() const { - DetourDetach((LPVOID*)&v_exit_or_terminate_process, &h_exit_or_terminate_process); +#ifdef DEDICATED + //DetourDetach(&v_exit_or_terminate_process, &h_exit_or_terminate_process); +#endif // DEDICATED } \ No newline at end of file diff --git a/r5dev/launcher/prx.h b/r5dev/launcher/prx.h index f9cde49e..efc545f0 100644 --- a/r5dev/launcher/prx.h +++ b/r5dev/launcher/prx.h @@ -4,16 +4,12 @@ inline CMemory p_exit_or_terminate_process; inline auto v_exit_or_terminate_process = p_exit_or_terminate_process.RCast(); -void PRX_Attach(); -void PRX_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VPRX : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: exit_or_terminate_process : {:#18x} |\n", p_exit_or_terminate_process.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("exit_or_terminate_process", p_exit_or_terminate_process.GetPtr()); } virtual void GetFun(void) const { @@ -22,9 +18,7 @@ class VPRX : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VPRX); diff --git a/r5dev/materialsystem/cmaterialglue.h b/r5dev/materialsystem/cmaterialglue.h index d4d5822d..657783bc 100644 --- a/r5dev/materialsystem/cmaterialglue.h +++ b/r5dev/materialsystem/cmaterialglue.h @@ -80,10 +80,9 @@ class VMaterialGlue : public IDetour virtual void GetAdr(void) const { #ifndef DEDICATED - spdlog::debug("| FUN: CMaterialGlue::GetMaterialAtCrossHair: {:#18x} |\n", p_GetMaterialAtCrossHair.GetPtr()); + LogFunAdr("CMaterialGlue::GetMaterialAtCrossHair", p_GetMaterialAtCrossHair.GetPtr()); #endif // !DEDICATED - spdlog::debug("| CON: g_pMaterialGlueVFTable : {:#18x} |\n", reinterpret_cast(g_pMaterialGlueVFTable)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogConAdr("g_pMaterialGlueVFTable", reinterpret_cast(g_pMaterialGlueVFTable)); } virtual void GetFun(void) const { @@ -101,5 +100,3 @@ class VMaterialGlue : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VMaterialGlue); \ No newline at end of file diff --git a/r5dev/materialsystem/cmaterialsystem.cpp b/r5dev/materialsystem/cmaterialsystem.cpp index e6302b4a..3409a2ff 100644 --- a/r5dev/materialsystem/cmaterialsystem.cpp +++ b/r5dev/materialsystem/cmaterialsystem.cpp @@ -130,7 +130,7 @@ Vector2D CMaterialSystem::GetScreenSize(CMaterialSystem* pMatSys) #endif // !DEDICATED /////////////////////////////////////////////////////////////////////////////// -void CMaterialSystem_Attach() +void VMaterialSystem::Attach() const { // TODO: This has to be removed!!! #ifndef _DEBUG @@ -149,7 +149,7 @@ void CMaterialSystem_Attach() #endif // !DEDICATED } -void CMaterialSystem_Detach() +void VMaterialSystem::Detach() const { #ifndef DEDICATED DetourDetach((LPVOID*)&v_StreamDB_Init, &StreamDB_Init); diff --git a/r5dev/materialsystem/cmaterialsystem.h b/r5dev/materialsystem/cmaterialsystem.h index 16a88a88..3268a613 100644 --- a/r5dev/materialsystem/cmaterialsystem.h +++ b/r5dev/materialsystem/cmaterialsystem.h @@ -44,25 +44,23 @@ inline int* g_nUnusableStreamingTextureMemory = nullptr; #endif // !DEDICATED __declspec(noinline) bool IsMaterialInternal(void** pCandidate); -void CMaterialSystem_Attach(); -void CMaterialSystem_Detach(); + /////////////////////////////////////////////////////////////////////////////// class VMaterialSystem : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CMaterialSystem::Init : {:#18x} |\n", p_CMaterialSystem__Init.GetPtr()); + LogFunAdr("CMaterialSystem::Init", p_CMaterialSystem__Init.GetPtr()); #ifndef DEDICATED - spdlog::debug("| FUN: CMaterialSystem::DispatchDrawCall : {:#18x} |\n", p_DispatchDrawCall.GetPtr()); - spdlog::debug("| FUN: CMaterialSystem::DrawStreamOverlay : {:#18x} |\n", p_DrawStreamOverlay.GetPtr()); - spdlog::debug("| VAR: g_nTotalStreamingTextureMemory : {:#18x} |\n", reinterpret_cast(g_nTotalStreamingTextureMemory)); - spdlog::debug("| VAR: g_nUnfreeStreamingTextureMemory : {:#18x} |\n", reinterpret_cast(g_nUnfreeStreamingTextureMemory)); - spdlog::debug("| VAR: g_nUnusableStreamingTextureMemory : {:#18x} |\n", reinterpret_cast(g_nUnusableStreamingTextureMemory)); - spdlog::debug("| VAR: s_pRenderContext : {:#18x} |\n", s_pRenderContext.GetPtr()); + LogFunAdr("CMaterialSystem::DispatchDrawCall", p_DispatchDrawCall.GetPtr()); + LogFunAdr("CMaterialSystem::DrawStreamOverlay", p_DrawStreamOverlay.GetPtr()); + LogVarAdr("g_nTotalStreamingTextureMemory", reinterpret_cast(g_nTotalStreamingTextureMemory)); + LogVarAdr("g_nUnfreeStreamingTextureMemory", reinterpret_cast(g_nUnfreeStreamingTextureMemory)); + LogVarAdr("g_nUnusableStreamingTextureMemory", reinterpret_cast(g_nUnusableStreamingTextureMemory)); + LogVarAdr("s_pRenderContext", s_pRenderContext.GetPtr()); #endif // !DEDICATED - spdlog::debug("| VAR: g_pMaterialSystem : {:#18x} |\n", reinterpret_cast(g_pMaterialSystem)); - spdlog::debug("| CON: g_pMaterialVFTable : {:#18x} |\n", reinterpret_cast(g_pMaterialVFTable)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pMaterialSystem", reinterpret_cast(g_pMaterialSystem)); + LogConAdr("g_pMaterialVFTable", reinterpret_cast(g_pMaterialVFTable)); } virtual void GetFun(void) const { @@ -100,11 +98,9 @@ class VMaterialSystem : public IDetour { g_pMaterialVFTable = g_GameDll.GetVirtualMethodTable(".?AVCMaterial@@").RCast(); } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VMaterialSystem); - #endif // MATERIALSYSTEM_H \ No newline at end of file diff --git a/r5dev/materialsystem/cshaderglue.h b/r5dev/materialsystem/cshaderglue.h index d9e0cd62..864196a4 100644 --- a/r5dev/materialsystem/cshaderglue.h +++ b/r5dev/materialsystem/cshaderglue.h @@ -43,9 +43,8 @@ class VShaderGlue : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CShaderGlue::SetupShader : {:#18x} |\n", reinterpret_cast(CShaderGlue_SetupShader)); - spdlog::debug("| CON: g_pShaderGlueVFTable : {:#18x} |\n", reinterpret_cast(g_pShaderGlueVFTable)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CShaderGlue::SetupShader", reinterpret_cast(CShaderGlue_SetupShader)); + LogConAdr("g_pShaderGlueVFTable", reinterpret_cast(g_pShaderGlueVFTable)); } virtual void GetFun(void) const { @@ -61,5 +60,3 @@ class VShaderGlue : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VShaderGlue); \ No newline at end of file diff --git a/r5dev/public/edict.h b/r5dev/public/edict.h index a839cc95..968d5479 100644 --- a/r5dev/public/edict.h +++ b/r5dev/public/edict.h @@ -53,12 +53,11 @@ class VEdict : public IDetour virtual void GetAdr(void) const { #ifndef CLIENT_DLL - spdlog::debug("| VAR: g_ServerGlobalVariables : {:#18x} |\n", reinterpret_cast(g_ServerGlobalVariables)); + LogVarAdr("g_ServerGlobalVariables", reinterpret_cast(g_ServerGlobalVariables)); #endif // !CLIENT_DLL #ifndef DEDICATED - spdlog::debug("| VAR: g_ClientGlobalVariables : {:#18x} |\n", reinterpret_cast(g_ClientGlobalVariables)); + LogVarAdr("g_ClientGlobalVariables", reinterpret_cast(g_ClientGlobalVariables)); #endif // !DEDICATED - spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -82,5 +81,3 @@ class VEdict : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VEdict); diff --git a/r5dev/rtech/rtech_game.cpp b/r5dev/rtech/rtech_game.cpp index c6454cff..5c4701c4 100644 --- a/r5dev/rtech/rtech_game.cpp +++ b/r5dev/rtech/rtech_game.cpp @@ -84,16 +84,16 @@ void CPakFile::UnloadPak(RPakHandle_t handle) CPakFile_UnloadPak(handle); } -void RTech_Game_Attach() +void V_RTechGame::Attach() const { - DetourAttach((LPVOID*)&CPakFile_LoadAsync, &CPakFile::LoadAsync); - DetourAttach((LPVOID*)&CPakFile_UnloadPak, &CPakFile::UnloadPak); + DetourAttach(&CPakFile_LoadAsync, &CPakFile::LoadAsync); + DetourAttach(&CPakFile_UnloadPak, &CPakFile::UnloadPak); } -void RTech_Game_Detach() +void V_RTechGame::Detach() const { - DetourDetach((LPVOID*)&CPakFile_LoadAsync, &CPakFile::LoadAsync); - DetourDetach((LPVOID*)&CPakFile_UnloadPak, &CPakFile::UnloadPak); + DetourDetach(&CPakFile_LoadAsync, &CPakFile::LoadAsync); + DetourDetach(&CPakFile_UnloadPak, &CPakFile::UnloadPak); } // Symbols taken from R2 dll's. diff --git a/r5dev/rtech/rtech_game.h b/r5dev/rtech/rtech_game.h index 202b6d85..128868c0 100644 --- a/r5dev/rtech/rtech_game.h +++ b/r5dev/rtech/rtech_game.h @@ -42,22 +42,19 @@ public: static RPakHandle_t LoadAsync(const char* szPakFileName, void* pMalloc = g_pMallocPool, int nIdx = NULL, bool bUnk = false); static void UnloadPak(RPakHandle_t handle); }; + extern CPakFile* g_pakLoadApi; - -void RTech_Game_Attach(); -void RTech_Game_Detach(); - extern vector g_vLoadedPakHandle; + /////////////////////////////////////////////////////////////////////////////// -class VRTechGame : public IDetour +class V_RTechGame : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CPakFile::LoadAsync : {:#18x} |\n", p_CPakFile_LoadAsync.GetPtr()); - spdlog::debug("| FUN: CPakFile::LoadPak : {:#18x} |\n", p_CPakFile_LoadPak.GetPtr()); - spdlog::debug("| FUN: CPakFile::UnloadPak : {:#18x} |\n", p_CPakFile_UnloadPak.GetPtr()); - spdlog::debug("| CON: CPakFile::LoadPak_OpenFileOffset : {:#18x} |\n", p_CPakFile_LoadPak_OpenFileOffset.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CPakFile::LoadAsync", p_CPakFile_LoadAsync.GetPtr()); + LogFunAdr("CPakFile::LoadPak", p_CPakFile_LoadPak.GetPtr()); + LogFunAdr("CPakFile::UnloadPak", p_CPakFile_UnloadPak.GetPtr()); + LogConAdr("CPakFile::LoadPak_OpenFileOffset", p_CPakFile_LoadPak_OpenFileOffset.GetPtr()); } virtual void GetFun(void) const { @@ -83,9 +80,7 @@ class VRTechGame : public IDetour { p_CPakFile_LoadPak_OpenFileOffset = g_GameDll.FindPatternSIMD("48 89 7C 24 30 C7 44 24 28 ?? ?? ?? 40"); /*48 89 7C 24 30 C7 44 24 28 00 00 00 40*/ } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VRTechGame); diff --git a/r5dev/rtech/rtech_utils.cpp b/r5dev/rtech/rtech_utils.cpp index a635e3fb..906aff36 100644 --- a/r5dev/rtech/rtech_utils.cpp +++ b/r5dev/rtech/rtech_utils.cpp @@ -790,29 +790,29 @@ void RTech::PakProcessGuidRelationsForAsset(PakFile_t* pPak, RPakAssetEntry_t* p } } -void RTech_Utils_Attach() +void V_RTechUtils::Attach() const { - DetourAttach((LPVOID*)&RTech_OpenFile, &RTech::OpenFile); + DetourAttach(&RTech_OpenFile, &RTech::OpenFile); #ifdef GAMEDLL_S3 - DetourAttach((LPVOID*)&RTech_Pak_ProcessGuidRelationsForAsset, &RTech::PakProcessGuidRelationsForAsset); + DetourAttach(&RTech_Pak_ProcessGuidRelationsForAsset, &RTech::PakProcessGuidRelationsForAsset); #endif #if not defined DEDICATED && defined GAMEDLL_S3 - DetourAttach((LPVOID*)&RTech_CreateDXTexture, &RTech::CreateDXTexture); + DetourAttach(&RTech_CreateDXTexture, &RTech::CreateDXTexture); #endif // !DEDICATED } -void RTech_Utils_Detach() +void V_RTechUtils::Detach() const { - DetourDetach((LPVOID*)&RTech_OpenFile, &RTech::OpenFile); + DetourDetach(&RTech_OpenFile, &RTech::OpenFile); #ifdef GAMEDLL_S3 - DetourDetach((LPVOID*)&RTech_Pak_ProcessGuidRelationsForAsset, &RTech::PakProcessGuidRelationsForAsset); + DetourDetach(&RTech_Pak_ProcessGuidRelationsForAsset, &RTech::PakProcessGuidRelationsForAsset); #endif #if not defined DEDICATED && defined GAMEDLL_S3 - DetourDetach((LPVOID*)&RTech_CreateDXTexture, &RTech::CreateDXTexture); + DetourDetach(&RTech_CreateDXTexture, &RTech::CreateDXTexture); #endif // !DEDICATED } diff --git a/r5dev/rtech/rtech_utils.h b/r5dev/rtech/rtech_utils.h index 01be022d..42062d41 100644 --- a/r5dev/rtech/rtech_utils.h +++ b/r5dev/rtech/rtech_utils.h @@ -366,37 +366,33 @@ public: #endif // !DEDICATED }; -void RTech_Utils_Attach(); -void RTech_Utils_Detach(); - /////////////////////////////////////////////////////////////////////////////// extern RTech* g_pRTech; /////////////////////////////////////////////////////////////////////////////// -class VPakFile : public IDetour +class V_RTechUtils : public IDetour { virtual void GetAdr(void) const { #if not defined DEDICATED - spdlog::debug("| FUN: RTech::CreateDXTexture : {:#18x} |\n", p_RTech_CreateDXTexture.GetPtr()); + LogFunAdr("RTech::CreateDXTexture", p_RTech_CreateDXTexture.GetPtr()); #endif // !DEDICATED - spdlog::debug("| FUN: RTech::FindFreeSlotInFiles : {:#18x} |\n", p_RTech_FindFreeSlotInFiles.GetPtr()); - spdlog::debug("| FUN: RTech::OpenFile : {:#18x} |\n", p_RTech_OpenFile.GetPtr()); + LogFunAdr("RTech::FindFreeSlotInFiles", p_RTech_FindFreeSlotInFiles.GetPtr()); + LogFunAdr("RTech::OpenFile", p_RTech_OpenFile.GetPtr()); #if not defined DEDICATED - spdlog::debug("| FUN: GetStreamOverlay : {:#18x} |\n", p_GetStreamOverlay.GetPtr()); + LogFunAdr("GetStreamOverlay", p_GetStreamOverlay.GetPtr()); #endif // !DEDICATED - spdlog::debug("| FUN: StreamDB_Init : {:#18x} |\n", p_StreamDB_Init.GetPtr()); - spdlog::debug("| VAR: g_pLoadedPakInfo : {:#18x} |\n", reinterpret_cast(g_pLoadedPakInfo)); - spdlog::debug("| VAR: s_pLoadedPakCount : {:#18x} |\n", reinterpret_cast(s_pLoadedPakCount)); - spdlog::debug("| VAR: s_pParsedPakCount : {:#18x} |\n", reinterpret_cast(s_pParsedPakCount)); - spdlog::debug("| VAR: s_pFileArray : {:#18x} |\n", reinterpret_cast(s_pFileArray)); - spdlog::debug("| VAR: g_pPakFileSlotLock : {:#18x} |\n", reinterpret_cast(g_pPakFileSlotLock)); - spdlog::debug("| VAR: m_FileHandles : {:#18x} |\n", reinterpret_cast(m_FileHandles)); - spdlog::debug("| VAR: g_pUnknownPakStruct : {:#18x} |\n", reinterpret_cast(g_pUnknownPakStruct)); - spdlog::debug("| VAR: g_pPakFifoLock : {:#18x} |\n", reinterpret_cast(g_pPakFifoLock)); - spdlog::debug("| VAR: g_pPakFifoLockWrapper : {:#18x} |\n", reinterpret_cast(g_pPakFifoLockWrapper)); - spdlog::debug("| VAR: g_bPakFifoLockAcquired : {:#18x} |\n", reinterpret_cast(g_bPakFifoLockAcquired)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("StreamDB_Init", p_StreamDB_Init.GetPtr()); + LogVarAdr("g_pLoadedPakInfo", reinterpret_cast(g_pLoadedPakInfo)); + LogVarAdr("s_pLoadedPakCount", reinterpret_cast(s_pLoadedPakCount)); + LogVarAdr("s_pParsedPakCount", reinterpret_cast(s_pParsedPakCount)); + LogVarAdr("s_pFileArray", reinterpret_cast(s_pFileArray)); + LogVarAdr("g_pPakFileSlotLock", reinterpret_cast(g_pPakFileSlotLock)); + LogVarAdr("m_FileHandles", reinterpret_cast(m_FileHandles)); + LogVarAdr("g_pUnknownPakStruct", reinterpret_cast(g_pUnknownPakStruct)); + LogVarAdr("g_pPakFifoLock", reinterpret_cast(g_pPakFifoLock)); + LogVarAdr("g_pPakFifoLockWrapper", reinterpret_cast(g_pPakFifoLockWrapper)); + LogVarAdr("g_bPakFifoLockAcquired", reinterpret_cast(g_bPakFifoLockAcquired)); } virtual void GetFun(void) const { @@ -445,9 +441,7 @@ class VPakFile : public IDetour g_bPakFifoLockAcquired = p_JT_HelpWithAnything.Offset(0x50).FindPatternSelf("C6 05").ResolveRelativeAddressSelf(0x2, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VPakFile); diff --git a/r5dev/rtech/rui/rui.cpp b/r5dev/rtech/rui/rui.cpp index 8c402f4a..d6d49a42 100644 --- a/r5dev/rtech/rui/rui.cpp +++ b/r5dev/rtech/rui/rui.cpp @@ -22,14 +22,14 @@ bool __fastcall Rui_Draw(__int64* a1, __m128* a2, const __m128i* a3, __int64 a4, return v_Rui_Draw(a1, a2, a3, a4, a5); } -void Rui_Attach() +void V_Rui::Attach() const { - DetourAttach((LPVOID*)&v_Rui_Draw, &Rui_Draw); + DetourAttach(&v_Rui_Draw, &Rui_Draw); } -void Rui_Detach() +void V_Rui::Detach() const { - DetourDetach((LPVOID*)&v_Rui_Draw, &Rui_Draw); + DetourDetach(&v_Rui_Draw, &Rui_Draw); } #endif // !DEDICATED \ No newline at end of file diff --git a/r5dev/rtech/rui/rui.h b/r5dev/rtech/rui/rui.h index 9cc50d8a..76fc2f04 100644 --- a/r5dev/rtech/rui/rui.h +++ b/r5dev/rtech/rui/rui.h @@ -10,18 +10,14 @@ inline auto v_Rui_LoadAsset = p_Rui_LoadAsset.RCast(); -void Rui_Attach(); -void Rui_Detach(); - /////////////////////////////////////////////////////////////////////////////// -class VRui : public IDetour +class V_Rui : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Rui_Draw : {:#18x} |\n", p_Rui_Draw.GetPtr()); - spdlog::debug("| FUN: Rui_LoadAsset : {:#18x} |\n", p_Rui_LoadAsset.GetPtr()); - spdlog::debug("| FUN: Rui_GetFontFace : {:#18x} |\n", p_Rui_GetFontFace.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("Rui_Draw", p_Rui_Draw.GetPtr()); + LogFunAdr("Rui_LoadAsset", p_Rui_LoadAsset.GetPtr()); + LogFunAdr("Rui_GetFontFace", p_Rui_GetFontFace.GetPtr()); } virtual void GetFun(void) const { @@ -36,9 +32,7 @@ class VRui : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VRui); diff --git a/r5dev/rtech/stryder/stryder.h b/r5dev/rtech/stryder/stryder.h index b3cf29fd..ea749c97 100644 --- a/r5dev/rtech/stryder/stryder.h +++ b/r5dev/rtech/stryder/stryder.h @@ -12,9 +12,8 @@ class VStryder : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Stryder_StitchRequest : {:#18x} |\n", p_Stryder_StitchRequest.GetPtr()); - spdlog::debug("| FUN: Stryder_SendOfflineRequest : {:#18x} |\n", p_Stryder_SendOfflineRequest.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("Stryder_StitchRequest", p_Stryder_StitchRequest.GetPtr()); + LogFunAdr("Stryder_SendOfflineRequest", p_Stryder_SendOfflineRequest.GetPtr()); } virtual void GetFun(void) const { @@ -34,5 +33,3 @@ class VStryder : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VStryder); \ No newline at end of file diff --git a/r5dev/server/persistence.cpp b/r5dev/server/persistence.cpp index 50faf88c..a57dfe86 100644 --- a/r5dev/server/persistence.cpp +++ b/r5dev/server/persistence.cpp @@ -10,13 +10,13 @@ bool Persistence_SetXP(int a1, int* a2) } #endif -void Persistence_Attach() +void VPersistence::Attach() const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) DetourAttach((LPVOID*)&v_Persistence_SetXP, &Persistence_SetXP); #endif } -void Persistence_Detach() +void VPersistence::Detach() const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) DetourDetach((LPVOID*)&v_Persistence_SetXP, &Persistence_SetXP); diff --git a/r5dev/server/persistence.h b/r5dev/server/persistence.h index 736ff1c5..23effefe 100644 --- a/r5dev/server/persistence.h +++ b/r5dev/server/persistence.h @@ -6,17 +6,13 @@ inline CMemory p_Persistence_SetXP; inline auto v_Persistence_SetXP = p_Persistence_SetXP.RCast(); #endif -void Persistence_Attach(); -void Persistence_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VPersistence : public IDetour { virtual void GetAdr(void) const { #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) - spdlog::debug("| FUN: Persistence_SetXP : {:#18x} |\n", p_Persistence_SetXP.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("Persistence_SetXP", p_Persistence_SetXP.GetPtr()); #endif } virtual void GetFun(void) const @@ -28,10 +24,9 @@ class VPersistence : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VPersistence); #endif // PERSISTENCE_H diff --git a/r5dev/server/vengineserver_impl.cpp b/r5dev/server/vengineserver_impl.cpp index d7b955c2..142ad43a 100644 --- a/r5dev/server/vengineserver_impl.cpp +++ b/r5dev/server/vengineserver_impl.cpp @@ -40,14 +40,14 @@ bool CVEngineServer::PersistenceAvailable(void* entidx, int clienthandle) return IVEngineServer__PersistenceAvailable(entidx, clienthandle); } -void IVEngineServer_Attach() +void HVEngineServer::Attach() const { - DetourAttach((LPVOID*)&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable); + DetourAttach(&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable); } -void IVEngineServer_Detach() +void HVEngineServer::Detach() const { - DetourDetach((LPVOID*)&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable); + DetourDetach(&IVEngineServer__PersistenceAvailable, &CVEngineServer::PersistenceAvailable); } /////////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/server/vengineserver_impl.h b/r5dev/server/vengineserver_impl.h index 7a9f1fab..98d5302c 100644 --- a/r5dev/server/vengineserver_impl.h +++ b/r5dev/server/vengineserver_impl.h @@ -8,10 +8,6 @@ inline auto IVEngineServer__PersistenceAvailable = p_IVEngineServer__Persistence inline bool* g_bDedicated = nullptr; -/////////////////////////////////////////////////////////////////////////////// -void IVEngineServer_Attach(); -void IVEngineServer_Detach(); - /////////////////////////////////////////////////////////////////////////////// struct ServerPlayer_t @@ -55,10 +51,9 @@ class HVEngineServer : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CVEngineServer::PersistenceAvailable : {:#18x} |\n", p_IVEngineServer__PersistenceAvailable.GetPtr()); - spdlog::debug("| VAR: g_bDedicated : {:#18x} |\n", reinterpret_cast(g_bDedicated)); - spdlog::debug("| VAR: g_pEngineServerVFTable : {:#18x} |\n", reinterpret_cast(g_pEngineServerVFTable)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CVEngineServer::PersistenceAvailable", p_IVEngineServer__PersistenceAvailable.GetPtr()); + LogVarAdr("g_bDedicated", reinterpret_cast(g_bDedicated)); + LogVarAdr("g_pEngineServerVFTable", reinterpret_cast(g_pEngineServerVFTable)); } virtual void GetFun(void) const { @@ -73,9 +68,7 @@ class HVEngineServer : public IDetour g_bDedicated = pEngineServerVFTable.WalkVTableSelf(3).DerefSelf().ResolveRelativeAddress(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(HVEngineServer); diff --git a/r5dev/squirrel/sqapi.cpp b/r5dev/squirrel/sqapi.cpp index d46ffddd..9a248ab6 100644 --- a/r5dev/squirrel/sqapi.cpp +++ b/r5dev/squirrel/sqapi.cpp @@ -86,7 +86,7 @@ SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerr return v_sq_call(v, params, retval, raiseerror); } -void SQAPI_Attach() +void VSqapi::Attach() const { DetourAttach((LPVOID*)&v_sq_pushroottable, &sq_pushroottable); DetourAttach((LPVOID*)&v_sq_pushbool, &sq_pushbool); @@ -101,7 +101,7 @@ void SQAPI_Attach() DetourAttach((LPVOID*)&v_sq_call, &sq_call); } -void SQAPI_Detach() +void VSqapi::Detach() const { DetourDetach((LPVOID*)&v_sq_pushroottable, &sq_pushroottable); DetourDetach((LPVOID*)&v_sq_pushbool, &sq_pushbool); diff --git a/r5dev/squirrel/sqapi.h b/r5dev/squirrel/sqapi.h index bac7cb90..3f272178 100644 --- a/r5dev/squirrel/sqapi.h +++ b/r5dev/squirrel/sqapi.h @@ -18,9 +18,6 @@ SQRESULT sq_pushstructure(HSQUIRRELVM v, const SQChar* name, const SQChar* membe SQRESULT sq_compilebuffer(HSQUIRRELVM v, SQBufState* bufferState, const SQChar* buffer, SQInteger context); SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror); -void SQAPI_Attach(); -void SQAPI_Detach(); - /* ==== SQUIRREL ======================================================================================================================================================== */ inline CMemory p_sq_pushroottable; inline auto v_sq_pushroottable = p_sq_pushroottable.RCast(); @@ -60,18 +57,17 @@ class VSqapi : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: sq_pushroottable : {:#18x} |\n", p_sq_pushroottable.GetPtr()); - spdlog::debug("| FUN: sq_pushbool : {:#18x} |\n", p_sq_pushbool.GetPtr()); - spdlog::debug("| FUN: sq_pushstring : {:#18x} |\n", p_sq_pushstring.GetPtr()); - spdlog::debug("| FUN: sq_pushinteger : {:#18x} |\n", p_sq_pushinteger.GetPtr()); - spdlog::debug("| FUN: sq_newarray : {:#18x} |\n", p_sq_newarray.GetPtr()); - spdlog::debug("| FUN: sq_arrayappend : {:#18x} |\n", p_sq_arrayappend.GetPtr()); - spdlog::debug("| FUN: sq_newtable : {:#18x} |\n", p_sq_newtable.GetPtr()); - spdlog::debug("| FUN: sq_newslot : {:#18x} |\n", p_sq_newslot.GetPtr()); - spdlog::debug("| FUN: sq_pushstructure : {:#18x} |\n", p_sq_pushstructure.GetPtr()); - spdlog::debug("| FUN: sq_compilebuffer : {:#18x} |\n", p_sq_compilebuffer.GetPtr()); - spdlog::debug("| FUN: sq_call : {:#18x} |\n", p_sq_call.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("sq_pushroottable", p_sq_pushroottable.GetPtr()); + LogFunAdr("sq_pushbool", p_sq_pushbool.GetPtr()); + LogFunAdr("sq_pushstring", p_sq_pushstring.GetPtr()); + LogFunAdr("sq_pushinteger", p_sq_pushinteger.GetPtr()); + LogFunAdr("sq_newarray", p_sq_newarray.GetPtr()); + LogFunAdr("sq_arrayappend", p_sq_arrayappend.GetPtr()); + LogFunAdr("sq_newtable", p_sq_newtable.GetPtr()); + LogFunAdr("sq_newslot", p_sq_newslot.GetPtr()); + LogFunAdr("sq_pushstructure", p_sq_pushstructure.GetPtr()); + LogFunAdr("sq_compilebuffer", p_sq_compilebuffer.GetPtr()); + LogFunAdr("sq_call", p_sq_call.GetPtr()); } virtual void GetFun(void) const { @@ -110,9 +106,7 @@ class VSqapi : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VSqapi); diff --git a/r5dev/squirrel/sqinit.h b/r5dev/squirrel/sqinit.h index 85599e7d..49796ab9 100644 --- a/r5dev/squirrel/sqinit.h +++ b/r5dev/squirrel/sqinit.h @@ -67,15 +67,14 @@ class VSqInit : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Remote_BeginRegisteringFunctions : {:#18x} |\n", p_Script_Remote_BeginRegisteringFunctions.GetPtr()); - spdlog::debug("| FUN: RestoreRemoteChecksumsFromSaveGame : {:#18x} |\n", p_RestoreRemoteChecksumsFromSaveGame.GetPtr()); + LogFunAdr("Remote_BeginRegisteringFunctions", p_Script_Remote_BeginRegisteringFunctions.GetPtr()); + LogFunAdr("RestoreRemoteChecksumsFromSaveGame", p_RestoreRemoteChecksumsFromSaveGame.GetPtr()); #ifndef CLIENT_DLL - spdlog::debug("| VAR: g_nServerRemoteChecksum : {:#18x} |\n", reinterpret_cast(g_nServerRemoteChecksum)); + LogVarAdr("g_nServerRemoteChecksum", reinterpret_cast(g_nServerRemoteChecksum)); #endif // !CLIENT_DLL #ifndef DEDICATED - spdlog::debug("| VAR: g_nClientRemoteChecksum : {:#18x} |\n", reinterpret_cast(g_nClientRemoteChecksum)); + LogVarAdr("g_nClientRemoteChecksum", reinterpret_cast(g_nClientRemoteChecksum)); #endif // !DEDICATED - spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { @@ -99,5 +98,3 @@ class VSqInit : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VSqInit); diff --git a/r5dev/squirrel/sqscript.cpp b/r5dev/squirrel/sqscript.cpp index 5105d4f0..1fe18ecf 100644 --- a/r5dev/squirrel/sqscript.cpp +++ b/r5dev/squirrel/sqscript.cpp @@ -325,7 +325,7 @@ void Script_Execute(const SQChar* code, const SQCONTEXT context) } //--------------------------------------------------------------------------------- -void SQScript_Attach() +void VSquirrelVM::Attach() const { DetourAttach((LPVOID*)&v_Script_RegisterConstant, &Script_RegisterConstant); #ifndef DEDICATED @@ -344,7 +344,7 @@ void SQScript_Attach() DetourAttach((LPVOID*)&v_Script_LoadScript, &Script_LoadScript); } //--------------------------------------------------------------------------------- -void SQScript_Detach() +void VSquirrelVM::Detach() const { DetourDetach((LPVOID*)&v_Script_RegisterConstant, &Script_RegisterConstant); #ifndef DEDICATED diff --git a/r5dev/squirrel/sqscript.h b/r5dev/squirrel/sqscript.h index 16bc937b..f111cf0c 100644 --- a/r5dev/squirrel/sqscript.h +++ b/r5dev/squirrel/sqscript.h @@ -143,39 +143,36 @@ SQBool Script_LoadScript(HSQUIRRELVM v, const SQChar* path, const SQChar* name, void Script_Execute(const SQChar* code, const SQCONTEXT context); -void SQScript_Attach(); -void SQScript_Detach(); /////////////////////////////////////////////////////////////////////////////// class VSquirrelVM : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Script_RegisterConstant : {:#18x} |\n", p_Script_RegisterConstant.GetPtr()); - spdlog::debug("| FUN: Script_RegisterFunction : {:#18x} |\n", p_Script_RegisterFunction.GetPtr()); + LogFunAdr("Script_RegisterConstant", p_Script_RegisterConstant.GetPtr()); + LogFunAdr("Script_RegisterFunction", p_Script_RegisterFunction.GetPtr()); #ifndef CLIENT_DLL - spdlog::debug("| FUN: Script_InitializeSVGlobalStructs : {:#18x} |\n", p_Script_InitializeSVGlobalStructs.GetPtr()); + LogFunAdr("Script_InitializeSVGlobalStructs", p_Script_InitializeSVGlobalStructs.GetPtr()); #endif // !CLIENT_DLL #ifndef DEDICATED - spdlog::debug("| FUN: Script_InitializeCLGlobalStructs : {:#18x} |\n", p_Script_InitializeCLGlobalStructs.GetPtr()); + LogFunAdr("Script_InitializeCLGlobalStructs", p_Script_InitializeCLGlobalStructs.GetPtr()); #endif // !DEDICATED #ifndef CLIENT_DLL - spdlog::debug("| FUN: Script_CreateServerVM : {:#18x} |\n", p_Script_CreateServerVM.GetPtr()); + LogFunAdr("Script_CreateServerVM", p_Script_CreateServerVM.GetPtr()); #endif // !CLIENT_DLL #ifndef DEDICATED - spdlog::debug("| FUN: Script_CreateClientVM : {:#18x} |\n", p_Script_CreateClientVM.GetPtr()); - spdlog::debug("| FUN: Script_CreateUIVM : {:#18x} |\n", p_Script_CreateUIVM.GetPtr()); + LogFunAdr("Script_CreateClientVM", p_Script_CreateClientVM.GetPtr()); + LogFunAdr("Script_CreateUIVM", p_Script_CreateUIVM.GetPtr()); #endif // !DEDICATED - spdlog::debug("| FUN: Script_DestroySignalEntryListHead : {:#18x} |\n", p_Script_DestroySignalEntryListHead.GetPtr()); - spdlog::debug("| FUN: Script_LoadRson : {:#18x} |\n", p_Script_LoadRson.GetPtr()); - spdlog::debug("| FUN: Script_LoadScript : {:#18x} |\n", p_Script_LoadScript.GetPtr()); + LogFunAdr("Script_DestroySignalEntryListHead", p_Script_DestroySignalEntryListHead.GetPtr()); + LogFunAdr("Script_LoadRson", p_Script_LoadRson.GetPtr()); + LogFunAdr("Script_LoadScript", p_Script_LoadScript.GetPtr()); #ifndef CLIENT_DLL - spdlog::debug("| VAR: g_pServerScript : {:#18x} |\n", g_pServerScript.GetPtr()); + LogVarAdr("g_pServerScript", g_pServerScript.GetPtr()); #endif // !CLIENT_DLL #ifndef DEDICATED - spdlog::debug("| VAR: g_pClientScript : {:#18x} |\n", g_pClientScript.GetPtr()); - spdlog::debug("| VAR: g_pUIScript : {:#18x} |\n", g_pUIScript.GetPtr()); + LogVarAdr("g_pClientScript", g_pClientScript.GetPtr()); + LogVarAdr("g_pUIScript", g_pUIScript.GetPtr()); #endif // !DEDICATED - spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { @@ -237,9 +234,7 @@ class VSquirrelVM : public IDetour #endif // !DEDICATED } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VSquirrelVM); \ No newline at end of file diff --git a/r5dev/squirrel/sqstdaux.cpp b/r5dev/squirrel/sqstdaux.cpp index d4a85267..61285f7f 100644 --- a/r5dev/squirrel/sqstdaux.cpp +++ b/r5dev/squirrel/sqstdaux.cpp @@ -29,14 +29,14 @@ SQInteger sqstd_aux_badlogic(HSQUIRRELVM v, __m128i* a2, __m128i* a3) return results; } -void SQAUX_Attach() +void VSqStdAux::Attach() const { - DetourAttach((LPVOID*)&v_sqstd_aux_printerror, &sqstd_aux_printerror); - DetourAttach((LPVOID*)&v_sqstd_aux_badlogic, &sqstd_aux_badlogic); + DetourAttach(&v_sqstd_aux_printerror, &sqstd_aux_printerror); + DetourAttach(&v_sqstd_aux_badlogic, &sqstd_aux_badlogic); } -void SQAUX_Detach() +void VSqStdAux::Detach() const { - DetourDetach((LPVOID*)&v_sqstd_aux_printerror, &sqstd_aux_printerror); - DetourDetach((LPVOID*)&v_sqstd_aux_badlogic, &sqstd_aux_badlogic); + DetourDetach(&v_sqstd_aux_printerror, &sqstd_aux_printerror); + DetourDetach(&v_sqstd_aux_badlogic, &sqstd_aux_badlogic); } \ No newline at end of file diff --git a/r5dev/squirrel/sqstdaux.h b/r5dev/squirrel/sqstdaux.h index 20d2b97d..89e69912 100644 --- a/r5dev/squirrel/sqstdaux.h +++ b/r5dev/squirrel/sqstdaux.h @@ -11,16 +11,13 @@ inline auto v_sqstd_aux_printerror = p_sqstd_aux_printerror.RCast(); -void SQAUX_Attach(); -void SQAUX_Detach(); /////////////////////////////////////////////////////////////////////////////// class VSqStdAux : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: sqstd_aux_printerror : {:#18x} |\n", p_sqstd_aux_printerror.GetPtr()); - spdlog::debug("| FUN: sqstd_aux_badlogic : {:#18x} |\n", p_sqstd_aux_badlogic.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("sqstd_aux_printerror", p_sqstd_aux_printerror.GetPtr()); + LogFunAdr("sqstd_aux_badlogic", p_sqstd_aux_badlogic.GetPtr()); } virtual void GetFun(void) const { @@ -36,9 +33,7 @@ class VSqStdAux : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VSqStdAux); diff --git a/r5dev/squirrel/sqvm.cpp b/r5dev/squirrel/sqvm.cpp index d3b29086..002315b8 100644 --- a/r5dev/squirrel/sqvm.cpp +++ b/r5dev/squirrel/sqvm.cpp @@ -382,7 +382,7 @@ const SQCONTEXT SQVM_GetContextIndex(HSQUIRRELVM v) } //--------------------------------------------------------------------------------- -void SQVM_Attach() +void HSQVM::Attach() const { DetourAttach((LPVOID*)&v_SQVM_PrintFunc, &SQVM_PrintFunc); DetourAttach((LPVOID*)&v_SQVM_WarningFunc, &SQVM_WarningFunc); @@ -390,7 +390,7 @@ void SQVM_Attach() DetourAttach((LPVOID*)&v_SQVM_LogicError, &SQVM_LogicError); } //--------------------------------------------------------------------------------- -void SQVM_Detach() +void HSQVM::Detach() const { DetourDetach((LPVOID*)&v_SQVM_PrintFunc, &SQVM_PrintFunc); DetourDetach((LPVOID*)&v_SQVM_WarningFunc, &SQVM_WarningFunc); diff --git a/r5dev/squirrel/sqvm.h b/r5dev/squirrel/sqvm.h index a3303bf5..d27163f4 100644 --- a/r5dev/squirrel/sqvm.h +++ b/r5dev/squirrel/sqvm.h @@ -84,23 +84,19 @@ void SQVM_CompileError(HSQUIRRELVM v, const SQChar* pszError, const SQChar* pszF const SQChar* SQVM_GetContextName(SQCONTEXT context); const SQCONTEXT SQVM_GetContextIndex(HSQUIRRELVM v); -void SQVM_Attach(); -void SQVM_Detach(); - /////////////////////////////////////////////////////////////////////////////// class HSQVM : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: SQVM_PrintFunc : {:#18x} |\n", p_SQVM_PrintFunc.GetPtr()); - spdlog::debug("| FUN: SQVM_WarningFunc : {:#18x} |\n", p_SQVM_WarningFunc.GetPtr()); - spdlog::debug("| FUN: SQVM_GetErrorLine : {:#18x} |\n", p_SQVM_GetErrorLine.GetPtr()); - spdlog::debug("| FUN: SQVM_WarningCmd : {:#18x} |\n", p_SQVM_WarningCmd.GetPtr()); - spdlog::debug("| FUN: SQVM_CompileError : {:#18x} |\n", p_SQVM_CompileError.GetPtr()); - spdlog::debug("| FUN: SQVM_LogicError : {:#18x} |\n", p_SQVM_LogicError.GetPtr()); - spdlog::debug("| FUN: SQVM_ScriptError : {:#18x} |\n", p_SQVM_ScriptError.GetPtr()); - spdlog::debug("| FUN: SQVM_RaiseError : {:#18x} |\n", p_SQVM_RaiseError.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("SQVM_PrintFunc", p_SQVM_PrintFunc.GetPtr()); + LogFunAdr("SQVM_WarningFunc", p_SQVM_WarningFunc.GetPtr()); + LogFunAdr("SQVM_GetErrorLine", p_SQVM_GetErrorLine.GetPtr()); + LogFunAdr("SQVM_WarningCmd", p_SQVM_WarningCmd.GetPtr()); + LogFunAdr("SQVM_CompileError", p_SQVM_CompileError.GetPtr()); + LogFunAdr("SQVM_LogicError", p_SQVM_LogicError.GetPtr()); + LogFunAdr("SQVM_ScriptError", p_SQVM_ScriptError.GetPtr()); + LogFunAdr("SQVM_RaiseError", p_SQVM_RaiseError.GetPtr()); } virtual void GetFun(void) const { @@ -129,9 +125,7 @@ class HSQVM : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(HSQVM); diff --git a/r5dev/studiorender/studiorendercontext.h b/r5dev/studiorender/studiorendercontext.h index e0ea8517..9df75d65 100644 --- a/r5dev/studiorender/studiorendercontext.h +++ b/r5dev/studiorender/studiorendercontext.h @@ -11,9 +11,8 @@ class VStudioRenderContext : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CStudioRenderContext::LoadModel : {:#18x} |\n", CStudioRenderContext__LoadModel.GetPtr()); - spdlog::debug("| FUN: CStudioRenderContext::LoadMaterials : {:#18x} |\n", CStudioRenderContext__LoadMaterials.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CStudioRenderContext::LoadModel", CStudioRenderContext__LoadModel.GetPtr()); + LogFunAdr("CStudioRenderContext::LoadMaterials", CStudioRenderContext__LoadMaterials.GetPtr()); } virtual void GetFun(void) const { @@ -37,5 +36,3 @@ class VStudioRenderContext : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VStudioRenderContext); diff --git a/r5dev/tier0/commandline.h b/r5dev/tier0/commandline.h index 8f9eacfa..49314d84 100644 --- a/r5dev/tier0/commandline.h +++ b/r5dev/tier0/commandline.h @@ -24,8 +24,7 @@ class VCommandLine : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pCmdLine : {:#18x} |\n", reinterpret_cast(g_pCmdLine)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pCmdLine", reinterpret_cast(g_pCmdLine)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -38,5 +37,3 @@ class VCommandLine : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VCommandLine); diff --git a/r5dev/tier0/jobthread.h b/r5dev/tier0/jobthread.h index e4c3b2a2..aeb37f49 100644 --- a/r5dev/tier0/jobthread.h +++ b/r5dev/tier0/jobthread.h @@ -24,11 +24,10 @@ class VJobThread : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: JT_ParallelCall : {:#18x} |\n", p_JT_ParallelCall.GetPtr()); - spdlog::debug("| FUN: JT_HelpWithAnything : {:#18x} |\n", p_JT_HelpWithAnything.GetPtr()); - spdlog::debug("| FUN: JT_AcquireFifoLock : {:#18x} |\n", p_JT_AcquireFifoLock.GetPtr()); - spdlog::debug("| FUN: JT_ReleaseFifoLock : {:#18x} |\n", p_JT_ReleaseFifoLock.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("JT_ParallelCall", p_JT_ParallelCall.GetPtr()); + LogFunAdr("JT_HelpWithAnything", p_JT_HelpWithAnything.GetPtr()); + LogFunAdr("JT_AcquireFifoLock", p_JT_AcquireFifoLock.GetPtr()); + LogFunAdr("JT_ReleaseFifoLock", p_JT_ReleaseFifoLock.GetPtr()); } virtual void GetFun(void) const { @@ -54,6 +53,4 @@ class VJobThread : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VJobThread); - #endif // JOBTHREAD_H diff --git a/r5dev/tier0/memstd.h b/r5dev/tier0/memstd.h index 76a3abec..ab46612f 100644 --- a/r5dev/tier0/memstd.h +++ b/r5dev/tier0/memstd.h @@ -55,9 +55,8 @@ class VMemStd : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CreateGlobalMemAlloc : {:#18x} |\n", p_CreateGlobalMemAlloc.GetPtr()); - spdlog::debug("| VAR: g_pMemAllocSingleton : {:#18x} |\n", reinterpret_cast(g_pMemAllocSingleton)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CreateGlobalMemAlloc", p_CreateGlobalMemAlloc.GetPtr()); + LogVarAdr("g_pMemAllocSingleton", reinterpret_cast(g_pMemAllocSingleton)); } virtual void GetFun(void) const { @@ -74,6 +73,4 @@ class VMemStd : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VMemStd); - #endif // MEMSTD_H diff --git a/r5dev/tier0/platform_internal.h b/r5dev/tier0/platform_internal.h index 185ce982..74f1dbf8 100644 --- a/r5dev/tier0/platform_internal.h +++ b/r5dev/tier0/platform_internal.h @@ -13,10 +13,9 @@ class VPlatform : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Plat_FloatTime : {:#18x} |\n", p_Plat_FloatTime.GetPtr()); - spdlog::debug("| FUN: Plat_MSTime : {:#18x} |\n", p_Plat_MSTime.GetPtr()); - spdlog::debug("| VAR: g_flErrorTimeStamp : {:#18x} |\n", reinterpret_cast(g_flErrorTimeStamp)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("Plat_FloatTime", p_Plat_FloatTime.GetPtr()); + LogFunAdr("Plat_MSTime", p_Plat_MSTime.GetPtr()); + LogVarAdr("g_flErrorTimeStamp", reinterpret_cast(g_flErrorTimeStamp)); } virtual void GetFun(void) const { @@ -36,6 +35,4 @@ class VPlatform : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VPlatform); - #endif /* PLATFORM_INTERNAL_H */ \ No newline at end of file diff --git a/r5dev/tier0/threadtools.h b/r5dev/tier0/threadtools.h index ae41553a..19e5c825 100644 --- a/r5dev/tier0/threadtools.h +++ b/r5dev/tier0/threadtools.h @@ -246,12 +246,11 @@ class VThreadTools : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CThreadFastMutex::WaitForLock : {:#18x} |\n", p_MutexInternal_WaitForLock.GetPtr()); - spdlog::debug("| FUN: CThreadFastMutex::ReleaseWaiter : {:#18x} |\n", p_MutexInternal_ReleaseWaiter.GetPtr()); - spdlog::debug("| FUN: DeclareCurrentThreadIsMainThread : {:#18x} |\n", p_DeclareCurrentThreadIsMainThread.GetPtr()); - spdlog::debug("| VAR: g_ThreadMainThreadID : {:#18x} |\n", reinterpret_cast(g_ThreadMainThreadID)); - spdlog::debug("| VAR: g_ThreadServerFrameThreadID : {:#18x} |\n", reinterpret_cast(g_ThreadServerFrameThreadID)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CThreadFastMutex::WaitForLock", p_MutexInternal_WaitForLock.GetPtr()); + LogFunAdr("CThreadFastMutex::ReleaseWaiter", p_MutexInternal_ReleaseWaiter.GetPtr()); + LogFunAdr("DeclareCurrentThreadIsMainThread", p_DeclareCurrentThreadIsMainThread.GetPtr()); + LogVarAdr("g_ThreadMainThreadID", reinterpret_cast(g_ThreadMainThreadID)); + LogVarAdr("g_ThreadServerFrameThreadID", reinterpret_cast(g_ThreadServerFrameThreadID)); } virtual void GetFun(void) const { @@ -274,6 +273,4 @@ class VThreadTools : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VThreadTools); - #endif // THREADTOOLS_H diff --git a/r5dev/tier0/tslist.h b/r5dev/tier0/tslist.h index 86247862..298c6c45 100644 --- a/r5dev/tier0/tslist.h +++ b/r5dev/tier0/tslist.h @@ -3,15 +3,12 @@ inline void* g_pMallocPool; -void TSList_Attach(); -void TSList_Detach(); /////////////////////////////////////////////////////////////////////////////// class VTSListBase : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pMallocPool : {:#18x} |\n", reinterpret_cast(g_pMallocPool)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pMallocPool", reinterpret_cast(g_pMallocPool)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -30,6 +27,4 @@ class VTSListBase : public IDetour }; /////////////////////////////////////////////////////////////////////////////// -REGISTER(VTSListBase); - #endif // TSLIST_H diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index 70ddff34..bb71c259 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -1076,13 +1076,13 @@ void ConVar_PrintDescription(ConCommandBase* pVar) } /////////////////////////////////////////////////////////////////////////////// -void IConVar_Attach() +void VConVar::Attach() const { DetourAttach((LPVOID*)&v_ConVar_IsFlagSet, &ConVar::IsFlagSetInternal); DetourAttach((LPVOID*)&v_ConVar_PrintDescription, &ConVar_PrintDescription); } -void IConVar_Detach() +void VConVar::Detach() const { DetourDetach((LPVOID*)&v_ConVar_IsFlagSet, &ConVar::IsFlagSetInternal); DetourDetach((LPVOID*)&v_ConVar_PrintDescription, &ConVar_PrintDescription); diff --git a/r5dev/tier1/IConVar.h b/r5dev/tier1/IConVar.h index 7e1dc61d..b672596a 100644 --- a/r5dev/tier1/IConVar.h +++ b/r5dev/tier1/IConVar.h @@ -109,9 +109,6 @@ inline CMemory g_pConVarVFTable; inline CMemory g_pIConVarVFTable; /////////////////////////////////////////////////////////////////////////////// -void IConVar_Attach(); -void IConVar_Detach(); - void ConVar_PrintDescription(ConCommandBase* pVar); /////////////////////////////////////////////////////////////////////////////// @@ -119,12 +116,11 @@ class VConVar : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: ConVar::IsFlagSet : {:#18x} |\n", p_ConVar_IsFlagSet.GetPtr()); - spdlog::debug("| FUN: ConVar::Register : {:#18x} |\n", p_ConVar_Register.GetPtr()); - spdlog::debug("| FUN: ConVar_PrintDescription : {:#18x} |\n", p_ConVar_PrintDescription.GetPtr()); - spdlog::debug("| CON: g_pConVarVFTable : {:#18x} |\n", g_pConVarVFTable.GetPtr()); - spdlog::debug("| CON: g_pIConVarVFTable : {:#18x} |\n", g_pIConVarVFTable.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("ConVar::IsFlagSet", p_ConVar_IsFlagSet.GetPtr()); + LogFunAdr("ConVar::Register", p_ConVar_Register.GetPtr()); + LogFunAdr("ConVar_PrintDescription", p_ConVar_PrintDescription.GetPtr()); + LogConAdr("g_pConVarVFTable", g_pConVarVFTable.GetPtr()); + LogConAdr("g_pIConVarVFTable", g_pIConVarVFTable.GetPtr()); } virtual void GetFun(void) const { @@ -146,9 +142,7 @@ class VConVar : public IDetour g_pConVarVFTable = g_GameDll.GetVirtualMethodTable(".?AVConVar@@", 0); g_pIConVarVFTable = g_GameDll.GetVirtualMethodTable(".?AVConVar@@", 1); } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VConVar); diff --git a/r5dev/tier1/cmd.cpp b/r5dev/tier1/cmd.cpp index 02d15d51..81aecb9b 100644 --- a/r5dev/tier1/cmd.cpp +++ b/r5dev/tier1/cmd.cpp @@ -722,12 +722,12 @@ bool Cmd_ForwardToServer(const CCommand* args) } /////////////////////////////////////////////////////////////////////////////// -void ConCommand_Attach() +void VConCommand::Attach() const { DetourAttach((LPVOID*)&ConCommandBase_IsFlagSet, &ConCommandBase::IsFlagSetInternal); DetourAttach((LPVOID*)&v_Cmd_ForwardToServer, &Cmd_ForwardToServer); } -void ConCommand_Detach() +void VConCommand::Detach() const { DetourDetach((LPVOID*)&ConCommandBase_IsFlagSet, &ConCommandBase::IsFlagSetInternal); DetourDetach((LPVOID*)&v_Cmd_ForwardToServer, &Cmd_ForwardToServer); diff --git a/r5dev/tier1/cmd.h b/r5dev/tier1/cmd.h index 4479b563..1c3e4bd3 100644 --- a/r5dev/tier1/cmd.h +++ b/r5dev/tier1/cmd.h @@ -182,32 +182,25 @@ inline CMemory g_pConCommandVFTable; /////////////////////////////////////////////////////////////////////////////// ECommandTarget_t Cbuf_GetCurrentPlayer(void); -void ConCommand_Attach(); -void ConCommand_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VConCommand : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: Cbuf_AddText : {:#18x} |\n", p_Cbuf_AddText.GetPtr()); - spdlog::debug("| FUN: Cbuf_Execute : {:#18x} |\n", p_Cbuf_Execute.GetPtr()); - spdlog::debug("| FUN: Cmd_ForwardToServer : {:#18x} |\n", p_Cmd_ForwardToServer.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: ConCommandBase::IsFlagSet : {:#18x} |\n", p_ConCommandBase_IsFlagSet.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| FUN: CallbackStub : {:#18x} |\n", p_CallbackStub.GetPtr()); - spdlog::debug("| FUN: NullSub : {:#18x} |\n", p_NullSub.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| CON: g_pConCommandVFTable : {:#18x} |\n", g_pConCommandVFTable.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("ConCommandBase::IsFlagSet", p_ConCommandBase_IsFlagSet.GetPtr()); + LogFunAdr("Cbuf_AddText", p_Cbuf_AddText.GetPtr()); + LogFunAdr("Cbuf_Execute", p_Cbuf_Execute.GetPtr()); + LogFunAdr("Cmd_ForwardToServer", p_Cmd_ForwardToServer.GetPtr()); + LogFunAdr("CallbackStub", p_CallbackStub.GetPtr()); + LogFunAdr("NullSub", p_NullSub.GetPtr()); + LogConAdr("g_pConCommandVFTable", g_pConCommandVFTable.GetPtr()); } virtual void GetFun(void) const { + p_ConCommandBase_IsFlagSet = g_GameDll.FindPatternSIMD("85 51 38 0F 95 C0 C3"); p_Cbuf_AddText = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 63 D9 41 8B F8 48 8D 0D ?? ?? ?? ?? 48 8B F2 FF 15 ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 41 B9 ?? ?? ?? ??"); p_Cbuf_Execute = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 FF 15 ?? ?? ?? ??"); p_Cmd_ForwardToServer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 44 8B 59 04"); - p_ConCommandBase_IsFlagSet = g_GameDll.FindPatternSIMD("85 51 38 0F 95 C0 C3"); p_NullSub = g_GameDll.FindPatternSIMD("C2 ?? ?? CC CC CC CC CC CC CC CC CC CC CC CC CC 40 53 48 83 EC 20 48 8D 05 ?? ?? ?? ??"); p_CallbackStub = g_GameDll.FindPatternSIMD("33 C0 C3 CC CC CC CC CC CC CC CC CC CC CC CC CC 80 49 68 08"); @@ -223,9 +216,7 @@ class VConCommand : public IDetour { g_pConCommandVFTable = g_GameDll.GetVirtualMethodTable(".?AVConCommand@@"); } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VConCommand); diff --git a/r5dev/tier1/cvar.h b/r5dev/tier1/cvar.h index 9058e043..4ce3f189 100644 --- a/r5dev/tier1/cvar.h +++ b/r5dev/tier1/cvar.h @@ -331,8 +331,7 @@ class VCVar : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pCVar : {:#18x} |\n", reinterpret_cast(g_pCVar)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pCVar", reinterpret_cast(g_pCVar)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -345,5 +344,3 @@ class VCVar : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VCVar); diff --git a/r5dev/vgui/vgui_baseui_interface.cpp b/r5dev/vgui/vgui_baseui_interface.cpp index 6493c5a5..58338a2a 100644 --- a/r5dev/vgui/vgui_baseui_interface.cpp +++ b/r5dev/vgui/vgui_baseui_interface.cpp @@ -30,12 +30,12 @@ int CEngineVGui::Paint(CEngineVGui* thisptr, PaintMode_t mode) } /////////////////////////////////////////////////////////////////////////////// -void CEngineVGui_Attach() +void VEngineVGui::Attach() const { DetourAttach((LPVOID*)&CEngineVGui_Paint, &CEngineVGui::Paint); } -void CEngineVGui_Detach() +void VEngineVGui::Detach() const { DetourDetach((LPVOID*)&CEngineVGui_Paint, &CEngineVGui::Paint); } diff --git a/r5dev/vgui/vgui_baseui_interface.h b/r5dev/vgui/vgui_baseui_interface.h index 01452e13..6c6bb0fb 100644 --- a/r5dev/vgui/vgui_baseui_interface.h +++ b/r5dev/vgui/vgui_baseui_interface.h @@ -46,11 +46,10 @@ class VEngineVGui : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CEngineVGui::Paint : {:#18x} |\n", p_CEngineVGui_Paint.GetPtr()); - spdlog::debug("| FUN: CEngineVGui::RenderStart : {:#18x} |\n", p_CEngineVGui_RenderStart.GetPtr()); - spdlog::debug("| FUN: CEngineVGui::RenderEnd : {:#18x} |\n", p_CEngineVGui_RenderEnd.GetPtr()); - spdlog::debug("| VAR: g_pEngineVGui : {:#18x} |\n", reinterpret_cast(g_pEngineVGui)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CEngineVGui::Paint", p_CEngineVGui_Paint.GetPtr()); + LogFunAdr("CEngineVGui::RenderStart", p_CEngineVGui_RenderStart.GetPtr()); + LogFunAdr("CEngineVGui::RenderEnd", p_CEngineVGui_RenderEnd.GetPtr()); + LogVarAdr("g_pEngineVGui", reinterpret_cast(g_pEngineVGui)); } virtual void GetFun(void) const { @@ -76,9 +75,7 @@ class VEngineVGui : public IDetour .FindPatternSelf("48 8D ?? ?? ?? ?? 01", CMemory::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VEngineVGui); \ No newline at end of file diff --git a/r5dev/vgui/vgui_debugpanel.h b/r5dev/vgui/vgui_debugpanel.h index fcbbccc6..ca21a762 100644 --- a/r5dev/vgui/vgui_debugpanel.h +++ b/r5dev/vgui/vgui_debugpanel.h @@ -46,9 +46,5 @@ public: char m_pszCon_NPrintf_Buf[4096]{}; }; -/////////////////////////////////////////////////////////////////////////////// -void CEngineVGui_Attach(); -void CEngineVGui_Detach(); - /////////////////////////////////////////////////////////////////////////////// extern CTextOverlay* g_pOverlay; diff --git a/r5dev/vgui/vgui_fpspanel.cpp b/r5dev/vgui/vgui_fpspanel.cpp index f4d7aa28..02e2db87 100644 --- a/r5dev/vgui/vgui_fpspanel.cpp +++ b/r5dev/vgui/vgui_fpspanel.cpp @@ -20,12 +20,12 @@ ConVar* HCFPSPanel_Paint(void* thisptr) } /////////////////////////////////////////////////////////////////////////////// -void CFPSPanel_Attach() +void VFPSPanel::Attach() const { - DetourAttach((LPVOID*)&CFPSPanel_Paint, &HCFPSPanel_Paint); + DetourAttach(&CFPSPanel_Paint, &HCFPSPanel_Paint); } -void CFPSPanel_Detach() +void VFPSPanel::Detach() const { - DetourDetach((LPVOID*)&CFPSPanel_Paint, &HCFPSPanel_Paint); + DetourDetach(&CFPSPanel_Paint, &HCFPSPanel_Paint); } diff --git a/r5dev/vgui/vgui_fpspanel.h b/r5dev/vgui/vgui_fpspanel.h index 120df57d..59ee505d 100644 --- a/r5dev/vgui/vgui_fpspanel.h +++ b/r5dev/vgui/vgui_fpspanel.h @@ -5,16 +5,12 @@ inline CMemory p_CFPSPanel_Paint; inline auto CFPSPanel_Paint = p_CFPSPanel_Paint.RCast(); -void CFPSPanel_Attach(); -void CFPSPanel_Detach(); - /////////////////////////////////////////////////////////////////////////////// class VFPSPanel : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CFPSPanel::Paint : {:#18x} |\n", p_CFPSPanel_Paint.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CFPSPanel::Paint", p_CFPSPanel_Paint.GetPtr()); } virtual void GetFun(void) const { @@ -23,9 +19,7 @@ class VFPSPanel : public IDetour } virtual void GetVar(void) const { } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VFPSPanel); diff --git a/r5dev/vguimatsurface/MatSystemSurface.h b/r5dev/vguimatsurface/MatSystemSurface.h index 238bba81..a6897265 100644 --- a/r5dev/vguimatsurface/MatSystemSurface.h +++ b/r5dev/vguimatsurface/MatSystemSurface.h @@ -17,10 +17,9 @@ class VMatSystemSurface : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: CMatSystemSurface::DrawColoredText : {:#18x} |\n", p_CMatSystemSurface_DrawColoredText.GetPtr()); - spdlog::debug("| VAR: g_pMatSystemSurface : {:#18x} |\n", reinterpret_cast(g_pMatSystemSurface)); - spdlog::debug("| VAR: g_pVGuiSurface : {:#18x} |\n", reinterpret_cast(g_pVGuiSurface)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("CMatSystemSurface::DrawColoredText", p_CMatSystemSurface_DrawColoredText.GetPtr()); + LogVarAdr("g_pMatSystemSurface", reinterpret_cast(g_pMatSystemSurface)); + LogVarAdr("g_pVGuiSurface", reinterpret_cast(g_pVGuiSurface)); } virtual void GetFun(void) const { @@ -44,5 +43,3 @@ class VMatSystemSurface : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VMatSystemSurface); diff --git a/r5dev/vpc/IAppSystem.h b/r5dev/vpc/IAppSystem.h index d21bd672..2d4d9604 100644 --- a/r5dev/vpc/IAppSystem.h +++ b/r5dev/vpc/IAppSystem.h @@ -9,8 +9,7 @@ class VAppSystem : public IDetour { virtual void GetAdr(void) const { - //spdlog::debug("| FUN: IAppSystem::LoadLibrary : {:#18x} |\n", p_IAppSystem_LoadLibrary.GetPtr()); - //spdlog::debug("+----------------------------------------------------------------+\n"); + //LogFunAdr("CAppSystem::LoadLibrary", p_IAppSystem_LoadLibrary.GetPtr()); } virtual void GetFun(void) const { @@ -23,5 +22,3 @@ class VAppSystem : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VAppSystem); diff --git a/r5dev/vpc/interfaces.h b/r5dev/vpc/interfaces.h index bf49f19c..1aec1c99 100644 --- a/r5dev/vpc/interfaces.h +++ b/r5dev/vpc/interfaces.h @@ -104,7 +104,7 @@ class VFactory : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: s_pInterfacesRegs : {:#18x} |\n", s_pInterfacesRegs.GetPtr()); + LogVarAdr("s_pInterfacesRegs", s_pInterfacesRegs.GetPtr()); spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { } @@ -117,5 +117,3 @@ class VFactory : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VFactory); \ No newline at end of file diff --git a/r5dev/vpc/keyvalues.cpp b/r5dev/vpc/keyvalues.cpp index 107cb56c..11553720 100644 --- a/r5dev/vpc/keyvalues.cpp +++ b/r5dev/vpc/keyvalues.cpp @@ -1367,18 +1367,18 @@ KeyValues* KeyValues::ReadKeyValuesFile(CFileSystem_Stdio* pFileSystem, const ch } /////////////////////////////////////////////////////////////////////////////// -void CKeyValueSystem_Attach() +void VKeyValues::Attach() const { - DetourAttach((LPVOID*)&KeyValues_LoadPlaylists, &KeyValues::LoadPlaylists); - DetourAttach((LPVOID*)&KeyValues_ParsePlaylists, &KeyValues::ParsePlaylists); - DetourAttach((LPVOID*)&KeyValues_ReadKeyValuesFile, &KeyValues::ReadKeyValuesFile); + DetourAttach(&KeyValues_LoadPlaylists, &KeyValues::LoadPlaylists); + DetourAttach(&KeyValues_ParsePlaylists, &KeyValues::ParsePlaylists); + DetourAttach(&KeyValues_ReadKeyValuesFile, &KeyValues::ReadKeyValuesFile); } -void CKeyValueSystem_Detach() +void VKeyValues::Detach() const { - DetourDetach((LPVOID*)&KeyValues_LoadPlaylists, &KeyValues::LoadPlaylists); - DetourDetach((LPVOID*)&KeyValues_ParsePlaylists, &KeyValues::ParsePlaylists); - DetourDetach((LPVOID*)&KeyValues_ReadKeyValuesFile, &KeyValues::ReadKeyValuesFile); + DetourDetach(&KeyValues_LoadPlaylists, &KeyValues::LoadPlaylists); + DetourDetach(&KeyValues_ParsePlaylists, &KeyValues::ParsePlaylists); + DetourDetach(&KeyValues_ReadKeyValuesFile, &KeyValues::ReadKeyValuesFile); } /////////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/vpc/keyvalues.h b/r5dev/vpc/keyvalues.h index ca66ec5a..06f8e138 100644 --- a/r5dev/vpc/keyvalues.h +++ b/r5dev/vpc/keyvalues.h @@ -183,10 +183,6 @@ public: KeyValues* m_pChain; // 0x0040 }; -/////////////////////////////////////////////////////////////////////////////// -void CKeyValueSystem_Attach(); -void CKeyValueSystem_Detach(); - /////////////////////////////////////////////////////////////////////////////// extern KeyValues** g_pPlaylistKeyValues; @@ -195,15 +191,14 @@ class VKeyValues : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: KeyValues::FindKey : {:#18x} |\n", p_KeyValues_FindKey.GetPtr()); - spdlog::debug("| FUN: KeyValues::LoadPlaylists : {:#18x} |\n", p_KeyValues_LoadPlaylists.GetPtr()); - spdlog::debug("| FUN: KeyValues::ParsePlaylists : {:#18x} |\n", p_KeyValues_ParsePlaylists.GetPtr()); - spdlog::debug("| FUN: KeyValues::GetCurrentPlaylist : {:#18x} |\n", p_KeyValues_GetCurrentPlaylist.GetPtr()); - spdlog::debug("| FUN: KeyValues::ReadKeyValuesFile : {:#18x} |\n", p_KeyValues_ReadKeyValuesFile.GetPtr()); - spdlog::debug("| FUN: KeyValues::RecursiveSaveToFile : {:#18x} |\n", p_KeyValues_RecursiveSaveToFile.GetPtr()); - spdlog::debug("| FUN: KeyValues::LoadFromFile : {:#18x} |\n", p_KeyValues_LoadFromFile.GetPtr()); - spdlog::debug("| VAR: g_pPlaylistKeyValues : {:#18x} |\n", reinterpret_cast(g_pPlaylistKeyValues)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("KeyValues::FindKey", p_KeyValues_FindKey.GetPtr()); + LogFunAdr("KeyValues::LoadPlaylists", p_KeyValues_LoadPlaylists.GetPtr()); + LogFunAdr("KeyValues::ParsePlaylists", p_KeyValues_ParsePlaylists.GetPtr()); + LogFunAdr("KeyValues::GetCurrentPlaylist", p_KeyValues_GetCurrentPlaylist.GetPtr()); + LogFunAdr("KeyValues::ReadKeyValuesFile", p_KeyValues_ReadKeyValuesFile.GetPtr()); + LogFunAdr("KeyValues::RecursiveSaveToFile", p_KeyValues_RecursiveSaveToFile.GetPtr()); + LogFunAdr("KeyValues::LoadFromFile", p_KeyValues_LoadFromFile.GetPtr()); + LogVarAdr("g_pPlaylistKeyValues", reinterpret_cast(g_pPlaylistKeyValues)); } virtual void GetFun(void) const { @@ -241,9 +236,7 @@ class VKeyValues : public IDetour #endif } virtual void GetCon(void) const { } - virtual void Attach(void) const { } - virtual void Detach(void) const { } + virtual void Attach(void) const; + virtual void Detach(void) const; }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VKeyValues); diff --git a/r5dev/vphysics/QHull.cpp b/r5dev/vphysics/QHull.cpp index 5ef0867d..8c3e2dba 100644 --- a/r5dev/vphysics/QHull.cpp +++ b/r5dev/vphysics/QHull.cpp @@ -43,12 +43,12 @@ int HQHull_PrintFunc(const char* fmt, ...) } /////////////////////////////////////////////////////////////////////////////// -void QHull_Attach() +void VQHull::Attach() const { DetourAttach((LPVOID*)&QHull_PrintFunc, &HQHull_PrintFunc); } -void QHull_Detach() +void VQHull::Detach() const { DetourDetach((LPVOID*)&QHull_PrintFunc, &HQHull_PrintFunc); } diff --git a/r5dev/vphysics/QHull.h b/r5dev/vphysics/QHull.h index f9f81988..f1032bf9 100644 --- a/r5dev/vphysics/QHull.h +++ b/r5dev/vphysics/QHull.h @@ -9,17 +9,13 @@ inline auto QHull_PrintFunc = p_QHull_PrintFunc.RCast + @@ -254,6 +255,7 @@ + diff --git a/r5dev/vproj/clientsdk.vcxproj.filters b/r5dev/vproj/clientsdk.vcxproj.filters index 6d2179a4..3427a218 100644 --- a/r5dev/vproj/clientsdk.vcxproj.filters +++ b/r5dev/vproj/clientsdk.vcxproj.filters @@ -669,6 +669,9 @@ sdk\engine + + sdk\launcher + @@ -1976,6 +1979,9 @@ sdk\engine + + sdk\launcher + diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index efafa247..3213ef15 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -86,6 +86,7 @@ + @@ -294,6 +295,7 @@ + diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index 9c555431..b7b712e3 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -732,6 +732,9 @@ sdk\game\server + + sdk\launcher + @@ -2141,6 +2144,9 @@ sdk\game\server + + sdk\launcher + diff --git a/r5dev/vstdlib/callback.h b/r5dev/vstdlib/callback.h index ed85788f..2f9d1fc8 100644 --- a/r5dev/vstdlib/callback.h +++ b/r5dev/vstdlib/callback.h @@ -77,9 +77,8 @@ class VCallback : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: SetupGamemode : {:#18x} |\n", p_SetupGamemode.GetPtr()); - spdlog::debug("| FUN: DownloadPlaylist_f : {:#18x} |\n", p_DownloadPlaylists_f.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("SetupGamemode", p_SetupGamemode.GetPtr()); + LogFunAdr("DownloadPlaylist_f", p_DownloadPlaylists_f.GetPtr()); } virtual void GetFun(void) const { @@ -95,5 +94,3 @@ class VCallback : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VCallback); diff --git a/r5dev/vstdlib/completion.h b/r5dev/vstdlib/completion.h index dba12c28..c6596e00 100644 --- a/r5dev/vstdlib/completion.h +++ b/r5dev/vstdlib/completion.h @@ -11,5 +11,3 @@ class VCompletion : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(VCompletion); diff --git a/r5dev/vstdlib/keyvaluessystem.h b/r5dev/vstdlib/keyvaluessystem.h index 57aad31b..96de64bf 100644 --- a/r5dev/vstdlib/keyvaluessystem.h +++ b/r5dev/vstdlib/keyvaluessystem.h @@ -43,9 +43,8 @@ class HKeyValuesSystem : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| VAR: g_pKeyValuesMemPool : {:#18x} |\n", reinterpret_cast(g_pKeyValuesMemPool)); - spdlog::debug("| VAR: g_pKeyValuesSystem : {:#18x} |\n", reinterpret_cast(g_pKeyValuesSystem)); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogVarAdr("g_pKeyValuesMemPool", reinterpret_cast(g_pKeyValuesMemPool)); + LogVarAdr("g_pKeyValuesSystem", reinterpret_cast(g_pKeyValuesSystem)); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -60,5 +59,3 @@ class HKeyValuesSystem : public IDetour virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// - -REGISTER(HKeyValuesSystem); diff --git a/r5dev/windows/id3dx.cpp b/r5dev/windows/id3dx.cpp index 41f360b4..5c77c0d3 100644 --- a/r5dev/windows/id3dx.cpp +++ b/r5dev/windows/id3dx.cpp @@ -507,13 +507,12 @@ void DirectX_Shutdown() void VDXGI::GetAdr(void) const { /////////////////////////////////////////////////////////////////////////////// - spdlog::debug("| FUN: IDXGISwapChain::Present : {:#18x} |\n", reinterpret_cast(s_fnSwapChainPresent)); - spdlog::debug("| VAR: s_pSwapChain : {:#18x} |\n", reinterpret_cast(s_pSwapChain) ); - spdlog::debug("| VAR: s_pRenderTargetView : {:#18x} |\n", reinterpret_cast(s_pRenderTargetView) ); - spdlog::debug("| VAR: s_pDeviceContext : {:#18x} |\n", reinterpret_cast(s_pDeviceContext) ); - spdlog::debug("| VAR: s_pDevice : {:#18x} |\n", reinterpret_cast(s_pDevice) ); - spdlog::debug("| VAR: g_ppGameDevice : {:#18x} |\n", reinterpret_cast(g_ppGameDevice) ); - spdlog::debug("+----------------------------------------------------------------+\n"); + LogFunAdr("IDXGISwapChain::Present", reinterpret_cast(s_fnSwapChainPresent)); + LogVarAdr("s_pSwapChain", reinterpret_cast(s_pSwapChain)); + LogVarAdr("s_pRenderTargetView", reinterpret_cast(s_pRenderTargetView)); + LogVarAdr("s_pDeviceContext", reinterpret_cast(s_pDeviceContext)); + LogVarAdr("s_pDevice", reinterpret_cast(s_pDevice)); + LogVarAdr("g_ppGameDevice", reinterpret_cast(g_ppGameDevice)); } //################################################################################# diff --git a/r5dev/windows/id3dx.h b/r5dev/windows/id3dx.h index 4f6df8ac..87540389 100644 --- a/r5dev/windows/id3dx.h +++ b/r5dev/windows/id3dx.h @@ -129,5 +129,4 @@ class VDXGI : public IDetour virtual void Detach(void) const { } /////////////////////////////////////////////////////////////////////////////// }; -REGISTER(VDXGI); #endif // !DEDICATED