예제 #1
0
        private Process StartProcessInternal(ProcessStartInfo startInfo, ExecutionUserContext context, ExecutionPrivileges privileges, int redirectionBufferSize, bool fullProcessAccess)
        {
            if (startInfo.UseShellExecute == true)
            {
                throw new ArgumentException("You cannot use shell execute to execute applications under LUA", "startInfo");
            }
            if (startInfo.UserName.Length > 0)
            {
                throw new ArgumentException("You cannot use user credencials to execute applications under LUA", "startInfo");
            }

            bool runAsUser    = context == ExecutionUserContext.FirstActiveSessionUser;
            bool elevated     = (privileges & ExecutionPrivileges.Administrator) == ExecutionPrivileges.Administrator;
            bool lowIntegrity = (privileges & ExecutionPrivileges.Low) == ExecutionPrivileges.Low;

            //

            //Because the process hosting the proxy has a different Current Directory then
            //this process, we fully qualify the path if it is relative to the current directory.
            string filename = ProcessHelper.GetExeFullPath(startInfo.FileName);

            int    threadId;
            string stdOut, stdErr, stdIn;
            int    pid = proxy.BeginCreateProcess(
                filename,
                startInfo.Arguments,
                startInfo.WorkingDirectory,
                startInfo.CreateNoWindow,
                startInfo.RedirectStandardError,
                startInfo.RedirectStandardInput,
                startInfo.RedirectStandardOutput,
                startInfo.StandardErrorEncoding,
                startInfo.StandardOutputEncoding,
                startInfo.EnvironmentVariables,
                runAsUser,
                null,
                lowIntegrity,
                elevated,
                redirectionBufferSize,
                out threadId,
                out stdOut,
                out stdErr,
                out stdIn);

            //Get the process object
            return(ProcessHelper.EndCreateProcess(startInfo, pid, threadId, stdOut, stdErr, stdIn, redirectionBufferSize, fullProcessAccess));
        }
예제 #2
0
        public Process StartProcess(ProcessStartInfo startInfo, ExecutionUserContext context, ExecutionPrivileges privileges, int redirectionBufferSize, bool fullProcessAccess)
        {
            IntPtr hGroupObject = IntPtr.Zero;

            return(StartProcessInternal(startInfo, context, privileges, redirectionBufferSize, fullProcessAccess));
        }
예제 #3
0
 public IntPtr StartProcessGroup(ProcessStartInfo startInfo, ExecutionUserContext context, ExecutionPrivileges privileges, bool fullProcessAccess, out Process process)
 {
     process = StartProcessInternal(startInfo, context, privileges, ProcessHelper.DefaultRedirectionBufferSize, fullProcessAccess);
     return((IntPtr)CreateProcessGroup(process.Id));
 }
예제 #4
0
 public Process StartProcess(ProcessStartInfo startInfo, ExecutionUserContext context, ExecutionPrivileges privileges, bool fullProcessAccess)
 {
     return(StartProcess(startInfo, context, privileges, ProcessHelper.DefaultRedirectionBufferSize, fullProcessAccess));
 }