1
I’m having doubts about how I can read/write the data from this image pointer below (Cheat Engine):
My question is: How to add the module name "server.dll" + address + offsets?
Code made:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace TrainerTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("Kernel32.dll")]
private static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("Kernel32.dll")]
private static extern Boolean ReadProcessMemory(IntPtr hProcess, int lpBaseAddress, out int lpBuffer, int nSize, int lpNumberOfBytesRead);
private const int PROCESS_VM_READ = 0x0010;
private int pId = 0;
private int lpBaseAddress = 0x0058059C;
private int[] offsetList = new int[] { 0x4, 0x0, 0x280, 0xF0, 0x4B4 };
private int getAdressValue = 0;
IntPtr hProcess = IntPtr.Zero;
private void button1_Click(object sender, EventArgs e)
{
foreach (Process getProcess in Process.GetProcessesByName("hl2"))
pId = getProcess.Id;
if (pId == 0)
return;
hProcess = OpenProcess(PROCESS_VM_READ, false, pId);
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (ReadProcessMemory(hProcess, lpBaseAddress, out getAdressValue, 4, 0))
textBox1.Text = getAdressValue.ToString();
}
}
}
This code works using a simple address, but not a Pointer with offsets, because I do not know how to make this sum. I searched and saw that with a loop in the offsets array I can generate the Pointer. Something like:
int calcAddress = 0x0058059C;
for (int x = 0; x < offsetList.Length; x++)
{
calcAddress += ofsetList[x];
}
But what about the module "server.dll"???