Esempio n. 1
0
        /// <summary>
        /// Attach and stop process
        /// </summary>
        internal void AttachAndStop()
        {
            if (!isAttached)
            {
                try
                {
                    debuggeeProcess = debugger.DebugActiveProcess(processId, false);

                    debuggeeProcess.OnCreateProcess   += CreateProcessEventHandler;
                    debuggeeProcess.OnCreateThread    += CreateThreadEventHandler;
                    debuggeeProcess.OnThreadExit      += ExitThreadEventHandler;
                    debuggeeProcess.OnCreateAppDomain += CreateAppDomainEventHandler;
                    debuggeeProcess.OnAppDomainExit   += ExitAppDomainEventHandler;
                    debuggeeProcess.OnProcessExit     += ExitProcessEventHandler;
                    debuggeeProcess.OnModuleLoad      += CreateModuleEventHandler;

                    Go().WaitOne();                     //run the process but wait until its been attached before proceeding
                    //it should be stopped now
                }
                catch (COMException ex)
                {
                    Debug.WriteLine(ex.ToString());
                }
            }
        }
Esempio n. 2
0
 void AttachToProcessImpl(int procId)
 {
     attaching = true;
     MtaThread.Run(delegate
     {
         var iCorDebug = CoreClrShimUtil.CreateICorDebugForProcess(dbgShimInterop, procId, RuntimeLoadTimeout);
         dbg           = new CorDebugger(iCorDebug);
         process       = dbg.DebugActiveProcess(procId, false);
         SetupProcess(process);
         process.Continue(false);
     });
     OnStarted();
 }
Esempio n. 3
0
 protected override void OnRun(DebuggerStartInfo startInfo)
 {
     MtaThread.Run(() => {
         var workingDir = PrepareWorkingDirectory(startInfo);
         var env        = PrepareEnvironment(startInfo);
         var cmd        = PrepareCommandLine(startInfo);
         int procId;
         var iCorDebug = CoreClrShimUtil.CreateICorDebugForCommand(
             dbgShimInterop, cmd, workingDir, env, RuntimeLoadTimeout, out procId);
         dbg       = new CorDebugger(iCorDebug);
         process   = dbg.DebugActiveProcess(procId, false);
         processId = process.Id;
         SetupProcess(process);
         process.Continue(false);
     });
     OnStarted();
 }