Guest User

Untitled

a guest
Nov 26th, 2012
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.81 KB | None | 0 0
  1. namespace UIDump
  2. {
  3.     internal enum UIFrame
  4.     {
  5.         UIBase = 0xAD742C,
  6.         Visible = 0x64,
  7.         Name = 0x1C,
  8.         Enabled = 0x200,
  9.         FirstFrame = 0xCE4,
  10.         NextFrame = 0xCDC
  11.     }
  12.  
  13.     internal class Program
  14.     {
  15.         private static ExternalProcessReader _mem;
  16.  
  17.         public static List<Frame> GetFrames
  18.         {
  19.             get
  20.             {
  21.                 List<Frame> result = new List<Frame>();
  22.                 IntPtr Base = _mem.Read<IntPtr>(_mem.Process.MainModule.BaseAddress + (int) UIFrame.UIBase);
  23.                 IntPtr currentFrame = _mem.Read<IntPtr>(Base + (int) UIFrame.FirstFrame);
  24.  
  25.                 while (currentFrame != (IntPtr) 0)
  26.                 {
  27.                     result.Add(new Frame(currentFrame));
  28.                     currentFrame = _mem.Read<IntPtr>(currentFrame + _mem.Read<int>(Base + (int) UIFrame.NextFrame) + 4);
  29.                 }
  30.                 return result;
  31.             }
  32.         }
  33.  
  34.         public static Frame GetFrameByName(String frameName)
  35.         {
  36.             return GetFrames.FirstOrDefault(f => f.Name == frameName);
  37.         }
  38.  
  39.         private static void Main()
  40.         {
  41.             Int32 totalFrames = 0;
  42.             Int32 totalVisibleFrames = 0;
  43.  
  44.             _mem = new ExternalProcessReader(Process.GetProcessesByName("Wow")[0]);
  45.  
  46.             foreach (Frame f in GetFrames)
  47.             {
  48.                 if (f.IsVisible)
  49.                     totalVisibleFrames++;
  50.  
  51.                 if (f.Name.Length > 0 && f.Name.Contains("MicroButton"))
  52.                 {
  53.                     Console.WriteLine("Frame 0x" + f.BaseAddress.ToString("X") + " Name : " + f.Name + " Enabled : " +
  54.                                       f.IsEnabled);
  55.                 }
  56.  
  57.                 totalFrames++;
  58.             }
  59.  
  60.             Console.WriteLine("Total frames : " + totalFrames);
  61.             Console.WriteLine("Total visible frames : " + totalVisibleFrames);
  62.             Console.ReadLine();
  63.         }
  64.  
  65.         public class Frame
  66.         {
  67.             public IntPtr BaseAddress;
  68.  
  69.             public Frame(IntPtr baseAddress)
  70.             {
  71.                 BaseAddress = baseAddress;
  72.             }
  73.  
  74.             public Boolean IsVisible
  75.             {
  76.                 get { return ((_mem.Read<int>(BaseAddress + (int) UIFrame.Visible) >> 0x1a & 1) == 1); }
  77.             }
  78.  
  79.             public bool IsEnabled
  80.             {
  81.                 get { return (_mem.Read<int>(BaseAddress + (int)UIFrame.Enabled) & 15) == 1; }
  82.             }
  83.  
  84.             public String Name
  85.             {
  86.                 get
  87.                 {
  88.                     var t = _mem.Read<IntPtr>(BaseAddress + (int) UIFrame.Name);
  89.                     return (int) t > 0 ? _mem.ReadString(t, Encoding.ASCII, 255) : "";
  90.                 }
  91.             }
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment