Detour SteamGameServer_InitSafe to get interfaces earlier.
This commit is contained in:
@@ -60,6 +60,10 @@ ret name(p1type p1name)
|
|||||||
ret (*name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
|
ret (*name##_Actual)(p1type, p2type, p3type, p4type) = NULL; \
|
||||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
|
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name)
|
||||||
|
|
||||||
|
#define DETOUR_DECL_STATIC6(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name) \
|
||||||
|
ret (*name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type) = NULL; \
|
||||||
|
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name)
|
||||||
|
|
||||||
#define DETOUR_DECL_MEMBER0(name, ret) \
|
#define DETOUR_DECL_MEMBER0(name, ret) \
|
||||||
class name##Class \
|
class name##Class \
|
||||||
{ \
|
{ \
|
||||||
|
|||||||
+44
-10
@@ -34,6 +34,13 @@ DETOUR_DECL_STATIC0(SteamAPIShutdown, void)
|
|||||||
DETOUR_STATIC_CALL(SteamAPIShutdown)(); /* We're not a monster. */
|
DETOUR_STATIC_CALL(SteamAPIShutdown)(); /* We're not a monster. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DETOUR_DECL_STATIC6(SteamGameServer_InitSafe, bool, uint32, unIP, uint16, usSteamPort, uint16, usGamePort, uint16, usQueryPort, EServerMode, eServerMode, const char *, pchVersionString)
|
||||||
|
{
|
||||||
|
bool bRet = DETOUR_STATIC_CALL(SteamGameServer_InitSafe)(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString); /* Call to init game interfaces. */
|
||||||
|
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
SteamWorksGSDetours::SteamWorksGSDetours()
|
SteamWorksGSDetours::SteamWorksGSDetours()
|
||||||
{
|
{
|
||||||
#if defined POSIX
|
#if defined POSIX
|
||||||
@@ -53,29 +60,50 @@ SteamWorksGSDetours::SteamWorksGSDetours()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ILibrary *pLibrary = libsys->OpenLibrary(pLibSteamPath, NULL, 0);
|
ILibrary *pLibrary = libsys->OpenLibrary(pLibSteamPath, NULL, 0);
|
||||||
void *pAddress = NULL;
|
void *pSteamSafeInitAddress = NULL;
|
||||||
|
void *pSteamShutdownAddress = NULL;
|
||||||
if (pLibrary != NULL)
|
if (pLibrary != NULL)
|
||||||
{
|
{
|
||||||
const char *pFunctionName = "SteamGameServer_Shutdown";
|
const char *pInitSafeFuncName = "SteamGameServer_InitSafe";
|
||||||
if (pConfig == NULL || pConfig->GetMemSig(pFunctionName, &pAddress) == false)
|
const char *pShutdownFuncName = "SteamGameServer_Shutdown";
|
||||||
|
if (pConfig != NULL)
|
||||||
{
|
{
|
||||||
pAddress = pLibrary->GetSymbolAddress(pFunctionName);
|
pConfig->GetMemSig(pShutdownFuncName, &pSteamShutdownAddress);
|
||||||
|
pConfig->GetMemSig(pInitSafeFuncName, &pSteamSafeInitAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSteamShutdownAddress == NULL)
|
||||||
|
{
|
||||||
|
pSteamShutdownAddress = pLibrary->GetSymbolAddress(pShutdownFuncName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSteamSafeInitAddress == NULL)
|
||||||
|
{
|
||||||
|
pSteamSafeInitAddress = pLibrary->GetSymbolAddress(pInitSafeFuncName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pLibrary->CloseLibrary();
|
pLibrary->CloseLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pAddress == NULL)
|
CDetourManager::Init(g_pSM->GetScriptingEngine(), pConfig);
|
||||||
|
if (pSteamShutdownAddress != NULL)
|
||||||
|
{
|
||||||
|
this->m_pShutdownDetour = DETOUR_CREATE_STATIC_FIXED(SteamAPIShutdown, pSteamShutdownAddress);
|
||||||
|
this->m_pShutdownDetour->EnableDetour();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
this->m_pShutdownDetour = NULL;
|
this->m_pShutdownDetour = NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CDetourManager::Init(g_pSM->GetScriptingEngine(), pConfig);
|
if (pSteamSafeInitAddress != NULL)
|
||||||
this->m_pShutdownDetour = DETOUR_CREATE_STATIC_FIXED(SteamAPIShutdown, pAddress);
|
|
||||||
if (this->m_pShutdownDetour != NULL)
|
|
||||||
{
|
{
|
||||||
this->m_pShutdownDetour->EnableDetour();
|
this->m_pSafeInitDetour = DETOUR_CREATE_STATIC_FIXED(SteamGameServer_InitSafe, pSteamSafeInitAddress);
|
||||||
|
this->m_pSafeInitDetour->EnableDetour();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->m_pSafeInitDetour = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,4 +114,10 @@ SteamWorksGSDetours::~SteamWorksGSDetours()
|
|||||||
this->m_pShutdownDetour->Destroy();
|
this->m_pShutdownDetour->Destroy();
|
||||||
this->m_pShutdownDetour = NULL;
|
this->m_pShutdownDetour = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->m_pSafeInitDetour != NULL)
|
||||||
|
{
|
||||||
|
this->m_pSafeInitDetour->Destroy();
|
||||||
|
this->m_pSafeInitDetour = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class SteamWorksGSDetours
|
|||||||
~SteamWorksGSDetours();
|
~SteamWorksGSDetours();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CDetour *m_pSafeInitDetour;
|
||||||
CDetour *m_pShutdownDetour;
|
CDetour *m_pShutdownDetour;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user