CmpCommitRenameKeyUoW

__int64 __fastcall CmpCommitRenameKeyUoW(__int64 a1, __int64 *a2, __int64 a3){
  __int64 v4; 
  UINT64 v5; 
  HSTORAGE_TYPE v6; 
  UINT64 v7; 
  ULONG_PTR v8; 
  UINT64 v9; 
  ULONG_PTR v10; 
  __int64 v11; 
  int v12; 
  __int64 v13; 
  UINT8 *v14; 
  unsigned int v15; 
  _DWORD *v16; 
  unsigned int v17; 
  __int64 v18; 
  CHAR updated; 
  __int64 v20; 
  __int64 v22; 
  unsigned __int16 v23; 
  unsigned int v24; 
  __int64 v25; 
  _HV_GET_CELL_CONTEXT CellAddressContext; 
  int v27[2]; 
  ULONG_PTR BugCheckParameter2; 
  VOID *CellAddress; 
  __int64 v30; 
  INT64 v31[2]; 
  __int64 v32; 
  __int64 v33; 
  HSTORAGE_TYPE Type; 
  int v37; 
  int v38; 
  CellAddress = 0i64;
  CellAddressContext.Cell = -1;
  v27[0] = -1;
  v4 = a3;
  v37 = -1;
  v5 = *(_QWORD *)(a1 + 48);
  *(_DWORD *)&CellAddressContext.BinContext = 0;
  v27[1] = 0;
  v38 = 0;
  v6 = *(_DWORD *)(a1 + 72);
  *(_OWORD *)v31 = 0i64;
  v7 = *(_QWORD *)(v5 + 32);
  Type = v6;
  CmpReferenceKeyControlBlock(v5);
  v8 = *(_QWORD *)(a1 + 48);
  v9 = *(_QWORD *)(a1 + 88);
  BugCheckParameter2 = v8;
  CmpReferenceKeyControlBlock(v9);
  v10 = *(_QWORD *)(a1 + 88);
  v11 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(v7 + 8))(
          v7,
          *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 40i64),
          v27);
  if( !v11 )
  {
    v12 = -1073741670;
LABEL_25:
    if( v8 )
      CmpDereferenceKeyControlBlockWithLock(v8, v4, 0);
    if( v10 )
      CmpDereferenceKeyControlBlockWithLock(v10, v4, 0);
    CmpCleanupRollbackPacket((INT64)v31);
    return(unsigned int)v12;
  }
  if( !HvMarkCellDirty(v7, *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 40i64), 1)
    || !HvMarkCellDirty(v7, *(unsigned int *)(*(_QWORD *)(a1 + 48) + 40i64), 1)
    || !HvMarkCellDirty(v7, *(unsigned int *)(*(_QWORD *)(a1 + 88) + 40i64), 1)
    || !CmpMarkIndexDirty(
          v7,
          *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 40i64),
          *(unsigned int *)(*(_QWORD *)(a1 + 88) + 40i64)) )
  {
    v12 = -1073741443;
LABEL_24:
    (*(void(__fastcall **)(UINT64, int *))(v7 + 16))(v7, v27);
    goto LABEL_25;
  }
  ++*(_QWORD *)(v8 + 304);
  ++*(_QWORD *)(v10 + 304);
  v12 = CmpPrepareToInvalidateAllHigherLayerKcbs(v8, 1u, (INT64)v31);
  if( v12 < 0 )
    goto LABEL_24;
  v12 = CmpPrepareToInvalidateAllHigherLayerKcbs(v10, 1u, (INT64)v31);
  if( v12 < 0 )
    goto LABEL_24;
  CmpInvalidateAllHigherLayerKcbs(v8, 1u, 8i64, v4);
  CmpInvalidateAllHigherLayerKcbs(v10, 1u, 8i64, v4);
  v13 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(v7 + 8))(
          v7,
          *(unsigned int *)(*(_QWORD *)(a1 + 48) + 40i64),
          &v37);
  v30 = v13;
  v14 = (UINT8 *)v13;
  if( !v13 )
  {
    v12 = -1073741670;
    goto LABEL_24;
  }
  v15 = HvAllocateCell((_HHIVE *)v7, (unsigned int)(-4 - *(_DWORD *)(v13 - 4)), Type, &CellAddress, &CellAddressContext);
  v16 = CellAddress;
  v17 = v15;
  if( v15 == -1 )
  {
    v12 = -1073741443;
    goto LABEL_19;
  }
  memmove((UINT8 *)CellAddress, v14, -4 - *((_DWORD *)v14 - 1));
  (*(void(__fastcall **)(UINT64, int *))(v7 + 16))(v7, &v37);
  v18 = *(_QWORD *)(a1 + 48);
  v30 = 0i64;
  if( !CmpAddSubKey(v7, *(unsigned int *)(*(_QWORD *)(v18 + 72) + 40i64), v17)
    || !CmpRemoveSubKey(
          (_HHIVE *)v7,
          *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 40i64),
          *(unsigned int *)(*(_QWORD *)(a1 + 88) + 40i64)) )
  {
    v12 = -1073741670;
LABEL_21:
    if( v16 )
    {
      (*(void(__fastcall **)(UINT64, _HV_GET_CELL_CONTEXT *))(v7 + 16))(v7, &CellAddressContext);
      CmpFreeKeyByCell((_HHIVE *)v7, v17, 0);
    }
    v4 = a3;
    v8 = BugCheckParameter2;
    goto LABEL_24;
  }
  updated = CmpUpdateParentForEachSon(v7, v17, 1);
  v20 = *(_QWORD *)(a1 + 48);
  if( !updated )
  {
    v12 = -1073741670;
    CmpRemoveSubKey((_HHIVE *)v7, *(unsigned int *)(*(_QWORD *)(v20 + 72) + 40i64), v17);
    CmpAddSubKey(
      v7,
      *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 40i64),
      *(unsigned int *)(*(_QWORD *)(a1 + 88) + 40i64));
LABEL_19:
    if( v30 )
      (*(void(__fastcall **)(UINT64, int *))(v7 + 16))(v7, &v37);
    goto LABEL_21;
  }
  *(_DWORD *)(a1 + 96) = *(_DWORD *)(v20 + 40);
  *(_DWORD *)(v20 + 40) = v17;
  v22 = *a2;
  v16[4] = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 40i64);
  ++*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 304i64);
  *(_QWORD *)(v11 + 4) = v22;
  *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 168i64) = v22;
  v23 = *((_WORD *)v16 + 36);
  if( (*((_BYTE *)v16 + 2) & 0x20) != 0 )
    v23 *= 2;
  if( (unsigned __int16)*(_DWORD *)(v11 + 52) < (unsigned int)v23 )
  {
    *(_WORD *)(v11 + 52) = v23;
    *(_WORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64) + 176i64) = v23;
  }
  v24 = *((unsigned __int16 *)v16 + 37);
  if( *(_DWORD *)(v11 + 56) < v24 )
    *(_DWORD *)(v11 + 56) = v24;
  (*(void(__fastcall **)(UINT64, _HV_GET_CELL_CONTEXT *))(v7 + 16))(v7, &CellAddressContext);
  (*(void(__fastcall **)(UINT64, int *))(v7 + 16))(v7, v27);
  v25 = *(_QWORD *)(a1 + 88);
  v33 = *(_QWORD *)(a1 + 48);
  v32 = v25;
  CmpSearchKeyControlBlockTreeEx(
    (__int64(__fastcall *)(ULONG_PTR, ULONG_PTR, __int64, __int64))CmpRefreshParent,
    *(_QWORD *)(v33 + 32),
    a3,
    (__int64)&v32,
    1);
  CmpSearchForOpenSubKeys(*(_QWORD *)(a1 + 48), 1i64, 0i64);
  HvFreeCell(v7, *(unsigned int *)(*(_QWORD *)(a1 + 88) + 40i64));
  CmpFlushNotifiesOnKeyBodyList(*(_QWORD *)(a1 + 88), 8i64, a3, 1);
  CmpMarkKeyUnbacked(*(_CM_KEY_CONTROL_BLOCK **)(a1 + 88));
  CmpDiscardKcb(*(_QWORD *)(a1 + 88), a3);
  CmpDereferenceKeyControlBlockWithLock(BugCheckParameter2, a3, 0);
  CmpDereferenceKeyControlBlockWithLock(v10, a3, 0);
  CmpCleanupRollbackPacket((INT64)v31);
  return 0i64;
}

Referenced by:

CmpTransMgrCommitUoW