public static unsafe int GetStartupStringArg(ProcessHandle handle, int arg, char *output, int maxput) { Process process = HandleTable.GetHandle(handle.id) as Process; string s = process.GetStartupStringArg(arg); Tracing.Log(Tracing.Debug, "Process.GetStartupStringArg(arg={0}, out={1:x8}, max={2}) = {3}", (UIntPtr) unchecked ((uint)arg), (UIntPtr)output, (UIntPtr) unchecked ((uint)maxput), (UIntPtr) unchecked ((uint)(s != null ? s.Length : 0))); if (s == null) { return(0); } if (output == null) { return(s.Length + 1); } return(s.InternalGetChars(output, maxput)); }
public static extern ParameterCode SetStartupLongArg(ProcessHandle handle, int index, long value);
public static extern int GetStartupLongArgCount(ProcessHandle handle);
public static extern bool Start(ProcessHandle handle);
public static int GetStartupBoolArgCount(ProcessHandle handle) { Process process = HandleTable.GetHandle(handle.id) as Process; return(process.GetStartupBoolArgCount()); }
public static unsafe bool Create(char *cmdName, int cmdLength, char *actionName, int actionLength, char *role, int roleLength, out ProcessHandle handle) { Kernel.Waypoint(550); string mycmd = null; if (cmdName != null && cmdLength > 0) { mycmd = String.StringCTOR(cmdName, 0, cmdLength); } else { //should never happen DebugStub.Break(); } string myrole = null; if (role != null && roleLength > 0) { myrole = String.StringCTOR(role, 0, roleLength); } string myaction = null; if (actionName != null && actionLength > 0) { myaction = String.StringCTOR(actionName, 0, actionLength); } Kernel.Waypoint(551); // // Find image to run. // Manifest appManifest; IoMemory image = Binder.LoadImage(Thread.CurrentProcess, mycmd, out appManifest); Kernel.Waypoint(552); if (image != null && image.Length > 0 && appManifest != null) { // // Check manifest to see what resources are needed // // // Create a Managed process, and a handle in the current // process to hold it. // // REVIEW: create empty args array so that we // do not need to change the process constructor; String[] myargs; if (myaction != null) { myargs = new String[2]; myargs[1] = myaction; } else { myargs = new String[1]; } myargs[0] = mycmd; Process process = new Process(Thread.CurrentProcess, image, myrole, myargs, appManifest); // // Check manifest to see what resources are needed // int epCount = appManifest.SetEndpoints(process, myaction); #if VERBOSE DebugStub.WriteLine("new process create: endpoints from manifest {0}", __arglist(epCount)); #endif int boolCount, longCount, stringCount, stringArrayCount; bool ok = appManifest.GetParameterCounts(myaction, out boolCount, out longCount, out stringCount, out stringArrayCount); //DebugStub.WriteLine("ProcessHandle: args strings={0}, longs={1}, bools={2}", // __arglist(stringCount, longCount, boolCount)); process.SetBoolArgCount(boolCount); process.SetLongArgCount(longCount); process.SetStringArgCount(stringCount); process.SetStringArrayArgCount(stringArrayCount); handle = new ProcessHandle( Thread.CurrentProcess.AllocateHandle(process)); Tracing.Log(Tracing.Debug, "ProcessHandle.Create(out id={0:x8})", handle.id); Kernel.Waypoint(553); IoMemory.Release(image); appManifest = null; return(true); } Tracing.Log(Tracing.Debug, "ProcessHandle.Create() failed"); handle = new ProcessHandle(); Kernel.Waypoint(554); return(false); }
public static unsafe void JoinImpl(ProcessHandle handle, bool *started) { Join(handle, out *started); }
public static extern unsafe bool SetStartupEndpoint(ProcessHandle handle, int index, SharedHeapService.Allocation *endpoint);
public static extern int GetProcessId(ProcessHandle handle);
public static extern void Stop(ProcessHandle handle, int exitcode);
public static extern bool Resume(ProcessHandle handle, bool recursive);
public static extern bool Suspend(ProcessHandle handle, bool recursive);
public static extern unsafe bool JoinImpl( ProcessHandle handle, SchedulerTime stop, bool *started);
public static extern unsafe bool JoinImpl( ProcessHandle handle, TimeSpan timeout, bool *started);
public static extern unsafe void JoinImpl( ProcessHandle handle, bool *started);
public static extern ParameterCode GetStartupBoolArg(ProcessHandle handle, int index, out bool value);
public static extern unsafe ParameterCode SetStartupBoolArg(ProcessHandle handle, int index, bool value);
public static extern int GetExitCode(ProcessHandle handle);
public static unsafe bool Create(char *args, int *argLengths, int argCount, char *role, int roleLength, int endpointCount, out ProcessHandle handle) { Kernel.Waypoint(550); // // Create a kernel String[] object populated with the argument // values passed in from userland. // String[] arguments = new String[argCount]; int offset = 0; for (int argument = 0; argument < argCount; argument++) { arguments[argument] = String.StringCTOR( args, offset, argLengths[argument]); offset += argLengths[argument]; } string myrole = null; if (role != null && roleLength > 0) { myrole = String.StringCTOR(role, 0, roleLength); } Kernel.Waypoint(551); // // Find image to run. // Manifest appManifest; IoMemory image = Binder.LoadImage(Thread.CurrentProcess, arguments[0], out appManifest); Kernel.Waypoint(552); if (image != null && image.Length > 0 && appManifest != null) { // // Check manifest to see what resources are needed // // // Create a Managed process, and a handle in the current // process to hold it. // Process process = new Process(Thread.CurrentProcess, image, myrole, arguments, appManifest); // // Check manifest to see what resources are needed // int epCount = appManifest.SetEndpoints(process, null); #if VERBOSE DebugStub.WriteLine("endpoints passed in={0}, endpoints from manifest {1}", __arglist(endpointCount, epCount)); #endif if (epCount == 0) { process.SetEndpointCount(endpointCount); } int boolCount, longCount, stringCount, stringArrayCount; bool ok = appManifest.GetParameterCounts(null, out boolCount, out longCount, out stringCount, out stringArrayCount); //DebugStub.WriteLine("ProcessHandle: args strings={0}, longs={1}, bools={2}", // __arglist(stringCount, longCount, boolCount)); process.SetBoolArgCount(boolCount); process.SetLongArgCount(longCount); process.SetStringArgCount(stringCount); process.SetStringArrayArgCount(stringArrayCount); handle = new ProcessHandle( Thread.CurrentProcess.AllocateHandle(process)); Tracing.Log(Tracing.Debug, "ProcessHandle.Create(out id={0:x8})", handle.id); Kernel.Waypoint(553); IoMemory.Release(image); appManifest = null; return(true); } Tracing.Log(Tracing.Debug, "ProcessHandle.Create() failed"); handle = new ProcessHandle(); Kernel.Waypoint(554); return(false); }
public static extern PrincipalHandle GetPrincipalHandle(ProcessHandle handle);
public static extern ProcessState GetState(ProcessHandle handle);
public static extern unsafe int GetStartupStringArg(ProcessHandle handle, int arg, char *output, int maxout);
public static ParameterCode GetStartupLongArg(ProcessHandle handle, int index, out long value) { Process process = HandleTable.GetHandle(handle.id) as Process; return((ParameterCode)process.GetStartupLongArg(index, out value)); }
public static extern unsafe ParameterCode SetStartupStringArg(ProcessHandle handle, int arg, char *input, int length);
public static ParameterCode SetStartupBoolArg(ProcessHandle handle, int index, bool value) { Process process = HandleTable.GetHandle(handle.id) as Process; return((ParameterCode)process.SetStartupBoolArg(index, value)); }
public static extern void Dispose(ProcessHandle handle);