Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Function Hooking
Re: Function Hooking [message #490118 is a reply to message #490117] Wed, 24 December 2014 17:41 Go to previous messageGo to previous message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma:
Recruit
jonwil wrote on Wed, 24 December 2014 14:42

If you want to hook Commands->Find_Object, just read the address out of that variable (the "original" Find_Object) then replace it with the address of your new function.
Your new funxtion would then call the stock function through the pointer you saved ealier.
p


That would result in an infinite loop? For example:

typedef GameObject *(** FindObjectPointer)(int);
FindObjectPointer OriginalFindObject;
GameObject *Find_Object_Test(int obj_id)
{
	Console_Output("Finding object with id: %d\n", obj_id);

	return (* OriginalFindObject)(obj_id);
}

TimeMachine::TimeMachine()
{
	OriginalFindObject = &Commands->Find_Object;
	*&Commands->Find_Object = &Find_Object_Test;
}


The OriginalFindObject would point right back to the hooked one. Im trying to catch all calls to the original method and then do some stuff. I'm just using Find_Object as an example, the actual command I'm going to target is Start_Timer.

When I compile and run this I get an infinite loop.

NOTE: I'm also trying to catch calls to the method outside of my DLL. So there's no other way than memory hooking it with a jump? Or am I just thinking to difficult right now?

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Human Animations System
Next Topic: C&C_Walls_Flying
Goto Forum:
  


Current Time: Wed May 15 10:41:29 MST 2024

Total time taken to generate the page: 0.01069 seconds