Created
January 10, 2016 22:56
-
-
Save henqqqcs/08255fa362dc8c897be2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace TestMemory | |
{ | |
class Program | |
{ | |
[DllImport("kernel32.dll")] | |
public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, | |
[In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead); | |
static void Main(string[] args) | |
{ | |
Process tibia = Process.GetProcessesByName("Tibia")[0]; | |
ProcessModule module = tibia.MainModule; | |
IntPtr handle = tibia.Handle; | |
//base address | |
UInt32 baseAdr = Convert.ToUInt32(module.BaseAddress.ToInt32()); | |
Console.WriteLine("Base address : " + baseAdr.ToString("X")); | |
//experience addres -> working! | |
UInt32 xpAddr = 0x534660; | |
Console.WriteLine("Experience (working) : " + Convert.ToString(ReadInt32(handle, xpAddr + baseAdr))); | |
//gui pointer from MemoryScanner of | |
UInt32 guiPointer = 0x534970; | |
Console.WriteLine("Gui pointer address : " + guiPointer.ToString("X")); | |
//game window container | |
UInt32 gWindowContainer = guiPointer + 0x30; | |
//game window width 0x38 -> not working | |
UInt32 gWindowWidth = gWindowContainer + 0x38; | |
Console.WriteLine("Game width (not working): " + Convert.ToString(ReadInt32(handle, gWindowWidth + baseAdr))); | |
Console.ReadLine(); | |
} | |
public static byte[] ReadBytes(IntPtr Handle, Int64 Address, uint BytesToRead) | |
{ | |
IntPtr ptrBytesRead; | |
byte[] buffer = new byte[BytesToRead]; | |
ReadProcessMemory(Handle, new IntPtr(Address), buffer, BytesToRead, out ptrBytesRead); | |
return buffer; | |
} | |
public static int ReadInt32(IntPtr Handle, long Address) | |
{ | |
return BitConverter.ToInt32(ReadBytes(Handle, Address, 4), 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment