/// <summary> /// Open a private namespace directory. /// </summary> /// <param name="boundary_descriptor">Boundary descriptor for the namespace</param> /// <returns>The directory object</returns> /// <exception cref="NtException">Thrown on error</exception> public static NtDirectory OpenPrivateNamespace(BoundaryDescriptor boundary_descriptor) { using (ObjectAttributes obja = new ObjectAttributes()) { return(OpenPrivateNamespace(obja, boundary_descriptor, DirectoryAccessRights.MaximumAllowed)); } }
/// <summary> /// Create a boundary descriptor from a string representation. /// </summary> /// <param name="descriptor">A boundary descriptor string of the form [SID[:SID...]@]NAME where SID is an SDDL format SID.</param> /// <returns>The new boundary descriptor.</returns> public static BoundaryDescriptor CreateFromString(string descriptor) { string[] parts = descriptor.Split(new char[] { '@' }, 2); string obj_name = parts.Length > 1 ? parts[1] : parts[0]; BoundaryDescriptor boundary = new BoundaryDescriptor(obj_name); if (parts.Length > 1) { boundary.AddSids(parts[0].Split(':').Select(s => new Sid(s))); } return(boundary); }
/// <summary> /// Open a private namespace directory. /// </summary> /// <param name="obj_attributes">Object attributes for the directory</param> /// <param name="boundary_descriptor">Boundary descriptor for the namespace</param> /// <param name="desired_access">Desired access for the directory</param> /// <returns>The directory object</returns> /// <exception cref="NtException">Thrown on error</exception> public static NtDirectory OpenPrivateNamespace(ObjectAttributes obj_attributes, BoundaryDescriptor boundary_descriptor, DirectoryAccessRights desired_access) { return(OpenPrivateNamespace(obj_attributes, boundary_descriptor, desired_access, true).Result); }
/// <summary> /// Open a private namespace directory. /// </summary> /// <param name="obj_attributes">Object attributes for the directory</param> /// <param name="boundary_descriptor">Boundary descriptor for the namespace</param> /// <param name="desired_access">Desired access for the directory</param> /// <param name="throw_on_error">True to throw an exception on error.</param> /// <returns>The directory object</returns> /// <exception cref="NtException">Thrown on error</exception> public static NtResult <NtDirectory> OpenPrivateNamespace(ObjectAttributes obj_attributes, BoundaryDescriptor boundary_descriptor, DirectoryAccessRights desired_access, bool throw_on_error) { return(NtSystemCalls.NtOpenPrivateNamespace(out SafeKernelObjectHandle handle, desired_access, obj_attributes, boundary_descriptor.Handle) .CreateResult(throw_on_error, () => new NtDirectory(handle, true))); }
/// <summary> /// Open a private namespace directory. /// </summary> /// <param name="obj_attributes">Object attributes for the directory</param> /// <param name="boundary_descriptor">Boundary descriptor for the namespace</param> /// <param name="desired_access">Desired access for the directory</param> /// <returns>The directory object</returns> /// <exception cref="NtException">Thrown on error</exception> public static NtDirectory OpenPrivateNamespace(ObjectAttributes obj_attributes, BoundaryDescriptor boundary_descriptor, DirectoryAccessRights desired_access) { NtSystemCalls.NtOpenPrivateNamespace(out SafeKernelObjectHandle handle, desired_access, obj_attributes, boundary_descriptor.Handle).ToNtException(); NtDirectory ret = new NtDirectory(handle) { _private_namespace = true }; return ret; }