RtlValidRelativeSecurityDescriptor

UINT8 __stdcall RtlValidRelativeSecurityDescriptor(
        PVOID SecurityDescriptorInput,
        UINT64 SecurityDescriptorLength,
        UINT64 RequiredInformation){
  char v3; 
  unsigned int v4; 
  __int16 v6; 
  UINT64 v7; 
  UINT64 v8; 
  __int64 v9; 
  int v10; 
  UINT64 v11; 
  __int64 v12; 
  int v13; 
  UINT64 v14; 
  __int64 v15; 
  ACL *v16; 
  UINT64 v18; 
  __int64 v19; 
  ACL *v20; 
  UINT64 v21[2]; 
  UINT64 MaxLength; 
  UINT64 v23; 
  v3 = RequiredInformation;
  LODWORD(MaxLength) = 0;
  v4 = SecurityDescriptorLength;
  LODWORD(v23) = 0;
  v21[0] = 0i64;
  if( (unsigned int)SecurityDescriptorLength < 0x14 )
    return 0;
  if( *(_BYTE *)SecurityDescriptorInput != 1 )
    return 0;
  v6 = *((_WORD *)SecurityDescriptorInput + 1);
  if( v6 >= 0 )
    return 0;
  v7 = *((unsigned int *)SecurityDescriptorInput + 1);
  v8 = 12i64;
  if( (_DWORD)v7 )
  {
    if( !RtlpValidateSDOffsetAndSize(v7, SecurityDescriptorLength, 0xCui64, &MaxLength) )
      return 0;
    if( *((_BYTE *)SecurityDescriptorInput + v9) != 1 )
      return 0;
    v10 = *((unsigned __int8 *)SecurityDescriptorInput + v9 + 1);
    if( (unsigned __int8)v10 > 0xFu || (unsigned int)MaxLength < 4 * v10 + 8 )
      return 0;
  }
  else if( (v3 & 1) != 0 )
  {
    return 0;
  }
  v11 = *((unsigned int *)SecurityDescriptorInput + 2);
  if( (_DWORD)v11 )
  {
    if( !RtlpValidateSDOffsetAndSize(v11, v4, v8, &v23) )
      return 0;
    if( *((_BYTE *)SecurityDescriptorInput + v12) != 1 )
      return 0;
    v13 = *((unsigned __int8 *)SecurityDescriptorInput + v12 + 1);
    if( (unsigned __int8)v13 > 0xFu || (unsigned int)v23 < 4 * v13 + 8 )
      return 0;
  }
  else if( (v3 & 2) != 0 )
  {
    return 0;
  }
  if( (v6 & 4) == 0
    || (v14 = *((unsigned int *)SecurityDescriptorInput + 4), !(_DWORD)v14)
    || RtlpValidateSDOffsetAndSize(v14, v4, 8ui64, v21)
    && (v16 = (ACL *)((char *)SecurityDescriptorInput + v15), LODWORD(v21[0]) >= v16->AclSize)
    && RtlValidAcl(v16) )
  {
    if( (*((_BYTE *)SecurityDescriptorInput + 2) & 0x10) == 0 )
      return 1;
    v18 = *((unsigned int *)SecurityDescriptorInput + 3);
    if( !(_DWORD)v18 )
      return 1;
    if( RtlpValidateSDOffsetAndSize(v18, v4, 8ui64, (UINT64 *)((char *)v21 + 4)) )
    {
      v20 = (ACL *)((char *)SecurityDescriptorInput + v19);
      if( HIDWORD(v21[0]) >= v20->AclSize )
      {
        if( RtlValidAcl(v20) )
          return 1;
      }
    }
  }
  return 0;
}

Referenced by:

CmSetDeviceRegPropWorker
CmSetInstallerClassRegPropWorker
CmpValidateHiveSecurityDescriptors
CmpVerifyCreateOrDeleteKeyLogRecord
CmpVerifySetSecurityDescriptorLogRecord
ExpWnfLookupPermanentName
PipGetRegistrySecurityWithFallback
PnpValidatePropertyData