using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using WoW;
using MemoryLib;
namespace WoWTestNames
{
class Program
{
static void Main(string[] args)
{
WoWAmeliorator wow = new WoWAmeliorator(Memory.GetProcessIdByProcessName("wow"));
while (true)
{
//exit if player pressed Esc
if (Console.KeyAvailable)
if (Console.ReadKey(true).Key == ConsoleKey.Escape)
break;
//read our player's target from address 0x00DDEC88 (WoW 2.4.2)
UInt64 target = wow.GetPlayerTargetGUID();
//if we have a target
if (target != 0)
{
//clear the console so the name appears on the top line
Console.Clear();
//Get the object's name and write it out in format:
//'Name of target: TARGETNAME'
//hopefully you already have a way of looping through objects
//and getting the object's base address from its GUID, which is
//what wow.GetObjectByGUID(UInt64 GUID) does
Console.WriteLine("Name of target: {0}", GetName(wow.ProcessHandle, wow.GetObjectByGUID(target)));
}
else
Console.Clear();
//let the cpu rest for chrissake
Thread.Sleep(100);
}
wow.Close();
}
static string GetName(IntPtr hProcess, uint obj)
{
//obj == base address of object
if (hProcess == IntPtr.Zero || obj <= 0)
return String.Empty;
//get the object's type from obj+0x14 (like normal)
ObjectType type = (ObjectType)Memory.ReadByte(hProcess, (obj + 0x14));
//determine what type of object it is and call associated routine
switch (type)
{
case ObjectType.Player:
return GetPlayerName(hProcess, obj);
case ObjectType.Unit:
return GetUnitName(hProcess, obj);
default:
return "Unknown Object";
}
}
static string GetUnitName(IntPtr hProcess, uint unit)
{
//unit names are easy to get!
return Memory.ReadString(hProcess, Memory.ReadUInt(hProcess, (Memory.ReadUInt(hProcess, (unit + 0xDB8)) + 0x40)), 40);
}
static string GetPlayerName(IntPtr hProcess, uint player)
{
//read the object's GUID from obj+0x30 (again, pretty basic)
UInt64 GUID = Memory.ReadUInt64(hProcess, (player + 0x30));
//some sort of list index
int var1 = Memory.ReadInt(hProcess, (0x00D4C4F8 + 0x24));
if (var1 == -1)
return "Unknown Player";
//here we're getting the pointer to the start of the linked list
int var2 = Memory.ReadInt(hProcess, (0x00D4C4F8 + 0x1C));
var1 &= (int)GUID;
var1 += var1 * 2;
var1 = (var2 + (var1 * 4) + 4);
var1 = Memory.ReadInt(hProcess, (var1 + 4));
//iterate through the linked list until the current entry has
//the same GUID as the object whose name we want
while (Memory.ReadInt(hProcess, var1) != (int)GUID)
{
int var3 = Memory.ReadInt(hProcess, (0x00D4C4F8 + 0x1C));
var2 = (int)GUID;
var2 &= Memory.ReadInt(hProcess, (0x00D4C4F8 + 0x24));
var2 += var2 * 2;
var2 = Memory.ReadInt(hProcess, (var3 + (var2 * 4)));
var2 += var1;
var1 = Memory.ReadInt(hProcess, (var2 + 4));
}
//now that we have the correct entry in the linked list,
//read its name from entry+0x20
return Memory.ReadString(hProcess, (var1 + 0x20), 40);
}
}
}