在进程的虚拟内存空间中,加载了映像文件(“something.exe”)。如果您添加0x00F8EBE0
到该地址并读取该位置,您将获得0x127B5450
. 将箭头读作“指向”,方括号中的值读作“地址加偏移量”。您可以使用 ToolHelp32 API 以编程方式获取图像库。
您在这里拥有的是指向对象结构的指针链,每个偏移量都为您提供下一个指针在结构/对象中的位置。
要使用来自另一个程序的此信息,您可以使用ReadProcessMemory。从第一个偏移量(图像库)开始,调用ReadProcessMemory
并添加相关偏移量,然后重复。一般流程如下:
//assuming you've calculated the image base of the target
//and acquired a handle to the process:
LPVOID base = ImageBase + 0x00F8EBE0; //note: EntryPoint needs obtaining properly
LPVOID value;
ReadProcessMemory(hnd,base,(LPVOID) &value,sizeof value, NULL);
base = value + 0x20;
ReadProcessMemory(hnd,base,(LPVOID) &value,sizeof value, NULL);
base = value + 0xc;
ReadProcessMemory(hnd,base,(LPVOID) &value,sizeof value, NULL);
base = value + 0x10;
ReadProcessMemory(hnd,base,(LPVOID) &value,sizeof value, NULL);
base = value + 0x20;
ReadProcessMemory(hnd,base,(LPVOID) &value,sizeof value, NULL);
base = value + 0x44;
ReadProcessMemory(hnd,base,buf,sizeof value, NULL);
//value will now contain the number 1000.
请注意,不能保证每次运行时进程的地址空间看起来都一样;如果它分配任何内存,则入口点 ( 0x00F8EBE0
) 的第一个偏移量将不同。