Raised This Month: $32 Target: $400
 8% 

Calculating a virtual function offset from a signature


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 09-29-2010 , 20:28   Calculating a virtual function offset from a signature
Reply With Quote #1

I have come up with this rather simple solution for calculating a virtual offset of a function given it's signature. My only annoyance with this solution is that it requires an object with the respective virtual table in order to calculate the offset.

I would quite like a solution which does not require an object in order to calculate the offset mainly so all the calculations can be done when the plugin loads rather than when the first instance of an object appears. Other than reading op-codes from the class constructor (which would require another signature), is there another method of locating the address of a virtual table, using RTTI perhaps?

Here is what I have currently: http://hg.paulclothier.com/OBV_CHax/...nsion.cpp#l150 and yes I know, there's some terri-bad coding in there but I am only interested in the concepts at the moment.
Wazz is offline
pRED*
Join Date: Dec 2006
Old 09-30-2010 , 04:29   Re: Calculating a virtual function offset from a signature
Reply With Quote #2

On linux the vtable has a symbol, so you can look this up fairly trivially.

Windows would be more interesting, finding a byte signature that doesn't break would probably be difficult.

The vtable is definitely locatable using RTTI information, though I haven't look into this.

If you look for IDA plugins (on OpenRCE) and find one called MSVC reversing helpers (I think), and run the ms_rtti4.idc it will dump a text file with all the vtable addresses. It should be possible to use similar logic at runtime.

I can find a download link tomorrow if you can't find it.
pRED* is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 10-05-2010 , 21:12   Re: Calculating a virtual function offset from a signature
Reply With Quote #3

Thanks for the tip, It has taken me a while (and the TF2 update put this on hold for a short while) but I have finally been able to locate class vtables using RTTI. I will clean up the code soon and push it to the repo, in case anyone is interested.
Wazz is offline
Reply


Thread Tools
Display Modes

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 22:26.


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