Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Blockable change team hook
Blockable change team hook [message #469929] Tue, 26 June 2012 11:57 Go to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Could a blockable team change hook be added?

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
Re: Blockable change team hook [message #470127 is a reply to message #469929] Thu, 28 June 2012 02:30 Go to previous messageGo to next message
StealthEye is currently offline  StealthEye
Messages: 2518
Registered: May 2006
Location: The Netherlands
Karma: 0
General (2 Stars)

TT hooks the event at 0x004B4910, you can hook that place yourself and call the TT hook function iff you don't want it to be blocked.

It's not too hard to make a proper hook for it though, so I'll add it to the TODO.


BlackIntel admin/founder/coder
Please visit http://www.blackintel.org/
Re: Blockable change team hook [message #470131 is a reply to message #469929] Thu, 28 June 2012 02:42 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
I guess I could try that out, I've never modified a hook like that so it sounds challenging.

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

[Updated on: Thu, 28 June 2012 03:16]

Report message to a moderator

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: 0
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
Previous Topic: Advanced Listings - Nothing there
Next Topic: Client object changes via Resource downloader
Goto Forum:
  


Current Time: Thu Nov 07 19:29:02 MST 2024

Total time taken to generate the page: 0.01026 seconds