I am having difficulty in understanding where I am going wrong with the below code to loop through objects and locate my character amongst them.
Below is the code I have
Offsets 18414 x86
Code:
enum Offsets : uint
{
PlayerName = 0xEC4668,
ObjMgr = 0xEC4628,
CurMgr = 0x462c,
LocalGUID = 0xE8,
FirstObject = 0xCC,
NextObject = 0x34
}
Classes Used (Simplified so you can see quickly whats happening)
Code:
public class WoWObject
{
public WoWObject(IntPtr BaseAddress)
{
this.BaseAddress = BaseAddress;
}
[Category("General"), Description("The objects base address pointer.")]
public IntPtr BaseAddress { get; set; }
[Category("Informations"), Description("Every object has an unique Guid. Use this to identify and access the object.")]
public ulong Guid
{
get
{
return MemSharp.Read<ulong>(this.BaseAddress + 40, false);
}
}
}
public class WoWUnit : WoWObject
{
public WoWUnit(IntPtr BaseAddress)
: base(BaseAddress)
{
}
}
public class WoWPlayerMe : WoWUnit
{
public WoWPlayerMe(IntPtr BaseAddress)
: base(BaseAddress)
{
}
}
Main Program Extract
Code:
ulong WoWBaseAddr = (ulong)MemSharp.Modules.MainModule.BaseAddress;
ulong ObjMgrBase = MemSharp.Read<ulong>(new IntPtr((uint)WoWBaseAddr + (uint)Offsets.ObjMgr) , false);
ulong ObjMgr = MemSharp.Read<ulong>(new IntPtr((uint)ObjMgrBase + (uint)Offsets.CurMgr) , false);
ulong PlayerGUID = MemSharp.Read<ulong>(new IntPtr((uint)ObjMgr + (uint)Offsets.LocalGUID) , false);
ulong CurObj = MemSharp.Read<ulong>(new IntPtr((uint)ObjMgr + (uint)Offsets.FirstObject) , false);
LogActivity("ObjMgrBase : 0x" + ObjMgrBase.ToString("X"));
LogActivity("ObjMgr : 0x" + ObjMgr.ToString("X"));
LogActivity("Player GUID: 0x" + PlayerGUID.ToString("X"));
LogActivity("CurObj : 0x" + CurObj.ToString("X"));
WoWPlayerMe Me;
while ((CurObj != 0) && ((CurObj & 1) == 0)) <-- This loop throws the error on first or 2nd loop
{
ulong num = MemSharp.Read<ulong>(new IntPtr((uint)CurObj + (uint)Offsets.NextObject), false);
WoWObject currentObj = new WoWObject((IntPtr)CurObj);
if (currentObj.Guid == PlayerGUID)
{
Me = new WoWPlayerMe((IntPtr)CurObj);
}
CurObj = num;
}
Outputs
Code:
Player Name: BobYesReallyBob
ObjMgrBase : 0xDA3B1580AF86D38
ObjMgr : 0xD9D1E90327F33C0
Player GUID: 0x9999999999999999 <-- This is correct but not showing it here
CurObj : 0x381280ED3C
Arithmetic operation resulted in an overflow. <-- The error I am encountering mentioned above