CmpLightWeightPrepareRenameKeyUoW

INT64 __stdcall CmpLightWeightPrepareRenameKeyUoW(PCM_KCB_UOW UoW){
  _CM_KEY_CONTROL_BLOCK *KeyControlBlock; 
  __int64 StorageType; 
  UINT64 KeyHive; 
  _CM_UOW_KEY_STATE_MODIFICATION *ModifyKeysData; 
  int v6; 
  int v7; 
  INT64 v8; 
  _CM_KEY_CONTROL_BLOCK *ChildKCB; 
  _CM_KEY_CONTROL_BLOCK *v10; 
  INT64 QuadPart; 
  unsigned int v12; 
  unsigned int *v13; 
  unsigned int v14; 
  _WORD *v15; 
  _CM_KEY_CONTROL_BLOCK *v16; 
  unsigned __int64 v17; 
  char v18; 
  INT64 v19; 
  _CM_KEY_CONTROL_BLOCK *v20; 
  int v22[2]; 
  VOID *CellAddress; 
  INT64 a4[2]; 
  __int128 v25; 
  _CM_UOW_KEY_STATE_MODIFICATION *Data; 
  INT64 a1; 
  INT64 v28; 
  _HV_GET_CELL_CONTEXT CellAddressContext; 

  v22[1] = 0;
  *(_DWORD *)&CellAddressContext.BinContext._bf_0 = 0;
  v22[0] = -1;
  KeyControlBlock = UoW->KeyControlBlock;
  StorageType = UoW->StorageType;
  CellAddressContext.Cell = -1;
  *(_OWORD *)a4 = 0i64;
  KeyHive = (UINT64)KeyControlBlock->KeyHash.KeyHive;
  v25 = 0i64;
  CellAddress = 0i64;
  CmpInitializeDelayDerefContext(a4);
  ModifyKeysData = UoW->ParentUoW->ModifyKeysData;
  Data = ModifyKeysData;
  if( ModifyKeysData )
  {
    ++ModifyKeysData->RefCount;
  }
  else
  {
    v6 = CmpLightWeightCreateModificationData(UoW, &Data);
    ModifyKeysData = Data;
    v7 = v6;
    if( v6 < 0 )
      goto LABEL_32;
  }
  CmpReferenceKeyControlBlock(UoW->KeyControlBlock);
  v8 = (INT64)UoW->KeyControlBlock;
  ChildKCB = UoW->ChildKCB;
  a1 = v8;
  CmpReferenceKeyControlBlock(ChildKCB);
  v10 = UoW->KeyControlBlock;
  QuadPart = UoW->LastWriteTime.QuadPart;
  v28 = QuadPart;
  if( (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(KeyHive + 8))(
         KeyHive,
         v10->ParentKcb->KeyHash.$0C446697F936DAB21E8D4AF094591EF0::KeyCell,
         v22) )
  {
    if( !HvMarkCellDirty((PVOID)KeyHive, (PVOID)UoW->KeyControlBlock->ParentKcb->KeyHash.KeyCell, 1u)
      || !HvMarkCellDirty((PVOID)KeyHive, (PVOID)UoW->KeyControlBlock->KeyHash.KeyCell, 1u)
      || !HvMarkCellDirty((PVOID)KeyHive, (PVOID)*(unsigned int *)(UoW->LastWriteTime.QuadPart + 40), 1u) )
    {
      v7 = -1073741443;
LABEL_27:
      (*(void(__fastcall **)(UINT64, int *))(KeyHive + 16))(KeyHive, v22);
      goto LABEL_28;
    }
    v12 = CmpCopyCell(KeyHive, UoW->KeyControlBlock->KeyHash.KeyCell, KeyHive, (unsigned int)StorageType);
    if( v12 == -1 )
    {
      v7 = -1073741670;
LABEL_26:
      QuadPart = v28;
      goto LABEL_27;
    }
    v13 = &ModifyKeysData->RefCount + StorageType;
    if( v13[3] == -1 )
    {
      LODWORD(Data) = *(_DWORD *)(KeyHive + 212);
      v14 = HvAllocateCell(KeyHive, 0xCui64, StorageType, &CellAddress, &CellAddressContext);
      v13[3] = v14;
      if( v14 == -1 )
        goto LABEL_15;
      v15 = CellAddress;
      *(_WORD *)CellAddress = (unsigned int)Data < 5 ? 26220 : 26732;
      v15[1] = 0;
      ModifyKeysData->SubKeyListCount[StorageType] = 0;
      (*(void(__fastcall **)(UINT64, _HV_GET_CELL_CONTEXT *))(KeyHive + 16))(KeyHive, &CellAddressContext);
    }
    if( CmpAddSubKeyToList(KeyHive, (UINT64 *)(v13 + 3), v12) )
    {
      ++ModifyKeysData->SubKeyListCount[StorageType];
      v16 = UoW->ChildKCB;
      v17 = (unsigned __int64)v16->KeyHash.KeyCell >> 31;
      if( CmpRemoveSubKeyFromList(KeyHive, &ModifyKeysData->NewSubKeyList[v17], v16->KeyHash.KeyCell) )
      {
        --ModifyKeysData->SubKeyListCount[v17];
        v18 = CmpMarkAllChildrenDirty((PVOID)KeyHive, v12);
        v8 = a1;
        if( v18 )
        {
          v7 = CmpPrepareToInvalidateAllHigherLayerKcbs(a1, 1u, (__int64)&v25);
          if( v7 >= 0 )
          {
            v19 = v28;
            v7 = CmpPrepareToInvalidateAllHigherLayerKcbs(v28, 1u, (__int64)&v25);
            if( v7 >= 0 )
            {
              CmpInvalidateAllHigherLayerKcbs(v8, 1u, 8i64, (INT64)a4);
              CmpInvalidateAllHigherLayerKcbs(v19, 1u, 8i64, (INT64)a4);
              v20 = UoW->KeyControlBlock;
              UoW->PrepareDataPointer = ModifyKeysData;
              v7 = 0;
              ModifyKeysData = 0i64;
              v28 = 0i64;
              v8 = 0i64;
              UoW->TxSecurityCell = v20->KeyHash.KeyCell;
              v20->KeyHash.KeyCell = v12;
              v12 = -1;
            }
          }
        }
        else
        {
          v7 = -1073741670;
        }
        goto LABEL_24;
      }
    }
LABEL_15:
    v8 = a1;
    v7 = -1073741670;
LABEL_24:
    if( v12 != -1 )
      CmpFreeKeyByCell(KeyHive, v12, 0);
    goto LABEL_26;
  }
  v7 = -1073741670;
LABEL_28:
  if( QuadPart )
    CmpDereferenceKeyControlBlockWithLock(QuadPart, (INT64)a4, 0);
  if( v8 )
    CmpDereferenceKeyControlBlockWithLock(v8, (INT64)a4, 0);
LABEL_32:
  if( ModifyKeysData )
    CmpLightWeightCleanupModifyKeyDataUoW(KeyHive, (UINT64 *)&ModifyKeysData->RefCount);
  CmpCleanupRollbackPacket((INT64)&v25);
  CmpDrainDelayDerefContext((UINT64 **)a4);
  return(unsigned int)v7;
}

Referenced by:

CmpProcessLightWeightUOW