当前位置: 首页>>代码示例>>C#>>正文


C# PipeSecurity.GetSecurityDescriptorBinaryForm方法代码示例

本文整理汇总了C#中System.IO.Pipes.PipeSecurity.GetSecurityDescriptorBinaryForm方法的典型用法代码示例。如果您正苦于以下问题:C# PipeSecurity.GetSecurityDescriptorBinaryForm方法的具体用法?C# PipeSecurity.GetSecurityDescriptorBinaryForm怎么用?C# PipeSecurity.GetSecurityDescriptorBinaryForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Pipes.PipeSecurity的用法示例。


在下文中一共展示了PipeSecurity.GetSecurityDescriptorBinaryForm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSecAttrs

        internal unsafe static UnsafeNativeMethods.SECURITY_ATTRIBUTES GetSecAttrs(HandleInheritability inheritability, PipeSecurity pipeSecurity, out Object pinningHandle) {
            pinningHandle = null;
            UnsafeNativeMethods.SECURITY_ATTRIBUTES secAttrs = null;
            if ((inheritability & HandleInheritability.Inheritable) != 0 || pipeSecurity != null) {
                secAttrs = new UnsafeNativeMethods.SECURITY_ATTRIBUTES();
                secAttrs.nLength = (int)Marshal.SizeOf(secAttrs);

                if ((inheritability & HandleInheritability.Inheritable) != 0) {
                    secAttrs.bInheritHandle = 1;
                }

                // For ACLs, get the security descriptor from the PipeSecurity.
                if (pipeSecurity != null) {
                    byte[] sd = pipeSecurity.GetSecurityDescriptorBinaryForm();
                    pinningHandle = GCHandle.Alloc(sd, GCHandleType.Pinned);
                    fixed (byte* pSecDescriptor = sd) {
                        secAttrs.pSecurityDescriptor = pSecDescriptor;
                    }
                }
            }
            return secAttrs;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:22,代码来源:PipeStream.cs

示例2: Win32NamedPipeServer

		// .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);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:33,代码来源:PipeWin32.cs

示例3: Win32AnonymousPipeServer

		// 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;
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:PipeWin32.cs

示例4: GetSecAttrs

 internal static unsafe Microsoft.Win32.UnsafeNativeMethods.SECURITY_ATTRIBUTES GetSecAttrs(HandleInheritability inheritability, PipeSecurity pipeSecurity, out object pinningHandle)
 {
     pinningHandle = null;
     Microsoft.Win32.UnsafeNativeMethods.SECURITY_ATTRIBUTES structure = null;
     if (((inheritability & HandleInheritability.Inheritable) != HandleInheritability.None) || (pipeSecurity != null))
     {
         structure = new Microsoft.Win32.UnsafeNativeMethods.SECURITY_ATTRIBUTES {
             nLength = Marshal.SizeOf(structure)
         };
         if ((inheritability & HandleInheritability.Inheritable) != HandleInheritability.None)
         {
             structure.bInheritHandle = 1;
         }
         if (pipeSecurity == null)
         {
             return structure;
         }
         byte[] securityDescriptorBinaryForm = pipeSecurity.GetSecurityDescriptorBinaryForm();
         pinningHandle = GCHandle.Alloc(securityDescriptorBinaryForm, GCHandleType.Pinned);
         fixed (byte* numRef = securityDescriptorBinaryForm)
         {
             structure.pSecurityDescriptor = numRef;
         }
     }
     return structure;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:PipeStream.cs


注:本文中的System.IO.Pipes.PipeSecurity.GetSecurityDescriptorBinaryForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。