FsRtlIsFatDbcsLegal

INT8 __fastcall FsRtlIsFatDbcsLegal(UINT16 *a1, INT8 a2, INT8 a3, INT8 a4){
  UINT16 v4; 
  char v6; 
  _BYTE *v7; 
  unsigned int v8; 
  unsigned __int64 v9; 
  __int64 v10; 
  char v12; 
  __int64 v13; 
  _STRING v14; 
  __int16 v15; 
  int v16; 
  __int64 v17; 
  _STRING RemainingName; 
  _STRING FirstName; 
  _STRING struct_ptr; 

  v4 = *a1;
  v6 = 0;
  if( !*a1 )
    return 0;
  if( a2 )
  {
    if( v4 == 1 )
    {
      v12 = **((_BYTE **)a1 + 1);
      if( v12 == 46 || v12 == 34 )
        return 1;
    }
    if( v4 == 2 )
    {
      v13 = *((_QWORD *)a1 + 1);
      if( *(_WORD *)v13 == 11822 || *(_BYTE *)v13 == 34 && *(_BYTE *)(v13 + 1) == 34 )
        return 1;
    }
  }
  v7 = (_BYTE *)*((_QWORD *)a1 + 1);
  if( *v7 != 92 )
    goto LABEL_4;
  if( !a4 )
    return 0;
  if( v4 <= 1u )
    return 1;
  ++v7;
  --v4;
  *((_QWORD *)a1 + 1) = v7;
  --a1[1];
  *a1 = v4;
LABEL_4:
  if( a3 )
  {
    v14 = *(_STRING *)a1;
    v15 = _mm_cvtsi128_si32(*(__m128i *)a1);
    FirstName = 0i64;
    RemainingName = v14;
    if( v15 )
    {
      while( *(_BYTE *)_mm_srli_si128((__m128i)v14, 8).m128i_i8[0] != 92 )
      {
        struct_ptr = v14;
        FsRtlDissectDbcs(&struct_ptr, &FirstName, &RemainingName);
        struct_ptr = FirstName;
        if( !FsRtlIsFatDbcsLegal(&struct_ptr.Length, a2, 0, 0) )
          break;
        if( !RemainingName.Length )
          return 1;
        v14 = RemainingName;
      }
      return 0;
    }
    return 1;
  }
  if( a2 && FsRtlDoesDbcsContainWildCards(a1) )
  {
    v16 = 0;
    if( v4 )
    {
      while( 1 )
      {
        v17 = (unsigned __int8)v7[v16];
        if( (unsigned __int8)v17 >= 0x80u && (_BYTE)NlsMbOemCodePageTag && NlsOemLeadByteInfoTable[v17] )
        {
          ++v16;
        }
        else if( (v17 & 0x80u) == 0i64 && (*((_BYTE *)qword_140011770 + v17) & 9) == 0 )
        {
          return 0;
        }
        if( ++v16 >= (unsigned int)v4 )
          return 1;
      }
    }
    return 1;
  }
  if( v4 <= 0xCu )
  {
    v8 = 0;
    if( !v4 )
      return 1;
    do
    {
      v9 = (unsigned __int8)v7[v8];
      if( (unsigned __int8)v9 >= 0x80u && (_BYTE)NlsMbOemCodePageTag && NlsOemLeadByteInfoTable[v9] )
      {
        if( !v6 && v8 >= 7 || v8 == v4 - 1 )
          return 0;
        ++v8;
      }
      else
      {
        if( (v9 & 0x80u) == 0i64 && ((a2 != 0 ? 9 : 1) & *((unsigned __int8 *)qword_140011770 + v9)) == 0 )
          return 0;
        if( (_BYTE)v9 == 46 || (_BYTE)v9 == 34 )
        {
          if( !v8 || v6 || v4 - v8 - 1 > 3 || v7[v8 - 1] == 32 )
            return 0;
          v6 = 1;
        }
        if( v8 >= 8 && !v6 )
          return 0;
      }
      ++v8;
    }
    while( v8 < v4 );
    if( (unsigned __int8)v9 > 0x2Eu )
      return 1;
    v10 = 0x400500000000i64;
    if( !_bittest64(&v10, v9) )
      return 1;
  }
  return 0;
}

Referenced by:

FsRtlIsFatDbcsLegal