简化多个ReadProcessMemory调用

时间:2015-11-27 20:29:40

标签: c++ memory memory-management process reverse-engineering

我最近开始尝试使用Cheat Engine,以便能够从正在运行的进程的内存中读取数据,并偶然发现本教程的第8步。我希望从我正在阅读的第二个进程的[[[[[0x00645390]+0xC]+0x14]+0x0]+0x18]存储的应用程序中读取一个特定值,0x00645390是静态的。

目前它可以使用以下疯狂指针处理片段:

::ReadProcessMemory(hProcess, (void *)0x00645390,           (void *)&dwAddress, sizeof(dwAddress), NULL);
::ReadProcessMemory(hProcess, (void *)(dwAddress + 0xc),    (void *)&dwAddress, sizeof(dwAddress), NULL);
::ReadProcessMemory(hProcess, (void *)(dwAddress + 0x14),   (void *)&dwAddress, sizeof(dwAddress), NULL);
::ReadProcessMemory(hProcess, (void *)(dwAddress),          (void *)&dwAddress, sizeof(dwAddress), NULL);
::ReadProcessMemory(hProcess, (void *)(dwAddress + 0x18),   (void *)&dwValue,   sizeof(dwAddress), NULL);

我想知道当我同时拥有基本地址和一些偏移时,是否有功能或更短的符号。

1 个答案:

答案 0 :(得分:1)

你当然可以使用静态数组:

int offset[] = { 0, 12, 20, 0, 24 };/* (or 0xC, 0x14,m 0, 0x18) */

dwAddress = 0x00645390;
for( auto i : offset)
    ::ReadProcessMemory(hProcess, (void *)(dwAddress + i),
                        (void *)&dwAddress, sizeof(dwAddress), NULL);
dwValue = dwAddress;

不确定它收益多少。

你在做什么基本上是遵循一组指针,所以:

 global->something->other->thingy->value

您需要读取每个级别的每个指针,因此没有读取所有地址的快捷方式。 [当编译器必须访问一长串指针时,这也适用 - 必须在指针指向的元素之前读取每个指针]

(不确定我有足够的元素,但这个概念适用)