using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const int PROCESS_WM_READ = 0x0010;
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(int hProcess,
int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead);
private void timerUpdate_Tick(object sender, EventArgs e)
{
Process[] processes = Process.GetProcessesByName("tibia");
if (processes.Length == 0) {
labelOutput.Text = "Tibia.exe not found.";
return;
}
Process process = processes[0];
IntPtr processHandle = OpenProcess(PROCESS_WM_READ, false, process.Id);
int bytesRead = 0;
byte[] bufferX = new byte[4];
byte[] bufferY = new byte[4];
byte[] bufferZ = new byte[4];
Int32 baseAddr = process.MainModule.BaseAddress.ToInt32();
ReadProcessMemory((int)processHandle, baseAddr + 0x587EA8, bufferX, bufferX.Length, ref bytesRead);
ReadProcessMemory((int)processHandle, baseAddr + 0x587EAC, bufferY, bufferY.Length, ref bytesRead);
ReadProcessMemory((int)processHandle, baseAddr + 0x587EB0, bufferZ, bufferZ.Length, ref bytesRead);
labelOutput.Text = BitConverter.ToInt32(bufferX, 0).ToString() + " " + BitConverter.ToInt32(bufferY, 0).ToString() + " " + BitConverter.ToInt32(bufferZ, 0).ToString();
}
}
}