Fix SDKHooks load issue and reliance on gEntList ptr on CS:GO and Dota 2 on Windows.

This commit is contained in:
Nicholas Hastings 2014-02-07 22:11:31 -05:00
parent 39c82d6ea0
commit 4093fa0588
3 changed files with 68 additions and 52 deletions

View File

@ -118,6 +118,29 @@ IGameConfig *g_pGameConf = NULL;
char g_szMapEntities[2097152];
CUtlVector<IEntityListener *> *EntListeners()
{
void *gEntList = gamehelpers->GetGlobalEntityList();
if (gEntList)
{
int offset = -1; /* 65572 */
if (g_pGameConf->GetOffset("EntityListeners", &offset))
{
return (CUtlVector<IEntityListener *> *)((intptr_t) gEntList + offset);
}
}
else
{
void *entListeners;
if (g_pGameConf->GetAddress("EntityListenersPtr", &entListeners))
{
return (CUtlVector<IEntityListener *> *)entListeners;
}
}
return NULL;
}
/**
* IServerGameDLL & IVEngineServer Hooks
@ -215,22 +238,14 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
return false;
}
void *gEntList = gamehelpers->GetGlobalEntityList();
if (!gEntList)
CUtlVector<IEntityListener *> *entListeners = EntListeners();
if (!entListeners)
{
g_pSM->Format(error, maxlength, "Cannot find gEntList pointer");
g_pSM->Format(error, maxlength, "Failed to setup entity listeners");
return false;
}
int offset = -1; /* 65572 */
if (!g_pGameConf->GetOffset("EntityListeners", &offset))
{
g_pSM->Format(error, maxlength, "Cannot find EntityListeners offset");
return false;
}
CUtlVector<IEntityListener *> *pListeners = (CUtlVector<IEntityListener *> *)((intptr_t)gEntList + offset);
pListeners->AddToTail(this);
entListeners->AddToTail(this);
SetupHooks();
@ -324,16 +339,8 @@ void SDKHooks::SDK_OnUnload()
sharesys->DropCapabilityProvider(myself, this, "SDKHook_DmgCustomInOTD");
sharesys->DropCapabilityProvider(myself, this, "SDKHook_LogicalEntSupport");
void *gEntList = gamehelpers->GetGlobalEntityList();
if (gEntList)
{
int offset = -1; /* 65572 */
if (g_pGameConf->GetOffset("EntityListeners", &offset))
{
CUtlVector<IEntityListener *> *pListeners = (CUtlVector<IEntityListener *> *)((intptr_t)gEntList + offset);
pListeners->FindAndRemove(this);
}
}
CUtlVector<IEntityListener *> *entListeners = EntListeners();
entListeners->FindAndRemove(this);
gameconfs->CloseGameConfigFile(g_pGameConf);
}

View File

@ -136,29 +136,6 @@
"linux" "283"
"mac" "283"
}
// no longer used
"UpdateOnRemove"
{
"windows" "109"
"linux" "110"
"mac" "110"
}
//
}
"Signatures"
{
// no longer used
"IEntityFactoryDictionary"
{
"library" "server"
"windows" "\xB8\x01\x00\x00\x00\x84\x2A\x2A\x2A\x2A\x2A\x75\x1D\x09\x2A\x2A\x2A\x2A\x2A\xB9\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x68\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x83\xC4\x04\xB8\x2A\x2A\x2A\x2A\xC3"
"linux" "@_Z23EntityFactoryDictionaryv"
"mac" "@_Z23EntityFactoryDictionaryv"
}
//
}
}
@ -168,10 +145,31 @@
{
"EntityListeners"
{
"windows" "196644"
"linux" "196644"
"mac" "196644"
}
}
"Addresses"
{
"EntityListenersPtr"
{
"windows"
{
"signature" "EntityListenersFinder"
"read" "18"
}
}
}
"Signatures"
{
// Find call to AddListenerEntity in CPhysSaveRestoreBlockHandler::PreRestore (virtual)
"EntityListenersFinder"
{
"library" "server"
"windows" "\x55\x8B\xEC\x8B\x0D\x2A\x2A\x2A\x2A\x33\xC0\x56\x85\xC9\x7E\x32\x8B"
}
}
}
}

View File

@ -89,14 +89,25 @@
"#default"
{
// CGlobalEntityList vtable, first function (OnAddEntity [+0]), near end, getting multiplied by 4
// mov eax, [edi+20024h]
// mov ecx, [eax+esi*4]
"Offsets"
"Addresses"
{
"EntityListeners"
"EntityListenersPtr"
{
"windows" "131108"
"windows"
{
"signature" "EntityListenersFinder"
"read" "20"
}
}
}
"Signatures"
{
// Find AddListenerEntity inlined in CPhysSaveRestoreBlockHandler::PreRestore (virtual)
"EntityListenersFinder"
{
"library" "server"
"windows" "\x33\xC9\x8B\x2A\x2A\x2A\x2A\x2A\x33\xC0\x89\x4D\xFC\x56\x85\xD2\x7E\x2A\x8B"
}
}
}