使用DebugActiveProcess和WaitForDebugEvent似乎挂起

时间:2011-08-03 08:37:54

标签: c++

我使用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 );
        }
    }

1 个答案:

答案 0 :(得分:4)

您未在ContinuteDebugEvent事件上致电CREATE_PROCESS_DEBUG_EVENT

如果你还没有读过,你应该:

Writing Windows DebuggerPart 2