Example #1
0
        // This function is used to terminate a process that the SampleEngine launched
        // The debugger will call IDebugEngineLaunch2::CanTerminateProcess before calling this method.
        int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 process)
        {
            Debug.Assert(_pollThread != null);
            Debug.Assert(_engineCallback != null);
            Debug.Assert(_debuggedProcess != null);

            try
            {
                AD_PROCESS_ID processId = EngineUtils.GetProcessId(process);
                if (!EngineUtils.ProcIdEquals(processId, _debuggedProcess.Id))
                {
                    return(Constants.S_FALSE);
                }

                _pollThread.RunOperation(() => _debuggedProcess.CmdTerminate());
                _debuggedProcess.Terminate();

                return(Constants.S_OK);
            }
            catch (MIException e)
            {
                return(e.HResult);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
Example #2
0
        // This function is used to terminate a process that the SampleEngine launched
        // The debugger will call IDebugEngineLaunch2::CanTerminateProcess before calling this method.
        int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 process)
        {
            Debug.Assert(_pollThread != null);
            Debug.Assert(_engineCallback != null);
            Debug.Assert(_debuggedProcess != null);

            AD_PROCESS_ID processId = EngineUtils.GetProcessId(process);

            if (!EngineUtils.ProcIdEquals(processId, _debuggedProcess.Id))
            {
                return(Constants.S_FALSE);
            }

            try
            {
                _pollThread.RunOperation(() => _debuggedProcess.CmdTerminate());

                if (_debuggedProcess.MICommandFactory.Mode != MIMode.Clrdbg)
                {
                    _debuggedProcess.Terminate();
                }
                else
                {
                    // Clrdbg issues a proper exit event on CmdTerminate call, don't call _debuggedProcess.Terminate() which
                    // simply sends a fake exit event that overrides the exit code of the real one
                }
            }
            catch (ObjectDisposedException)
            {
                // Ignore failures caused by the connection already being dead.
            }

            return(Constants.S_OK);
        }
Example #3
0
        // This function is used to terminate a process that the SampleEngine launched
        // The debugger will call IDebugEngineLaunch2::CanTerminateProcess before calling this method.
        int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 process)
        {
            Debug.Assert(_pollThread != null);
            Debug.Assert(_engineCallback != null);
            Debug.Assert(_debuggedProcess != null);

            AD_PROCESS_ID processId = EngineUtils.GetProcessId(process);

            if (!EngineUtils.ProcIdEquals(processId, _debuggedProcess.Id))
            {
                return(Constants.S_FALSE);
            }

            try
            {
                _pollThread.RunOperation(() => _debuggedProcess.CmdTerminate());
                _debuggedProcess.Terminate();
            }
            catch (ObjectDisposedException)
            {
                // Ignore failures caused by the connection already being dead.
            }

            return(Constants.S_OK);
        }