Like what, manual callclasses!
Hello people, it's me again.
Today I've decided to implement manual callclasses. What you need: In fact, the only thing you need to use the new manual callclasses is the newest sourcehook.h from CVS (the one commited today :) ). You don't need to update sourcemm or anything. How to use them: The first thing you need to do is request a manual callclass: Code:
SourceHook::ManualCallClass *mcc = SH_GET_MCALLCLASS(ptr, size);When you're done with the callclass, release it using SH_RELEASE_CALLCLASS as with normal callclasses. Assuming that you have declared a manual hook: Code:
SH_DECL_MANUALHOOK0_void(Some_Hook, vtable index, vtable offset, this ptr offset);Code:
SH_MCALL(mcc, Some_Hook)();Code:
typedef int (SourceHook::EmptyClass::*MFP_MyFunc)(const char *, bool);Code:
int ret = SH_MCALL2(mcc, MFP_MyFunc(), vtable index, vtable offset, this pointer offset)("hello", true);So, what about the size thing passed to SH_GET_MCALLCLASS ? Well, it should be larger than the maximal sum of vtable offset and this ptr offset you use on that callclass. Whatever, you most likely just need to use sizeof(void*), so that the callclass includes the first machine word (which is usually the vtable pointer) of the object. Have fun, report problems, if everything works, please say that it works for you. If you feel like it, you can add info about its usage to the wiki, otherwise I'll do it once I find my password. Thanks, your PM. |
Nicely done, PM :) this is very cool!
As mentioned on IRC, you can very well use this to call virtual functions you don't even bother hooking, if you just want the call ability. |
Quote:
|
Very nice PM, that's a useful addition to sourcehook.
I'll try switching some of my non-hooked vfunc calls to this method and let you know how I get on. |
LoL @ // The pope is dead. -> :(
|
The fixes for SH_CALL worked like a charm, thanks =)
|
Worked flawlessly for me too, calling a couple of CBaseCombatCharacter functions via offsets, and if I can ues it then anyone can :)
|
Ok this isn't working for the call classes...
Code:
SourceHook::ManualCallClass *mcc = SH_GET_MCALLCLASS( g_Players[iPlayer].pPlayer, sizeof(void*)); |
Neither is this...
Code:
typedef void (SourceHook::EmptyClass::*MFP_Teleport)( const Vector *, const QAngle *, const Vector * ); Quote:
Code:
sourcehook.h:3452 |
The topmost stack frame's address is 0xbaadf00d, so SH_MCALL actually jumped to that address).
I've seen that you do: Code:
SH_MCALL( mcc, Teleport_Hook)( &vecLocation, &qAngles, &vecVelocity ); |
| All times are GMT -4. The time now is 07:19. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.