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

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