RtlpValidRelativeAttribute

UINT8 __stdcall RtlpValidRelativeAttribute(
        _CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 *RelativeAttribute,
        UINT64 RelativeAttributeSize,
        INT64 a3,
        INT64 a4,
        INT64 a5,
        size_t a6){
  unsigned int v6; 
  __int64 Name; 
  int v9; 
  unsigned int ValueCount; 
  unsigned __int64 v11; 
  unsigned __int16 ValueType; 
  unsigned int v13; 
  $BE44A4FCE80D7C8ECAC3D77A2C4713B9 *i; 
  $BE44A4FCE80D7C8ECAC3D77A2C4713B9 *m; 
  __int64 v17; 
  $BE44A4FCE80D7C8ECAC3D77A2C4713B9 *k; 
  __int64 v19; 
  int v20; 
  $BE44A4FCE80D7C8ECAC3D77A2C4713B9 *j; 
  __int64 v22; 
  unsigned int v23; 
  int v24; 
  __int64 v25; 
  UINT64 pcbLength; 

  v6 = RelativeAttributeSize;
  if( RelativeAttribute )
  {
    if( (unsigned int)RelativeAttributeSize >= 0x14
      && !RelativeAttribute->Reserved
      && (RelativeAttribute->Flags & 0xFFC0) == 0 )
    {
      if( RelativeAttribute->ValueCount )
      {
        Name = RelativeAttribute->Name;
        if( (unsigned int)RelativeAttributeSize >= (unsigned int)Name
          && (unsigned int)(RelativeAttributeSize - Name) >= 4
          && RtlStringCbLengthW(
               (WCHAR *)((char *)RelativeAttribute + Name),
               (unsigned int)(RelativeAttributeSize - Name),
               &pcbLength) >= 0 )
        {
          ValueCount = RelativeAttribute->ValueCount;
          v11 = 4i64 * ValueCount;
          if( v11 <= 0xFFFFFFFF && v6 - 16 >= (unsigned int)v11 )
          {
            ValueType = RelativeAttribute->ValueType;
            if( ValueType )
            {
              v13 = v9 + 2;
              if( ValueType <= (unsigned __int16)(v9 + 2) )
              {
                if( ValueCount )
                {
                  for( i = &RelativeAttribute->Values; v6 >= i->pInt64[0] && v6 - i->pInt64[0] >= 8; ++i )
                  {
                    if( ++v9 >= ValueCount )
                      return 1;
                  }
                  return 0;
                }
                return 1;
              }
              switch( ValueType )
              {
                case 3u:
                  v24 = v9;
                  if( ValueCount )
                  {
                    while( 1 )
                    {
                      v25 = RelativeAttribute->Values.pInt64[v24];
                      if( v6 < (unsigned int)v25
                        || v6 - (unsigned int)v25 < v13
                        || RtlStringCbLengthW(
                             (WCHAR *)((char *)RelativeAttribute + v25),
                             v6 - (unsigned int)v25,
                             &pcbLength) < 0 )
                      {
                        break;
                      }
                      if( ++v24 >= RelativeAttribute->ValueCount )
                        return 1;
                    }
                    return 0;
                  }
                  return 1;
                case 5u:
                  v20 = v9;
                  if( ValueCount )
                  {
                    for( j = &RelativeAttribute->Values; ; ++j )
                    {
                      v22 = j->pInt64[0];
                      if( v6 < (unsigned int)v22 )
                        break;
                      if( v6 - (unsigned int)v22 < 4 )
                        break;
                      v23 = *(unsigned int *)((char *)&RelativeAttribute->Name + v22);
                      if( !v23 || (int)v22 + 4 < (unsigned int)v22 || v6 - ((_DWORD)v22 + 4) < v23 )
                        break;
                      if( ++v20 >= ValueCount )
                        return 1;
                    }
                    return 0;
                  }
                  return 1;
                case 6u:
                  if( ValueCount )
                  {
                    for( k = &RelativeAttribute->Values; ; ++k )
                    {
                      v19 = k->pInt64[0];
                      if( v6 < (unsigned int)v19
                        || v6 - (unsigned int)v19 < 8
                        || *(_QWORD *)((char *)&RelativeAttribute->Name + v19) > 1ui64 )
                      {
                        break;
                      }
                      if( ++v9 >= ValueCount )
                        return 1;
                    }
                    return 0;
                  }
                  return 1;
                case 0x10u:
                  if( ValueCount )
                  {
                    for( m = &RelativeAttribute->Values; ; ++m )
                    {
                      v17 = m->pInt64[0];
                      if( v6 < (unsigned int)v17
                        || v6 - (unsigned int)v17 < 4
                        || (int)v17 + 4 < (unsigned int)v17
                        || v6 - ((_DWORD)v17 + 4) < *(unsigned int *)((char *)&RelativeAttribute->Name + v17) )
                      {
                        break;
                      }
                      if( ++v9 >= ValueCount )
                        return 1;
                    }
                    return 0;
                  }
                  return 1;
              }
            }
          }
        }
      }
    }
  }
  return 0;
}

Referenced by:

No references.