Utilities
Code:
public IntPtr GetVMTFunction(IntPtr baseAddress, uint methodIndex)
{
return Read<IntPtr>(baseAddress, new IntPtr(methodIndex * 4));
}
public T RegisterDelegate<T>(IntPtr address) where T : class
{
return Marshal.GetDelegateForFunctionPointer(address, typeof(T)) as T;
}
Points
Code:
[StructLayout(LayoutKind.Sequential)]
public struct WowPoint
{
public float X;
public float Y;
public float Z;
}
Point3D
The function
Code:
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate int GetPositionDelegate(IntPtr instance, out WowPoint position);
private GetPositionDelegate _getPositionHandler;
How to use it
Code:
public Point3D Position
{
get
{
if (this._getPositionHandler == null)
{
this._getPositionHandler = AdvantageBase.Memory.RegisterDelegate<GetPositionDelegate>(AdvantageBase.Memory.GetVMTFunction(this, Addresses.VMTIndex.GetPosition));
}
WowPoint p;
this._getPositionHandler(this, out p);
return new Point3D(p.X, p.Y, p.Z);
}
}
That is the way I am doing it.
And if it hasn't changed (which i doubt it has) GetPosition is at index 12 in the object VMT.
I remember i had some trouble with WowPoints as well, that is why i prefer to cast them to my own points, and make wrappers for all the functions that need WowPoints.