CreateProcess() 공개 메소드

public CreateProcess ( String applicationName, String commandLine ) : Microsoft.Samples.Debugging.CorDebug.CorProcess
applicationName String
commandLine String
리턴 Microsoft.Samples.Debugging.CorDebug.CorProcess
예제 #1
0
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			// Create the debugger

			string dversion;
			try {
				dversion = CorDebugger.GetDebuggerVersionFromFile (startInfo.Command);
			}
			catch {
				dversion = CorDebugger.GetDefaultDebuggerVersion ();
			}
			dbg = new CorDebugger (dversion);

			Dictionary<string, string> env = new Dictionary<string, string> ();
			foreach (DictionaryEntry de in Environment.GetEnvironmentVariables ())
				env[(string) de.Key] = (string) de.Value;

			foreach (KeyValuePair<string, string> var in startInfo.EnvironmentVariables)
				env[var.Key] = var.Value;

            // The second parameter of CreateProcess is the command line, and it includes the application being launched
            string cmdLine = "\"" + startInfo.Command + "\" " + startInfo.Arguments;

			int flags = 0;
			if (!startInfo.UseExternalConsole) {
				flags = 0x08000000; /* CREATE_NO_WINDOW*/
				flags |= CorDebugger.CREATE_REDIRECT_STD;
			}

			process = dbg.CreateProcess (startInfo.Command, cmdLine, startInfo.WorkingDirectory, env, flags);
			processId = process.Id;

			process.OnCreateProcess += new CorProcessEventHandler (OnCreateProcess);
			process.OnCreateAppDomain += new CorAppDomainEventHandler (OnCreateAppDomain);
			process.OnAssemblyLoad += new CorAssemblyEventHandler (OnAssemblyLoad);
			process.OnAssemblyUnload += new CorAssemblyEventHandler (OnAssemblyUnload);
			process.OnCreateThread += new CorThreadEventHandler (OnCreateThread);
			process.OnThreadExit += new CorThreadEventHandler (OnThreadExit);
			process.OnModuleLoad += new CorModuleEventHandler (OnModuleLoad);
			process.OnModuleUnload += new CorModuleEventHandler (OnModuleUnload);
			process.OnProcessExit += new CorProcessEventHandler (OnProcessExit);
			process.OnUpdateModuleSymbols += new UpdateModuleSymbolsEventHandler (OnUpdateModuleSymbols);
			process.OnDebuggerError += new DebuggerErrorEventHandler (OnDebuggerError);
			process.OnBreakpoint += new BreakpointEventHandler (OnBreakpoint);
			process.OnStepComplete += new StepCompleteEventHandler (OnStepComplete);
			process.OnBreak += new CorThreadEventHandler (OnBreak);
			process.OnNameChange += new CorThreadEventHandler (OnNameChange);
			process.OnEvalComplete += new EvalEventHandler (OnEvalComplete);
			process.OnEvalException += new EvalEventHandler (OnEvalException);
			process.OnLogMessage += new LogMessageEventHandler (OnLogMessage);
			process.OnStdOutput += new CorTargetOutputEventHandler (OnStdOutput);

			process.Continue (false);

			OnStarted ();
		}
예제 #2
0
        private void prepareDebugger(string arguments)
        {
            var debugger = new CorDebugger(CorDebugger.GetDefaultDebuggerVersion());
            _process = debugger.CreateProcess(_assembly, arguments);

            _process.OnCreateAppDomain += new CorAppDomainEventHandler(process_OnCreateAppDomain);
            _process.OnProcessExit += new CorProcessEventHandler(process_OnProcessExit);
            _process.OnBreakpoint += new BreakpointEventHandler(process_OnBreakpoint);
            _process.OnStepComplete += new StepCompleteEventHandler(_process_OnStepComplete);
            _process.OnModuleLoad += new CorModuleEventHandler(_process_OnModuleLoad);
            _process.OnDebuggerError += new DebuggerErrorEventHandler(_process_OnDebuggerError);
        }