IntersectSegment hook causing weird results?

Posts 1–15 of 19 · Page 1 of 2
IntersectSegment hook causing weird results?
Code:
bool PatchedIntersectSegment(IntersectQuery& Query, IntersectInfo* Info) {
	DWORD CShellBase = reinterpret_cast<DWORD>(GetModuleHandle("CShell.dll"));
	DWORD LTClientShell = *reinterpret_cast<DWORD*>(CShellBase + aLTClientShell);
	CFPlayer* MyPlayer = GetPlayerFromIndex(LTClientShell, GetMyPlayersIndex(LTClientShell));
	if (IsValidPlayer(MyPlayer, true) && ((MyPlayer -> Health) > 0)) {
		for (int ThisPlayerIndex = 0; (ThisPlayerIndex < 16); ThisPlayerIndex++) {
			CFPlayer* OtherPlayer = GetPlayerFromIndex(LTClientShell, ThisPlayerIndex);
			if (IsValidPlayer(OtherPlayer, false) && !IsMe(MyPlayer, OtherPlayer) && !IsTeammate(MyPlayer, OtherPlayer)) {
				D3DXVECTOR3 HitPosition = GetBonePosition((OtherPlayer -> Object), 6);
				Query.StartPosition = (HitPosition + D3DXVECTOR3(0.0f, 50.0f, 0.0f));
				Query.EndPosition = (HitPosition - D3DXVECTOR3(0.0f, 50.0f, 0.0f));
				Query.CollisionFlags = (INTERSECT_OBJECTS | IGNORE_NONSOLID | INTERSECT_HPOLY);
				Query.ObjectFilterOne = FilterObjectsCallback;
				(Info -> ImpactObject) = (OtherPlayer -> Object);
				(Info -> ImpactPosition) = HitPosition;
				return true;
			};
		};
	};
	return OriginalIntersectSegment(Query, Info);
};
Seems to work. I've successfully hooked it, I know that much.
However, even though it displays a red player name on my screen, even if I actually am aiming at them - I don't deal any damage.

Help? Just trying to setup a simple remote kill...
maybe something wrong in ThisPlayerIndex code
Quote Originally Posted by Goocolax View Post
Code:
bool PatchedIntersectSegment(IntersectQuery& Query, IntersectInfo* Info) {
	DWORD CShellBase = reinterpret_cast<DWORD>(GetModuleHandle("CShell.dll"));
	DWORD LTClientShell = *reinterpret_cast<DWORD*>(CShellBase + aLTClientShell);
	CFPlayer* MyPlayer = GetPlayerFromIndex(LTClientShell, GetMyPlayersIndex(LTClientShell));
	if (IsValidPlayer(MyPlayer, true) && ((MyPlayer -> Health) > 0)) {
		for (int ThisPlayerIndex = 0; (ThisPlayerIndex < 16); ThisPlayerIndex++) {
			CFPlayer* OtherPlayer = GetPlayerFromIndex(LTClientShell, ThisPlayerIndex);
			if (IsValidPlayer(OtherPlayer, false) && !IsMe(MyPlayer, OtherPlayer) && !IsTeammate(MyPlayer, OtherPlayer)) {
				D3DXVECTOR3 HitPosition = GetBonePosition((OtherPlayer -> Object), 6);
				Query.StartPosition = (HitPosition + D3DXVECTOR3(0.0f, 50.0f, 0.0f));
				Query.EndPosition = (HitPosition - D3DXVECTOR3(0.0f, 50.0f, 0.0f));
				Query.CollisionFlags = (INTERSECT_OBJECTS | IGNORE_NONSOLID | INTERSECT_HPOLY);
				Query.ObjectFilterOne = FilterObjectsCallback;
				(Info -> ImpactObject) = (OtherPlayer -> Object);
				(Info -> ImpactPosition) = HitPosition;
				return true;
			};
		};
	};
	return OriginalIntersectSegment(Query, Info);
};
Seems to work. I've successfully hooked it, I know that much.
However, even though it displays a red player name on my screen, even if I actually am aiming at them - I don't deal any damage.

Help? Just trying to setup a simple remote kill...
you are returning true, u have to return the original function...
Quote Originally Posted by Goocolax View Post
Code:
bool PatchedIntersectSegment(IntersectQuery& Query, IntersectInfo* Info) {
	DWORD CShellBase = reinterpret_cast<DWORD>(GetModuleHandle("CShell.dll"));
	DWORD LTClientShell = *reinterpret_cast<DWORD*>(CShellBase + aLTClientShell);
	CFPlayer* MyPlayer = GetPlayerFromIndex(LTClientShell, GetMyPlayersIndex(LTClientShell));
	if (IsValidPlayer(MyPlayer, true) && ((MyPlayer -> Health) > 0)) {
		for (int ThisPlayerIndex = 0; (ThisPlayerIndex < 16); ThisPlayerIndex++) {
			CFPlayer* OtherPlayer = GetPlayerFromIndex(LTClientShell, ThisPlayerIndex);
			if (IsValidPlayer(OtherPlayer, false) && !IsMe(MyPlayer, OtherPlayer) && !IsTeammate(MyPlayer, OtherPlayer)) {
				D3DXVECTOR3 HitPosition = GetBonePosition((OtherPlayer -> Object), 6);
				Query.StartPosition = (HitPosition + D3DXVECTOR3(0.0f, 50.0f, 0.0f));
				Query.EndPosition = (HitPosition - D3DXVECTOR3(0.0f, 50.0f, 0.0f));
				Query.CollisionFlags = (INTERSECT_OBJECTS | IGNORE_NONSOLID | INTERSECT_HPOLY);
				Query.ObjectFilterOne = FilterObjectsCallback;
				(Info -> ImpactObject) = (OtherPlayer -> Object);
				(Info -> ImpactPosition) = HitPosition;
				return true;
			};
		};
	};
	return OriginalIntersectSegment(Query, Info);
};
Seems to work. I've successfully hooked it, I know that much.
However, even though it displays a red player name on my screen, even if I actually am aiming at them - I don't deal any damage.

Help? Just trying to setup a simple remote kill...
Like @vaisefud3 said
Anyway I will share the remote kill today
Quote Originally Posted by (Virus) View Post


Like @vaisefud3 said
Anyway I will share the remote kill today
Be my guest, crossfire is ded
Quote Originally Posted by (Virus) View Post


Like @vaisefud3 said
Anyway I will share the remote kill today
please dont ruin this fucking game
also, returning the results of the original function does the same thing.

- - - Updated - - -

Quote Originally Posted by vaisefud3 View Post
Be my guest, crossfire is ded
returning the results of the original function does the same thing.
Code:
	bool mRemotekill(IntersectQuery* rQuery, IntersectInfo* rInfo)
	{
		int BONE_ID = 6;

		switch (MenuRemoteBone)
		{
			case 1: BONE_ID = 5; break; // Neck
			case 2: BONE_ID = 2; break; // Body
			case 3: BONE_ID = 10; break; // Left Hand
			case 4: BONE_ID = 17; break; // Right Hand
			case 5: BONE_ID = 23; break; // Left Foot
			case 6: BONE_ID = 28; break; // Right Foot
			default: BONE_ID = 6; // Head
		}

		int TargetIndex = GetNearestBy360();

		switch (MenuRemoteMode)
		{
			case 1: TargetIndex = GetNearestByCrossHair(); break;
			case 2: TargetIndex = GetNearestByDistance(); break;
			default: TargetIndex = GetNearestBy360();
		}
		CPlayer* MyPlayer = Engine->GetPlayerByIndex(Engine->GetMyIndex());
		if (TargetIndex != -1)
		{
			CPlayer* TargetPlayer = Engine->GetPlayerByIndex(TargetIndex);
			if (MyPlayer && MyPlayer->Object && TargetPlayer->Object && TargetPlayer->CharacterFx && !TargetPlayer->CharacterFx->IsDead())
			{
				if(TargetPlayer->Team != MyPlayer->Team)
				{
					if (MenuRemoteVisibleCheck == 1)
					{
						if (Engine->IsVisible(Engine->GetBonePosition(MyPlayer->Object, 6), Engine->GetBonePosition(TargetPlayer->Object, 6)) && Engine->isValidClient(TargetPlayer))
						{
							int IsRemoteKey = VK_LBUTTON;

							switch (MenuRemoteKey)
							{
								case 1: IsRemoteKey = VK_LBUTTON; break;
								case 2: IsRemoteKey = VK_RBUTTON; break;
								case 3:	IsRemoteKey = VK_SHIFT; break;
								case 4:	IsRemoteKey = VK_MENU; break;
								default: IsRemoteKey = VK_LBUTTON;
							}
							if (GetAsyncKeyState(IsRemoteKey) < 0)
							{
								D3DXVECTOR3 Pos = Engine->GetBonePosition(TargetPlayer->Object, BONE_ID);
								rQuery->m_From = Pos + D3DXVECTOR3(0.0f, 50.0f, 0.0f);
								rQuery->m_To = Pos - D3DXVECTOR3(0.0f, 50.0f, 0.0f);
								rQuery->m_Flags = ::INTERSECT_OBJECTS|::INTERSECT_HPOLY|::IGNORE_NONSOLID;
								rQuery->m_FilterFn = FilterObjects;

								bool Result = pIntersectSegment(*rQuery, rInfo);
								if (Result)
								{
									rInfo->hObjImpact = TargetPlayer->Object;
									rInfo->vImpactPos = Pos;
								}
								return pIntersectSegment(*rQuery, rInfo);
							}
						}
					}
				}
			}
		}
		return pIntersectSegment(*rQuery, rInfo);
	}
Credits: @aS1an1Sm, @~FALLEN~, @MiNT, @gellin, @vaisefud3, @giniyat101
Quote Originally Posted by MemoryThePast View Post
Code:
	bool mRemotekill(IntersectQuery* rQuery, IntersectInfo* rInfo)
	{
		int BONE_ID = 6;

		switch (MenuRemoteBone)
		{
			case 1: BONE_ID = 5; break; // Neck
			case 2: BONE_ID = 2; break; // Body
			case 3: BONE_ID = 10; break; // Left Hand
			case 4: BONE_ID = 17; break; // Right Hand
			case 5: BONE_ID = 23; break; // Left Foot
			case 6: BONE_ID = 28; break; // Right Foot
			default: BONE_ID = 6; // Head
		}

		int TargetIndex = GetNearestBy360();

		switch (MenuRemoteMode)
		{
			case 1: TargetIndex = GetNearestByCrossHair(); break;
			case 2: TargetIndex = GetNearestByDistance(); break;
			default: TargetIndex = GetNearestBy360();
		}
		CPlayer* MyPlayer = Engine->GetPlayerByIndex(Engine->GetMyIndex());
		if (TargetIndex != -1)
		{
			CPlayer* TargetPlayer = Engine->GetPlayerByIndex(TargetIndex);
			if (MyPlayer && MyPlayer->Object && TargetPlayer->Object && TargetPlayer->CharacterFx && !TargetPlayer->CharacterFx->IsDead())
			{
				if(TargetPlayer->Team != MyPlayer->Team)
				{
					if (MenuRemoteVisibleCheck == 1)
					{
						if (Engine->IsVisible(Engine->GetBonePosition(MyPlayer->Object, 6), Engine->GetBonePosition(TargetPlayer->Object, 6)) && Engine->isValidClient(TargetPlayer))
						{
							int IsRemoteKey = VK_LBUTTON;

							switch (MenuRemoteKey)
							{
								case 1: IsRemoteKey = VK_LBUTTON; break;
								case 2: IsRemoteKey = VK_RBUTTON; break;
								case 3:	IsRemoteKey = VK_SHIFT; break;
								case 4:	IsRemoteKey = VK_MENU; break;
								default: IsRemoteKey = VK_LBUTTON;
							}
							if (GetAsyncKeyState(IsRemoteKey) < 0)
							{
								D3DXVECTOR3 Pos = Engine->GetBonePosition(TargetPlayer->Object, BONE_ID);
								rQuery->m_From = Pos + D3DXVECTOR3(0.0f, 50.0f, 0.0f);
								rQuery->m_To = Pos - D3DXVECTOR3(0.0f, 50.0f, 0.0f);
								rQuery->m_Flags = ::INTERSECT_OBJECTS|::INTERSECT_HPOLY|::IGNORE_NONSOLID;
								rQuery->m_FilterFn = FilterObjects;

								bool Result = pIntersectSegment(*rQuery, rInfo);
								if (Result)
								{
									rInfo->hObjImpact = TargetPlayer->Object;
									rInfo->vImpactPos = Pos;
								}
								return pIntersectSegment(*rQuery, rInfo);
							}
						}
					}
				}
			}
		}
		return pIntersectSegment(*rQuery, rInfo);
	}
Credits: @aS1an1Sm, @~FALLEN~, @MiNT, @gellin, @vaisefud3, @giniyat101
Fuck
why !!!!!!!
BTW he still need hook it
Quote Originally Posted by (Virus) View Post


Fuck
why !!!!!!!
BTW he still need hook it
The hook? easy part...

Code:
DWORD pLTClient = *(DWORD*)(ILTClient);
pIntersectSegment = (_IntersectSegment)*(DWORD*)(pLTClient + 0x7C);
*(DWORD*)(pLTClient + 0x7C) = (DWORD)mRemotekill;
Quote Originally Posted by (Virus) View Post


Fuck
why !!!!!!!
BTW he still need hook it
no need to worry because this remotekill already posted many times
Quote Originally Posted by MemoryThePast View Post
Code:
	bool mRemotekill(IntersectQuery* rQuery, IntersectInfo* rInfo)
	{
		int BONE_ID = 6;

		switch (MenuRemoteBone)
		{
			case 1: BONE_ID = 5; break; // Neck
			case 2: BONE_ID = 2; break; // Body
			case 3: BONE_ID = 10; break; // Left Hand
			case 4: BONE_ID = 17; break; // Right Hand
			case 5: BONE_ID = 23; break; // Left Foot
			case 6: BONE_ID = 28; break; // Right Foot
			default: BONE_ID = 6; // Head
		}

		int TargetIndex = GetNearestBy360();

		switch (MenuRemoteMode)
		{
			case 1: TargetIndex = GetNearestByCrossHair(); break;
			case 2: TargetIndex = GetNearestByDistance(); break;
			default: TargetIndex = GetNearestBy360();
		}
		CPlayer* MyPlayer = Engine->GetPlayerByIndex(Engine->GetMyIndex());
		if (TargetIndex != -1)
		{
			CPlayer* TargetPlayer = Engine->GetPlayerByIndex(TargetIndex);
			if (MyPlayer && MyPlayer->Object && TargetPlayer->Object && TargetPlayer->CharacterFx && !TargetPlayer->CharacterFx->IsDead())
			{
				if(TargetPlayer->Team != MyPlayer->Team)
				{
					if (MenuRemoteVisibleCheck == 1)
					{
						if (Engine->IsVisible(Engine->GetBonePosition(MyPlayer->Object, 6), Engine->GetBonePosition(TargetPlayer->Object, 6)) && Engine->isValidClient(TargetPlayer))
						{
							int IsRemoteKey = VK_LBUTTON;

							switch (MenuRemoteKey)
							{
								case 1: IsRemoteKey = VK_LBUTTON; break;
								case 2: IsRemoteKey = VK_RBUTTON; break;
								case 3:	IsRemoteKey = VK_SHIFT; break;
								case 4:	IsRemoteKey = VK_MENU; break;
								default: IsRemoteKey = VK_LBUTTON;
							}
							if (GetAsyncKeyState(IsRemoteKey) < 0)
							{
								D3DXVECTOR3 Pos = Engine->GetBonePosition(TargetPlayer->Object, BONE_ID);
								rQuery->m_From = Pos + D3DXVECTOR3(0.0f, 50.0f, 0.0f);
								rQuery->m_To = Pos - D3DXVECTOR3(0.0f, 50.0f, 0.0f);
								rQuery->m_Flags = ::INTERSECT_OBJECTS|::INTERSECT_HPOLY|::IGNORE_NONSOLID;
								rQuery->m_FilterFn = FilterObjects;

								bool Result = pIntersectSegment(*rQuery, rInfo);
								if (Result)
								{
									rInfo->hObjImpact = TargetPlayer->Object;
									rInfo->vImpactPos = Pos;
								}
								return pIntersectSegment(*rQuery, rInfo);
							}
						}
					}
				}
			}
		}
		return pIntersectSegment(*rQuery, rInfo);
	}
Credits: @aS1an1Sm, @~FALLEN~, @MiNT, @gellin, @vaisefud3, @giniyat101
thanks but i already got it working

- - - Updated - - -

Quote Originally Posted by vaisefud3 View Post
The hook? easy part...

Code:
DWORD pLTClient = *(DWORD*)(ILTClient);
pIntersectSegment = (_IntersectSegment)*(DWORD*)(pLTClient + 0x7C);
*(DWORD*)(pLTClient + 0x7C) = (DWORD)mRemotekill;
yup
i was using MinHook on the raw address originally until I switched to using a reference swap in LTClient (also, thanks to you and my friend for helping me understand that concept better)

already got it tho

- - - Updated - - -

Quote Originally Posted by (Virus) View Post


Fuck
why !!!!!!!
BTW he still need hook it
dude i said i already hooked it in the first post lol
Quote Originally Posted by vaisefud3 View Post
The hook? easy part...

Code:
DWORD pLTClient = *(DWORD*)(ILTClient);
pIntersectSegment = (_IntersectSegment)*(DWORD*)(pLTClient + 0x7C);
*(DWORD*)(pLTClient + 0x7C) = (DWORD)mRemotekill;
credtis to Davinci Junior the MXVIII
for being the first to publish
Code:
class EngineHook
{
public:
	EngineHook()
	{
		memset(this, 0, sizeof(EngineHook));
	}

	EngineHook(DWORD* ppdwClassBase)
	{
		bInitialize(ppdwClassBase);
	}

	~EngineHook()
	{
		UnHook();
	}

	bool bInitialize(DWORD* ppdwClassBase)
	{
		dwClassBase = ppdwClassBase;
		m_OldVT = *ppdwClassBase;
		*ppdwClassBase = m_OldVT;
		return true;
	}

	void UnHook()
	{
		if (dwClassBase && m_OldVT)
		{
			*dwClassBase = m_OldVT;
		}
	}
	void ReHook()
	{
		if (dwClassBase && m_NewVT)
		{
			*dwClassBase = m_NewVT;
		}
	}

	DWORD HookFunction(DWORD dwNewFunc)
	{
		if (m_OldVT)
		{
			m_NewVT = dwNewFunc;
			return m_OldVT;
		}
		return NULL;
	} 
private:
	DWORD* dwClassBase;
	DWORD m_NewVT, m_OldVT;
};

EngineHook* IntersectSegment;

IntersectSegment = new EngineHook((DWORD*)I::IntersectSegment); 
oIntersectSegment = (IntersectSegmentFn)IntersectSegment->HookFunction((DWORD)Hooks::hkIntersectSegment);

IntersectSegment->ReHook()
IntersectSegment->UnHook()
Quote Originally Posted by jayjay153 View Post
Code:
class EngineHook
{
public:
	EngineHook()
	{
		memset(this, 0, sizeof(EngineHook));
	}

	EngineHook(DWORD* ppdwClassBase)
	{
		bInitialize(ppdwClassBase);
	}

	~EngineHook()
	{
		UnHook();
	}

	bool bInitialize(DWORD* ppdwClassBase)
	{
		dwClassBase = ppdwClassBase;
		m_OldVT = *ppdwClassBase;
		*ppdwClassBase = m_OldVT;
		return true;
	}

	void UnHook()
	{
		if (dwClassBase && m_OldVT)
		{
			*dwClassBase = m_OldVT;
		}
	}
	void ReHook()
	{
		if (dwClassBase && m_NewVT)
		{
			*dwClassBase = m_NewVT;
		}
	}

	DWORD HookFunction(DWORD dwNewFunc)
	{
		if (m_OldVT)
		{
			m_NewVT = dwNewFunc;
			return m_OldVT;
		}
		return NULL;
	} 
private:
	DWORD* dwClassBase;
	DWORD m_NewVT, m_OldVT;
};

EngineHook* IntersectSegment;

IntersectSegment = new EngineHook((DWORD*)I::IntersectSegment); 
oIntersectSegment = (IntersectSegmentFn)IntersectSegment->HookFunction((DWORD)Hooks::hkIntersectSegment);

IntersectSegment->ReHook()
IntersectSegment->UnHook()
i already tried it but nothings happen
Quote Originally Posted by MemoryThePast View Post
i already tried it but nothings happen
replace the reference in LTClient using a pointer, backup the original
credit: vaisefud, kakashi

or hook the actual routine using MinHook @ 0x683F70 (CFWest)
you can copy the instructions into a new block of memory using malloc() to create a backup
you'll need to calculate the function size dynamically
you can also use MinHook's returned backup, but for me it doesn't seem to work right
credit: me, jdp (not mpgh), eternal (not mpgh)
Posts 1–15 of 19 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?