예제 #1
0
        public static byte[] GetByteSecurityDescriptor(SafeFileHandle handle, SecurityInformationClass infoClass)
        {
            var tempSD = IntPtr.Zero;
            var buffer = new byte[0];

            try
            {
                uint error = GetSecurityInfo(handle,
                                             ObjectType.File,
                                             infoClass,
                                             IntPtr.Zero,
                                             IntPtr.Zero,
                                             IntPtr.Zero,
                                             IntPtr.Zero,
                                             out tempSD);
                if (error != Win32Error.ERROR_SUCCESS)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                UInt32 sdLength = GetSecurityDescriptorLength(tempSD);

                buffer = new byte[sdLength];
                Marshal.Copy(tempSD, buffer, 0, (int)sdLength);
            }
            finally
            {
                Marshal.FreeHGlobal(tempSD);
                tempSD = IntPtr.Zero;
            }

            return(buffer);
        }
 internal static extern DWORD GetSecurityInfo(
     SafeFileHandle handle,
     ObjectType objectType,
     SecurityInformationClass infoClass,
     PSID owner,
     PSID group,
     PACL dacl,
     PACL sacl,
     out PSECURITY_DESCRIPTOR securityDescriptor);
예제 #3
0
 internal static extern UInt32 GetSecurityInfo(
     SafeFileHandle handle,
     ObjectType objectType,
     SecurityInformationClass infoClass,
     IntPtr owner,
     IntPtr group,
     IntPtr dacl,
     IntPtr sacl,
     out IntPtr securityDescriptor);
예제 #4
0
 static RawSecurityDescriptor GetRawSecurityDescriptor(SafeFileHandle handle, SecurityInformationClass infoClass)
 {
     return(new RawSecurityDescriptor(GetByteSecurityDescriptor(handle, infoClass), 0));
 }
 internal static extern DWORD GetSecurityInfo(
     SafeFileHandle handle,
     ObjectType objectType,
     SecurityInformationClass infoClass,
     PSID owner,
     PSID group,
     PACL dacl,
     PACL sacl,
     out PSECURITY_DESCRIPTOR securityDescriptor);