Hello everyone,
I have been following some tutorials and now I'm trying to work with an ObjectManager to get some more understanding of the whole process.
After some reading I'm quite understanding the architecture of the WoWObjects and with some help of sample code I made a little program which should return (my) player object.
There is going something wrong (I think with the player base), because the WowObject that I'm creating has some invalid values. For example, the WoWobject carries a (int) Type to see which type of object it is. It has to be something like 1,2,3,4 but it returns something like 899283829. There COULD be an offset wrong, but I went through the dump and couldn't find my mistake. Hopefully you guys can see my problem so I can (finally) move on.
ObjectManager class:
Code:
static class ObjectManager
{
public static BlackMagic WowReader = new BlackMagic();
private const uint staticClientConnection = 0x009BE678, // client connection, same address every boot
objectManagerOffset = 0x463C, // offset from the ClientConnection to the object manager
localGuidOffset = 0xC8, // offset from the object manager to the local guid
firstObjectOffset = 0xC0, // offset from the object manager to the first object
nextObjectOffset = 0x3C; // offset from one object to the next
static private uint objectManagerBase; // the address off the object manager
static public ulong localGuid; // the local guid.
public static PlayerObject LocalPlayer;
public static IDictionary<ulong, PlayerObject> PlayerObjectList = new Dictionary<ulong, PlayerObject>();
public static void LoadAddresses()
{
WowReader.OpenProcessAndThread(SProcess.GetProcessFromProcessName("Wow"));
objectManagerBase = WowReader.ReadUInt(WowReader.ReadUInt(staticClientConnection + (uint)WowReader.MainModule.BaseAddress) + objectManagerOffset);
localGuid = (uint)WowReader.ReadInt64((uint)(objectManagerBase + localGuidOffset));
}
public static void PopulateLists()
{
PlayerObjectList.Clear();
WowObject CurrentObject = new WowObject(WowReader.ReadUInt((objectManagerBase + firstObjectOffset)));
while (CurrentObject.BaseAddress != 0 && CurrentObject.BaseAddress % 2 == 0)
{
if (CurrentObject.Type == 4) { // a player
PlayerObjectList.Add(CurrentObject.Guid, new PlayerObject(CurrentObject.BaseAddress));
if (CurrentObject.Guid == localGuid) // it is the local player
LocalPlayer = PlayerObjectList[localGuid];
}
CurrentObject.BaseAddress = WowReader.ReadUInt((CurrentObject.BaseAddress + nextObjectOffset));
}
}
}
WoWObjects
Code:
class WowObject
{
protected const uint GuidOffset = 0x0,
NextObjectOffset = 0x3C,
TypeOffset = 0x10,
XPositionOffset = 0x790,
YPositionOffset = 0x794,
ZPositionOffset = 0x798,
RotationOffset = XPositionOffset + 0x10,
DescriptorFieldsOffset = 0xc;
protected uint baseAddress;
public WowObject(uint baseAddress)
{
this.baseAddress = baseAddress;
}
public uint BaseAddress
{
get { return baseAddress; }
set { baseAddress = value; }
}
public uint DescriptorFields
{
get { return ObjectManager.WowReader.ReadUInt((BaseAddress + DescriptorFieldsOffset)); }
}
public int Type
{
get { return ObjectManager.WowReader.ReadInt((BaseAddress + TypeOffset)); }
}
public virtual UInt64 Guid
{
get { return ObjectManager.WowReader.ReadUInt64((BaseAddress + GuidOffset)); }
set { return; }
}
public virtual float XPosition
{
get { return ObjectManager.WowReader.ReadFloat((BaseAddress + XPositionOffset)); }
}
public virtual float YPosition
{
get { return ObjectManager.WowReader.ReadFloat((BaseAddress + YPositionOffset)); }
}
public virtual float ZPosition
{
get { return ObjectManager.WowReader.ReadFloat((BaseAddress + ZPositionOffset)); }
}
public float Rotation
{
get { return ObjectManager.WowReader.ReadFloat((BaseAddress + RotationOffset)); }
}
}
class CreatureObject : WowObject
{
protected const uint LevelOffset = 0x20 + 0xA0 * 4,
CurrentHealthOffset = 0x20 + 0x48 * 4,
MaxHealthOffset = 0x20 + 0x60 * 4,
CurrentManaOffset = 0x20 + 0x1AC * 4,
MaxManaOffset = 0x20 * 4,
TargetGuidOffset = 0x20 + 0x30 * 4;
public CreatureObject(uint BaseAddress)
: base(BaseAddress)
{ }
public UInt64 TargetGuid
{
get { return ObjectManager.WowReader.ReadUInt64((DescriptorFields + TargetGuidOffset)); }
}
public int Level
{
get { return ObjectManager.WowReader.ReadInt((DescriptorFields + LevelOffset)); }
}
public int CurrentHealth
{
get { return ObjectManager.WowReader.ReadInt((DescriptorFields + CurrentHealthOffset)); }
}
public int MaxHealth
{
get { return ObjectManager.WowReader.ReadInt((DescriptorFields + MaxHealthOffset)); }
}
public int CurrentMana
{
get { return ObjectManager.WowReader.ReadInt((DescriptorFields + CurrentManaOffset)); }
}
public int MaxMana
{
get { return ObjectManager.WowReader.ReadInt((DescriptorFields + MaxManaOffset)); }
}
public int HealthPercent
{
get
{
double percentage = CurrentHealth / MaxHealth;
percentage = percentage * 100;
return (int)Math.Round(percentage);
}
}
}
There could be an offset wrong, but I am not sure.. I hope someone is able to assist me with this problem. And I do have one question; how are you able to debug with Memory editing? How do you know what you're doing wrong, like having a wrong offset? You're not getting an exception, just wrong data.
Thanks alot,
Require