我必须在内核模式调试会话期间捕获用户模式应用程序中发生的第一次异常。
我编写了名为Exceptions.exe 的简单示例应用程序:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
MessageBox(NULL, "Press OK to generate exception.", "Title", MB_OK);
__try
{
__asm
{
xor eax, eax
mov dword ptr[eax], eax // I wanna break here
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
MessageBox(NULL, "In exception handler.", "Title", MB_ICONINFORMATION);
}
return 0;
}
我在正在调试的系统中启动它。然后转到windbg,按“ctrl+break”并输入以下命令:
3: kd> !process 0 0 Exceptions.exe
PROCESS 853b37e0 SessionId: 1 Cid: 0f48 Peb: 7ffdf000 ParentCid: 06c4
DirBase: be658280 ObjectTable: 8f97acf8 HandleCount: 35.
Image: Exceptions.exe
3: kd> .process /i 853b37e0
You need to continue execution (press 'g' ) for the context
to be switched. When the debugger breaks in again, you will be in
the new process context.
3: kd> g
Break instruction exception - code 80000003 (first chance)
nt!RtlpBreakWithStatusInstruction:
82ab6110 cc int 3
2: kd> sxe *
2: kd> g
我希望中断指令mov dword ptr[eax], eax但什么也没发生。在正在调试的系统中,我有消息框“在异常处理程序中”。
有什么办法可以得到我想要的吗?我无法在用户模式下调试目标进程,因为它不受附加调试器的保护。