4

我知道有很多教程向您展示如何使用“ProcessMemoryReader”功能。但这个问题似乎是独一无二的或尚未解决。

很长一段时间以来,我一直在研究其他人的代码以找到一种使用多个偏移量的方法。而且我认为使用多个偏移量对我来说是个问题,但我认为这是一个问题,因为我的偏移量值大于 255。

我试图从中获取内存值的游戏称为“突击魔方”。因为我不确定我是否得到了正确的偏移值,所以我用谷歌搜索了其他人的结果。它们似乎完全相同: http ://cheatengine.org/tables/moreinfo.php?tid= 1142(如果您没有安装作弊引擎,您可以使用记事本查看 .ct 文件。)

这是我的代码,使用ProcessMemoryReader.cs.

private void timer1_Tick(object sender, EventArgs e)
{
int bytesread;
int pointerbase;
byte[] memory;
Process[] myprocess = Process.GetProcessesByName("ac_client");
if (myprocess.Length != 0)
{
preader.ReadProcess = myprocess[0];
preader.OpenProcess();

//Ammo
memory = preader.ReadProcessMemory((IntPtr)0x4DF73C, 4, out bytesread);
pointerbase = BitConverter.ToInt32(memory, 0);
pointerbase += 0x00; //0 // 14 // 378

byte[] memory1 = preader.ReadProcessMemory((IntPtr)pointerbase, 4, out bytesread);
int pointerbase1 = BitConverter.ToInt32(memory1, 0);
pointerbase1 += 0x14; //0 // 14 // 378

byte[] memory2 = preader.ReadProcessMemory((IntPtr)pointerbase1, 4, out bytesread);
int pointerbase2 = BitConverter.ToInt32(memory2, 0);
pointerbase2 += 0x378; //00 // 14 // 378

byte[] memory3 = preader.ReadProcessMemory((IntPtr)pointerbase2, 4, out bytesread);
int valueis = BitConverter.ToInt32(memory3, 0);
label1.Text = valueis.ToString();
}

尽管使用单个指针,该过程可以正常工作,例如:

 //HP
 memory = preader.ReadProcessMemory((IntPtr)0x4DF73C, 4, out bytesread);
 pointerbase = BitConverter.ToInt32(memory, 0);
 pointerbase += 0xf4;

 byte[] memory1 = preader.ReadProcessMemory((IntPtr)pointerbase, 4, out bytesread);
 int valueis = BitConverter.ToInt32(memory1, 0);
 label2.Text = valueis.ToString();

这样就可以了,这里发生的事情非常简单,但是我不知道如何读取具有多个偏移量的弹药代码。

4

2 回答 2

0

我不熟悉 CheatEngine 和它的表格格式,但我没有得到它指向您正在使用的内存地址的印象。

您在 处读取了 4 个字节0x4DF73C,用作下一次读取的新内存地址。这重复了几次。基本上,您正在从指向指针的指针读取信息。你确定这是预期的吗?

没有任何理由认为大于 255 的偏移值会成为问题。

于 2013-04-18T12:10:30.333 回答
0

使用 FindDMAAddy 为您遍历指针链,这是一个工作示例,请确保您以管理员身份运行:

public static IntPtr FindDMAAddy(IntPtr hProc, IntPtr ptr, int[] offsets)
{
    var buffer = new byte[IntPtr.Size];

    foreach (int i in offsets)
    {
        ReadProcessMemory(hProc, ptr, buffer, buffer.Length, out
        var read);
        ptr = (IntPtr.Size == 4) ? IntPtr.Add(new IntPtr(BitConverter.ToInt32(buffer, 0)), i) : ptr = IntPtr.Add(new IntPtr(BitConverter.ToInt64(buffer, 0)), i);
    }
    return ptr;
}

var modBase = GetModuleBaseAddress(proc.Id, "ac_client.exe");

var ammoAddr = FindDMAAddy(hProc, (IntPtr)(modBase + 0x10f4f4), new int[] { 0x374, 0x14, 0 });

Console.WriteLine("Ammo address " + "0x" + ammoAddr.ToString("X"));

int newAmmo = 1337;

byte[] buffer = new byte[4];

ReadProcessMemory(proc.Handle, ammoAddr, buffer, 4, out _);

Console.WriteLine("Ammo value " + BitConverter.ToInt32(buffer, 0).ToString());

WriteProcessMemory(hProc, ammoAddr, newAmmo, 4, out _);
于 2020-04-20T01:46:22.930 回答