CmpFreeKeyByCell

INT64 __fastcall CmpFreeKeyByCell(UINT64 a1, UINT64 a2, CHAR a3){
  unsigned int v4; 
  ULONG_PTR v5; 
  __int64 v7; 
  __int64 v8; 
  __int64 v9; 
  unsigned int v10; 
  __int64 v12; 
  unsigned int i; 
  int v14[4]; 
  int v15; 
  int v16; 
  int v17; 
  int v18; 

  v16 = 0;
  v4 = a2;
  v15 = -1;
  v17 = -1;
  v14[0] = -1;
  v5 = a1 + 1776;
  v18 = 0;
  v14[1] = 0;
  ExAcquirePushLockExclusiveEx((_EX_PUSH_LOCK *)(a1 + 1776), 0i64);
  if( !CmpMarkKeyDirty((PVOID)a1, (PVOID)v4, a3) )
  {
    v10 = -1073741443;
    goto LABEL_17;
  }
  v7 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, v4, &v15);
  v8 = v7;
  if( !v7 )
    goto LABEL_23;
  if( a3 == 1 )
  {
    if( !CmpRemoveSubKey(a1, *(unsigned int *)(v7 + 16), v4) )
      goto LABEL_24;
    v9 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, *(unsigned int *)(v8 + 16), &v17);
    if( !v9 )
      goto LABEL_24;
    if( !(*(_DWORD *)(v9 + 20) + *(_DWORD *)(v9 + 24)) )
    {
      *(_WORD *)(v9 + 52) = 0;
      *(_DWORD *)(v9 + 56) = 0;
    }
    (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v17);
  }
  if( (*(_BYTE *)(v8 + 2) & 0x42) != 0 )
    goto LABEL_13;
  if( !*(_DWORD *)(v8 + 36) )
  {
LABEL_11:
    if( *(_DWORD *)(v8 + 44) != -1 )
      CmpFreeSecurityDescriptor((_HHIVE *)a1, v4);
LABEL_13:
    (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v15);
    v8 = 0i64;
    if( CmpFreeKeyBody(a1, v4) )
    {
      v10 = 0;
      goto LABEL_15;
    }
LABEL_23:
    v10 = -1073741670;
    goto LABEL_17;
  }
  v12 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, *(unsigned int *)(v8 + 40), v14);
  if( v12 )
  {
    for( i = 0; i < *(_DWORD *)(v8 + 36); ++i )
      CmpFreeValue(a1, *(unsigned int *)(v12 + 4i64 * i));
    (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, v14);
    HvFreeCell(a1, *(_DWORD *)(v8 + 40));
    goto LABEL_11;
  }
LABEL_24:
  v10 = -1073741670;
LABEL_15:
  if( v8 )
    (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v15);
LABEL_17:
  ExReleasePushLockEx(v5, 0);
  return v10;
}

Referenced by:

CmDeleteLayeredKey
CmRestoreKey
CmpCleanupLightWeightPrepare
CmpCommitAddKeyUoW
CmpCommitDeleteKeyUoW
CmpCommitRenameKeyUoW
CmpCopyMergeOfLayeredKeyNode
CmpCreateChild
CmpCreateTombstone
CmpDeleteTree
CmpLightWeightCommitDeleteKeyUoW
CmpLightWeightPrepareAddKeyUoW
CmpLightWeightPrepareRenameKeyUoW
CmpPartialPromoteSingleKeyFromKeyNodeStacks
CmpRemoveHiveFromNamespace
CmpSyncSubKeysAfterDelete
CmpTransMgrFreeVolatileData