[Code] VTable Calls menu

User Tag List

Results 1 to 3 of 3
  1. #1
    wraithZX's Avatar Active Member
    Reputation
    43
    Join Date
    May 2007
    Posts
    122
    Thanks G/R
    0/1
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Code] VTable Calls

    The example below is something I cooked up to "mirror" the CGObject_C virtual functions.
    Basically, from version to version of WoW, you'll likely only need to update the indices.
    You can discover at runtime which entries in the vtable are used for each function, that's an exercise for the reader.
    And if you don't know how to do so, and wish to just update the indexes on a per-release basis.... have fun, but you're not going to learn anything by copy/pasting.

    Code:
    template <typename T, typename F>
    T CallVTable0(void *o, int fptr_idx)
    {
    	if(!o) return T();
    	void** vtable = (*reinterpret_cast<void***>(o));
    	F f = reinterpret_cast<F>(vtable[fptr_idx]);
    	return f(o);
    }
    
    template <typename T, typename F, typename T1>
    T CallVTable1(void *o, int fptr_idx, T1 t1)
    {
    	if(!o) return T();
    	void** vtable = (*reinterpret_cast<void***>(o));
    	F f = reinterpret_cast<F>(vtable[fptr_idx]);
    	return f(o, t1);
    }
    
    struct Object_Wrapper
    {
    private:
    	/* These have a first parameter acting as a 'this' pointer */
    	typedef void (__thiscall *fGetPosition)( void *o, WOWPOS& wowPos );
    	typedef float (__thiscall *fGetFacing)(void *o);
    	typedef float (__thiscall *fGetScale)(void *o);
    	typedef void (__thiscall *fInteract)(void *o);
    	typedef const char * (__thiscall *fGetObjectName)(void *o);
    
    	static const int fGetPositionVTidx = 9;
    	static const int fGetFacingVTidx = 10;
    	static const int fGetScaleVTidx = 11;
    	static const int fInteractVTidx = 38;
    	static const int fGetObjectNameVTidx = 48;
    
    public:
    	Object_Wrapper(void *object_) : object(object_) {}
    	void *object;
    
    	inline void GetPosition(WOWPOS& pos) { 
    		return CallVTable1<void,fGetPosition,WOWPOS&>(object, fGetPositionVTidx, pos); 
    	}
    	inline float GetFacing() { 
    		return CallVTable0<float,fGetFacing>(object, fGetFacingVTidx); 
    	}
    	inline float GetScale() { 
    		return CallVTable0<float,fGetScale>(object, fGetScaleVTidx); 
    	}
    	inline void Interact() { 
    		return CallVTable0<void,fInteract>(object, fInteractVTidx); 
    	}
    	inline const char * GetObjectName() { 
    		return CallVTable0<const char *,fGetObjectName>(object, fGetObjectNameVTidx); 
    	}
    };
    
    /******************************/
    /******************************/
    
    Object_Wrapper wplayer = GetObjectByGUID(g_curMgr->wLocal, -1);

    [Code] VTable Calls
  2. #2
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for contributing.

  3. #3
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unless you are doing runtime identification, doing this is no different to just constructing a normal VMT and using that.

    Thanks for sharing though, nice trick.

Similar Threads

  1. [Trading] Trading Reaper of Souls (code) for Call of Duty: Ghost (code for pc)
    By pavede in forum Diablo 3 Buy Sell Trade
    Replies: 0
    Last Post: 03-09-2014, 05:55 PM
  2. Replies: 11
    Last Post: 11-21-2011, 12:25 AM
  3. [CODE] Calling the Python disassembler from C
    By GliderPro in forum Programming
    Replies: 1
    Last Post: 05-14-2009, 06:58 PM
  4. [Out of Process] Calling functions in the VTable.
    By cenron in forum WoW Memory Editing
    Replies: 12
    Last Post: 01-31-2009, 08:39 PM
All times are GMT -5. The time now is 10:04 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search