CreatePipe() private méthode

private CreatePipe ( IntPtr &readHandle, IntPtr &writeHandle, SecurityAttributesHack &pipeAtts, int size ) : bool
readHandle System.IntPtr
writeHandle System.IntPtr
pipeAtts SecurityAttributesHack
size int
Résultat bool
Exemple #1
0
        // AnonymousPipeServerStream owner;

        public unsafe Win32AnonymousPipeServer(AnonymousPipeServerStream owner, PipeDirection direction,
                                               HandleInheritability inheritability, int bufferSize,
                                               PipeSecurity pipeSecurity)
        {
            IntPtr r, w;

            byte[] securityDescriptor = null;
            if (pipeSecurity != null)
            {
                securityDescriptor = pipeSecurity.GetSecurityDescriptorBinaryForm();

                fixed(byte *securityDescriptorPtr = securityDescriptor)
                {
                    SecurityAttributes att = new SecurityAttributes(inheritability, (IntPtr)securityDescriptorPtr);

                    if (!Win32Marshal.CreatePipe(out r, out w, ref att, bufferSize))
                    {
                        throw Win32PipeError.GetException();
                    }
                }

                var rh = new SafePipeHandle(r, true);
                var wh = new SafePipeHandle(w, true);

                if (direction == PipeDirection.Out)
                {
                    server_handle = wh;
                    client_handle = rh;
                }
                else
                {
                    server_handle = rh;
                    client_handle = wh;
                }
        }
        // AnonymousPipeServerStream owner;

        public Win32AnonymousPipeServer(AnonymousPipeServerStream owner, PipeDirection direction, HandleInheritability inheritability, int bufferSize)
        {
            IntPtr r, w;
            SecurityAttributesHack att = new SecurityAttributesHack(inheritability == HandleInheritability.Inheritable);

            if (!Win32Marshal.CreatePipe(out r, out w, ref att, bufferSize))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            var rh = new SafePipeHandle(r, true);
            var wh = new SafePipeHandle(w, true);

            if (direction == PipeDirection.Out)
            {
                server_handle = wh;
                client_handle = rh;
            }
            else
            {
                server_handle = rh;
                client_handle = wh;
            }
        }