CmpCompareInIndex

INT64 __fastcall CmpCompareInIndex(
        _HHIVE *Hive,
        const _UNICODE_STRING *SearchName,
        UINT64 Count,
        _CM_KEY_INDEX *Index,
        UINT *Child){
  __int16 v8; 
  __int16 v9; 
  UINT *v10; 
  unsigned int v11; 
  unsigned int v12; 
  UINT *v13; 
  __int64 v14; 
  _BYTE *v15; 
  unsigned int v16; 
  unsigned int v17; 
  unsigned int v18; 
  UINT16 v19; 
  unsigned int v20; 
  int v21; 
  int v22; 
  int v23; 
  unsigned int v24; 
  INT64 result; 
  _DWORD *v26; 

  v8 = *(_WORD *)Child;
  v9 = *(_WORD *)Child;
  *v26 = -1;
  if( ((v9 - 26220) & 0xFDFF) != 0 )
  {
    v10 = &Child[(unsigned int)Index];
    v11 = CmpDoCompareKeyName((INT64)Hive, SearchName, (_WCHAR **)Count, v10[1]);
    v12 = v11;
    if( v11 != 2 )
    {
      if( !v11 )
        *v26 = v10[1];
      return v12;
    }
    return 2i64;
  }
  v13 = &Child[2 * (unsigned int)Index];
  if( v8 != 26220 )
    goto LABEL_32;
  v14 = 0i64;
  v15 = v13 + 2;
  v16 = 0;
  v17 = 4;
  while( *v15 )
  {
    ++v16;
    ++v15;
    if( v16 >= 4 )
      goto LABEL_11;
  }
  v17 = v16;
LABEL_11:
  if( Count )
    v18 = *(unsigned __int16 *)Count;
  else
    v18 = SearchName->Length >> 1;
  if( v18 >= v17 )
    v18 = v17;
  if( !v18 )
  {
LABEL_32:
    v24 = CmpDoCompareKeyName((INT64)Hive, SearchName, (_WCHAR **)Count, v13[1]);
    v12 = v24;
    if( v24 != 2 )
    {
      if( !v24 )
        *v26 = v13[1];
      return v12;
    }
    return 2i64;
  }
  while( 1 )
  {
    v19 = Count ? *(unsigned __int8 *)(v14 + *(_QWORD *)(Count + 8)) : SearchName->Buffer[v14];
    v20 = *((unsigned __int8 *)v13 + v14 + 8);
    if( v19 >= 0x61u )
      v21 = v19 <= 0x7Au ? v19 - 32 : NLS_UPCASE(v19);
    else
      v21 = v19;
    if( v20 >= 0x61 )
      v22 = v20 <= 0x7A ? v20 - 32 : NLS_UPCASE(v20);
    else
      v22 = v20;
    v23 = v21 - v22;
    if( v23 )
      break;
    v14 = (unsigned int)(v14 + 1);
    if( (unsigned int)v14 >= v18 )
      goto LABEL_32;
  }
  result = 1i64;
  if( v23 <= 0 )
    return 0xFFFFFFFFi64;
  return result;
}

Referenced by:

CmpAddToLeaf
CmpFindSubKeyInLeafWithStatus
CmpFindSubKeyInRoot