// 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;
}
}