IopGetSecurityDescriptorInformation

NTSTATUS __stdcall IopGetSecurityDescriptorInformation(PSECURITY_DESCRIPTOR SecurityDescriptor){
  UINT8 *v1; 
  _DWORD *v2; 
  _DWORD *v3; 
  UINT8 *v4; 
  int OwnerSecurityDescriptor; 
  int v7; 
  PVOID Owner[2]; 
  UINT8 OwnerDefaulted; 
  unsigned __int8 SaclPresent; 

  Owner[0] = 0i64;
  *v2 = 0;
  v3 = v2;
  v4 = v1;
  *v1 = 0;
  SaclPresent = 0;
  OwnerDefaulted = 0;
  OwnerSecurityDescriptor = RtlGetOwnerSecurityDescriptor(SecurityDescriptor, Owner, &OwnerDefaulted);
  if( OwnerSecurityDescriptor >= 0 )
  {
    v7 = Owner[0] != 0i64;
    OwnerSecurityDescriptor = RtlGetGroupSecurityDescriptor(SecurityDescriptor, Owner, &OwnerDefaulted);
    if( OwnerSecurityDescriptor >= 0 )
    {
      if( Owner[0] )
        v7 |= 2u;
      OwnerSecurityDescriptor = RtlGetSaclSecurityDescriptor(
                                  SecurityDescriptor,
                                  &SaclPresent,
                                  (_ACL **)Owner,
                                  &OwnerDefaulted);
      if( OwnerSecurityDescriptor >= 0 )
      {
        if( SaclPresent )
          v7 |= 8u;
        OwnerSecurityDescriptor = RtlGetDaclSecurityDescriptor(
                                    SecurityDescriptor,
                                    &SaclPresent,
                                    (_ACL **)Owner,
                                    &OwnerDefaulted);
        if( OwnerSecurityDescriptor >= 0 )
        {
          if( SaclPresent )
            v7 |= 4u;
          *v4 = OwnerDefaulted;
          *v3 = v7;
        }
      }
    }
  }
  return OwnerSecurityDescriptor;
}

Referenced by:

IoCreateDeviceSecure
IopQuerySecureDeviceClassState