protected override bool InternalReleaseHandle() { BoundaryDescriptorHandle h = handle; DeleteBoundaryDescriptor(h); return(true); }
public static SafeNamespaceHandle OpenPrivateNamespace(BoundaryDescriptorHandle lpBoundaryDescriptor, string lpAliasPrefix) { var h = OpenPrivateNamespaceInternal(lpBoundaryDescriptor, lpAliasPrefix); h.flag = 0; return(h); }
public void AddToBoundaryTest() { var bdh = CreateBoundaryDescriptor(Path.GetRandomFileName()); Assert.That(bdh.IsInvalid, Is.False); BoundaryDescriptorHandle h = bdh; try { var b = AddSIDToBoundaryDescriptor(ref h, SafePSID.Current); if (!b) { TestContext.WriteLine($"ERR: AddSid={Win32Error.GetLastError()}"); } Assert.That(b, Is.True); //var plsid = SafePSID.Init(KnownSIDAuthority.SECURITY_MANDATORY_LABEL_AUTHORITY, MandatoryIntegrityLevelSIDRelativeID.SECURITY_MANDATORY_MEDIUM_RID); //b = AddIntegrityLabelToBoundaryDescriptor(ref h, plsid); //if (!b) TestContext.WriteLine($"ERR: AddSid={Win32Error.GetLastError()}"); //Assert.That(b, Is.True); } finally { //DeleteBoundaryDescriptor(h); bdh.Close(); } }
/// <summary>Adds a security identifier (SID) to the boundary descriptor.</summary> /// <param name="pSid">A pointer to a <c>SID</c> structure.</param> /// <returns> /// <para>If the function succeeds, the return value is nonzero.</para> /// <para>If the function fails, the return value is zero. To get extended error information, call <c>GetLastError</c>.</para> /// </returns> public bool AddSid(PSID pSid) { BoundaryDescriptorHandle h = handle; if (Marshal.ReadByte(pSid.DangerousGetHandle(), 7) == 16) { return(AddIntegrityLabelToBoundaryDescriptor(ref h, pSid)); } return(AddSIDToBoundaryDescriptor(ref h, pSid)); }
public static extern bool AddSIDToBoundaryDescriptor(ref BoundaryDescriptorHandle BoundaryDescriptor, IntPtr RequiredSid);
public static extern bool AddIntegrityLabelToBoundaryDescriptor(ref BoundaryDescriptorHandle BoundaryDescriptor, IntPtr IntegrityLabel);
public static extern NamespaceHandle OpenPrivateNamespace(BoundaryDescriptorHandle lpBoundaryDescriptor, string lpAliasPrefix);
public static extern void DeleteBoundaryDescriptor(BoundaryDescriptorHandle BoundaryDescriptor);
public static extern SafeNamespaceHandle CreatePrivateNamespace(SECURITY_ATTRIBUTES lpPrivateNamespaceAttributes, BoundaryDescriptorHandle lpBoundaryDescriptor, string lpAliasPrefix);
private static extern SafeNamespaceHandle OpenPrivateNamespaceInternal(BoundaryDescriptorHandle lpBoundaryDescriptor, string lpAliasPrefix);