CreateNamedPipe() private méthode

private CreateNamedPipe ( string name, uint openMode, int pipeMode, int maxInstances, int outBufferSize, int inBufferSize, int defaultTimeout, SecurityAttributesHack &securityAttributes, IntPtr atts ) : IntPtr
name string
openMode uint
pipeMode int
maxInstances int
outBufferSize int
inBufferSize int
defaultTimeout int
securityAttributes SecurityAttributesHack
atts System.IntPtr
Résultat System.IntPtr
Exemple #1
0
        // .ctor without handle - create new
        public unsafe Win32NamedPipeServer(NamedPipeServerStream owner, string pipeName, int maxNumberOfServerInstances,
                                           PipeTransmissionMode transmissionMode, PipeAccessRights rights,
                                           PipeOptions options, int inBufferSize, int outBufferSize,
                                           PipeSecurity pipeSecurity, HandleInheritability inheritability)
        {
            string name = String.Format("\\\\.\\pipe\\{0}", pipeName);

            uint openMode;

            openMode = (uint)rights | (uint)options;             // Enum values match Win32 flags exactly.

            int pipeMode = 0;

            if ((owner.TransmissionMode & PipeTransmissionMode.Message) != 0)
            {
                pipeMode |= 4;
            }
            //if ((readTransmissionMode & PipeTransmissionMode.Message) != 0)
            //	pipeMode |= 2;
            if ((options & PipeOptions.Asynchronous) != 0)
            {
                pipeMode |= 1;
            }

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

            fixed(byte *securityDescriptorPtr = securityDescriptor)
            {
                // FIXME: is nDefaultTimeout = 0 ok?
                var att = new SecurityAttributes(inheritability, (IntPtr)securityDescriptorPtr);
                var ret = Win32Marshal.CreateNamedPipe(name, openMode, pipeMode, maxNumberOfServerInstances,
                                                       outBufferSize, inBufferSize, 0, ref att, IntPtr.Zero);

                if (ret == new IntPtr(-1L))
                {
                    throw Win32PipeError.GetException();
                }
                handle = new SafePipeHandle(ret, true);
            }
        }
        // .ctor without handle - create new
        public Win32NamedPipeServer(NamedPipeServerStream owner, string pipeName, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeAccessRights rights, PipeOptions options, int inBufferSize, int outBufferSize, HandleInheritability inheritability)
        {
            string name = String.Format("\\\\.\\pipe\\{0}", pipeName);

            uint openMode = 0;

            if ((rights & PipeAccessRights.ReadData) != 0)
            {
                openMode |= 1;
            }
            if ((rights & PipeAccessRights.WriteData) != 0)
            {
                openMode |= 2;
            }
            if ((options & PipeOptions.WriteThrough) != 0)
            {
                openMode |= 0x80000000;
            }
            int pipeMode = 0;

            if ((owner.TransmissionMode & PipeTransmissionMode.Message) != 0)
            {
                pipeMode |= 4;
            }
            //if ((readTransmissionMode & PipeTransmissionMode.Message) != 0)
            //	pipeMode |= 2;
            if ((options & PipeOptions.Asynchronous) != 0)
            {
                pipeMode |= 1;
            }

            // FIXME: is nDefaultTimeout = 0 ok?
            var att = new SecurityAttributesHack(inheritability == HandleInheritability.Inheritable);
            var ret = Win32Marshal.CreateNamedPipe(name, openMode, pipeMode, maxNumberOfServerInstances, outBufferSize, inBufferSize, 0, ref att, IntPtr.Zero);

            if (ret == new IntPtr(-1L))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            handle = new SafePipeHandle(ret, true);
        }