Code:
using System;
using System.Collections;
public class DescriptorClass
{
public static DescriptorClass Main;// = new DescriptorClass();
# region Fields
public uint StartAddress;
public SortedList DescriptorList;
public bool Dump = false;
# endregion
# region Constructors
public DescriptorClass()
{
this.StartAddress = GetStartAddress();
this.DescriptorList = new SortedList();
this.Dump = false;
this.Init();
}
public DescriptorClass(bool Dump)
{
this.StartAddress = GetStartAddress();
this.DescriptorList = new SortedList();
this.Dump = Dump;
this.Init();
}
# endregion
# region Methods
public void Init()
{
# region
LoadFields(Memory.Read<UInt32>(this.StartAddress + 0xD), "OBJECT", null);
LoadFields(Memory.Read<UInt32>(this.StartAddress + 0x32), "ITEM", "OBJECT_END");
LoadFields(Memory.Read<UInt32>(this.StartAddress + 0x57), "CONTAINER", "ITEM_END");
LoadFields(Memory.Read<UInt32>(this.StartAddress + 0x7C), "UNIT", "OBJECT_END");
LoadFields(Memory.Read<UInt32>(this.StartAddress + 0xA1), "PLAYER", "UNIT_END");
LoadFields(Memory.Read<UInt32>(this.StartAddress + 0xC6), "GAMEOBJECT", "OBJECT_END");
LoadFields(Memory.Read<UInt32>(this.StartAddress + 0xEB), "DYNAMICOBJECT", "OBJECT_END");
LoadFields(Memory.Read<UInt32>(this.StartAddress + 0x110), "CORPSE", "OBJECT_END");
# endregion
}
private void LoadFields(uint dwPointer, string szPrefix, string szStart)
{
# region
if (Dump)
{
GLogClass.WriteLog(LOG_CATEGORY.INFORMATION, "Dump descriptor: " + szPrefix + " start: " + dwPointer.ToString("x8"));
}
uint dwFieldCount = 0;
uint dwLastIndex = 0;
while (true)
{
string pszName = Memory.ReadCString(Memory.Read<UInt32>(dwPointer), 0x40);
if (Dump)
{
GLogClass.WriteLog(LOG_CATEGORY.INFORMATION, pszName);
}
if (pszName == "")
{
break;
}
if (pszName.Contains(szPrefix))//strstr(pszName, szPrefix) == 0)
{
uint dwIndex;
dwIndex = Memory.Read<UInt32>(dwPointer + 4);
dwLastIndex = dwIndex + Memory.Read<UInt32>(dwPointer + 8);
//if (szStart != 0)
// fprintf(hFile, "\t%s = %s + 0x%X,\n", pszName, szStart, dwIndex * 4);
//else
// fprintf(hFile, "\t%s = 0x%X,\n", pszName, dwIndex * 4);
if (!this.DescriptorList.ContainsKey(pszName))
{
this.DescriptorList.Add(pszName, dwIndex);
}
if (Dump)
{
GLogClass.WriteLog(LOG_CATEGORY.INFORMATION, pszName + " = " + dwIndex.ToString("x4"));
}
dwFieldCount = dwFieldCount + 1;
}
dwPointer = dwPointer + 0x14;
}
if (!String.IsNullOrEmpty(szPrefix))
{
if (!this.DescriptorList.ContainsKey(szPrefix + "_END"))
{
this.DescriptorList.Add(szPrefix + "_END", dwFieldCount);
}
if (Dump)
{
GLogClass.WriteLog(LOG_CATEGORY.INFORMATION, szPrefix + "_END" + " = " + dwFieldCount.ToString("x4"));
}
}
# endregion
}
private uint GetStartAddress()
{
# region
try
{
CPattern pattern = new CPattern(Memory.GetModule("Wow.exe"), new ReadDelegate(Memory.ReadBytes));
if (true || Dump)
{
GLogClass.WriteLog(LOG_CATEGORY.EXCEPTION, "Module: 0x" + Memory.GetModule("Wow.exe").BaseAddress.ToString("x8"));
}
//uint dwStartFunc = pattern.FindPattern("56 57 68 00 00 00 00 B8 05", "xxx????xx", ' '); // 3.3.5.12345
//uint dwStartFunc = pattern.FindPattern("68 70 12 E2 00 B8 05", "x????xx", ' ');
uint dwStartFunc = pattern.FindPattern("56 57 68 00 00 00 00 B8 00", "xxx????x?", ' ');
// 56 57 68 00 00 00 00 B8 06
if (Dump)
{
GLogClass.WriteLog(LOG_CATEGORY.INFORMATION, "dwStartFunc: " + dwStartFunc.ToString("x8"));
}
return dwStartFunc;
}
catch (Exception ex)
{
GLogClass.WriteLog(LOG_CATEGORY.EXCEPTION, ex.Message);
return 0;
}
# endregion
}
public uint Get(string What)
{
# region
uint Start = 0;
# region Get Start
if (What.StartsWith("ITEM") || What.StartsWith("UNIT") || What.StartsWith("GAMEOBJECT") || What.StartsWith("DYNAMICOBJECT") || What.StartsWith("CORPSE"))
{
if (this.DescriptorList.ContainsKey("OBJECT_END"))
{
Start += 4 * (uint)this.DescriptorList["OBJECT_END"];
}
}
else if (What.StartsWith("CONTAINER"))
{
if (this.DescriptorList.ContainsKey("OBJECT_END"))
{
Start += 4 * (uint)this.DescriptorList["OBJECT_END"];
}
if (this.DescriptorList.ContainsKey("ITEM_END"))
{
Start += 4 * (uint)this.DescriptorList["ITEM_END"];
}
}
else if (What.StartsWith("PLAYER"))
{
if (this.DescriptorList.ContainsKey("OBJECT_END"))
{
Start += 4 * (uint)this.DescriptorList["OBJECT_END"];
}
if (this.DescriptorList.ContainsKey("UNIT_END"))
{
Start += 4 * (uint)this.DescriptorList["UNIT_END"];
}
}
# endregion
if (this.DescriptorList.ContainsKey(What))
{
//GLogClass.WriteLog(LOG_CATEGORY.INFORMATION, What + " : " + Start + 4 * (uint)this.DescriptorList[What]);
return Start + 4 * (uint)this.DescriptorList[What];
}
return 0;
# endregion
}
# endregion
}
public delegate byte[] ReadDelegate(uint dwStart, uint nSize);