Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using DebugActiveProcess and WaitForDebugEvent seems to hang

Tags:

c++

I have used DebugActiveProcess to attach a process. After that I used WaitForDebugEvent, but it seems that the application is stuck in some infinite loop and I am not able to debug the attached process.

Below is my code:

    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 );
        }
    }
like image 799
questioner Avatar asked Aug 03 '11 08:08

questioner


1 Answers

You are not calling ContinuteDebugEvent on CREATE_PROCESS_DEBUG_EVENT event.

If you have not read it yet, you should:

Writing Windows Debugger and Part 2

like image 108
Ajay Avatar answered Oct 13 '22 21:10

Ajay