コード例 #1
0
ファイル: Process.cs プロジェクト: quatauta/ansible.windows
        internal static SafeMemoryBuffer CreateSecurityAttributes(SecurityAttributes attributes)
        {
            IntPtr lpAttributes = IntPtr.Zero;

            if (attributes != null)
            {
                NativeHelpers.SECURITY_ATTRIBUTES attr = new NativeHelpers.SECURITY_ATTRIBUTES()
                {
                    bInheritHandle = attributes.InheritHandle,
                };

                lpAttributes = Marshal.AllocHGlobal(Marshal.SizeOf(attr));
                Marshal.StructureToPtr(attr, lpAttributes, false);
            }

            return(new SafeMemoryBuffer(lpAttributes));
        }
コード例 #2
0
ファイル: Process.cs プロジェクト: yasir2000/ansible.windows
        internal static void CreateStdioPipes(NativeHelpers.STARTUPINFOEX si, out SafeFileHandle stdoutRead,
                                              out SafeFileHandle stdoutWrite, out SafeFileHandle stderrRead, out SafeFileHandle stderrWrite,
                                              out SafeFileHandle stdinRead, out SafeFileHandle stdinWrite)
        {
            NativeHelpers.SECURITY_ATTRIBUTES pipesec = new NativeHelpers.SECURITY_ATTRIBUTES();
            pipesec.bInheritHandle = true;

            if (!NativeMethods.CreatePipe(out stdoutRead, out stdoutWrite, pipesec, 0))
            {
                throw new Win32Exception("STDOUT pipe setup failed");
            }
            if (!NativeMethods.SetHandleInformation(stdoutRead, NativeHelpers.HandleFlags.INHERIT, 0))
            {
                throw new Win32Exception("STDOUT pipe handle setup failed");
            }

            if (!NativeMethods.CreatePipe(out stderrRead, out stderrWrite, pipesec, 0))
            {
                throw new Win32Exception("STDERR pipe setup failed");
            }
            if (!NativeMethods.SetHandleInformation(stderrRead, NativeHelpers.HandleFlags.INHERIT, 0))
            {
                throw new Win32Exception("STDERR pipe handle setup failed");
            }

            if (!NativeMethods.CreatePipe(out stdinRead, out stdinWrite, pipesec, 0))
            {
                throw new Win32Exception("STDIN pipe setup failed");
            }
            if (!NativeMethods.SetHandleInformation(stdinWrite, NativeHelpers.HandleFlags.INHERIT, 0))
            {
                throw new Win32Exception("STDIN pipe handle setup failed");
            }

            si.startupInfo.hStdOutput = stdoutWrite;
            si.startupInfo.hStdError  = stderrWrite;
            si.startupInfo.hStdInput  = stdinRead;
        }
コード例 #3
0
ファイル: Process.cs プロジェクト: yasir2000/ansible.windows
 public static extern bool CreatePipe(
     out SafeFileHandle hReadPipe,
     out SafeFileHandle hWritePipe,
     NativeHelpers.SECURITY_ATTRIBUTES lpPipeAttributes,
     UInt32 nSize);