// Attach the debug engine to a program. int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason) { int processId = EngineUtils.GetProcessId(rgpPrograms[0]); if (processId == 0) { return(VSConstants.E_NOTIMPL); } pID = (uint)processId; events = ad7Callback; EngineUtils.RequireOk(rgpPrograms[0].GetProgramId(out m_ad7ProgramId)); AD7EngineCreateEvent.Send(this); AD7ProgramCreateEvent.Send(this); debugThread = new AD7Thread(this); AD7ThreadCreateEvent.Send(this); // This event is optional AD7LoadCompleteEvent.Send(this); return(VSConstants.S_OK); }
// Determines if a process can be terminated. int IDebugEngineLaunch2.CanTerminateProcess(IDebugProcess2 process) { if (EngineUtils.GetProcessId(process) == EngineUtils.GetProcessId(debugProcess)) { return(VSConstants.S_OK); } return(VSConstants.S_FALSE); }
// 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) { if (EngineUtils.GetProcessId(process) != EngineUtils.GetProcessId(debugProcess)) { return(VSConstants.S_FALSE); } EnqueueCommand(new Command(CommandKind.Detach)); return(debugProcess.Terminate()); }