private static NtResult <SecurityDescriptor> GetServiceSecurityDescriptor(
     SafeServiceHandle handle, string type_name, SecurityInformation security_information,
     bool throw_on_error)
 {
     byte[] sd = new byte[8192];
     return(Win32NativeMethods.QueryServiceObjectSecurity(handle, security_information,
                                                          sd, sd.Length, out _).CreateWin32Result(throw_on_error,
                                                                                                  () => new SecurityDescriptor(sd, GetServiceNtType(type_name))));
 }
        private static SecurityDescriptor GetServiceSecurityDescriptor(SafeServiceHandle handle,
                                                                       string type_name, SecurityInformation security_information)
        {
            byte[] sd = new byte[8192];
            if (!Win32NativeMethods.QueryServiceObjectSecurity(handle, security_information, sd, sd.Length, out _))
            {
                throw new SafeWin32Exception();
            }

            return(new SecurityDescriptor(sd, GetServiceNtType(type_name)));
        }
示例#3
0
        private static SecurityDescriptor GetServiceSecurityDescriptor(SafeServiceHandle handle, string type_name)
        {
            byte[] sd = new byte[8192];
            if (!Win32NativeMethods.QueryServiceObjectSecurity(handle, SecurityInformation.Dacl
                                                               | SecurityInformation.Owner
                                                               | SecurityInformation.Label
                                                               | SecurityInformation.Group, sd, sd.Length, out int required))
            {
                throw new SafeWin32Exception();
            }

            return(new SecurityDescriptor(sd, GetServiceNtType(type_name)));
        }