CmpSelectLeaf

INT64 __fastcall CmpSelectLeaf(UINT64 a1, UINT64 *a2, const UNICODE_STRING *a3, UINT64 a4, UINT64 **a5){
  UINT64 v6; 
  char *v8; 
  NTSTATUS i; 
  __int64 v10; 
  unsigned int v12; 
  int v13[2]; 
  int v14[4]; 
  HSTORAGE_TYPE Type; 
  Type = (int)a4;
  v14[0] = -1;
  v13[0] = -1;
  v6 = *(unsigned int *)a2;
  v14[1] = 0;
  v13[1] = 0;
  if( HvMarkCellDirty(a1, v6, 0) )
  {
    v8 = (char *)(*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, *(unsigned int *)a2, v14);
    if( v8 )
    {
      for( i = CmpFindSubKeyInRoot((PVOID)a1, v8); i >= 0; i = CmpFindSubKeyInRoot((PVOID)a1, v8) )
      {
        v10 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, 0i64, v13);
        if( !v10 )
          break;
        if( *(_WORD *)(v10 + 2) < 0x3F5u )
        {
          *a5 = (UINT64 *)&v8[4 * i + 4];
          (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, v13);
          (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, v14);
          return 0i64;
        }
        v12 = CmpSplitLeaf((_HHIVE *)a1, *(unsigned int *)a2, (unsigned int)i, Type);
        if( v12 == -1
          || ((*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, v14),
              *(_DWORD *)a2 = v12,
              (v8 = (char *)(*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, v12, v14)) == 0i64) )
        {
          (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, v13);
          break;
        }
        (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, v13);
      }
      if( v8 )
        (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, v14);
    }
  }
  return 0xFFFFFFFFi64;
}

Referenced by:

CmpAddSubKeyToList