예제 #1
0
        public DebuggeeProcess StartProcess(DebuggerProcessStartInfo info)
        {
            IsActive = true;
            var             started = new ManualResetEvent(false);
            DebuggeeProcess process = null;

            // Spawn debugger loop on new thread.
            new Thread(() =>
            {
                // Initialize startup info.
                var startupInfo = new STARTUPINFO();
                startupInfo.cb  = (uint)Marshal.SizeOf <STARTUPINFO>();

                // Create process with debug flag set.
                var processInfo = NativeMethods.CreateProcess(
                    null, info.CommandLine, IntPtr.Zero, IntPtr.Zero, false,
                    ProcessCreationFlags.DEBUG_ONLY_THIS_PROCESS | ProcessCreationFlags.CREATE_NEW_CONSOLE,
                    IntPtr.Zero, null, ref startupInfo);

                process = GetOrCreateProcess(processInfo.hProcess, processInfo.dwProcessId);

                // Signal process has started.
                started.Set();

                // Enter debugger loop.
                DebuggerLoop();
            })
            {
                IsBackground = true
            }.Start();

            // Wait for process.
            started.WaitOne();

            return(process);
        }
예제 #2
0
 IDebuggeeProcess IDebuggerSession.StartProcess(DebuggerProcessStartInfo info)
 {
     return(StartProcess(info));
 }