我已经使用DebugActiveProcess来附加一个进程。之后,我使用了WaitForDebugEvent,但似乎应用程序陷入了无限循环,无法调试附加的进程。

下面是我的代码:

    DebugActiveProcess( processID );
    int temp = 0;

    DEBUG_EVENT DBEvent;

    while (1)
    {
        WaitForDebugEvent( &DBEvent, INFINITE );
        if ( DBEvent.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT )
            break;
        if ( DBEvent.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT )
        {
            //MessageBox(0,"Debugging started!","Ble",0);
            temp = 1;
        }
        else if ( DBEvent.dwDebugEventCode == EXCEPTION_DEBUG_EVENT )
        {
            if ( DBEvent.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT )
            {
                ContinueDebugEvent( processID, qalsrvid, DBG_CONTINUE );
                continue;
            }
            ContinueDebugEvent( processID, qalsrvid, DBG_EXCEPTION_NOT_HANDLED );
        }
    }

最佳答案

您没有在ContinuteDebugEvent事件上调用CREATE_PROCESS_DEBUG_EVENT

如果尚未阅读,则应:

Writing Windows DebuggerPart 2

10-07 13:38