CmpTransMgrCommitUoW

NTSTATUS __stdcall CmpTransMgrCommitUoW(_CM_KCB_UOW *UoW, _LARGE_INTEGER *CommitTime){
  NTSTATUS v2; 
  UoWActionType ActionType; 
  NTSTATUS v6; 
  __int64 v8; 
  NTSTATUS v9; 
  _CM_KEY_CONTROL_BLOCK *KeyControlBlock; 
  _HHIVE *KeyHive; 
  unsigned int KeyCell; 
  __int64 v13; 
  unsigned int v14; 
  _LARGE_INTEGER v15; 
  int v16[2]; 
  _QWORD a1[2]; 
  _LOOKASIDE_LIST_EX DeferredPostAsync; 

  v2 = 0;
  *(_OWORD *)a1 = 0i64;
  if( *(&stru_140C00F40 + 1148) > 5u && tlgKeywordOn((__int64)&stru_140C00F40 + 4592, 1i64) )
    tlgWriteTransfer_EtwWriteTransfer(
      (__int64)&stru_140C00F40 + 4592,
      (unsigned __int8 *)word_140022AB2,
      0i64,
      0i64,
      2u,
      (PEVENT_DATA_DESCRIPTOR)&DeferredPostAsync.L.Depth);
  DeferredPostAsync.L.ListHead.Region = (unsigned __int64)&DeferredPostAsync;
  DeferredPostAsync.L.ListHead.Alignment = (unsigned __int64)&DeferredPostAsync;
  CmpInitializeDelayDerefContext(a1);
  ActionType = UoW->ActionType;
  if( ActionType == UoWAddThisKey )
  {
    CmpLockRegistryExclusive();
    v2 = CmpCommitAddKeyUoW(UoW, CommitTime);
    if( v2 < 0 )
      goto LABEL_15;
    v8 = 1i64;
    UoW->KeyControlBlock->TransKCBOwner = 0i64;
    goto LABEL_26;
  }
  if( ActionType == UoWDeleteThisKey )
  {
    CmpLockRegistryExclusive();
    CmpReportNotify((__int64)UoW->KeyControlBlock, 0i64, 1i64, &DeferredPostAsync);
    v9 = CmpCommitDeleteKeyUoW(UoW, CommitTime);
LABEL_30:
    v2 = v9;
LABEL_14:
    CmpDrainDelayDerefContext((UINT64 **)a1);
LABEL_15:
    CmpUnlockRegistry();
    goto LABEL_16;
  }
  if( ActionType > UoWDeleteChildKey )
  {
    if( ActionType <= UoWSetValueExisting )
    {
      CmpLockRegistry();
      CmpLockKcbExclusive((INT64)UoW->KeyControlBlock);
      HvLockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
      v6 = CmpCommitSetValueKeyUoW(UoW, CommitTime);
      goto LABEL_11;
    }
    if( ActionType == UoWDeleteValue )
    {
      CmpLockRegistry();
      CmpLockKcbExclusive((INT64)UoW->KeyControlBlock);
      HvLockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
      v6 = CmpCommitDeleteValueKeyUoW(UoW, CommitTime);
LABEL_11:
      v2 = v6;
      if( v6 >= 0 )
        CmpReportNotify((__int64)UoW->KeyControlBlock, 0i64, 4i64, &DeferredPostAsync);
      HvUnlockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
      CmpUnlockKcb(UoW->KeyControlBlock);
      goto LABEL_14;
    }
    if( ActionType != UoWSetSecurityDescriptor )
    {
      if( ActionType == UoWSetKeyUserFlags )
      {
        v16[0] = -1;
        v16[1] = 0;
        CmpLockRegistry();
        CmpLockKcbExclusive((INT64)UoW->KeyControlBlock);
        HvLockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
        KeyControlBlock = UoW->KeyControlBlock;
        KeyHive = KeyControlBlock->KeyHash.KeyHive;
        KeyCell = KeyControlBlock->KeyHash.KeyCell;
        v13 = (__int64)KeyHive->GetCellRoutine(KeyHive, KeyCell, (_HV_GET_CELL_CONTEXT *)v16);
        if( v13 )
        {
          if( !HvMarkCellDirty(KeyHive, (PVOID)KeyCell, 0) )
          {
            KeyHive->ReleaseCellRoutine(KeyHive, (_HV_GET_CELL_CONTEXT *)v16);
            HvUnlockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
            CmpUnlockKcb(UoW->KeyControlBlock);
            CmpUnlockRegistry();
            v2 = -1073741443;
            goto LABEL_16;
          }
          v14 = *(_DWORD *)(v13 + 52) ^ (*(_DWORD *)(v13 + 52) ^ (UoW->VolatileKeyCell << 16)) & 0xF0000;
          *(_DWORD *)(v13 + 52) = v14;
          UoW->KeyControlBlock->_bf_b8 ^= (UoW->KeyControlBlock->_bf_b8 ^ HIWORD(v14)) & 0xF;
          v15 = *CommitTime;
          *(_LARGE_INTEGER *)(v13 + 4) = *CommitTime;
          ++UoW->KeyControlBlock->SequenceNumber;
          UoW->KeyControlBlock->KcbLastWriteTime = v15;
          KeyHive->ReleaseCellRoutine(KeyHive, (_HV_GET_CELL_CONTEXT *)v16);
        }
        else
        {
          v2 = -1073741670;
        }
        HvUnlockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
        CmpUnlockKcb(UoW->KeyControlBlock);
        goto LABEL_15;
      }
      if( ActionType != UoWRenameNewSubKey )
        goto LABEL_16;
      CmpLockRegistryExclusive();
      v9 = CmpCommitRenameKeyUoW(UoW, CommitTime);
      goto LABEL_30;
    }
    CmpLockRegistryExclusive();
    v2 = CmpCommitSetSecurityUoW(UoW, CommitTime);
    if( v2 < 0 )
      goto LABEL_15;
    v8 = 10i64;
LABEL_26:
    CmpReportNotify((__int64)UoW->KeyControlBlock, 0i64, v8, &DeferredPostAsync);
    goto LABEL_15;
  }
LABEL_16:
  CmpSignalDeferredPosts((_LIST_ENTRY *)&DeferredPostAsync);
  if( *(&stru_140C00F40 + 1148) > 5u && tlgKeywordOn((__int64)&stru_140C00F40 + 4592, 1i64) )
    tlgWriteTransfer_EtwWriteTransfer(
      (__int64)&stru_140C00F40 + 4592,
      (unsigned __int8 *)byte_140022A8D,
      0i64,
      0i64,
      2u,
      (PEVENT_DATA_DESCRIPTOR)&DeferredPostAsync.L.Depth);
  return v2;
}

Referenced by:

CmpTransMgrCommit