我试图用ReadProcessMemory记录指向指令,实际上我使用EIP寄存器来获取下一个指令地址。接下来,我使用distorm lib来显示助记符。但ReadProcessMemory什么都不读。
void display_instruction(Debuggee* debuggee)
{
CONTEXT lcContext;
lcContext.ContextFlags = CONTEXT_ALL;
GetThreadContext(debuggee->debugEvent->u.CreateProcessInfo.hThread, &lcContext);
BYTE cInstruction = 0;
DWORD dwReadBytes;
ReadProcessMemory(debuggee->debugEvent->u.CreateProcessInfo.hProcess, (void*)&lcContext.Eip, &cInstruction, 1, &dwReadBytes);
decode((void*)cInstruction); //Distorm Mnemonic
printf("Instruction : 0x%03.3X , %d\n",cInstruction,dwReadBytes);
}
}
我需要你的帮助!^^
答案 0 :(得分:0)
这可能是:
ReadProcessMemory(debuggee->debugEvent->u.CreateProcessInfo.hProcess,
(void*) &lcContext.Eip, // <
&cInstruction,
1,
&dwReadBytes);
应该是:
ReadProcessMemory(debuggee->debugEvent->u.CreateProcessInfo.hProcess,
(void*) lcContext.Eip, // <
&cInstruction,
1,
&dwReadBytes);
因为ReadProcessMemory
需要目标进程的虚拟内存中的地址。
加上你可以检查返回值和失败的原因。