本文整理汇总了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;
}
示例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);
}
}
示例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;
}
}
示例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;
}