我最近开始尝试使用 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;
不确定它有多大 yield 。
你所做的基本上是遵循一组指针,所以:
global->something->other->thingy->value
您需要读取每一层的每个指针,因此读取所有地址没有捷径可走。 [当编译器必须访问一长串指针时,这也适用——必须在访问指针指向的元素之前读取每个指针]
(不确定我那里有足够的元素,但这个概念适用)
关于c++ - 简化多个 ReadProcessMemory 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33964450/