2021-12-27 16:53:35 +01:00
|
|
|
#pragma once
|
2022-08-22 03:53:38 +02:00
|
|
|
#include "tier1/cmd.h"
|
2023-05-10 00:05:38 +02:00
|
|
|
#include "sys_dll.h"
|
2022-08-22 03:53:38 +02:00
|
|
|
|
2023-02-15 20:54:09 +01:00
|
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
// Forward declarations
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
class CClient;
|
|
|
|
|
2022-01-23 18:26:48 +01:00
|
|
|
struct EngineParms_t
|
|
|
|
{
|
|
|
|
char* baseDirectory;
|
|
|
|
char* modName;
|
|
|
|
char* rootGameName;
|
|
|
|
unsigned int memSizeAvailable;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern EngineParms_t* g_pEngineParms;
|
|
|
|
|
2022-04-09 02:18:57 +02:00
|
|
|
/* ==== HOST ============================================================================================================================================================ */
|
2022-04-18 03:35:08 +02:00
|
|
|
inline CMemory p_Host_Init;
|
2023-12-25 02:24:23 +01:00
|
|
|
inline void(*v_Host_Init)();
|
|
|
|
|
|
|
|
inline CMemory p_Host_Init_DuringVideo;
|
|
|
|
inline void(*v_Host_Init_DuringVideo)(bool* bDedicated);
|
|
|
|
|
|
|
|
inline CMemory p_Host_Init_PostVideo;
|
|
|
|
inline void(*v_Host_Init_PostVideo)(bool* bDedicated);
|
2022-04-12 02:48:46 +02:00
|
|
|
|
2023-06-18 22:16:43 +02:00
|
|
|
inline CMemory p_Host_Shutdown;
|
2023-07-02 23:01:29 +02:00
|
|
|
inline void(*v_Host_Shutdown)();
|
2023-06-18 22:16:43 +02:00
|
|
|
|
2022-04-18 03:35:08 +02:00
|
|
|
inline CMemory p_Host_NewGame;
|
2023-07-02 23:01:29 +02:00
|
|
|
inline bool(*v_Host_NewGame)(char* pszMapName, char* pszMapGroup, bool bLoadGame, char bBackground, LARGE_INTEGER PerformanceCount);
|
2022-03-01 02:39:46 +01:00
|
|
|
|
2023-06-18 22:16:43 +02:00
|
|
|
inline CMemory p_Host_Disconnect;
|
2023-07-02 23:01:29 +02:00
|
|
|
inline void(*v_Host_Disconnect)(bool bShowMainMenu);
|
2023-06-18 22:16:43 +02:00
|
|
|
|
2022-04-18 03:35:08 +02:00
|
|
|
inline CMemory p_Host_ChangeLevel;
|
2023-07-02 23:01:29 +02:00
|
|
|
inline bool(*v_Host_ChangeLevel)(bool bLoadFromSavedGame, const char* pszMapName, const char* pszMapGroup);
|
2021-12-27 16:53:35 +01:00
|
|
|
|
2023-02-15 20:54:09 +01:00
|
|
|
inline CMemory p_Host_Status_PrintClient;
|
2023-07-03 00:02:08 +02:00
|
|
|
inline void (*v_Host_Status_PrintClient)(CClient* client, bool bShowAddress, void (*print) (const char* fmt, ...));
|
2023-02-15 20:54:09 +01:00
|
|
|
|
2022-08-22 03:53:38 +02:00
|
|
|
inline CMemory p_SetLaunchOptions;
|
2023-07-02 23:01:29 +02:00
|
|
|
inline int(*v_SetLaunchOptions)(const CCommand& args);
|
2022-08-22 03:53:38 +02:00
|
|
|
|
2022-11-07 19:29:55 +01:00
|
|
|
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
|
|
|
|
inline CMemory p_DFS_InitializeFeatureFlagDefinitions;
|
2023-07-02 23:01:29 +02:00
|
|
|
inline bool(*v_DFS_InitializeFeatureFlagDefinitions)(const char* pszFeatureFlags);
|
2022-11-07 19:29:55 +01:00
|
|
|
#endif // !(GAMEDLL_S0) || !(GAMEDLL_S1) || !(GAMEDLL_S2)
|
2022-04-09 02:18:57 +02:00
|
|
|
|
2022-11-07 19:29:55 +01:00
|
|
|
extern EngineParms_t* g_pEngineParms;
|
2021-12-27 16:53:35 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2022-05-13 14:53:25 +02:00
|
|
|
class VHostCmd : public IDetour
|
2021-12-27 16:53:35 +01:00
|
|
|
{
|
2022-04-11 01:44:30 +02:00
|
|
|
virtual void GetAdr(void) const
|
2021-12-27 16:53:35 +01:00
|
|
|
{
|
2023-01-25 02:26:52 +01:00
|
|
|
LogFunAdr("Host_Init", p_Host_Init.GetPtr());
|
2023-12-25 02:24:23 +01:00
|
|
|
LogFunAdr("Host_Init_DuringVideo", p_Host_Init_DuringVideo.GetPtr());
|
|
|
|
LogFunAdr("Host_Init_PostVideo", p_Host_Init_PostVideo.GetPtr());
|
2023-06-18 22:16:43 +02:00
|
|
|
LogFunAdr("Host_Shutdown", p_Host_Shutdown.GetPtr());
|
|
|
|
LogFunAdr("Host_Disconnect", p_Host_Disconnect.GetPtr());
|
2023-01-25 02:26:52 +01:00
|
|
|
LogFunAdr("Host_NewGame", p_Host_NewGame.GetPtr());
|
|
|
|
LogFunAdr("Host_ChangeLevel", p_Host_ChangeLevel.GetPtr());
|
2023-02-15 20:54:09 +01:00
|
|
|
LogFunAdr("Host_Status_PrintClient", p_Host_Status_PrintClient.GetPtr());
|
2023-01-25 02:26:52 +01:00
|
|
|
LogFunAdr("SetLaunchOptions", p_SetLaunchOptions.GetPtr());
|
2022-11-07 19:29:55 +01:00
|
|
|
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
|
2023-01-25 02:26:52 +01:00
|
|
|
LogFunAdr("DFS_InitializeFeatureFlagDefinitions", p_DFS_InitializeFeatureFlagDefinitions.GetPtr());
|
2022-11-07 19:29:55 +01:00
|
|
|
#endif // !(GAMEDLL_S0) || !(GAMEDLL_S1) || !(GAMEDLL_S2)
|
2023-01-25 02:26:52 +01:00
|
|
|
LogVarAdr("g_pEngineParms", reinterpret_cast<uintptr_t>(g_pEngineParms));
|
2021-12-27 16:53:35 +01:00
|
|
|
}
|
2022-04-18 03:35:08 +02:00
|
|
|
virtual void GetFun(void) const
|
|
|
|
{
|
2023-12-25 02:24:23 +01:00
|
|
|
p_Host_Init = g_GameDll.FindPatternSIMD("88 4C 24 08 53 55 56 57 48 83 EC 68");
|
2022-04-18 03:35:08 +02:00
|
|
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
2023-12-25 02:24:23 +01:00
|
|
|
p_Host_Init_DuringVideo = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B D9 FF 15 ?? ?? ?? ??");
|
2023-06-18 22:16:43 +02:00
|
|
|
p_Host_NewGame = g_GameDll.FindPatternSIMD("48 8B C4 56 41 54 41 57 48 81 EC ?? ?? ?? ?? F2 0F 10 05 ?? ?? ?? ??");
|
|
|
|
p_Host_Disconnect = g_GameDll.FindPatternSIMD("48 83 EC 38 48 89 7C 24 ?? 0F B6 F9");
|
2022-12-01 22:44:55 +01:00
|
|
|
p_Host_ChangeLevel = g_GameDll.FindPatternSIMD("40 53 56 41 56 48 81 EC ?? ?? ?? ?? 49 8B D8");
|
|
|
|
p_SetLaunchOptions = g_GameDll.FindPatternSIMD("48 89 6C 24 ?? 57 48 83 EC 20 48 8B E9 48 8B 0D ?? ?? ?? ??");
|
2022-04-18 03:35:08 +02:00
|
|
|
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
2023-12-25 02:24:23 +01:00
|
|
|
p_Host_Init_DuringVideo = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B D9");
|
2022-12-01 22:44:55 +01:00
|
|
|
p_Host_NewGame = g_GameDll.FindPatternSIMD("48 8B C4 ?? 41 54 41 55 48 81 EC 70 04 ?? ?? F2 0F 10 05 ?? ?? ?? 0B");
|
2023-06-18 22:16:43 +02:00
|
|
|
p_Host_Disconnect = g_GameDll.FindPatternSIMD("40 53 48 83 EC 30 0F B6 D9");
|
2022-12-01 22:44:55 +01:00
|
|
|
p_Host_ChangeLevel = g_GameDll.FindPatternSIMD("40 56 57 41 56 48 81 EC ?? ?? ?? ??");
|
|
|
|
p_SetLaunchOptions = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 83 EC 20 48 8B 1D ?? ?? ?? ?? 48 8B E9 48 85 DB");
|
2022-04-18 03:35:08 +02:00
|
|
|
#endif
|
2023-12-25 02:24:23 +01:00
|
|
|
p_Host_Init_PostVideo = g_GameDll.FindPatternSIMD("48 8B C4 41 56 48 81 EC ?? ?? ?? ?? 45 33 F6");
|
2023-06-18 22:16:43 +02:00
|
|
|
p_Host_Shutdown = g_GameDll.FindPatternSIMD("48 8B C4 48 83 EC ?? 80 3D ?? ?? ?? ?? ?? 0F 85 ?? ?? ?? ?? 8B 15 ?? ?? ?? ??");
|
2023-02-15 20:54:09 +01:00
|
|
|
p_Host_Status_PrintClient = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 60 48 8B A9 ?? ?? ?? ??");
|
2022-11-07 19:29:55 +01:00
|
|
|
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
|
2023-04-23 17:05:00 +02:00
|
|
|
p_DFS_InitializeFeatureFlagDefinitions = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 40 38 3D ?? ?? ?? ?? 48 8D 15 ?? ?? ?? ?? 48 8B CE").FollowNearCallSelf();
|
2022-11-07 19:29:55 +01:00
|
|
|
v_DFS_InitializeFeatureFlagDefinitions = p_DFS_InitializeFeatureFlagDefinitions.RCast<bool (*)(const char*)>(); /*48 8B C4 55 53 48 8D 68 E8*/
|
|
|
|
#endif // !(GAMEDLL_S0) || !(GAMEDLL_S1) || !(GAMEDLL_S2)
|
2023-12-25 02:24:23 +01:00
|
|
|
v_Host_Init = p_Host_Init.RCast<void (*)()>();
|
|
|
|
v_Host_Init_DuringVideo = p_Host_Init_DuringVideo.RCast<void (*)(bool*)>(); /*48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 48 8B D9*/
|
|
|
|
v_Host_Init_PostVideo = p_Host_Init_PostVideo.RCast<void (*)(bool*)>();
|
2023-06-18 22:16:43 +02:00
|
|
|
v_Host_Shutdown = p_Host_Shutdown.RCast<void (*)()>();
|
2023-04-10 19:14:59 +02:00
|
|
|
v_Host_NewGame = p_Host_NewGame.RCast<bool (*)(char*, char*, bool, char, LARGE_INTEGER)>(); /*48 8B C4 ?? 41 54 41 55 48 81 EC 70 04 00 00 F2 0F 10 05 ?? ?? ?? 0B*/
|
2023-06-18 22:16:43 +02:00
|
|
|
v_Host_Disconnect = p_Host_Disconnect.RCast<void (*)(bool)>();
|
2023-04-10 19:14:59 +02:00
|
|
|
v_Host_ChangeLevel = p_Host_ChangeLevel.RCast<bool (*)(bool, const char*, const char*)>(); /*40 56 57 41 56 48 81 EC ?? ?? ?? ??*/
|
2023-02-15 20:54:09 +01:00
|
|
|
v_Host_Status_PrintClient = p_Host_Status_PrintClient.RCast<void (*)(CClient*, bool, void (*) (const char*, ...))>();
|
2022-08-22 03:53:38 +02:00
|
|
|
v_SetLaunchOptions = p_SetLaunchOptions.RCast<int (*)(const CCommand&)>(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 57 48 83 EC 20 48 8B 1D ?? ?? ?? ?? 48 8B E9 48 85 DB*/
|
2022-04-18 03:35:08 +02:00
|
|
|
}
|
|
|
|
virtual void GetVar(void) const
|
|
|
|
{
|
|
|
|
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
2022-08-22 03:53:38 +02:00
|
|
|
g_pEngineParms = p_CModAppSystemGroup_Main.FindPattern("48 8B", CMemory::Direction::DOWN, 100).ResolveRelativeAddress(0x3, 0x7).RCast<EngineParms_t*>();
|
2022-04-18 03:35:08 +02:00
|
|
|
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
2022-08-22 03:53:38 +02:00
|
|
|
g_pEngineParms = p_CModAppSystemGroup_Main.FindPattern("4C 8B", CMemory::Direction::DOWN, 100).ResolveRelativeAddress(0x3, 0x7).RCast<EngineParms_t*>();
|
2022-04-18 03:35:08 +02:00
|
|
|
#endif
|
|
|
|
}
|
2022-04-11 01:44:30 +02:00
|
|
|
virtual void GetCon(void) const { }
|
2023-11-26 13:21:20 +01:00
|
|
|
virtual void Detour(const bool bAttach) const;
|
2021-12-27 16:53:35 +01:00
|
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|