示例#1
0
文件: vcaller.cpp 项目: asceth/synapi
static cell_t PrepSDKCall_SetFromConf(IPluginContext *pContext, const cell_t *params)
{
	IGameConfig *conf;

	if (params[1] == BAD_HANDLE)
	{
		conf = g_pGameConf;
	} else {
		HandleError err;
		if ((conf = gameconfs->ReadHandle(params[1], pContext->GetIdentity(), &err)) == NULL)
		{
			return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
		}
	}
	
	char *key;
	pContext->LocalToString(params[3], &key);

	if (params[2] == 0)
	{
		return conf->GetOffset(key, &s_vtbl_index) ? 1 : 0;
	} else if (params[2] == 1) {
		bool result = conf->GetMemSig(key, &s_call_addr) ? 1 : 0;
		return (result && s_call_addr != NULL) ? 1 : 0;
	}

	return 0;
}
示例#2
0
SteamWorksGSDetours::SteamWorksGSDetours()
{
	const char *pLibSteamPath = g_SteamWorks.pSWGameServer->GetLibraryPath();

	void *pSteamSafeInitAddress = NULL;
	void *pSteamShutdownAddress = NULL;

	const char *pInitSafeFuncName = "SteamGameServer_InitSafe";
	const char *pShutdownFuncName = "SteamGameServer_Shutdown";

	IGameConfig *pConfig = NULL;
	if (g_SteamWorks.pSWGameData)
	{
		pConfig = g_SteamWorks.pSWGameData->GetGameData();
		if (pConfig != NULL)
		{
			pConfig->GetMemSig(pShutdownFuncName, &pSteamShutdownAddress);
			pConfig->GetMemSig(pInitSafeFuncName, &pSteamSafeInitAddress);
		}
	}

	ILibrary *pLibrary = libsys->OpenLibrary(pLibSteamPath, NULL, 0);
	if (pLibrary != NULL)
	{
		if (pSteamShutdownAddress == NULL)
		{
			pSteamShutdownAddress = pLibrary->GetSymbolAddress(pShutdownFuncName);
		}
		
		if (pSteamSafeInitAddress == NULL)
		{
			pSteamSafeInitAddress = pLibrary->GetSymbolAddress(pInitSafeFuncName);
		}
		
		pLibrary->CloseLibrary();
	}

	CDetourManager::Init(g_pSM->GetScriptingEngine(), pConfig);
	if (pSteamShutdownAddress != NULL)
	{
		this->m_pShutdownDetour = DETOUR_CREATE_STATIC_FIXED(SteamAPIShutdown, pSteamShutdownAddress);
		this->m_pShutdownDetour->EnableDetour();
	}
	else
	{
		this->m_pShutdownDetour = NULL;
	}

	if (pSteamSafeInitAddress != NULL)
	{
		this->m_pSafeInitDetour = DETOUR_CREATE_STATIC_FIXED(SteamGameServer_InitSafeDetour, pSteamSafeInitAddress);
		this->m_pSafeInitDetour->EnableDetour();
	}
	else
	{
		this->m_pSafeInitDetour = NULL;
	}
}
示例#3
0
static cell_t PrepSDKCall_SetFromConf(IPluginContext *pContext, const cell_t *params)
{
	IGameConfig *conf;

	if (params[1] == BAD_HANDLE)
	{
		conf = g_pGameConf;
	} else {
		HandleError err;
		if ((conf = gameconfs->ReadHandle(params[1], pContext->GetIdentity(), &err)) == NULL)
		{
			return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
		}
	}
	
	char *key;
	pContext->LocalToString(params[3], &key);

	switch (params[2])
	{
	case SDKConf_Virtual:
		if (conf->GetOffset(key, &s_vtbl_index))
		{
			return 1;
		}
		break;
	case SDKConf_Signature:
		if (conf->GetMemSig(key, &s_call_addr) && s_call_addr)
		{
			return 1;
		}
		break;
	case SDKConf_Address:
		if (conf->GetAddress(key, &s_call_addr) && s_call_addr)
		{
			return 1;
		}
		break;
	}

	return 0;
}