Im trying to figure out how to get the names of different kind of objects. But this really drives me insane. After reading serveral topics here this is what I came up with. Would be really thankful if someone could have a look at my code and tell me what Ive missed.
Code:
public class WoWObject
{
[UnmanagedFunctionPointer(CallingConvention.ThisCall, CharSet = CharSet.Ansi)]
private delegate IntPtr GetNameDelegate(IntPtr objectPtr);
private GetNameDelegate _GetName;
protected IntPtr _Pointer;
etc.etc.
}
_Pointer is the base address of an object. Im "quite" sure this is the right one since its what I use when I enumrerate the linked list, and so on. ;P
and where I get the name
Code:
public string Name
{
get
{
if (_GetName == null)
{
IntPtr ptr = Marshal.ReadIntPtr(_Pointer, (51 * 4));
_GetName = Utilities.RegisterDelegate<GetNameDelegate>(ptr);
}
return Marshal.PtrToStringAnsi(_GetName(_Pointer));
}
}
IntPtr ptr = Marshal.ReadIntPtr(_Pointer, (51 * 4));
This is where it fails.... I get 0 as return value. Im fairly sure that BaseAddress + 51*4 should be where the virtual function pointer is stored? Or what am I missing?