示例#1
0
        // .ctor without handle - create new
        public Win32NamedPipeClient(NamedPipeClientStream owner, string serverName, string pipeName, PipeAccessRights desiredAccessRights, PipeOptions options, HandleInheritability inheritability)
        {
            name = String.Format("\\\\{0}\\pipe\\{1}", serverName, pipeName);
            var att = new SecurityAttributesHack(inheritability == HandleInheritability.Inheritable);

            is_async = (options & PipeOptions.Asynchronous) != PipeOptions.None;

            opener = delegate {
                var ret = Win32Marshal.CreateFile(name, desiredAccessRights, 0, ref att, 3, 0, IntPtr.Zero);
                if (ret == new IntPtr(-1L))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                return(new SafePipeHandle(ret, true));
            };
            this.owner = owner;
        }
示例#2
0
		// 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;
			}
		}
        // .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);
        }
        // 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;
            }
        }
 internal static extern IntPtr CreateNamedPipe(string name, uint openMode, int pipeMode, int maxInstances, int outBufferSize, int inBufferSize, int defaultTimeout, ref SecurityAttributesHack securityAttributes, IntPtr atts);
 internal static extern bool CreatePipe(out IntPtr readHandle, out IntPtr writeHandle, ref SecurityAttributesHack pipeAtts, int size);
示例#7
0
		internal static extern IntPtr CreateFile (string name, PipeAccessRights desiredAccess, FileShare fileShare, ref SecurityAttributesHack atts, int creationDisposition, int flags, IntPtr templateHandle);
示例#8
0
		internal static extern IntPtr CreateNamedPipe (string name, uint openMode, int pipeMode, int maxInstances, int outBufferSize, int inBufferSize, int defaultTimeout, ref SecurityAttributesHack securityAttributes, IntPtr atts);
		internal static IntPtr CreateNamedPipe (string name, uint openMode, int pipeMode, int maxInstances, int outBufferSize, int inBufferSize, int defaultTimeout, ref SecurityAttributesHack securityAttributes, IntPtr atts)
		{
			throw new System.NotImplementedException();
		}
示例#10
0
		// .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);
		}
示例#11
0
		// .ctor without handle - create new
		public Win32NamedPipeClient (NamedPipeClientStream owner, string serverName, string pipeName, PipeAccessRights desiredAccessRights, PipeOptions options, HandleInheritability inheritability)
		{
			name = String.Format ("\\\\{0}\\pipe\\{1}", serverName, pipeName);
			var att = new SecurityAttributesHack (inheritability == HandleInheritability.Inheritable);
			is_async = (options & PipeOptions.Asynchronous) != PipeOptions.None;

			opener = delegate {
				var ret = Win32Marshal.CreateFile (name, desiredAccessRights, 0, ref att, 3, 0, IntPtr.Zero);
				if (ret == new IntPtr (-1L))
					throw new Win32Exception (Marshal.GetLastWin32Error ());

				return new SafePipeHandle (ret, true);
			};
			this.owner = owner;
		}
示例#12
0
 internal static IntPtr CreateFile(string name, PipeAccessRights desiredAccess, FileShare fileShare, ref SecurityAttributesHack atts, int creationDisposition, int flags, IntPtr templateHandle)
 {
     throw new System.NotImplementedException();
 }
示例#13
0
 internal static IntPtr CreateNamedPipe(string name, uint openMode, int pipeMode, int maxInstances, int outBufferSize, int inBufferSize, int defaultTimeout, ref SecurityAttributesHack securityAttributes, IntPtr atts)
 {
     throw new System.NotImplementedException();
 }
示例#14
0
 internal static bool CreatePipe(out IntPtr readHandle, out IntPtr writeHandle, ref SecurityAttributesHack pipeAtts, int size)
 {
     throw new System.NotImplementedException();
 }
		internal static IntPtr CreateFile (string name, PipeAccessRights desiredAccess, FileShare fileShare, ref SecurityAttributesHack atts, int creationDisposition, int flags, IntPtr templateHandle)
		{
			throw new System.NotImplementedException();
		}
 internal static extern IntPtr CreateFile(string name, PipeAccessRights desiredAccess, FileShare fileShare, ref SecurityAttributesHack atts, int creationDisposition, int flags, IntPtr templateHandle);
示例#17
0
		internal static extern bool CreatePipe (out IntPtr readHandle, out IntPtr writeHandle, ref SecurityAttributesHack pipeAtts, int size);
		internal static bool CreatePipe (out IntPtr readHandle, out IntPtr writeHandle, ref SecurityAttributesHack pipeAtts, int size)
		{
			throw new System.NotImplementedException();
		}