/// <summary> /// NULL SA and Empty SA are two different things. NULL SA writes the current user's security /// attributes (SID) to the object being secured. Empty SA allows literally everybody to access the /// object. /// </summary> /// <returns></returns> public static SECURITY_ATTRIBUTES GetNullDacl() { // Construct SECURITY_ATTRIBUTES structure SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES(); sa.nLength = Marshal.SizeOf(sa); sa.bInheritHandle = 1; // Build NULL DACL (Allow everyone full access) RawSecurityDescriptor gsd = new RawSecurityDescriptor(ControlFlags.DiscretionaryAclPresent, null, null, null, null); // Get binary form of the security descriptor and copy it into place byte[] desc = new byte[gsd.BinaryLength]; gsd.GetBinaryForm(desc, 0); sa.lpSecurityDescriptor = Marshal.AllocHGlobal(desc.Length); Marshal.Copy(desc, 0, sa.lpSecurityDescriptor, desc.Length); return sa; }
public static extern IntPtr CreateFileMapping( IntPtr hFile, // Handle to file SECURITY_ATTRIBUTES lpAttributes, // Security MemoryProtection flProtect, // protection uint dwMaximumSizeHigh, // High-order DWORD of size uint dwMaximumSizeLow, // Low-order DWORD of size string lpName // Object name );