Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Blockable change team hook
Re: Blockable change team hook [message #470143 is a reply to message #469929] Thu, 28 June 2012 05:34 Go to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma:
General (4 Stars)
Done, took me a bit to figure the displacement out. :/

Doesn't trigger on TEAM2 and TEAM but you can just replace them (and have them call the original console commands):

Hook *TeamChangeHook = new Hook;
int TTHookAddress = 0;

bool __cdecl ChangeTeamHook(int ID)
{
	Console_Output("playerid = %d\n", ID);
	return true;
}

void _declspec(naked) TeamChangeHook_Glue()
{
	_asm
	{

		mov  edi, ecx
		push [edi+6B4h]
		call ChangeTeamHook
		add esp, 4;
		mov ecx, edi

		test al, al
		jz BlockTeamChange

		mov edi, TTHookAddress
		jmp edi

BlockTeamChange:
		retn
	}
}

Toys::Toys()
{
	char OpCodeBuffer[5];
	Hooking::ReadMemory(0x004B4910, OpCodeBuffer, 5); // 0x004B4910 is where the JMP opcode (E9) starts, next 4 are the displacement/relative address

	int Displacement;
	memcpy(&Displacement, OpCodeBuffer+1, sizeof(OpCodeBuffer)); // OpCodeBuffer+1 or we'll also read the JMP opcode

	TTHookAddress = 0x004B4910 + 5 + Displacement;
	Console_Output("displacement = %x, function address = 0x%X\n", Displacement, TTHookAddress);

	TeamChangeHook->Install('\xE9', 0x004B4910, (int)&TeamChangeHook_Glue, "");
}


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Advanced Listings - Nothing there
Next Topic: Client object changes via Resource downloader
Goto Forum:
  


Current Time: Thu Dec 12 05:10:46 MST 2024

Total time taken to generate the page: 0.00672 seconds