PDA

View Full Version : Hook on CBaseCombatCharcter-Functions


Roger Devil
03-06-2005, 06:29
Hi
i have read the threads about hooking virtual functions of any class in the SDK.
Nevertheless i have a small question :
How to hook functions in CBaseComabtCharacter - Class ???
For engine -functions i can directly use IVEngineServer as the entry point,
but what about CBaseCombatCharacter ???
The only way i see is IPlayerInfo, but this is only a member of CBasePlayer.

What I want to do is calculate the damage inflicted to a player and getting the hitboxes, or is there an easier way to get this info ???
Can somebody help me ???

Mani
03-07-2005, 05:33
XAD knows how to do this, I think his project tracks hit box damage.

Mani

XAD
03-07-2005, 07:02
XAD knows how to do this, I think his project tracks hit box damage.
Damn you Mani,... pointing finger at me... :wink: :D

What I want to do is calculate the damage inflicted to a player and getting the hitboxes, or is there an easier way to get this info ???
Can somebody help me ???
Well, you don't have to calculate it... in CSS (for linux) you can get it compensated for both ammo-type, body-part (and distance?)... I hook a couple of functions in a couple of classes and using event-messages and timers... But you get the bodyhits in one functions with damage not fully compensated, and the real damage in another one. Some weapons, such as grenades, do not get the bodyhits info, as bodyhit only exist for "aiming" firearms (at least what I have tracked and logged)...

Unless you understand virtual tables, know how to hook and what happens (as all objects do not share the same vtable but some do), I would use SourceMod...

/X

Roger Devil
03-07-2005, 11:18
Hi XAD,
i know what a virtual-function table is, is the table at the first address of the class.
My Problem is how to find out at which position the function OnTakeDamage_Alive() for class CBaseCombatCharacter is, that i can overwrite the address with my own function.

vancelorgin
03-11-2005, 02:07
The lost art of counting works - or, if you're a lazy fuck [read: me], just call the func and put a breakpoint before it, debug the bitch and copy the offset.

PM
03-11-2005, 07:53
If you are compiling on GCC:


-fdump-class-hierarchy (C++ only)
-fdump-class-hierarchy-options (C++ only)
Dump a representation of each class's hierarchy and virtual function table layout to a file. The file name is made by appending .class to the source file name. If the -options form is used, options controls the details of the dump as described for the -fdump-tree options.

(http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Debugging-Options.html#Debugging-Options)

Under MSVC, breakpoint/disassembly, as lance said.

I prefer this method over counting, because the compiler may do weird things if it is a derived class ;o

vancelorgin
03-11-2005, 15:05
fuck damn that's handy

fysh
03-11-2005, 19:54
You can also load gdb and type disassemble funcname to get it.

vancelorgin
03-12-2005, 19:07
Not in windows - you linux people and your symbol info - scoff - envy :(

Roger Devil
03-15-2005, 01:31
Thanx for your help, got it working under Windows, under Linux I retrieved Segmentation Fault.

Have to find out whats wrong here

Roger Devil
03-16-2005, 10:51
If you are compiling on GCC:


-fdump-class-hierarchy (C++ only)
-fdump-class-hierarchy-options (C++ only)
Dump a representation of each class's hierarchy and virtual function table layout to a file. The file name is made by appending .class to the source file name. If the -options form is used, options controls the details of the dump as described for the -fdump-tree options.

(http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Debugging-Options.html#Debugging-Options)

Under MSVC, breakpoint/disassembly, as lance said.

I prefer this method over counting, because the compiler may do weird things if it is a derived class ;o

High PM, have tried this option with the gcc 3.4.3 compiler, got unknown command line option
-g -gccdb is o.k., anything else i have to do ???

PM
03-16-2005, 11:07
Hmm, what command line did you use? It seemed to work for me... GCC 3.4.something I guess.

Roger Devil
03-18-2005, 04:32
Got the following error :
/fat-g/gcc-3.4.3/usr/bin/g++-gcc-3.4.3 -I../dlls -I../game_shared -I../public/tier0 -I../public/tier1 -I../public/dlls -I../public/game_shared -I../public -Iinclude -w -fpermissive -fdump-class-hierachy -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -fPIC -mtune=i686 -march=pentium -mmmx -O3 -Usprintf=use_Q_snprintf_instead_of_sprintf -Ustrncpy=use_Q_strncpy_instead -UPROTECTED_THINGS_ENABLE -DARCH=i486 -o obj/plugin/statsmeminimum_convar.o -c ../utils/statsmeminimum_s/statsmeminimum_convar.cpp
cc1plus: error: unrecognized command line option "-fdump-class-hierachy"
make: *** [obj/plugin/statsmeminimum_convar.o] Error 1