Compatibility shim to fix IServer lookup on CS:S (bug 5450, r=asherkin).

This commit is contained in:
Nicholas Hastings 2012-08-27 17:52:15 -04:00
parent 129395c896
commit e95f0f333e
2 changed files with 43 additions and 9 deletions

View File

@ -125,6 +125,7 @@ void GetIServer()
int offset; int offset;
void *vfunc = NULL; void *vfunc = NULL;
#if SOURCE_ENGINE != SE_ORANGEBOXVALVE
#if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11 #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
/* Get the CreateFakeClient function pointer */ /* Get the CreateFakeClient function pointer */
if (!(vfunc=SH_GET_ORIG_VFNPTR_ENTRY(engine, &IVEngineServer::CreateFakeClient))) if (!(vfunc=SH_GET_ORIG_VFNPTR_ENTRY(engine, &IVEngineServer::CreateFakeClient)))
@ -142,7 +143,8 @@ void GetIServer()
void **vtable = *reinterpret_cast<void ***>(enginePatch->GetThisPtr() + info.thisptroffs + info.vtbloffs); void **vtable = *reinterpret_cast<void ***>(enginePatch->GetThisPtr() + info.thisptroffs + info.vtbloffs);
vfunc = vtable[info.vtblindex]; vfunc = vtable[info.vtblindex];
} }
#endif #endif // defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
#endif // SOURCE_ENGINE != SE_ORANGEBOXVALVE
/* Get signature string for IVEngineServer::CreateFakeClient() */ /* Get signature string for IVEngineServer::CreateFakeClient() */
sigstr = g_pGameConf->GetKeyValue("CreateFakeClient_Windows"); sigstr = g_pGameConf->GetKeyValue("CreateFakeClient_Windows");
@ -155,11 +157,19 @@ void GetIServer()
/* Convert signature string to signature bytes */ /* Convert signature string to signature bytes */
siglen = UTIL_StringToSignature(sigstr, sig, sizeof(sig)); siglen = UTIL_StringToSignature(sigstr, sig, sizeof(sig));
#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
vfunc = memutils->FindPattern(engine, sigstr, siglen);
if (!vfunc)
{
return;
}
#else
/* Check if we're on the expected function */ /* Check if we're on the expected function */
if (!UTIL_VerifySignature(vfunc, sig, siglen)) if (!UTIL_VerifySignature(vfunc, sig, siglen))
{ {
return; return;
} }
#endif
/* Get the offset into CreateFakeClient */ /* Get the offset into CreateFakeClient */
if (!g_pGameConf->GetOffset("sv", &offset)) if (!g_pGameConf->GetOffset("sv", &offset))

View File

@ -150,12 +150,7 @@
"Keys" "Keys"
{ {
/* Signature for the beginning of IVEngineServer::CreateFakeClientEx. /* Signature for the beginning of IVEngineServer::CreateFakeClientEx.
* * (Must be unique!)
* The engine binary is not actually scanned in order to look for
* this. SourceHook is used to used to determine the address of the
* function and this signature is used to verify that it contains
* the expected code. A pointer to sv (IServer interface) is used
* here.
*/ */
"CreateFakeClient_Windows" "\x55\x8B\xEC\x8B\x2A\x2A\x50\xB9\x2A\x2A\x2A\x2A\xE8" "CreateFakeClient_Windows" "\x55\x8B\xEC\x8B\x2A\x2A\x50\xB9\x2A\x2A\x2A\x2A\xE8"
@ -184,7 +179,36 @@
"#default" "#default"
{ {
// This is broken for now on css. Functionality is compiled in and we only have a unified ep2v/css build on 1.4.x. "#supported"
{
"game" "cstrike"
}
"Keys"
{
/* Signature for the beginning of IVEngineServer::CreateFakeClientEx.
* (Must be unique!)
*/
"CreateFakeClient_Windows" "\x55\x8B\xEC\x8B\x2A\x2A\x8A\x2A\x2A\x51\xB9\x2A\x2A\x2A\x2A\xA2"
}
"Offsets"
{
"sv"
{
"windows" "11"
}
}
"Signatures"
{
"sv"
{
"library" "engine"
"linux" "@sv"
"mac" "@sv"
}
}
} }
/* EntityFactoryDictionary function */ /* EntityFactoryDictionary function */