CmpCheckLexicographicalOrder

INT64 __fastcall CmpCheckLexicographicalOrder(_HHIVE *HiveToCheck, UINT64 PriorSibling, UINT64 Current){
  _CELL_DATA *(__fastcall *GetCellRoutine)(_HHIVE *, unsigned int, _HV_GET_CELL_CONTEXT *); 
  unsigned int v4; 
  __int64 v6; 
  _CELL_DATA *v7; 
  _CELL_DATA *v8; 
  WCHAR *Name; 
  __int16 v10; 
  unsigned __int8 *v11; 
  unsigned __int16 v12; 
  unsigned int v13; 
  unsigned int v14; 
  unsigned int v15; 
  int v16; 
  unsigned int v17; 
  UINT64 NameLength; 
  _UNICODE_STRING String2; 
  _UNICODE_STRING String1; 
  int v22; 
  int v23; 
  int v24; 
  int v25; 

  v23 = 0;
  v25 = 0;
  GetCellRoutine = HiveToCheck->GetCellRoutine;
  v4 = PriorSibling;
  v22 = -1;
  v24 = -1;
  String1 = 0i64;
  String2 = 0i64;
  v6 = (__int64)GetCellRoutine(HiveToCheck, Current, (_HV_GET_CELL_CONTEXT *)&v22);
  v7 = HiveToCheck->GetCellRoutine(HiveToCheck, v4, &v24);
  v8 = v7;
  if( !v6 || !v7 )
  {
    v17 = -1073741670;
    goto LABEL_15;
  }
  Name = v7->u.KeyNode.Name;
  v10 = v7->u.KeyNode.Flags & 0x20;
  v11 = (unsigned __int8 *)(v6 + 76);
  if( (*(_BYTE *)(v6 + 2) & 0x20) == 0 )
  {
    String2.Buffer = (wchar_t *)(v6 + 76);
    if( v10 )
    {
      NameLength = v7->u.KeyNode.NameLength;
      String2.Length = *(_WORD *)(v6 + 72);
      String2.MaximumLength = String2.Length;
      if( (int)CmpCompareCompressedName(&String2, Name, NameLength, 0i64) <= 0 )
      {
        v17 = -1073741492;
        goto LABEL_15;
      }
    }
    else
    {
      String1.Length = v7->u.KeyNode.NameLength;
      String1.MaximumLength = String1.Length;
      String2.Length = *(_WORD *)(v6 + 72);
      String2.MaximumLength = String2.Length;
      String1.Buffer = v7->u.KeyNode.Name;
      if( RtlCompareUnicodeString(&String1, &String2, 1u) >= 0 )
      {
        v17 = -1073741492;
        goto LABEL_15;
      }
    }
LABEL_14:
    v17 = 0;
    goto LABEL_15;
  }
  v12 = v7->u.KeyNode.NameLength;
  v13 = *(unsigned __int16 *)(v6 + 72);
  if( !v10 )
  {
    String1.Buffer = v7->u.KeyNode.Name;
    String1.Length = v12;
    String1.MaximumLength = v12;
    if( (int)CmpCompareCompressedName(&String1, (WCHAR *)(v6 + 76), v13, 0i64) >= 0 )
    {
      v17 = -1073741492;
      goto LABEL_15;
    }
    goto LABEL_14;
  }
  if( v12 )
  {
    while( (_WORD)v13 )
    {
      v14 = *(unsigned __int8 *)Name;
      Name = (WCHAR *)((char *)Name + 1);
      v15 = *v11++;
      if( (_WORD)v14 != (_WORD)v15 )
      {
        if( v14 >= 0x61 )
        {
          if( v14 > 0x7A )
            LOWORD(v14) = NLS_UPCASE(v14);
          else
            LOWORD(v14) = v14 - 32;
        }
        if( v15 >= 0x61 )
        {
          if( v15 > 0x7A )
            LOWORD(v15) = NLS_UPCASE(v15);
          else
            LOWORD(v15) = v15 - 32;
        }
        v16 = (unsigned __int16)v14 - (unsigned __int16)v15;
        if( (unsigned __int16)v14 != (unsigned __int16)v15 )
          goto LABEL_13;
      }
      LOWORD(v13) = v13 - 1;
      if( !--v12 )
        break;
    }
  }
  v16 = v12 - (unsigned __int16)v13;
LABEL_13:
  if( v16 < 0 )
    goto LABEL_14;
  v17 = -1073741492;
LABEL_15:
  if( v6 )
    HiveToCheck->ReleaseCellRoutine(HiveToCheck, (_HV_GET_CELL_CONTEXT *)&v22);
  if( v8 )
    HiveToCheck->ReleaseCellRoutine(HiveToCheck, (_HV_GET_CELL_CONTEXT *)&v24);
  return v17;
}

Referenced by:

CmpCheckRegistry2