1
0
mirror of https://github.com/Mauler125/r5sdk.git synced 2025-02-09 19:15:03 +01:00

Detour code refactor

This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files.
Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer.

TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
This commit is contained in:
Kawe Mazidjatari 2023-01-25 02:26:52 +01:00
parent 8d6358512b
commit a618990937
155 changed files with 920 additions and 1308 deletions

@ -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);

@ -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<uintptr_t>(sub_1404365A0));
//spdlog::debug("| FUN: sub_140270130 : {:#18x} |\n", reinterpret_cast<uintptr_t>(sub_140270130));
//spdlog::debug("| FUN: sub_14028F170 : {:#18x} |\n", reinterpret_cast<uintptr_t>(sub_14028F170));
//spdlog::debug("| FUN: sub_140257F20 : {:#18x} |\n", reinterpret_cast<uintptr_t>(sub_140257F20));
//spdlog::debug("| VAR: dword_1696A9D20 : {:#18x} |\n", reinterpret_cast<uintptr_t>(dword_1696A9D20));
//spdlog::debug("| VAR: dword_141744EBC : {:#18x} |\n", reinterpret_cast<uintptr_t>(dword_141744EBC));
//spdlog::debug("| VAR: dword_141744EE8 : {:#18x} |\n", reinterpret_cast<uintptr_t>(dword_141744EE8));
//spdlog::debug("| VAR: qword_141744EA8 : {:#18x} |\n", reinterpret_cast<uintptr_t>(qword_141744EA8));
//spdlog::debug("| VAR: qword_141744EA0 : {:#18x} |\n", reinterpret_cast<uintptr_t>(qword_141744EA0));
//spdlog::debug("| VAR: qword_141744E88 : {:#18x} |\n", reinterpret_cast<uintptr_t>(qword_141744E88));
//spdlog::debug("| VAR: xmmword_1415BD270 : {:#18x} |\n", reinterpret_cast<uintptr_t>(xmmword_1415BD270));
//spdlog::debug("| VAR: off_141744E70 : {:#18x} |\n", reinterpret_cast<uintptr_t>(off_141744E70));
//spdlog::debug("| VAR: off_141731448 : {:#18x} |\n", reinterpret_cast<uintptr_t>(off_141731448));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("BuildPropStaticFrustumCullMap", p_BuildPropStaticFrustumCullMap.GetPtr());
//LogFunAdr("sub_1404365A0", reinterpret_cast<uintptr_t>(sub_1404365A0));
//LogFunAdr("sub_140270130", reinterpret_cast<uintptr_t>(sub_140270130));
//LogFunAdr("sub_14028F170", reinterpret_cast<uintptr_t>(sub_14028F170));
//LogFunAdr("sub_140257F20", reinterpret_cast<uintptr_t>(sub_140257F20));
//LogVarAdr("dword_1696A9D20", reinterpret_cast<uintptr_t>(dword_1696A9D20));
//LogVarAdr("dword_141744EBC", reinterpret_cast<uintptr_t>(dword_141744EBC));
//LogVarAdr("dword_141744EE8", reinterpret_cast<uintptr_t>(dword_141744EE8));
//LogVarAdr("qword_141744EA8", reinterpret_cast<uintptr_t>(qword_141744EA8));
//LogVarAdr("qword_141744EA0", reinterpret_cast<uintptr_t>(qword_141744EA0));
//LogVarAdr("qword_141744E88", reinterpret_cast<uintptr_t>(qword_141744E88));
//LogVarAdr("xmmword_1415BD270", reinterpret_cast<uintptr_t>(xmmword_1415BD270));
//LogVarAdr("off_141744E70", reinterpret_cast<uintptr_t>(off_141744E70));
//LogVarAdr("off_141731448", reinterpret_cast<uintptr_t>(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);

@ -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
}

@ -63,27 +63,22 @@ inline auto CHLClient_GetAllClasses = p_CHLClient_GetAllClasses.RCast<ClientClas
inline CHLClient** gHLClient = nullptr;
inline CHLClient** g_pHLClient = nullptr;
///////////////////////////////////////////////////////////////////////////////
void CHLClient_Attach();
void CHLClient_Detach();
///////////////////////////////////////////////////////////////////////////////
class VDll_Engine_Int : public IDetour
{
virtual void GetAdr(void) const
{
#ifndef DEDICATED
spdlog::debug("| FUN: CHLClient::PostInit : {:#18x} |\n", p_CHLClient_PostInit.GetPtr());
LogFunAdr("CHLClient::PostInit", p_CHLClient_PostInit.GetPtr());
#endif // !DEDICATED
spdlog::debug("| FUN: CHLClient::LevelShutdown : {:#18x} |\n", p_CHLClient_LevelShutdown.GetPtr());
spdlog::debug("| FUN: CHLClient::HudProcessInput : {:#18x} |\n", p_CHLClient_HudProcessInput.GetPtr());
LogFunAdr("CHLClient::LevelShutdown", p_CHLClient_LevelShutdown.GetPtr());
LogFunAdr("CHLClient::HudProcessInput", p_CHLClient_HudProcessInput.GetPtr());
#ifndef DEDICATED
spdlog::debug("| FUN: CHLClient::FrameStageNotify : {:#18x} |\n", p_CHLClient_FrameStageNotify.GetPtr());
spdlog::debug("| FUN: CHLClient::GetAllClasses : {:#18x} |\n", p_CHLClient_GetAllClasses.GetPtr());
LogFunAdr("CHLClient::FrameStageNotify", p_CHLClient_FrameStageNotify.GetPtr());
LogFunAdr("CHLClient::GetAllClasses", p_CHLClient_GetAllClasses.GetPtr());
#endif // !DEDICATED
spdlog::debug("| VAR: gHLClient : {:#18x} |\n", reinterpret_cast<uintptr_t>(gHLClient));
spdlog::debug("| VAR: g_pHLClient : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pHLClient));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("gHLClient", reinterpret_cast<uintptr_t>(gHLClient));
LogVarAdr("g_pHLClient", reinterpret_cast<uintptr_t>(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<CHLClient**>();
}
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);

@ -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);

@ -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);

@ -14,17 +14,13 @@ inline auto v_MilesQueueEventRun = p_MilesQueueEventRun.RCast<void(*)(Miles::Que
inline CMemory p_MilesBankPatch;
inline auto v_MilesBankPatch = p_MilesBankPatch.RCast<void(*)(Miles::Bank*, char*, char*)>();
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);

@ -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);

@ -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);
}

@ -9,18 +9,14 @@ inline auto v_BinkClose = p_BinkClose.RCast<void(*)(HANDLE hBinkFile)>();
inline CMemory p_BinkGetError;
inline auto v_BinkGetError = p_BinkGetError.RCast<const char*(*)(void)>();
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);

@ -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
}

@ -111,18 +111,14 @@ inline void* g_pSVC_Print_VFTable = nullptr;
inline auto SVC_UserMessage_Process = CMemory().RCast<bool(*)(SVC_UserMessage* thisptr)>();
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<uintptr_t>(g_pSVC_Print_VFTable));
spdlog::debug("| CON: SVC_UserMessage (VFTable) : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pSVC_UserMessage_VFTable));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("MM_Heartbeat::ToString", MM_Heartbeat__ToString.GetPtr());
LogConAdr("SVC_Print (VFTable)", reinterpret_cast<uintptr_t>(g_pSVC_Print_VFTable));
LogConAdr("SVC_UserMessage (VFTable)", reinterpret_cast<uintptr_t>(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);

@ -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);

@ -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

@ -130,4 +130,17 @@ ReturnType CallVFunc(int index, void* thisPtr, Args... args)
{
return (*reinterpret_cast<ReturnType(__fastcall***)(void*, Args...)>(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

@ -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 !!!

@ -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<uintptr_t>(m_MDLMutex));
spdlog::debug("| VAR: m_MDLLock : {:#18x} |\n", reinterpret_cast<uintptr_t>(m_MDLLock));
spdlog::debug("| VAR: m_MDLDict : {:#18x} |\n", reinterpret_cast<uintptr_t>(m_MDLDict));
spdlog::debug("| VAR: g_MDLCache : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_MDLCache));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("m_MDLMutex", reinterpret_cast<uintptr_t>(m_MDLMutex));
LogVarAdr("m_MDLLock", reinterpret_cast<uintptr_t>(m_MDLLock));
LogVarAdr("m_MDLDict", reinterpret_cast<uintptr_t>(m_MDLDict));
LogVarAdr("g_MDLCache", reinterpret_cast<uintptr_t>(g_MDLCache));
}
virtual void GetFun(void) const
{
@ -178,10 +174,9 @@ class VMDLCache : public IDetour
.ResolveRelativeAddressSelf(0x3, 0x7).RCast<CMDLCache*>();
}
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

@ -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<uintptr_t>(g_NucleusID));
spdlog::debug("| VAR: g_OriginErrorLevel : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_OriginErrorLevel));
spdlog::debug("| VAR: g_OriginAuthCode : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_OriginAuthCode));
spdlog::debug("| VAR: g_OriginNucleusToken : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_OriginNucleusToken));
spdlog::debug("| VAR: g_bEbisuSDKInitialized : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_bEbisuSDKInitialized));
spdlog::debug("| VAR: g_bEbisuSDKCvarInitialized : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(g_NucleusID));
LogVarAdr("g_OriginErrorLevel", reinterpret_cast<uintptr_t>(g_OriginErrorLevel));
LogVarAdr("g_OriginAuthCode", reinterpret_cast<uintptr_t>(g_OriginAuthCode));
LogVarAdr("g_OriginNucleusToken", reinterpret_cast<uintptr_t>(g_OriginNucleusToken)); // TODO: rename to g_NucleusToken.
LogVarAdr("g_bEbisuSDKInitialized", reinterpret_cast<uintptr_t>(g_bEbisuSDKInitialized));
LogVarAdr("g_bEbisuSDKCvarInitialized", reinterpret_cast<uintptr_t>(g_bEbisuSDKCvarInitialized));
}
virtual void GetFun(void) const
{
@ -73,5 +72,3 @@ class VEbisuSDK : public IDetour
virtual void Detach(void) const { }
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(VEbisuSDK);

@ -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);
}

@ -4,14 +4,13 @@
inline CMemory p_CL_CopyExistingEntity;
inline auto v_CL_CopyExistingEntity = p_CL_CopyExistingEntity.RCast<bool (*)(__int64 a1, unsigned int* a2, char* a3)>();
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

@ -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);

@ -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;

@ -114,22 +114,17 @@ inline auto v_CClient_ProcessStringCmd = p_CClient_ProcessStringCmd.RCast<bool (
inline CMemory p_CClient_SetSignonState;
inline auto v_CClient_SetSignonState = p_CClient_SetSignonState.RCast<bool (*)(CClient* pClient, SIGNONSTATE signon)>();
///////////////////////////////////////////////////////////////////////////////
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<uintptr_t>(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<uintptr_t>(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<CClient*>();
}
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);

@ -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<uintptr_t>(g_pClientState));
spdlog::debug("| VAR: g_pClientState_Shifted : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pClientState_Shifted));
LogVarAdr("g_pClientState", reinterpret_cast<uintptr_t>(g_pClientState));
LogVarAdr("g_pClientState_Shifted", reinterpret_cast<uintptr_t>(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);

@ -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);

@ -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<uintptr_t>(sub_14045BAC0));
spdlog::debug("| FUN: sub_14045A1D0 : {:#18x} |\n", reinterpret_cast<uintptr_t>(sub_14045A1D0));
spdlog::debug("| FUN: sub_140441220 : {:#18x} |\n", reinterpret_cast<uintptr_t>(sub_140441220));
spdlog::debug("| VAR: dword_14B383420 : {:#18x} |\n", reinterpret_cast<uintptr_t>(dword_14B383420));
spdlog::debug("| VAR: dword_1634F445C : {:#18x} |\n", reinterpret_cast<uintptr_t>(dword_1634F445C));
spdlog::debug("| VAR: qword_167ED7BB8 : {:#18x} |\n", reinterpret_cast<uintptr_t>(qword_167ED7BB8));
spdlog::debug("| VAR: qword_14180A098 : {:#18x} |\n", reinterpret_cast<uintptr_t>(qword_14180A098));
spdlog::debug("| VAR: byte_16709DDDF : {:#18x} |\n", reinterpret_cast<uintptr_t>(byte_16709DDDF));
spdlog::debug("| VAR: off_141874660 : {:#18x} |\n", reinterpret_cast<uintptr_t>(off_141874660));
spdlog::debug("| VAR: unk_141874555 : {:#18x} |\n", reinterpret_cast<uintptr_t>(unk_141874555));
spdlog::debug("| VAR: unk_1418749B0 : {:#18x} |\n", reinterpret_cast<uintptr_t>(unk_1418749B0));
spdlog::debug("| VAR: unk_141874550 : {:#18x} |\n", reinterpret_cast<uintptr_t>(unk_141874550));
spdlog::debug("| VAR: qword_167ED7BC0 : {:#18x} |\n", reinterpret_cast<uintptr_t>(qword_167ED7BC0));
spdlog::debug("| VAR: qword_167ED7C68 : {:#18x} |\n", reinterpret_cast<uintptr_t>(qword_167ED7C68));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("Mod_LoadPakForMap", p_Mod_LoadPakForMap.GetPtr());
LogFunAdr("Mod_ProcessPakQueue", p_Mod_ProcessPakQueue.GetPtr());
LogFunAdr("sub_14045BAC0", reinterpret_cast<uintptr_t>(sub_14045BAC0));
LogFunAdr("sub_14045A1D0", reinterpret_cast<uintptr_t>(sub_14045A1D0));
LogFunAdr("sub_140441220", reinterpret_cast<uintptr_t>(sub_140441220));
LogVarAdr("dword_14B383420", reinterpret_cast<uintptr_t>(dword_14B383420));
LogVarAdr("dword_1634F445C", reinterpret_cast<uintptr_t>(dword_1634F445C));
LogVarAdr("qword_167ED7BB8", reinterpret_cast<uintptr_t>(qword_167ED7BB8));
LogVarAdr("qword_14180A098", reinterpret_cast<uintptr_t>(qword_14180A098));
LogVarAdr("byte_16709DDDF", reinterpret_cast<uintptr_t>(byte_16709DDDF));
LogVarAdr("off_141874660", reinterpret_cast<uintptr_t>(off_141874660));
LogVarAdr("unk_141874555", reinterpret_cast<uintptr_t>(unk_141874555));
LogVarAdr("unk_1418749B0", reinterpret_cast<uintptr_t>(unk_1418749B0));
LogVarAdr("unk_141874550", reinterpret_cast<uintptr_t>(unk_141874550));
LogVarAdr("qword_167ED7BC0", reinterpret_cast<uintptr_t>(qword_167ED7BC0));
LogVarAdr("qword_167ED7C68", reinterpret_cast<uintptr_t>(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);

@ -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);

@ -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);
}

@ -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<void (*)(bool bDraw)>();
@ -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<uintptr_t>(s_pOverlays));
spdlog::debug("| VAR: s_OverlayMutex : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_OverlayMutex));
spdlog::debug("| VAR: g_nOverlayTickCount : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_nOverlayTickCount));
spdlog::debug("| VAR: g_nRenderTickCount : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(s_pOverlays));
LogVarAdr("s_OverlayMutex", reinterpret_cast<uintptr_t>(s_OverlayMutex));
LogVarAdr("g_nOverlayTickCount", reinterpret_cast<uintptr_t>(g_nOverlayTickCount));
LogVarAdr("g_nRenderTickCount", reinterpret_cast<uintptr_t>(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);

@ -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<uintptr_t>(g_pEngineTraceServer));
LogVarAdr("g_pEngineTraceServer", reinterpret_cast<uintptr_t>(g_pEngineTraceServer));
#endif // CLIENT_DLL
#ifndef DEDICATED
spdlog::debug("| VAR: g_pEngineTraceClient : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pEngineTraceClient));
LogVarAdr("g_pEngineTraceClient", reinterpret_cast<uintptr_t>(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);

@ -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);

@ -29,6 +29,4 @@ class VGL_RMain : public IDetour
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(VGL_RMain);
#endif

@ -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);
}

@ -10,17 +10,14 @@ inline auto V_DrawWorldMeshesDepthOnly = P_DrawWorldMeshesDepthOnly.RCast<void*(
inline CMemory P_DrawWorldMeshesDepthAtTheEnd;
inline auto V_DrawWorldMeshesDepthAtTheEnd = P_DrawWorldMeshesDepthAtTheEnd.RCast<void* (*)(void* ptr1, void* ptr2, void* ptr3, DrawWorldLists_t worldLists)>();
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);

@ -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<uintptr_t>(scr_drawloading));
spdlog::debug("| VAR: scr_engineevent_loadingstarted : {:#18x} |\n", reinterpret_cast<uintptr_t>(scr_engineevent_loadingstarted));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("SCR_BeginLoadingPlaque", SCR_BeginLoadingPlaque.GetPtr());
LogVarAdr("scr_drawloading", reinterpret_cast<uintptr_t>(scr_drawloading));
LogVarAdr("scr_engineevent_loadingstarted", reinterpret_cast<uintptr_t>(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);

@ -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);
}

@ -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<uintptr_t>(interval_per_tick));
spdlog::debug("| VAR: host_abortserver : {:#18x} |\n", reinterpret_cast<uintptr_t>(host_abortserver));
spdlog::debug("| VAR: g_bAbortServerSet : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(interval_per_tick));
LogVarAdr("host_abortserver", reinterpret_cast<uintptr_t>(host_abortserver));
LogVarAdr("g_bAbortServerSet", reinterpret_cast<uintptr_t>(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);

@ -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);
}

@ -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<uintptr_t>(g_pEngineParms));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("g_pEngineParms", reinterpret_cast<uintptr_t>(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);

@ -459,13 +459,11 @@ FORCEINLINE void CHostState::ResetLevelName(void)
Q_snprintf(const_cast<char*>(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);
}

@ -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(*)(char const* pNewLevel, char const* pLandmarkName)>();
///////////////////////////////////////////////////////////////////////////////
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<uintptr_t>(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<uintptr_t>(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<CHostState*>();
}
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);

@ -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);
}

@ -15,19 +15,16 @@ inline CMemory p_LoadPlayerConfig;
inline auto v_UpdateCurrentVideoConfig = p_UpdateCurrentVideoConfig.RCast<bool (*)(MaterialSystem_Config_t* pConfig)>();
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

@ -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<uintptr_t>(g_pModelInfoServer));
LogFunAdr("g_pModelInfoServer", reinterpret_cast<uintptr_t>(g_pModelInfoServer));
#endif // CLIENT_DLL
#ifndef DEDICATED
spdlog::debug("| FUN: g_pModelInfoClient : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pModelInfoClient));
LogFunAdr("g_pModelInfoClient", reinterpret_cast<uintptr_t>(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

@ -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);

@ -76,24 +76,20 @@ inline auto BuildSpriteLoadName = p_BuildSpriteLoadName.RCast<void* (*)(const ch
inline CModelLoader* g_pModelLoader;
void CModelLoader_Attach();
void CModelLoader_Detach();
///////////////////////////////////////////////////////////////////////////////
class VModelLoader : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| FUN: CModelLoader::FindModel : {:#18x} |\n", p_CModelLoader__FindModel.GetPtr());
spdlog::debug("| FUN: CModelLoader::LoadModel : {:#18x} |\n", p_CModelLoader__LoadModel.GetPtr());
spdlog::debug("| FUN: CModelLoader::UnloadModel : {:#18x} |\n", p_CModelLoader__UnloadModel.GetPtr());
spdlog::debug("| FUN: CModelLoader::Map_LoadModelGuts : {:#18x} |\n", p_CModelLoader__Map_LoadModelGuts.GetPtr());
spdlog::debug("| FUN: CModelLoader::Map_IsValid : {:#18x} |\n", p_CModelLoader__Map_IsValid.GetPtr());
spdlog::debug("| FUN: CModelLoader::Studio_LoadModel : {:#18x} |\n", p_CModelLoader__Studio_LoadModel.GetPtr());
spdlog::debug("| FUN: GetSpriteInfo : {:#18x} |\n", p_GetSpriteInfo.GetPtr());
spdlog::debug("| FUN: BuildSpriteLoadName : {:#18x} |\n", p_BuildSpriteLoadName.GetPtr());
spdlog::debug("| VAR: g_pModelLoader : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(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<CModelLoader*>();
}
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);

@ -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);

@ -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);

@ -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);
}

@ -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

@ -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.
}
///////////////////////////////////////////////////////////////////////////////

@ -93,9 +93,6 @@ inline auto v_CServer_ConnectClient = p_CServer_Authenticate.RCast<CClient* (*)(
inline CMemory p_CServer_RejectConnection;
inline auto v_CServer_RejectConnection = p_CServer_RejectConnection.RCast<void* (*)(CServer* pServer, int iSocket, v_netadr_t* pNetAdr, const char* szMessage)>();
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<uintptr_t>(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<uintptr_t>(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);

@ -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<uintptr_t>(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<uintptr_t>(s_bDedicated));
}
virtual void GetFun(void) const
{
@ -62,5 +61,3 @@ class HSV_Main : public IDetour
virtual void Detach(void) const { }
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(HSV_Main);

@ -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);
}

@ -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<uintptr_t>(gfExtendedError));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("Sys_Error_Internal", p_Sys_Error_Internal.GetPtr());
LogVarAdr("gfExtendedError", reinterpret_cast<uintptr_t>(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<bool*>();
}
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);

@ -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);
}

@ -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<uintptr_t>(g_bTextMode));
spdlog::debug("| VAR: g_szBaseDir : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_szBaseDir));
spdlog::debug("| VAR: g_pMTVFTaskItem : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pMTVFTaskItem));
spdlog::debug("| VAR: g_szMTVFItemName : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_szMTVFItemName));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("ResetMTVFTaskItem", p_ResetMTVFTaskItem.GetPtr());
LogFunAdr("PakFile_Init", p_PakFile_Init.GetPtr());
LogVarAdr("g_bTextMode", reinterpret_cast<uintptr_t>(g_bTextMode));
LogVarAdr("g_szBaseDir", reinterpret_cast<uintptr_t>(g_szBaseDir));
LogVarAdr("g_pMTVFTaskItem", reinterpret_cast<uintptr_t>(g_pMTVFTaskItem));
LogVarAdr("g_szMTVFItemName", reinterpret_cast<uintptr_t>(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<char*>();
}
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);

@ -30,8 +30,7 @@ class VEngine : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: g_pEngine : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pEngine));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("g_pEngine", reinterpret_cast<uintptr_t>(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);

@ -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);
}

@ -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<HWND(*)(vrect_t* pnRect)>();
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);

@ -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);
}

@ -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);

@ -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
}

@ -19,21 +19,17 @@ inline auto v_Con_NPrintf = p_Con_NPrintf.RCast<void (*)(int pos, const char* fm
void HSys_Error(char* fmt, ...);
int Sys_GetProcessUpTime(char* szBuffer);
void SysUtils_Attach();
void SysUtils_Detach();
///////////////////////////////////////////////////////////////////////////////
class VSys_Utils : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| FUN: Sys_Error : {:#18x} |\n", p_Sys_Error.GetPtr());
spdlog::debug("| FUN: Sys_Warning : {:#18x} |\n", p_Sys_Warning.GetPtr());
spdlog::debug("| FUN: Sys_GetProcessUpTime : {:#18x} |\n", p_Sys_GetProcessUpTime.GetPtr());
LogFunAdr("Sys_Error", p_Sys_Error.GetPtr());
LogFunAdr("Sys_Warning", p_Sys_Warning.GetPtr());
LogFunAdr("Sys_GetProcessUpTime", p_Sys_GetProcessUpTime.GetPtr());
#ifndef DEDICATED
spdlog::debug("| FUN: Con_NPrintf : {:#18x} |\n", p_Con_NPrintf.GetPtr());
LogFunAdr("Con_NPrintf", p_Con_NPrintf.GetPtr());
#endif // !DEDICATED
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const
{
@ -52,9 +48,7 @@ class VSys_Utils : 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(VSys_Utils);

@ -9,8 +9,7 @@ class VTraceInit : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| FUN: TRACEINIT : {:#18x} |\n", p_TRACEINIT.GetPtr());
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("TRACEINIT", p_TRACEINIT.GetPtr());
}
virtual void GetFun(void) const
{
@ -24,6 +23,4 @@ class VTraceInit : public IDetour
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(VTraceInit);
#endif // TRACEINIT_H

@ -186,7 +186,7 @@ string CBaseFileSystem::ReadString(FileHandle_t pFile)
return svString;
}
void CBaseFileSystem_Attach()
void VBaseFileSystem::Attach() const
{
DetourAttach((LPVOID*)&v_CBaseFileSystem_Warning, &CBaseFileSystem::Warning);
DetourAttach((LPVOID*)&v_CBaseFileSystem_LoadFromVPK, &CBaseFileSystem::VReadFromVPK);
@ -195,7 +195,7 @@ void CBaseFileSystem_Attach()
DetourAttach((LPVOID*)&v_CBaseFileSystem_UnmountVPKFile, &CBaseFileSystem::VUnmountVPKFile);
}
void CBaseFileSystem_Detach()
void VBaseFileSystem::Detach() const
{
DetourDetach((LPVOID*)&v_CBaseFileSystem_Warning, &CBaseFileSystem::Warning);
DetourDetach((LPVOID*)&v_CBaseFileSystem_LoadFromVPK, &CBaseFileSystem::VReadFromVPK);

@ -62,23 +62,18 @@ inline auto v_CBaseFileSystem_GetMountedVPKHandle = p_CBaseFileSystem_GetMounted
extern CBaseFileSystem* g_pFileSystem;
///////////////////////////////////////////////////////////////////////////////
void CBaseFileSystem_Attach();
void CBaseFileSystem_Detach();
///////////////////////////////////////////////////////////////////////////////
class VBaseFileSystem : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| FUN: CBaseFileSystem::Warning : {:#18x} |\n", p_CBaseFileSystem_Warning.GetPtr());
spdlog::debug("| FUN: CBaseFileSystem::LoadFromVPK : {:#18x} |\n", p_CBaseFileSystem_LoadFromVPK.GetPtr());
spdlog::debug("| FUN: CBaseFileSystem::LoadFromCache : {:#18x} |\n", p_CBaseFileSystem_LoadFromCache.GetPtr());
spdlog::debug("| FUN: CBaseFileSystem::MountVPKFile : {:#18x} |\n", p_CBaseFileSystem_MountVPKFile.GetPtr());
spdlog::debug("| FUN: CBaseFileSystem::UnmountVPKFile : {:#18x} |\n", p_CBaseFileSystem_UnmountVPKFile.GetPtr());
spdlog::debug("| FUN: CBaseFileSystem::GetMountedVPKHandle : {:#18x} |\n", p_CBaseFileSystem_GetMountedVPKHandle.GetPtr());
spdlog::debug("| VAR: g_pFileSystem : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(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<CBaseFileSystem*>();
}
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);

@ -39,9 +39,8 @@ class VFileSystem_Stdio : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: g_pFullFileSystem : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pFullFileSystem));
spdlog::debug("| VAR: g_pFileSystem_Stdio : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pFileSystem_Stdio));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("g_pFullFileSystem", reinterpret_cast<uintptr_t>(g_pFullFileSystem));
LogVarAdr("g_pFileSystem_Stdio", reinterpret_cast<uintptr_t>(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

@ -35,8 +35,7 @@ class VMoveHelperClient : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: s_MoveHelperClient : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_MoveHelperClient));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("s_MoveHelperClient", reinterpret_cast<uintptr_t>(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

@ -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<uintptr_t>(g_vecRenderOrigin));
spdlog::debug("| VAR: g_vecRenderAngles : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_vecRenderAngles));
spdlog::debug("| VAR: g_pViewRender : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(g_vecRenderOrigin));
LogVarAdr("g_vecRenderAngles", reinterpret_cast<uintptr_t>(g_vecRenderAngles));
LogVarAdr("g_pViewRender", reinterpret_cast<uintptr_t>(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);

@ -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);
}

@ -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<void (*)(int node1, int node2, const char* pszformat, ...)>();
@ -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<uintptr_t>(g_pAINetwork));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("CAI_Network::DebugConnectMsg", p_CAI_Network__DebugConnectMsg.GetPtr());
LogVarAdr("g_pAINetwork", reinterpret_cast<uintptr_t>(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<CAI_Network**>();
}
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);

@ -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);

@ -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<uintptr_t>(g_nAiNodeClusters ));
spdlog::debug("| VAR: g_pppAiNodeClusters : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pppAiNodeClusters ));
spdlog::debug("| VAR: g_nAiNodeClusterLinks : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_nAiNodeClusterLinks ));
spdlog::debug("| VAR: g_pppAiNodeClusterLinks : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(g_nAiNodeClusters));
LogVarAdr("g_pppAiNodeClusters", reinterpret_cast<uintptr_t>(g_pppAiNodeClusters));
LogVarAdr("g_nAiNodeClusterLinks", reinterpret_cast<uintptr_t>(g_nAiNodeClusterLinks));
LogVarAdr("g_pppAiNodeClusterLinks", reinterpret_cast<uintptr_t>(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<AINodeClusterLinks***>();
}
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);

@ -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);

@ -1,4 +1 @@
#pragma once
void CAI_Utility_Attach();
void CAI_Utility_Detach();

@ -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

@ -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<uintptr_t>(g_pEntityList));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("CBaseEntity::GetBaseEntity", p_CBaseEntity__GetBaseEntity.GetPtr());
LogVarAdr("g_pEntityList", reinterpret_cast<uintptr_t>(g_pEntityList));
}
virtual void GetFun(void) const
{
@ -280,6 +279,4 @@ class VBaseEntity : public IDetour
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(VBaseEntity);
#endif // BASEENTITY_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<uintptr_t>(g_pNavMesh));
spdlog::debug("| VAR: g_pNavMeshQuery : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(g_pNavMesh));
LogVarAdr("g_pNavMeshQuery", reinterpret_cast<uintptr_t>(g_pNavMeshQuery));
}
virtual void GetFun(void) const
{
@ -95,9 +94,7 @@ class VRecast : public IDetour
.FindPatternSelf("48 89 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast<dtNavMeshQuery*>();
}
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);

@ -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);

@ -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);

@ -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<uintptr_t>(g_pServerGameDLL));
spdlog::debug("| VAR: g_pServerGameClients : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pServerGameClients));
spdlog::debug("| VAR: g_pServerGameEntities : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pServerGameEntities));
spdlog::debug("| VAR: g_pGlobals : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pGlobals));
spdlog::debug("+----------------------------------------------------------------+\n");
LogFunAdr("CServerGameDLL::OnReceivedSayTextMessage", p_CServerGameDLL__OnReceivedSayTextMessage.GetPtr());
LogFunAdr("RunFrameServer", p_RunFrameServer.GetPtr());
LogVarAdr("g_pServerGameDLL", reinterpret_cast<uintptr_t>(g_pServerGameDLL));
LogVarAdr("g_pServerGameClients", reinterpret_cast<uintptr_t>(g_pServerGameClients));
LogVarAdr("g_pServerGameEntities", reinterpret_cast<uintptr_t>(g_pServerGameEntities));
LogVarAdr("g_pGlobals", reinterpret_cast<uintptr_t>(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<CGlobalVars**>();
}
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

@ -34,8 +34,7 @@ class VMoveHelperServer : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: s_MoveHelperServer : {:#18x} |\n", reinterpret_cast<uintptr_t>(s_MoveHelperServer));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("s_MoveHelperServer", reinterpret_cast<uintptr_t>(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

@ -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);
}

@ -10,15 +10,12 @@
inline CMemory p_Physics_RunThinkFunctions;
inline auto v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast<void* (*)(bool bSimulating)>();
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

@ -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

@ -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);
}

@ -83,15 +83,12 @@ struct Player_AnimViewEntityData
inline CMemory p_CStudioHdr__LookupSequence;
inline auto v_CStudioHdr__LookupSequence = p_CStudioHdr__LookupSequence.RCast<int(*)(CStudioHdr* pStudio, const char* pszName)>();
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

@ -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

@ -48,8 +48,7 @@ class VUtil_Shared : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: g_pTraceFilterSimpleVFTable : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pTraceFilterSimpleVFTable));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("g_pTraceFilterSimpleVFTable", reinterpret_cast<uintptr_t>(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

@ -26,8 +26,7 @@ class VInputSystem : public IDetour
{
virtual void GetAdr(void) const
{
spdlog::debug("| VAR: g_pInputSystem : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pInputSystem));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("g_pInputSystem", reinterpret_cast<uintptr_t>(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);

@ -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);
}

@ -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<bool(*)(CModAppSystemGroup* pModAppSystemGroup)>();
///////////////////////////////////////////////////////////////////////////////
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);

@ -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);

@ -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

@ -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
}

@ -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(*)(UINT uExitCode)>();
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);

@ -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<uintptr_t>(g_pMaterialGlueVFTable));
spdlog::debug("+----------------------------------------------------------------+\n");
LogConAdr("g_pMaterialGlueVFTable", reinterpret_cast<uintptr_t>(g_pMaterialGlueVFTable));
}
virtual void GetFun(void) const
{
@ -101,5 +100,3 @@ class VMaterialGlue : public IDetour
virtual void Detach(void) const { }
};
///////////////////////////////////////////////////////////////////////////////
REGISTER(VMaterialGlue);

@ -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);

@ -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<uintptr_t>(g_nTotalStreamingTextureMemory));
spdlog::debug("| VAR: g_nUnfreeStreamingTextureMemory : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_nUnfreeStreamingTextureMemory));
spdlog::debug("| VAR: g_nUnusableStreamingTextureMemory : {:#18x} |\n", reinterpret_cast<uintptr_t>(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<uintptr_t>(g_nTotalStreamingTextureMemory));
LogVarAdr("g_nUnfreeStreamingTextureMemory", reinterpret_cast<uintptr_t>(g_nUnfreeStreamingTextureMemory));
LogVarAdr("g_nUnusableStreamingTextureMemory", reinterpret_cast<uintptr_t>(g_nUnusableStreamingTextureMemory));
LogVarAdr("s_pRenderContext", s_pRenderContext.GetPtr());
#endif // !DEDICATED
spdlog::debug("| VAR: g_pMaterialSystem : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pMaterialSystem));
spdlog::debug("| CON: g_pMaterialVFTable : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pMaterialVFTable));
spdlog::debug("+----------------------------------------------------------------+\n");
LogVarAdr("g_pMaterialSystem", reinterpret_cast<uintptr_t>(g_pMaterialSystem));
LogConAdr("g_pMaterialVFTable", reinterpret_cast<uintptr_t>(g_pMaterialVFTable));
}
virtual void GetFun(void) const
{
@ -100,11 +98,9 @@ class VMaterialSystem : public IDetour
{
g_pMaterialVFTable = g_GameDll.GetVirtualMethodTable(".?AVCMaterial@@").RCast<void*>();
}
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

Some files were not shown because too many files have changed in this diff Show More