Add gamedata for EntityFactoryDictionary and IServer for Dota 2 on Linux (bug 6068, r=psychonic).
This commit is contained in:
@@ -119,14 +119,31 @@ bool UTIL_VerifySignature(const void *addr, const char *sig, size_t len)
|
||||
}
|
||||
|
||||
#if defined PLATFORM_WINDOWS
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Windows"
|
||||
#elif defined PLATFORM_LINUX
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Linux"
|
||||
#elif defined PLATFORM_APPLE
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Mac"
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
void GetIServer()
|
||||
{
|
||||
void *addr;
|
||||
const char *sigstr;
|
||||
char sig[32];
|
||||
size_t siglen;
|
||||
int offset;
|
||||
void *vfunc = NULL;
|
||||
|
||||
/* Use the symbol if it exists */
|
||||
if (g_pGameConf->GetMemSig("sv", &addr) && addr)
|
||||
{
|
||||
iserver = reinterpret_cast<IServer *>(addr);
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
|
||||
/* Get the CreateFakeClient function pointer */
|
||||
if (!(vfunc=SH_GET_ORIG_VFNPTR_ENTRY(engine, &IVEngineServer::CreateFakeClient)))
|
||||
@@ -147,7 +164,7 @@ void GetIServer()
|
||||
#endif
|
||||
|
||||
/* Get signature string for IVEngineServer::CreateFakeClient() */
|
||||
sigstr = g_pGameConf->GetKeyValue("CreateFakeClient_Windows");
|
||||
sigstr = g_pGameConf->GetKeyValue(FAKECLIENT_KEY);
|
||||
|
||||
if (!sigstr)
|
||||
{
|
||||
@@ -172,18 +189,6 @@ void GetIServer()
|
||||
/* Finally we have the interface we were looking for */
|
||||
iserver = *reinterpret_cast<IServer **>(reinterpret_cast<unsigned char *>(vfunc) + offset);
|
||||
}
|
||||
#elif defined PLATFORM_POSIX
|
||||
void GetIServer()
|
||||
{
|
||||
void *addr;
|
||||
if (!g_pGameConf->GetMemSig("sv", &addr) || !addr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iserver = reinterpret_cast<IServer *>(addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void GetResourceEntity()
|
||||
{
|
||||
|
||||
@@ -533,11 +533,26 @@ CEntityFactoryDictionary *GetEntityFactoryDictionary()
|
||||
retData.type = PassType_Basic;
|
||||
|
||||
void *addr;
|
||||
if (g_pGameConf->GetMemSig("EntityFactory", &addr) && addr != NULL)
|
||||
if (!g_pGameConf->GetMemSig("EntityFactory", &addr) || !addr)
|
||||
{
|
||||
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0);
|
||||
int offset;
|
||||
|
||||
if (!g_pGameConf->GetMemSig("EntityFactoryCaller", &addr) || !addr)
|
||||
return NULL;
|
||||
|
||||
if (!g_pGameConf->GetOffset("EntityFactoryCallOffset", &offset))
|
||||
return NULL;
|
||||
|
||||
// Get relative offset to function
|
||||
int32_t funcOffset = *(int32_t *)((intptr_t)addr + offset);
|
||||
|
||||
// Get real address of function
|
||||
// Address of signature + offset of relative offset + sizeof(int32_t) offset + relative offset
|
||||
addr = (void *)((intptr_t)addr + offset + 4 + funcOffset);
|
||||
}
|
||||
|
||||
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0);
|
||||
|
||||
if (pWrapper)
|
||||
{
|
||||
void *returnData = NULL;
|
||||
|
||||
Reference in New Issue
Block a user