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