extensions/sdktools/vhelpers.cpp
changeset 4272 8b39aa02b05b
parent 4169 65eebc76e836
child 4304 bff9916aa9b2
     1.1 --- a/extensions/sdktools/vhelpers.cpp	Mon Mar 03 05:20:40 2014 -0600
     1.2 +++ b/extensions/sdktools/vhelpers.cpp	Mon Mar 03 05:20:40 2014 -0600
     1.3 @@ -533,11 +533,26 @@
     1.4  		retData.type = PassType_Basic;
     1.5  
     1.6  		void *addr;
     1.7 -		if (g_pGameConf->GetMemSig("EntityFactory", &addr) && addr != NULL)
     1.8 +		if (!g_pGameConf->GetMemSig("EntityFactory", &addr) || !addr)
     1.9  		{
    1.10 -			pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0);
    1.11 +			int offset;
    1.12 +
    1.13 +			if (!g_pGameConf->GetMemSig("EntityFactoryCaller", &addr) || !addr)
    1.14 +				return NULL;
    1.15 +
    1.16 +			if (!g_pGameConf->GetOffset("EntityFactoryCallOffset", &offset))
    1.17 +				return NULL;
    1.18 +
    1.19 +			// Get relative offset to function
    1.20 +			int32_t funcOffset = *(int32_t *)((intptr_t)addr + offset);
    1.21 +
    1.22 +			// Get real address of function
    1.23 +			// Address of signature + offset of relative offset + sizeof(int32_t) offset + relative offset
    1.24 +			addr = (void *)((intptr_t)addr + offset + 4 + funcOffset);
    1.25  		}
    1.26  
    1.27 +		pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0);
    1.28 +
    1.29  		if (pWrapper)
    1.30  		{
    1.31  			void *returnData = NULL;