Fix SDKHooks load issue and reliance on gEntList ptr on CS:GO and Dota 2 on Windows.
This commit is contained in:
		
							parent
							
								
									6e40168f79
								
							
						
					
					
						commit
						5916709430
					
				| @ -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 | ||||
| @ -211,22 +234,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(); | ||||
| 
 | ||||
| @ -320,16 +335,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); | ||||
| } | ||||
|  | ||||
| @ -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" | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user