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

Add new callbacks to server functions

A few new callback hooks which are perhaps useful in the future.
This commit is contained in:
Kawe Mazidjatari 2023-04-25 00:46:45 +02:00
parent 000f7c7f82
commit d9fa611418
2 changed files with 63 additions and 9 deletions
r5dev/engine/server

@ -1,6 +1,12 @@
//===========================================================================//
//
// Purpose:
//
//===========================================================================//
#include "core/stdafx.h"
#include "tier0/threadtools.h"
#include "tier0/frametask.h"
#include "tier1/cvar.h"
#include "engine/server/sv_main.h"
#include "networksystem/pylon.h"
#include "networksystem/bansystem.h"
@ -26,4 +32,43 @@ void SV_IsClientBanned(const string& svIPAddr, const uint64_t nNucleusID)
}
}
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// Purpose: loads the game .dll
//-----------------------------------------------------------------------------
void SV_InitGameDLL()
{
v_SV_InitGameDLL();
}
//-----------------------------------------------------------------------------
// Purpose: release resources associated with extension DLLs.
//-----------------------------------------------------------------------------
void SV_ShutdownGameDLL()
{
v_SV_ShutdownGameDLL();
}
//-----------------------------------------------------------------------------
// Purpose: activates the server
// Output : true on success, false on failure
//-----------------------------------------------------------------------------
bool SV_ActivateServer()
{
return v_SV_ActivateServer();
}
///////////////////////////////////////////////////////////////////////////////
void HSV_Main::Attach() const
{
//DetourAttach(&v_SV_InitGameDLL, SV_InitGameDLL);
//DetourAttach(&v_SV_ShutdownGameDLL, SV_ShutdownGameDLL);
//DetourAttach(&v_SV_ActivateServer, SV_ActivateServer);
}
void HSV_Main::Detach() const
{
//DetourDetach(&v_SV_InitGameDLL, SV_InitGameDLL);
//DetourDetach(&v_SV_ShutdownGameDLL, SV_ShutdownGameDLL);
//DetourDetach(&v_SV_ActivateServer, SV_ActivateServer);
}

@ -6,13 +6,16 @@
/* ==== SV_MAIN ======================================================================================================================================================= */
inline CMemory p_SV_InitGameDLL;
inline auto SV_InitGameDLL = p_SV_InitGameDLL.RCast<void(*)(void)>();
inline auto v_SV_InitGameDLL = p_SV_InitGameDLL.RCast<void(*)(void)>();
inline CMemory p_SV_ShutdownGameDLL;
inline auto SV_ShutdownGameDLL = p_SV_ShutdownGameDLL.RCast<void(*)(void)>();
inline auto v_SV_ShutdownGameDLL = p_SV_ShutdownGameDLL.RCast<void(*)(void)>();
inline CMemory p_SV_ActivateServer;
inline auto v_SV_ActivateServer = p_SV_ActivateServer.RCast<bool(*)(void)>();
inline CMemory p_SV_CreateBaseline;
inline auto SV_CreateBaseline = p_SV_CreateBaseline.RCast<bool(*)(void)>();
inline auto v_SV_CreateBaseline = p_SV_CreateBaseline.RCast<bool(*)(void)>();
inline CMemory p_CGameServer__SpawnServer;
inline auto CGameServer__SpawnServer = p_CGameServer__SpawnServer.RCast<bool(*)(void* thisptr, const char* pszMapName, const char* pszMapGroupName)>();
@ -21,6 +24,9 @@ inline bool* s_bIsDedicated = nullptr;
///////////////////////////////////////////////////////////////////////////////
void SV_InitGameDLL();
void SV_ShutdownGameDLL();
bool SV_ActivateServer();
void SV_IsClientBanned(const string& svIPAddr, const uint64_t nNucleusID);
///////////////////////////////////////////////////////////////////////////////
@ -32,6 +38,7 @@ class HSV_Main : public IDetour
LogFunAdr("CGameServer::SpawnServer", p_CGameServer__SpawnServer.GetPtr());
LogFunAdr("SV_InitGameDLL", p_SV_InitGameDLL.GetPtr());
LogFunAdr("SV_ShutdownGameDLL", p_SV_ShutdownGameDLL.GetPtr());
LogFunAdr("SV_ActivateServer", p_SV_ActivateServer.GetPtr());
LogFunAdr("SV_CreateBaseline", p_SV_CreateBaseline.GetPtr());
LogVarAdr("s_bIsDedicated", reinterpret_cast<uintptr_t>(s_bIsDedicated));
}
@ -39,6 +46,7 @@ class HSV_Main : public IDetour
{
p_SV_InitGameDLL = g_GameDll.FindPatternSIMD("48 81 EC ?? ?? ?? ?? E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 0F 85 ?? ?? ?? ??");
p_SV_ShutdownGameDLL = g_GameDll.FindPatternSIMD("48 83 EC 28 80 3D ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48");
p_SV_CreateBaseline = g_GameDll.FindPatternSIMD("48 8B C4 56 48 81 EC ?? ?? ?? ?? 48 89 ?? ?? 48 8D");
p_SV_CreateBaseline = g_GameDll.FindPatternSIMD("48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 85 C9 75 07");
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
p_CGameServer__SpawnServer = g_GameDll.FindPatternSIMD("40 53 55 56 57 41 55 41 56 41 57 48 81 EC ?? ?? ?? ??");
@ -46,9 +54,10 @@ class HSV_Main : public IDetour
p_CGameServer__SpawnServer = g_GameDll.FindPatternSIMD("48 8B C4 53 55 56 57 41 54 41 55 41 57");
// 0x140312D80 // 48 8B C4 53 55 56 57 41 54 41 55 41 57 //
#endif
SV_InitGameDLL = p_SV_InitGameDLL.RCast<void(*)(void)>();
SV_ShutdownGameDLL = p_SV_ShutdownGameDLL.RCast<void(*)(void)>();
SV_CreateBaseline = p_SV_CreateBaseline.RCast<bool(*)(void)>();
v_SV_InitGameDLL = p_SV_InitGameDLL.RCast<void(*)(void)>();
v_SV_ShutdownGameDLL = p_SV_ShutdownGameDLL.RCast<void(*)(void)>();
v_SV_ActivateServer = p_SV_CreateBaseline.RCast<bool(*)(void)>();
v_SV_CreateBaseline = p_SV_CreateBaseline.RCast<bool(*)(void)>();
CGameServer__SpawnServer = p_CGameServer__SpawnServer.RCast<bool(*)(void*, const char*, const char*)>();
}
virtual void GetVar(void) const
@ -57,7 +66,7 @@ class HSV_Main : public IDetour
.FindPatternSelf("40 38 3D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 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;
};
///////////////////////////////////////////////////////////////////////////////