RtlValidSecurityDescriptor

UINT8 __stdcall RtlValidSecurityDescriptor(VOID *SecurityDescriptor){
  VOID *v1; 
  VOID *v2; 
  __int16 v4; 
  __int64 v5; 
  __int64 v6; 
  __int64 v7; 
  _ACL *v8; 
  char v9; 
  __int16 v10; 
  _BYTE *v12; 
  _BYTE *v13; 
  __int64 v14; 
  _ACL *v15; 
  char v16; 

  if( *(_BYTE *)SecurityDescriptor != 1 )
    return 0;
  v4 = *((_WORD *)SecurityDescriptor + 1);
  if( v4 >= 0 )
  {
    v12 = (_BYTE *)*((_QWORD *)SecurityDescriptor + 1);
  }
  else
  {
    v5 = *((unsigned int *)SecurityDescriptor + 1);
    if( !(_DWORD)v5 )
      goto LABEL_4;
    v12 = (char *)SecurityDescriptor + v5;
  }
  if( v12 && !RtlValidSid(v12) )
    return 0;
LABEL_4:
  if( v4 >= 0 )
  {
    v13 = (_BYTE *)*((_QWORD *)SecurityDescriptor + 2);
  }
  else
  {
    v6 = *((unsigned int *)SecurityDescriptor + 2);
    if( !(_DWORD)v6 )
      goto LABEL_6;
    v13 = (char *)SecurityDescriptor + v6;
  }
  if( v13 && !RtlValidSid(v13) )
    return 0;
LABEL_6:
  if( (v4 & 4) != 0 )
  {
    if( v4 >= 0 )
    {
      v8 = (_ACL *)*((_QWORD *)SecurityDescriptor + 4);
      goto LABEL_10;
    }
    v7 = *((unsigned int *)SecurityDescriptor + 4);
    if( (_DWORD)v7 )
    {
      v8 = (_ACL *)((char *)SecurityDescriptor + v7);
LABEL_10:
      if( v8 )
      {
        RtlValidAcl(v8, v1, v2);
        if( !v9 )
          return 0;
      }
    }
  }
  v10 = *((_WORD *)SecurityDescriptor + 1);
  if( (v10 & 0x10) == 0 )
    return 1;
  if( v10 >= 0 )
  {
    v15 = (_ACL *)*((_QWORD *)SecurityDescriptor + 3);
  }
  else
  {
    v14 = *((unsigned int *)SecurityDescriptor + 3);
    if( !(_DWORD)v14 )
      return 1;
    v15 = (_ACL *)((char *)SecurityDescriptor + v14);
  }
  if( !v15 )
    return 1;
  RtlValidAcl(v15, v1, v2);
  return v16 != 0;
}

Referenced by:

AdtpIsSDValidSelfRelative
CMFCreateSecurityDescriptor
CmGetRegKeySecurityDescriptor
DrvDbGetSecurityDescriptor
ObInsertObjectEx
ObOpenObjectByNameEx
ObpAdjustAccessMask
ObpSetObjectAuditInfo
PiAuCreateLocalSystemSecurityObject
PiAuCreateStandardSecurityObject
PiAuGetDriverDataDirectorySecurityObject
PiAuGetServiceStateSecurityObject
PiAuGetStateDirectorySecurityObject
PiDevCfgGetKeySecurityDescriptor
PnpGetEnumSecurityDescriptor
PnpGetPropertiesSecurityDescriptor
PnpOpenPropertiesKey