Ejemplo n.º 1
0
        public void Attach(System.Diagnostics.Process existingProcess)
        {
            if (existingProcess == null)
            {
                return;
            }

            if (IsDebugging)
            {
                MessageBox.Show(errorDebugging);
                return;
            }
            if (!ServiceInitialized)
            {
                InitializeService();
            }

            string version = debugger.GetProgramVersion(existingProcess.MainModule.FileName);

            if (version.StartsWith("v1.0"))
            {
                MessageBox.Show("Net10NotSupported");
            }
            else
            {
                if (DebugStarting != null)
                {
                    DebugStarting(this, EventArgs.Empty);
                }

                try
                {
                    // set the JIT flag for evaluating optimized code
                    Process.DebugMode = DebugModeFlag.Debug;

                    Process process = debugger.Attach(existingProcess);
                    attached = true;
                    SelectProcess(process);
                }
                catch (System.Exception e)
                {
                    // CORDBG_E_DEBUGGER_ALREADY_ATTACHED
                    if (e is COMException || e is UnauthorizedAccessException)
                    {
                        string msg = "CannotAttachToProcess";
                        MessageBox.Show(msg + " " + e.Message);

                        if (DebugStopped != null)
                        {
                            DebugStopped(this, EventArgs.Empty);
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Attach(System.Diagnostics.Process existingProcess)
        {
            if (existingProcess == null)
            {
                return;
            }

            if (IsDebugging)
            {
                MessageService.ShowMessage(errorDebugging);
                return;
            }
            if (!ServiceInitialized)
            {
                InitializeService();
            }

            string version = debugger.GetProgramVersion(existingProcess.MainModule.FileName);

            if (version.StartsWith("v1.0"))
            {
                MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.Net10NotSupported}");
            }
            else
            {
                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 = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.CannotAttachToProcess}");
                        MessageService.ShowMessage(msg + " " + e.Message);

                        if (DebugStopped != null)
                        {
                            DebugStopped(this, EventArgs.Empty);
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new target VM for the giveb process id.
        /// </summary>
        /// <param name="pid">Process ID of the IKVM</param>
        internal TargetVM(int pid)
        {
            debugger = new NDebugger();
            System.Diagnostics.Process sysProcess = System.Diagnostics.Process.GetProcessById(pid);
            process         = debugger.Attach(sysProcess);
            process.Exited += new EventHandler(ProcessExited);

            process.ModuleLoaded += new EventHandler <ModuleEventArgs>(ModuleLoaded);
            process.Paused       += new EventHandler <ProcessEventArgs>(Paused);
            process.Resumed      += new EventHandler <ProcessEventArgs>(Resumed);
        }
Ejemplo n.º 4
0
        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;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a new target VM for the giveb process id.
        /// </summary>
        /// <param name="pid">Process ID of the IKVM</param>
        internal TargetVM(int pid, JdwpEventHandler jdwpEventHandler)
        {
            this.jdwpEventHandler = jdwpEventHandler;
            debugger = new NDebugger();
            System.Diagnostics.Process sysProcess = System.Diagnostics.Process.GetProcessById(pid);
            process         = debugger.Attach(sysProcess);
            process.Exited += new EventHandler(ProcessExited);

            process.ModuleLoaded  += new EventHandler <ModuleEventArgs>(ModuleLoaded);
            process.Paused        += new EventHandler <ProcessEventArgs>(Paused);
            process.Resumed       += new EventHandler <ProcessEventArgs>(Resumed);
            process.ThreadStarted += new EventHandler <ThreadEventArgs>(ThreadStarted);
        }