private static NtResult <NtFile> OpenFile(string name, FileAccessRights desired_access, bool open_server)
 {
     using (ObjectAttributes obja = new ObjectAttributes(NamedPipeBasePath + name,
                                                         AttributeFlags.CaseInsensitive, null))
     {
         if (open_server)
         {
             return(NtFile.CreateNamedPipe(obja, desired_access | FileAccessRights.Synchronize,
                                           FileShareMode.Read | FileShareMode.Write, FileOpenOptions.SynchronousIoNonAlert,
                                           FileDisposition.Open, NamedPipeType.Bytestream, NamedPipeReadMode.ByteStream,
                                           NamedPipeCompletionMode.CompleteOperation, 0, 0, 0, NtWaitTimeout.FromMilliseconds(0), false).Cast <NtFile>());
         }
         else
         {
             return(NtFile.Open(obja, desired_access,
                                FileShareMode.Read | FileShareMode.Write, FileOpenOptions.None, false));
         }
     }
 }
 /// <summary>
 /// Method to create an object from a set of object attributes.
 /// </summary>
 /// <param name="obj_attributes">The object attributes to create/open from.</param>
 /// <returns>The newly created object.</returns>
 protected override object CreateObject(ObjectAttributes obj_attributes)
 {
     return(NtFile.CreateNamedPipe(obj_attributes, Access, ShareMode, Options, FileDisposition.Open, NamedPipeType.Bytestream,
                                   NamedPipeReadMode.ByteStream, NamedPipeCompletionMode.CompleteOperation, 0, 0, 0, NtWaitTimeout.FromMilliseconds(0)));
 }
 /// <summary>
 /// Method to create an object from a set of object attributes.
 /// </summary>
 /// <param name="obj_attributes">The object attributes to create/open from.</param>
 /// <returns>The newly created object.</returns>
 protected override object CreateObject(ObjectAttributes obj_attributes)
 {
     return(NtFile.CreateNamedPipe(obj_attributes, Access, ShareMode, Options, Disposition, PipeType,
                                   ReadMode, CompletionMode, UnlimitedInstances ? -1 : MaximumInstances, InputQuota, OutputQuota, NtWaitTimeout.FromMilliseconds(DefaultTimeoutMs)));
 }