public void Attach(System.Diagnostics.Process existingProcess) { if (IsDebugging) { this.DebuggedProcess.OnLogMessage(new Debugger.MessageEventArgs(this.DebuggedProcess, errorDebugging)); return; } if (!ServiceInitialized) { InitializeService(); } if (DebugStarting != null) { DebugStarting(this, EventArgs.Empty); } try { Process process = debugger.Attach(existingProcess); attached = true; SelectProcess(process); process.Modules.Added += process_Modules_Added; } catch (System.Exception e) { // CORDBG_E_DEBUGGER_ALREADY_ATTACHED if (e is COMException || e is UnauthorizedAccessException) { string msg = null; if (Variables.Langue == "en") { msg = StringParser.Parse(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_CannotStartProcess_EN); } else { msg = StringParser.Parse(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_CannotStartProcess); } this.DebuggedProcess.OnLogMessage(new Debugger.MessageEventArgs(this.DebuggedProcess, msg + " " + e.Message)); if (DebugStopped != null) { DebugStopped(this, EventArgs.Empty); } } else { throw; } } }
/// <param name="process">Process on which to track debuggee state</param> public static void DoEvents(VelerSoftware.SZC.Debugger.Debugger.Process process) { if (process == null) { return; } DebuggeeState oldState = process.DebuggeeState; WpfDoEvents(); DebuggeeState newState = process.DebuggeeState; if (oldState != newState) { LoggingService.Info("Aborted because debuggee resumed"); throw new AbortedBecauseDebuggeeResumedException(); } }
public void SelectProcess(Process process) { if (debuggedProcess != null) { debuggedProcess.Paused -= debuggedProcess_DebuggingPaused; //debuggedProcess.ExceptionThrown -= debuggedProcess_ExceptionThrown; debuggedProcess.Resumed -= debuggedProcess_DebuggingResumed; } debuggedProcess = process; if (debuggedProcess != null) { debuggedProcess.Paused += debuggedProcess_DebuggingPaused; //debuggedProcess.ExceptionThrown += debuggedProcess_ExceptionThrown; debuggedProcess.Resumed += debuggedProcess_DebuggingResumed; } JumpToCurrentLine(); OnProcessSelected(new ProcessEventArgs(process)); }
public void Start(ProcessStartInfo processStartInfo) { if (IsDebugging) { System.Windows.Forms.MessageBox.Show(errorDebugging); return; } if (!ServiceInitialized) { InitializeService(); } string version = debugger.GetProgramVersion(processStartInfo.FileName); if (version.StartsWith("v1.0")) { if (Variables.Langue == "en") { System.Windows.Forms.MessageBox.Show(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_Net10NotSupported_EN); } else { System.Windows.Forms.MessageBox.Show(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_Net10NotSupported); } } else if (version.StartsWith("v1.1")) { if (Variables.Langue == "en") { System.Windows.Forms.MessageBox.Show(StringParser.Parse(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_Net10NotSupported_EN).Replace("1.0", "1.1")); } else { System.Windows.Forms.MessageBox.Show(StringParser.Parse(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_Net10NotSupported).Replace("1.0", "1.1")); } // } else if (string.IsNullOrEmpty(version)) { // // Not a managed assembly // MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.BadAssembly}"); } else if (debugger.IsKernelDebuggerEnabled) { if (Variables.Langue == "en") { System.Windows.Forms.MessageBox.Show(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_KernelDebuggerEnabled_EN); } else { System.Windows.Forms.MessageBox.Show(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_KernelDebuggerEnabled); } } else { attached = false; if (DebugStarting != null) { DebugStarting(this, EventArgs.Empty); } try { Process process = debugger.Start(processStartInfo.FileName, processStartInfo.WorkingDirectory, processStartInfo.Arguments); SelectProcess(process); } catch (System.Exception e) { // COMException: The request is not supported. (Exception from HRESULT: 0x80070032) // COMException: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail. (Exception from HRESULT: 0x800736B1) // COMException: The requested operation requires elevation. (Exception from HRESULT: 0x800702E4) // COMException: The directory name is invalid. (Exception from HRESULT: 0x8007010B) // BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) // UnauthorizedAccessException: Отказано в доступе. (Исключение из HRESULT: 0x80070005 (E_ACCESSDENIED)) if (e is COMException || e is BadImageFormatException || e is UnauthorizedAccessException) { string msg = null; if (Variables.Langue == "en") { msg = StringParser.Parse(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_CannotStartProcess_EN); } else { msg = StringParser.Parse(VelerSoftware.SZC.Properties.Resources.XML_MainMenu_DebugMenu_Error_CannotStartProcess); } msg += " " + e.Message + " " + e.StackTrace; // TODO: Remove if (e is COMException && ((uint)((COMException)e).ErrorCode == 0x80070032)) { msg += Environment.NewLine + Environment.NewLine; msg += "64-bit debugging is not supported. Please set Project -> Project Options... -> Compiling -> Target CPU to 32bit."; } System.Windows.Forms.MessageBox.Show(msg); if (DebugStopped != null) { DebugStopped(this, EventArgs.Empty); } } else { System.Windows.Forms.MessageBox.Show(e.Message); throw; } } } }