示例#1
0
        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));
        }
示例#2
0
 public static extern ParameterCode SetStartupLongArg(ProcessHandle handle,
                                                      int index, long value);
示例#3
0
 public static extern int GetStartupLongArgCount(ProcessHandle handle);
示例#4
0
 public static extern bool Start(ProcessHandle handle);
示例#5
0
        public static int GetStartupBoolArgCount(ProcessHandle handle)
        {
            Process process = HandleTable.GetHandle(handle.id) as Process;

            return(process.GetStartupBoolArgCount());
        }
示例#6
0
        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);
        }
示例#7
0
 public static unsafe void JoinImpl(ProcessHandle handle, bool *started)
 {
     Join(handle, out *started);
 }
示例#8
0
 public static extern unsafe bool SetStartupEndpoint(ProcessHandle handle,
                                                     int index,
                                                     SharedHeapService.Allocation *endpoint);
示例#9
0
 public static extern int GetProcessId(ProcessHandle handle);
示例#10
0
 public static extern void Stop(ProcessHandle handle,
                                int exitcode);
示例#11
0
 public static extern bool Resume(ProcessHandle handle,
                                  bool recursive);
示例#12
0
 public static extern bool Suspend(ProcessHandle handle,
                                   bool recursive);
示例#13
0
 public static extern unsafe bool JoinImpl(
     ProcessHandle handle,
     SchedulerTime stop,
     bool *started);
示例#14
0
 public static extern unsafe bool JoinImpl(
     ProcessHandle handle,
     TimeSpan timeout,
     bool *started);
示例#15
0
 public static extern unsafe void JoinImpl(
     ProcessHandle handle,
     bool *started);
示例#16
0
 public static extern ParameterCode GetStartupBoolArg(ProcessHandle handle,
                                                      int index, out bool value);
示例#17
0
 public static extern unsafe ParameterCode SetStartupBoolArg(ProcessHandle handle,
                                                             int index, bool value);
示例#18
0
 public static extern int GetExitCode(ProcessHandle handle);
示例#19
0
        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);
        }
示例#20
0
 public static extern PrincipalHandle GetPrincipalHandle(ProcessHandle handle);
示例#21
0
 public static extern ProcessState GetState(ProcessHandle handle);
示例#22
0
 public static extern unsafe int GetStartupStringArg(ProcessHandle handle,
                                                     int arg, char *output, int maxout);
示例#23
0
        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));
        }
示例#24
0
 public static extern unsafe ParameterCode SetStartupStringArg(ProcessHandle handle,
                                                               int arg, char *input, int length);
示例#25
0
        public static ParameterCode SetStartupBoolArg(ProcessHandle handle, int index, bool value)
        {
            Process process = HandleTable.GetHandle(handle.id) as Process;

            return((ParameterCode)process.SetStartupBoolArg(index, value));
        }
示例#26
0
 public static extern void Dispose(ProcessHandle handle);