Example #1
0
void InitialiseDetours()
{
	calcIsAttackCriticalDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCritical");
	calcIsAttackCriticalMeleeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperMelee, "CalcCriticalMelee");
	calcIsAttackCriticalKnifeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperKnife, "CalcCriticalKnife");

	bool HookCreated = false;

	if (calcIsAttackCriticalDetour != NULL)
	{
		calcIsAttackCriticalDetour->EnableDetour();
		HookCreated = true;
	}

	if (calcIsAttackCriticalMeleeDetour != NULL)
	{
		calcIsAttackCriticalMeleeDetour->EnableDetour();
		HookCreated = true;
	}

	if (calcIsAttackCriticalKnifeDetour != NULL)
	{
		calcIsAttackCriticalKnifeDetour->EnableDetour();
		HookCreated = true;
	}

	if (!HookCreated)
	{
		g_pSM->LogError(myself, "No critical hit forwards could be initialized - Disabled critical hit hooks");
		return;
	}

}
Example #2
0
bool EntityOutputManager::CreateFireEventDetour()
{
	fireOutputDetour = DETOUR_CREATE_MEMBER(FireOutput, "FireOutput");

	if (fireOutputDetour) return true;

	return false;
}
Example #3
0
bool CreateWeaponPriceDetour()
{
	if (weaponNameOffset == -1)
	{
		if (!g_pGameConf->GetOffset("WeaponName", &weaponNameOffset))
		{
			smutils->LogError(myself, "Could not find WeaponName offset - Disabled OnGetWeaponPrice forward");
			return false;
		}
	}

#if SOURCE_ENGINE == SE_CSGO
	if (g_iPriceOffset == -1)
	{
		if (!g_pGameConf->GetOffset("WeaponPrice", &g_iPriceOffset))
		{
			g_iPriceOffset = -1;
			g_pSM->LogError(myself, "Failed to get WeaponPrice offset - Disabled OnGetWeaponPrice forward");
			return false;
		}
	}
	if (!CreateHandleBuyDetour())
	{
		g_pSM->LogError(myself, "HandleCommand_Buy_Internal failed to detour, disabled OnGetWeaponPrice forward.");
		return false;
	}
	else
	{
		g_PriceDetoured = true;
		return true;
	}
#else

	DWeaponPrice = DETOUR_CREATE_MEMBER(DetourWeaponPrice, "GetWeaponPrice");

	if (DWeaponPrice != NULL)
	{
		if (!CreateHandleBuyDetour())
		{
			g_pSM->LogError(myself, "GetWeaponPrice detour could not be initialized - HandleCommand_Buy_Internal failed to detour, disabled OnGetWeaponPrice forward.");
			return false;
		}
		DWeaponPrice->EnableDetour();
		g_PriceDetoured = true;
		return true;
	}

	g_pSM->LogError(myself, "GetWeaponPrice detour could not be initialized - Disabled OnGetWeaponPrice forward.");

	return false;
#endif
}
Example #4
0
bool CreateTerminateRoundDetour()
{
	DTerminateRound = DETOUR_CREATE_MEMBER(DetourTerminateRound, "TerminateRound");

	if (DTerminateRound != NULL)
	{
		DTerminateRound->EnableDetour();
		g_pTerminateRoundDetoured = true;
		return true;
	}
	g_pSM->LogError(myself, "TerminateRound detour could not be initialized - Disabled OnTerminateRound forward");
	return false;
}
bool InitialiseRulesDetours()
{
	setInWaitingForPlayersDetour = DETOUR_CREATE_MEMBER(SetInWaitingForPlayers, "SetInWaitingForPlayers");

	if (setInWaitingForPlayersDetour != NULL)
	{
		setInWaitingForPlayersDetour->EnableDetour();
		return true;
	}

	g_pSM->LogError(myself, "No Gameplay Rules detours could be initialized - Disabled Gameplay Rules functions");
	return false;
}
Example #6
0
bool CreateCSWeaponDropDetour()
{
	DCSWeaponDrop = DETOUR_CREATE_MEMBER(DetourCSWeaponDrop, "CSWeaponDrop");

	if (DCSWeaponDrop != NULL)
	{
		DCSWeaponDrop->EnableDetour();
		g_pCSWeaponDropDetoured = true;
		return true;
	}

	g_pSM->LogError(myself, "CSWeaponDrop detour could not be initialized - Disabled OnCSWeaponDrop forward");
	return false;
}
Example #7
0
void CForwardManager::CreateBroadcastLocalChatDetour()
{
	if (m_bBroadcastLocalChatDetoured)
		return;

	m_DBroadcastLocalChat = DETOUR_CREATE_MEMBER(DetourHLTVServer_BroadcastLocalChat, "CHLTVServer::BroadcastLocalChat");

	if (m_DBroadcastLocalChat != nullptr)
	{
		m_DBroadcastLocalChat->EnableDetour();
		m_bBroadcastLocalChatDetoured = true;
		return;
	}
	smutils->LogError(myself, "CHLTVServer::BroadcastLocalChat detour could not be initialized.");
}
Example #8
0
bool CBotControl::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
	if (!gameconfs->LoadGameConfigFile("bot-control", &g_pGameConf, error, maxlength)) return false;
	
	CDetourManager::Init(g_pSM->GetScriptingEngine(), g_pGameConf);
	
	g_GetEventChangeAttributes = DETOUR_CREATE_MEMBER(GetEventChangeAttributes, "CTFBot::GetEventChangeAttributes");
	if (g_GetEventChangeAttributes != NULL)
	{
		g_GetEventChangeAttributes->EnableDetour();
		g_pSM->LogMessage(myself, "CTFBot::GetEventChangeAttributes detour enabled.");
	}

	return true;
}
Example #9
0
bool CreateHandleBuyDetour()
{
	if (g_HandleBuyDetoured)
		return true;

	DHandleBuy = DETOUR_CREATE_MEMBER(DetourHandleBuy, "HandleCommand_Buy_Internal");

	if (DHandleBuy != NULL)
	{
		DHandleBuy->EnableDetour();
		g_HandleBuyDetoured = true;
		return true;
	}
	g_pSM->LogError(myself, "HandleCommand_Buy_Internal detour could not be initialized - Disabled OnBuyCommand forward");
	return false;
}
Example #10
0
void CForwardManager::CreateStopRecordingDetour()
{
	if (m_bStopRecordingDetoured)
		return;

	m_DStopRecording = DETOUR_CREATE_MEMBER(DetourHLTVStopRecording, "CHLTVDemoRecorder::StopRecording");

	if (m_DStopRecording != nullptr)
	{
		m_DStopRecording->EnableDetour();
		m_bStopRecordingDetoured = true;
		return;
	}
	smutils->LogError(myself, "CHLTVDemoRecorder::StopRecording detour could not be initialized.");
	return;
}
Example #11
0
	bool SDKInit()
	{
		GET_DETOUR(AllocateDefaultRelationships, DETOUR_CREATE_MEMBER(CDetour_AllocateDefaultRelationships, "AllocateDefaultRelationships"));

		GET_DETOUR(UTIL_BloodDrips, DETOUR_CREATE_STATIC(CDetour_UTIL_BloodDrips, "UTIL_BloodDrips"));
		
		GET_DETOUR(ShouldRemoveThisRagdoll, DETOUR_CREATE_STATIC(CDetour_ShouldRemoveThisRagdoll, "ShouldRemoveThisRagdoll"));
	
		GET_DETOUR(FindInList, DETOUR_CREATE_STATIC(CDetour_FindInList, "FindInList"));

		GET_DETOUR(Pickup_ForcePlayerToDropThisObject, DETOUR_CREATE_STATIC(CDetour_Pickup_ForcePlayerToDropThisObject, "Pickup_ForcePlayerToDropThisObject"));

		GET_DETOUR(UTIL_GetLocalPlayer, DETOUR_CREATE_STATIC(CDetour_UTIL_GetLocalPlayer, "UTIL_GetLocalPlayer"));

		return true;
	}
bool CEntityManager::Init(IGameConfig *pConfig)
{
	/* Find the IEntityFactoryDictionary_CE* */
	void *addr;
	if (!pConfig->GetMemSig("EntityFactory", &addr) || addr == NULL)
	{
		g_pSM->LogError(myself, "[CENTITY] Couldn't find sig: %s.", "EntityFactory");
		return false;
	}

	EntityFactoryDictionary_CE = (EntityFactoryDictionaryCall)addr;
	pDict = EntityFactoryDictionary_CE();

	IEntityFactoryReal *pList = IEntityFactoryReal::m_Head;
	while (pList)
	{
		pList->AddToList();
		pList = pList->m_Next;
	}

	if (!pConfig->GetMemSig("FireOutput", &addr) || addr == NULL)
	{
		g_pSM->LogError(myself, "[CENTITY] Couldn't find sig: %s.", "FireOutput");
		return false;
	}

	FireOutputFunc = (FireOutputFuncType)addr;

	if (!pConfig->GetMemSig("PhysIsInCallback", &addr) || addr == NULL)
	{
		g_pSM->LogError(myself, "[CENTITY] Couldn't find sig: %s.", "PhysIsInCallback");
		return false;
	}

	PhysIsInCallback = (PhysIsInCallbackFuncType)addr;


	/* Reconfigure all the hooks */
	IHookTracker *pTracker = IHookTracker::m_Head;
	while (pTracker)
	{
		pTracker->ReconfigureHook(pConfig);
		pTracker = pTracker->m_Next;
	}

	CDetourManager::Init(g_pSM->GetScriptingEngine(), pConfig);

	RemoveEntity_CDetour = DETOUR_CREATE_MEMBER(RemoveEntity, "CBaseEntityList::RemoveEntity");
	RemoveEntity_CDetour->EnableDetour();

	PostConstructor_CDetour = DETOUR_CREATE_MEMBER(PostConstructor, "CBaseEntity::PostConstructor");
	PostConstructor_CDetour->EnableDetour();

	IDetourTracker *pDetourTracker = IDetourTracker::m_Head;
	while (pDetourTracker)
	{
		pDetourTracker->AddHook();
		pDetourTracker = pDetourTracker->m_Next;
	}

	ISigOffsetTracker *pSigOffsetTracker = ISigOffsetTracker::m_Head;
	while (pSigOffsetTracker)
	{
		pSigOffsetTracker->FindSig(pConfig);
		pSigOffsetTracker = pSigOffsetTracker->m_Next;
	}

	/* Start the creation hooks! */
	SH_ADD_HOOK(IVEngineServer, RemoveEdict, engine, SH_MEMBER(this, &CEntityManager::RemoveEdict), true);

	srand(time(NULL));

	m_bEnabled = true;
	return true;
}