public void GetSecurity(SecurityInformation RequestedInformation, out IntPtr ppSecurityDescriptor, [MarshalAs(UnmanagedType.Bool)] bool fDefault) { byte[] raw_sd = _handle.GetSecurityDescriptorBytes(RequestedInformation); IntPtr ret = LocalAlloc(0, new IntPtr(raw_sd.Length)); Marshal.Copy(raw_sd, 0, ret, raw_sd.Length); ppSecurityDescriptor = ret; }
void ReadSecurityDescriptor() { try { if (NtObject.CanOpenType(_type_name)) { using (NtObject obj = NtObject.OpenWithType(_type_name, _name, _directory.Directory, GenericAccessRights.ReadControl)) { _sd = obj.GetSecurityDescriptorBytes(SecurityInformation.Owner | SecurityInformation.Group | SecurityInformation.Dacl | SecurityInformation.Label); } } } catch { _sd = new byte[0]; } }