Hello, I'm working on my first bot for WoW and I'm having a huge problem creating the object manager. Im trying to, at this point, simply get the Guid and type of each object. Im not sure if the Guid is right, but im positive the type is wrong. Heres my code.
Code:
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using Magic;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public static BlackMagic wow;
IntPtr WowBase;
IntPtr WowData;
uint PlayerBase;
uint MovementData;
float CharPosX;
float CharPosY;
float CharPosZ;
float CharRotation;
//uint WM_KEYDOWN = 0x0100;
public class WowObject
{
uint GuidOffset = 0x30;
uint TypeOffset = 0x4;
protected uint BaseAddress;
public WowObject(uint BaseAddress)
{
this.BaseAddress = BaseAddress;
}
public long Type
{
get { return wow.ReadUInt(BaseAddress + TypeOffset); }
}
public uint Guid
{
get { return wow.ReadUInt(BaseAddress + GuidOffset); }
}
}
internal enum ClickToMove : uint
{
Angle = 0x9D43E4,
Base = 0x9D43D0,
DestinationX = Base+0x8C,
DestinationY = Base+0x90,
DestinationZ = Base+0x94,
Push = Base+0x1C,
StopDistance = 0x9D43DC,
TurnScale = 0x9D43D4
}
internal enum ObjectManager : uint
{
CurMgrPointer = 0x9BC9F8,
CurMgrOffset = 0x463C,
NextObject = 0x3C,
FirstObject = 0xC0,
LocalGUID = 0xC8
}
public Form1()
{
InitializeComponent();
}
public void DoObjectManager()
{
ObjectList.Items.Clear();
uint ObjBase = wow.ReadUInt(wow.ReadUInt((uint)WowBase+(uint)ObjectManager.CurMgrPointer)+(uint)ObjectManager.CurMgrOffset);
uint CurObj = wow.ReadUInt(ObjBase + (uint)ObjectManager.FirstObject);
uint NextObj = CurObj;
while (CurObj != 0 & CurObj % 2 == 0)
{
WowObject Object = new WowObject(wow.ReadUInt(CurObj));
ObjectList.Items.Add("Guid: " + Object.Guid);
ObjectList.Items.Add("Type: " + Object.Type);
ObjectList.Items.Add("\n");
NextObj = wow.ReadUInt(CurObj+(uint)ObjectManager.NextObject);
if (NextObj == CurObj)
{
break;
}
else
{
CurObj = NextObj;
}
}
}
public void newWowObject()
{
Process[] list = Process.GetProcesses();
foreach (Process p in list)
{
if (p.MainWindowTitle == "World of Warcraft")
{
PosX.Text = p.MainWindowHandle.ToString();
WowData = p.MainWindowHandle;
}
}
wow = new BlackMagic();
wow.OpenProcessAndThread(SProcess.GetProcessFromWindowTitle("World of Warcraft"));
WowBase = wow.MainModule.BaseAddress;
PlayerBase = wow.ReadUInt(wow.ReadUInt(wow.ReadUInt((uint)WowBase + 0x00A6EE68) + 0x38) + 0x24);
MovementData = wow.ReadUInt(PlayerBase + 0x100);
}
private void UpdatePlayerPos()
{
CharPosX = wow.ReadFloat(MovementData + 0x10);
CharPosY = wow.ReadFloat(MovementData + 0x14);
CharPosZ = wow.ReadFloat(MovementData + 0x18);
CharRotation = wow.ReadFloat(MovementData + 0x20);
}
private void Form1_Load(object sender, EventArgs e)
{
newWowObject();
}
public void MoveTo(float x, float y, float z)
{
wow.WriteFloat((uint)WowBase + (uint)ClickToMove.DestinationX, x);
wow.WriteFloat((uint)WowBase + (uint)ClickToMove.DestinationY, y);
wow.WriteFloat((uint)WowBase + (uint)ClickToMove.DestinationZ, z);
wow.WriteUInt((uint)WowBase + (uint)ClickToMove.Push, 4);
//PostMessage(WowData, WM_KEYDOWN, (IntPtr)Keys.D, IntPtr.Zero);
}
private void Button_Click(object sender, EventArgs e)
{
UpdatePlayerPos();
PosX.Text = "X: " + CharPosX;
PosY.Text = "Y: " + CharPosY;
PosZ.Text = "Z: " + CharPosZ;
ObjectList.Items.Add("Pos: " + CharPosX + " " + CharPosY + " " + CharPosZ);
Rotation.Text = "Rotation: " + CharRotation;
//MoveTo(0, 0, 0);
DoObjectManager();
}
}
}
The Guid is coming out with a ton of duplicates, and the type is coming out as a large number.