【发布时间】:2012-04-01 17:25:05
【问题描述】:
我有从内存中读取值的代码,当内存地址指向静态 4 字节值时该值有效,但我正在尝试访问位于动态位置的 4 字节值,因此需要搜索先指针再搜索,得到4字节的值。
下面是我的代码,它应该返回指针的地址,但它只输出 0...
bAddr = (IntPtr)0x0017C370; // Base address to find the Pointer (Currently: 0x00267A50)
ReadProcessMemory(hProc, bAddr, buffer, 4, out bytesRW);
output = BitConverter.ToInt32(buffer, 0);
txtOutput.Text = output.ToString();
我看到的伪代码如下:
bAddr = (IntPtr)0x0017C370; // Base address to find the Pointer (Currently: 0x00267A50)
ReadProcessMemory(hProc, bAddr, buffer, 4, out bytesRW);
output = BitConverter.ToInt32(buffer, 0);
bAddr = (IntPtr)output; // Should now contain the address 0x00267A50
ReadProcessMemory(hProc, bAddr, buffer, 4, out bytesRW);
output = BitConverter.ToInt32(buffer, 0);
txtOutput.Text = output.ToString();
谁能阐明我需要做什么才能找到地址然后搜索该地址以找到值?
【问题讨论】:
-
ReadProcessMemory返回什么?它可能只是失败了,在这种情况下GetLastError可能会有所启发。