Raised This Month: $51 Target: $400
 12% 

Hooking [engine/any virtual] functions... from a plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 01-04-2005 , 21:06  
Reply With Quote #11

Any possibility you could point us noobs in the direction of say a book/site that taught you guys this stuff?
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 01-05-2005 , 00:27  
Reply With Quote #12

::edit:: lol - nice idea about the struct of funcs. I'm far too lazy for that, however

Please watch your terminology. You aren't copying the functions, you're copying their addresses in the vtable. I've written funcs to copy functions before - not fun :/

About the 'about the custom vtable' - for some reason I thought you were implying 'try this'. I was and am tired - my apologies. Please, however, try it in linux. If it doesn't work, then I'll have to find another solution (though it's fkn linux, so I can detour the exact func I want ). This is pretty mandatory, though, as it's required for custom entities (unless you want an std::map scan on every single entity func we need for every single entity ever. Retarded.)

Further edit:

"With your info about "virtual" I checked the vtable and then thought why not change the pointers in the original vtable to your own functions?? "

That's exactly what I do, and have done for weeks now....... look at the macros... it's what that code does........
__________________
Avoid like the plague.
vancelorgin is offline
XAD
Senior Member
Join Date: Mar 2004
Location: Sweden
Old 01-05-2005 , 03:46  
Reply With Quote #13

Quote:
Originally Posted by Geesu
Any possibility you could point us noobs in the direction of say a book/site that taught you guys this stuff?
Yea :pointing-at: vancelorgin...

My "direction" is vancelorgin's first post in the thread... then I used my mdump server command (display memory in hex and printable chars, 16 per row) and a command to display the current engines class pointer... after that, well the hard part was to fool the GCC compiler as you are not allowed to cast virtual object functions (thats why my casting looks so ugly)...

Quote:
Originally Posted by vancelorgin
::edit:: lol - nice idea about the struct of funcs. I'm far too lazy for that, however
Well didn't take many minutes as it is only a slightly modified code from the IVEngineServer Class in the header file.

Quote:
Originally Posted by vancelorgin
Please watch your terminology. You aren't copying the functions, you're copying their addresses in the vtable. I've written funcs to copy functions before - not fun :/
Ouch... you are right... copying the functions would have been bad...
Well, to be correct I should then also correct myself and say I use a structure of function pointers and not a structure of functions... :hurtme:

Quote:
Originally Posted by vancelorgin
...Please, however, try it in linux...
Well I think I will leave that exercise to you as I have a feeling it could cause problems...

Quote:
Originally Posted by vancelorgin
...That's exactly what I do, and have done for weeks now....... look at the macros... it's what that code does...
Sorry... but well as I thought function pointer copying would be enough I didn't even check your assemblers and macros as I couldn't think of why you would need it and therefore I didn't dig in to it (but that's also why I asked in my reply if it was doing something more)....

/X

PS! Again... thanks for sharing your knowledge and findings :bowdown:... without your first post I wouldn't have been able to do my "hooking" so easy as the code I use to override three engine functions now looks as:
SET_ENGINEFUNC(LogPrint,MetaLogPrint);
SET_ENGINEFUNC(UserMessageBegin,MetaUserMessa geBegin);
SET_ENGINEFUNC(MessageEnd,MetaMessageEnd);
XAD is offline
Reply



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 13:50.


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