Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 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. using System.Diagnostics;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10.     class Program
  11.     {
  12.         [DllImport("kernel32.dll")]
  13.         public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
  14.         public static byte[] ReadBytes(IntPtr Handle, Int64 Address, uint BytesToRead)
  15.         {
  16.             IntPtr ptrBytesRead;
  17.             byte[] buffer = new byte[BytesToRead];
  18.             ReadProcessMemory(Handle, new IntPtr(Address), buffer, BytesToRead, out ptrBytesRead);
  19.             return buffer;
  20.         }
  21.  
  22.         public static int ReadInt32(Int64 Address, IntPtr Handle)
  23.         {
  24.             return BitConverter.ToInt32(ReadBytes(Handle, Address, 4), 0);
  25.         }
  26.         public static string ReadString(long Address, IntPtr Handle, uint length = 32)
  27.         {
  28.             return ASCIIEncoding.Default.GetString(ReadBytes(Handle, Address, length)).Split('\0')[0];
  29.         }
  30.  
  31.  
  32.         static void Main(string[] args)
  33.         {
  34.            
  35.             Process Tibia = Process.GetProcessesByName("Tibia")[0];
  36.             IntPtr Handle = Tibia.Handle;
  37.             UInt32 Base = (UInt32)Tibia.MainModule.BaseAddress.ToInt32();
  38.             UInt32 MaxHpAdr = 0x9A702C;
  39.             UInt32 Xor = 0x812588;
  40.             Console.WriteLine("HP : "+Convert.ToString(ReadInt32(Base + MaxHpAdr,Handle)));
  41.             Console.WriteLine("XOR: "+Convert.ToString(ReadInt32(Base+MaxHpAdr,Handle) ^ ReadInt32(Base+Xor,Handle)));
  42.             Console.ReadLine();
  43.         }
  44.         }
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement