-
Contributor
[C# snippet] Get player info by GUID (name, race and class)
Hey guys, whilst looking for a way to get the player name I came across a few old examples but here's another one using Process.NET
It iterates over the GUIDs until it finds what you're looking for.
Enjoy.
Oh btw, offsets are for 7.0.3.22522 courtesy of Torpedoes
Code:
using System;
using System.Text;
using Process.NET;
namespace Modules.Games.WoW.Data
{
public class WoWNameCache
{
public WoWNameCache(ProcessSharp process, IntPtr baseAddress)
{
Process = process;
CurrentCacheAddress = process.Native.MainModule.BaseAddress + baseAddress.ToInt32(); // 0x151BA88
}
public ProcessSharp Process { get; set; }
public IntPtr CurrentCacheAddress { get; set; }
public WoWName GetNameByGuid(Guid searchGuid)
{
var current = Process.Memory.Read<IntPtr>(CurrentCacheAddress);
while (current != IntPtr.Zero)
{
var guid = Process.Memory.Read<Guid>(current + 0x20);
if (guid.Equals(searchGuid))
{
var pRace = Process.Memory.Read<int>(current + 0x88);
var pClass = Process.Memory.Read<int>(current + 0x90);
var pName = Process.Memory.Read(current + 0x31, Encoding.ASCII, 48);
var name = new WoWName(guid, pRace, pClass, pName);
return name;
}
current = Process.Memory.Read<IntPtr>(current);
}
return null;
}
public class WoWName
{
public WoWName(Guid guid, int race, int @class, string name)
{
Guid = guid;
Race = (WoWEnums.WoWRace) race;
Class = (WoWEnums.WoWClass) @class;
Name = name;
}
public Guid Guid { get; set; }
public WoWEnums.WoWRace Race { get; set; }
public WoWEnums.WoWClass Class { get; set; }
public string Name { get; set; }
}
}
Last edited by T@rget; 09-06-2016 at 05:42 AM.
Reason: Removed pointless additions
-
Post Thanks / Like - 3 Thanks
-