1

我正在使用 Windbg sdk 编写自己的调试器。调试器能够收集被调试应用程序分配的所有句柄以避免句柄泄漏。这是我的代码:

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 );
}

问题是:我无法执行命令“.closehandle -a”。每当我运行代码时,我总是得到“ret 0x80040205 An unexpected exception was raise”。你能告诉我这有什么问题吗?

4

0 回答 0