Raised This Month: $ Target: $400
 0% 

New Virtual function table hook - worlds better, linux compa


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 01-18-2005 , 19:20   New Virtual function table hook - worlds better, linux compa
#1

Well this one's alot better. Again, it lets you hook virtual funcs on any class, but this time it's alot easier to work with, can do more, is faster, smaller, and should make the same code work on windows and linux with no hassle to the coder. Not a bad update. I horribly overengineered the first one. My bad - I blame the drugs. The goods are in the attachment, but here's a HL2 sample:

Code:
//declare the original func and the gate if in windows. syntax is:
//DEFVFUNC_
//        <name of the var you want to hold the original func>,
//        <return type>,
//        <args INCLUDING a pointer to the type of class it is in the beginning>
DEFVFUNC_(engine_CreateEdict, edict_t*, (IVEngineServer* pEngine, int iForceEdictIndex));

//just define the func you want to be called instead of the original
//making sure to include VFUNC between the return type and name
edict_t* VFUNC mycreateedict(IVEngineServer* pEngine, int iForceEdictIndex){
	LOG("Created edict: [%x] [%d]", pEngine, iForceEdictIndex);

	return engine_CreateEdict(pEngine, iForceEdictIndex);
}

your fkn load func {
//actually hooks the func. syntax is
//HOOKVFUNC
//        <a valid pointer to a class with that func in it>,
//        <the index of it in the vtable (weve been over this)>,
//        <name of original func var>,
//        <name of your hook func>
	HOOKVFUNC(engine, 21, engine_CreateEdict, mycreateedict);
}
Not too shabby eh?

This *should* work on linux - I went according to XAD's findings. I haven't even compiled it under linux though, but it's childishly simple to get working. When you do, please post so I can update the header
Attached Files
File Type: h vfnhook.h (3.9 KB, 610 views)
__________________
Avoid like the plague.
vancelorgin is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode