繁体   English   中英

简化多个ReadProcessMemory调用

[英]Simplify multiple ReadProcessMemory calls

最近,我开始对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);

我想知道当同时具有基本地址和一些偏移量时是否可以使用某个函数或更短的符号。

您当然可以使用以下静态数组:

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM