Esempio n. 1
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId);
            Debug.Assert(m_pollThread != null);
            Debug.Assert(m_engineCallback != null);
            Debug.Assert(m_debuggedProcess != null);
            Debug.Assert(m_ad7ProgramId == Guid.Empty);

            try
            {
                int processId = EngineUtils.GetProcessId(process);

                if (processId != m_debuggedProcess.Id)
                {
                    return(Constants.S_FALSE);
                }

                // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
                // which will complete the hookup with AD7
                IDebugPort2 port;
                EngineUtils.RequireOk(process.GetPort(out port));

                IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

                IDebugPortNotify2 portNotify;
                EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

                EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(m_debuggedProcess.Id)));

                if (m_ad7ProgramId == Guid.Empty)
                {
                    Debug.Fail("Unexpected problem -- IDebugEngine2.Attach wasn't called");
                    return(Constants.E_FAIL);
                }

                // Resume the threads in the debuggee process
                m_pollThread.RunOperation(new Operation(delegate
                {
                    m_debuggedProcess.ResumeFromLaunch();
                }));

                return(Constants.S_OK);
            }
            catch (ComponentException e)
            {
                return(e.HResult);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }