Collecting handles with Windbg

1

I'm using Windbg sdk to write my own debugger. The debugger is capable of collecting all handles allocated by debugged apps to avoid handle leaks. Here is my code:

void zAdvancedDebugger::debugProc(){
    // Creating interfaces including m_dbgClient, m_dbgControl
    if(!createInterfaces()){
        printf("Failed to create debugging interfaces\r\n");
        return;
    }
    std::string strRealCmdLine="\"" + app + "\"  " + args;
    // Every thing's set up so start the app.
    if (( m_dbgClient->CreateProcess(0, (PSTR)strRealCmdLine.c_str(), DEBUG_PROCESS )) != S_OK)
        return ;
    // event loop
    while(true){
        if(m_dbgControl->WaitForEvent(DEBUG_WAIT_DEFAULT,INFINITE)!= S_OK)
            break;
    }
    HRESULT ret=m_dbgControl->Execute(
        DEBUG_OUTCTL_IGNORE,
        ".closehandle -a", // Close all handles allocated
        DEBUG_EXECUTE_NOT_LOGGED );
}

The problem is: I can't execute the command ".closehandle -a". Whenever I run the code, I always get "ret 0x80040205 An unexpected exception was raised". Would you please tell me what wrong is with this?

windbg
handle
asked on Stack Overflow May 5, 2012 by anhldbk

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0