Advertisement
Guest User

Untitled

a guest
Aug 11th, 2010
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Runtime.InteropServices;
  6.  
  7. namespace DumpUI
  8. {
  9.     class Program
  10.     {
  11.  
  12.         [DllImport("user32")]
  13.         [return: MarshalAs(UnmanagedType.Bool)]
  14.         public static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
  15.  
  16.         [DllImport("user32.dll")]
  17.         public static extern bool SetCursorPos(int X, int Y);
  18.  
  19.         [DllImport("user32.dll")]
  20.         [return: MarshalAs(UnmanagedType.Bool)]
  21.         public static extern bool SetForegroundWindow(IntPtr hWnd);
  22.  
  23.         public struct POINT
  24.         {
  25.             public int X;
  26.             public int Y;
  27.         }
  28.  
  29.         static Magic.BlackMagic BM;
  30.  
  31.         public enum UIFrame
  32.         {
  33.  
  34.             UIBase = 0x00B499A8,
  35.             FirstFrame = 0x0CD4,
  36.             NextFrame = 0x0CCC,
  37.             UnkDivWidth = 0x00AC0CB4,
  38.             UnkDivHeight = 0x00AC0CB8,
  39.             ScreenWidth = 0x00BD07F0,
  40.             ScreenHeight = 0x00BD07F4,
  41.             FrameLeft = 0x68,
  42.             FrameRight = 0x70,
  43.             FrameTop = 0x6C,
  44.             FrameBottom = 0x64,
  45.             ParentPtr = 0x94,
  46.             EffectiveScale = 0x7C,
  47.             Name = 0x1C,
  48.             Visible = 0xDC,
  49.  
  50.         }
  51.  
  52.         public class Frame
  53.         {
  54.  
  55.             public UInt32 baseAddress;
  56.  
  57.             public Frame(UInt32 baseAddress)
  58.             {
  59.                 this.baseAddress = baseAddress;
  60.             }
  61.  
  62.             public Boolean IsVisible
  63.             {
  64.                 get
  65.                 {
  66.                     return (BM.ReadInt(baseAddress + (uint)UIFrame.Visible) == 1);
  67.                 }
  68.             }
  69.  
  70.             public String Name
  71.             {
  72.                 get
  73.                 {
  74.                     return BM.ReadASCIIString(BM.ReadUInt(baseAddress + (uint)UIFrame.Name), 255);
  75.                 }
  76.             }
  77.  
  78.             public Single EffectiveScale
  79.             {
  80.                 get
  81.                 {
  82.                     return BM.ReadFloat(baseAddress + (uint)UIFrame.EffectiveScale);
  83.                 }
  84.             }
  85.  
  86.             public UInt32 ParentPtr
  87.             {
  88.                 get
  89.                 {
  90.                     return BM.ReadUInt(baseAddress + (uint)UIFrame.ParentPtr);
  91.                 }
  92.             }
  93.  
  94.             public Frame Parent
  95.             {
  96.                 get
  97.                 {
  98.                     return new Frame(ParentPtr);
  99.                 }
  100.             }
  101.  
  102.             public Single Left
  103.             {
  104.                 get
  105.                 {
  106.  
  107.                     Single a1 = BM.ReadFloat(baseAddress + (uint)UIFrame.FrameLeft);
  108.                     return (a1 * BM.ReadInt((uint)UIFrame.ScreenWidth) / BM.ReadFloat((uint)UIFrame.UnkDivWidth));
  109.  
  110.                 }
  111.             }
  112.  
  113.             public Single Right
  114.             {
  115.                 get
  116.                 {
  117.  
  118.                     Single a1 = BM.ReadFloat(baseAddress + (uint)UIFrame.FrameRight);
  119.                     return (a1 * BM.ReadInt((uint)UIFrame.ScreenWidth) / BM.ReadFloat((uint)UIFrame.UnkDivWidth));
  120.  
  121.                 }
  122.             }
  123.  
  124.             public Single Top
  125.             {
  126.                 get
  127.                 {
  128.                     Single a1 = BM.ReadFloat(baseAddress + (uint)UIFrame.FrameTop);
  129.                     return (a1 * BM.ReadInt((uint)UIFrame.ScreenHeight) / BM.ReadFloat((uint)UIFrame.UnkDivHeight));
  130.                 }
  131.             }
  132.  
  133.             public Single Bottom
  134.             {
  135.                 get
  136.                 {
  137.                     Single a1 = BM.ReadFloat(baseAddress + (uint)UIFrame.FrameBottom);
  138.                     return (a1 * BM.ReadInt((uint)UIFrame.ScreenHeight) / BM.ReadFloat((uint)UIFrame.UnkDivHeight));
  139.                 }
  140.             }
  141.  
  142.             public Single Witdh
  143.             {
  144.                 get
  145.                 {
  146.                     return Right - Left;
  147.                 }
  148.             }
  149.  
  150.             public Single Height
  151.             {
  152.                 get
  153.                 {
  154.                     return Top - Bottom;
  155.                 }
  156.             }
  157.  
  158.             public void MoveMouseOver()
  159.             {
  160.  
  161.                 POINT p = new POINT();
  162.                 ScreenToClient(BM.WindowHandle, ref p);
  163.  
  164.                 SetCursorPos(Math.Abs(p.X) + (int)this.Left + (int)(this.Witdh / 2), Math.Abs(p.Y) + BM.ReadInt((uint)UIFrame.ScreenHeight) - (int)this.Top + (int)(this.Height / 2));
  165.  
  166.             }
  167.  
  168.         }
  169.  
  170.         public static Frame GetFrameByName(String frameName)
  171.         {
  172.  
  173.             foreach (Frame f in GetFrames)
  174.                 if (f.Name == frameName)
  175.                     return f;
  176.  
  177.             return null;
  178.  
  179.         }
  180.  
  181.         public static List<Frame> GetFrames
  182.         {
  183.             get
  184.             {
  185.  
  186.                 List<Frame> result = new List<Frame>();
  187.                 UInt32 Base = BM.ReadUInt((uint)UIFrame.UIBase);
  188.                 UInt32 CurrentFrame = BM.ReadUInt(Base + (uint)UIFrame.FirstFrame);
  189.  
  190.                 while (CurrentFrame != 0)
  191.                 {
  192.  
  193.                     result.Add(new Frame(CurrentFrame));
  194.  
  195.                     CurrentFrame = BM.ReadUInt(CurrentFrame + BM.ReadUInt(Base + (uint)UIFrame.NextFrame) + 4);
  196.  
  197.                 }
  198.  
  199.                 return result;
  200.  
  201.             }
  202.         }
  203.  
  204.         static void Main(string[] args)
  205.         {
  206.  
  207.             Int32 TotalFrames = 0;
  208.             Int32 TotalVisibleFrames = 0;
  209.  
  210.             BM = new Magic.BlackMagic(Magic.SProcess.GetProcessFromProcessName("Wow"));
  211.  
  212.             foreach (Frame f in GetFrames)
  213.             {
  214.  
  215.                 if (f.IsVisible)
  216.                     TotalVisibleFrames++;
  217.  
  218.                 if (f.Name.Length > 0)
  219.                     Console.WriteLine("Frame 0x" + f.baseAddress.ToString("X") + " Name : " + f.Name);
  220.  
  221.                 TotalFrames++;
  222.  
  223.             }
  224.            
  225.             Console.WriteLine("Total frames : " + TotalFrames);
  226.             Console.WriteLine("Total visible frames : " + TotalVisibleFrames);
  227.  
  228.             Console.ReadLine();
  229.  
  230.         }
  231.     }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement