Advertisement
CerditoDescargas

name428

Feb 20th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.67 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Windows.Forms;
  4. using System.Diagnostics;
  5.  
  6. namespace AOUtils
  7. {
  8.     public partial class Form1 : Form
  9.     {
  10.         public Form1()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.  
  15.         //Pointer: 77bb084;
  16.         //Gold Offset: c890;
  17.         uint pAddress = 0x7bb084;
  18.         int ptrOffset = 0xc890;
  19.         uint offset = 0;
  20.         int bytesOut = 0;
  21.        
  22.         /// <summary>
  23.         /// Form loading, and opening AOReader alias ReadProcessMemory.CS
  24.         /// </summary>
  25.         /// <param name="sender"></param>
  26.         /// <param name="e"></param>
  27.         private void Form1_Load(object sender, EventArgs e)
  28.         {
  29.             AOReader mreader = new AOReader();
  30.  
  31.             var p = GetProcess("Kukun");
  32.  
  33.             if (p != null)
  34.             {
  35.                 mreader.ReadProcess = p;
  36.                 mreader.OpenProcess();
  37.  
  38.                 offset = BitConverter
  39.                     .ToUInt32(mreader.ReadMemory((IntPtr)(pAddress + (uint)p.Modules[0].BaseAddress), 4, out bytesOut), 0);
  40.  
  41.                 if (ptrOffset < 0)
  42.                 {
  43.                     offset -= (uint)Math.Abs(ptrOffset);
  44.                 }
  45.                 else
  46.                 {
  47.                     offset += (uint)ptrOffset;
  48.                 }
  49.             }
  50.         }
  51.  
  52.         /// <summary>
  53.         /// All Clients called angel.dat also we can have multiple process opened
  54.         /// , so for identify it, we add parameter
  55.         /// with the name of character.
  56.         /// </summary>
  57.         /// <param name="altName"></param>
  58.         /// <returns></returns>
  59.         private static Process GetProcess(string altName)
  60.         {
  61.             Process p = Process.GetProcessesByName("angel.dat")
  62.                 .ToList().FirstOrDefault(d=>d.MainWindowTitle.Contains(altName));
  63.             if (p!= null)
  64.             {
  65.                 return p;
  66.             }
  67.             return null;
  68.         }
  69.  
  70.         /// <summary>
  71.         /// Trying to get gold amount and display to TextBox.
  72.         /// </summary>
  73.         /// <param name="sender"></param>
  74.         /// <param name="e"></param>
  75.         private void button1_Click_1(object sender, EventArgs e)
  76.         {
  77.             AOReader mreader = new AOReader();
  78.  
  79.             //This i add for check if GetProcess is working, can be removed.
  80.             IntPtr Base = GetProcess("Kukun").MainModule.BaseAddress;
  81.             MessageBox.Show("Base Address: " + Base);
  82.  
  83.             var gold = BitConverter
  84.                 .ToUInt32(mreader.ReadMemory((IntPtr)(pAddress + offset), 4, out bytesOut), 0);
  85.  
  86.             textBox1.Text = gold.ToString("n0");
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement