CmpTransMgrCommitUoW

NTSTATUS __stdcall CmpTransMgrCommitUoW(_CM_KCB_UOW *UoW, _LARGE_INTEGER *CommitTime, _CM_TRANS *CmTrans){
  NTSTATUS v3; 
  UoWActionType ActionType; 
  int v7; 
  INT64 v9; 
  NTSTATUS v10; 
  _CM_KEY_CONTROL_BLOCK *KeyControlBlock; 
  UINT64 KeyHive; 
  unsigned int KeyCell; 
  __int64 v14; 
  unsigned int v15; 
  _LARGE_INTEGER v16; 
  int v17[2]; 
  _QWORD a1[2]; 
  LIST_ENTRY v19; 
  struct _EVENT_DATA_DESCRIPTOR v20[2]; 
  v3 = 0;
  *(_OWORD *)a1 = 0i64;
  if( (unsigned int)dword_140C02130 > 5 && tlgKeywordOn((__int64)&dword_140C02130, 1i64) )
    tlgWriteTransfer_EtwWriteTransfer((__int64)&dword_140C02130, (unsigned __int8 *)word_140022AB2, 0i64, 0i64, 2u, v20);
  v19.Blink = &v19;
  v19.Flink = &v19;
  CmpInitializeDelayDerefContext(a1);
  ActionType = UoW->ActionType;
  if( ActionType == UoWAddThisKey )
  {
    CmpLockRegistryExclusive();
    v3 = CmpCommitAddKeyUoW((__int64)UoW, (__int64 *)CommitTime);
    if( v3 < 0 )
      goto LABEL_15;
    v9 = 1i64;
    UoW->KeyControlBlock->TransKCBOwner = 0i64;
    goto LABEL_26;
  }
  if( ActionType == UoWDeleteThisKey )
  {
    CmpLockRegistryExclusive();
    CmpReportNotify((INT64)UoW->KeyControlBlock, 0i64, 1i64, &v19);
    v10 = CmpCommitDeleteKeyUoW((__int64)UoW, (__int64 *)CommitTime, (__int64)a1);
LABEL_30:
    v3 = v10;
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);
      v7 = CmpCommitSetValueKeyUoW((__int64)UoW, (__int64 *)CommitTime, (__int64)a1);
      goto LABEL_11;
    }
    if( ActionType == UoWDeleteValue )
    {
      CmpLockRegistry();
      CmpLockKcbExclusive((__int64)UoW->KeyControlBlock);
      HvLockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
      v7 = CmpCommitDeleteValueKeyUoW((__int64)UoW, (__int64 *)CommitTime, (__int64)a1);
LABEL_11:
      v3 = v7;
      if( v7 >= 0 )
        CmpReportNotify((INT64)UoW->KeyControlBlock, 0i64, 4i64, &v19);
      HvUnlockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
      CmpUnlockKcb((UINT64)UoW->KeyControlBlock);
      goto LABEL_14;
    }
    if( ActionType != UoWSetSecurityDescriptor )
    {
      if( ActionType == UoWSetKeyUserFlags )
      {
        v17[0] = -1;
        v17[1] = 0;
        CmpLockRegistry();
        CmpLockKcbExclusive((__int64)UoW->KeyControlBlock);
        HvLockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
        KeyControlBlock = UoW->KeyControlBlock;
        KeyHive = (UINT64)KeyControlBlock->KeyHash.KeyHive;
        KeyCell = KeyControlBlock->KeyHash.KeyCell;
        v14 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(KeyHive + 8))(KeyHive, KeyCell, v17);
        if( v14 )
        {
          if( !HvMarkCellDirty(KeyHive, KeyCell, 0) )
          {
            (*(void(__fastcall **)(UINT64, int *))(KeyHive + 16))(KeyHive, v17);
            HvUnlockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
            CmpUnlockKcb((UINT64)UoW->KeyControlBlock);
            CmpUnlockRegistry();
            v3 = -1073741443;
            goto LABEL_16;
          }
          v15 = *(_DWORD *)(v14 + 52) ^ (*(_DWORD *)(v14 + 52) ^ (UoW->VolatileKeyCell << 16)) & 0xF0000;
          *(_DWORD *)(v14 + 52) = v15;
          *((_DWORD *)UoW->KeyControlBlock + 46) ^= (*((_DWORD *)UoW->KeyControlBlock + 46) ^ HIWORD(v15)) & 0xF;
          v16 = *CommitTime;
          *(_LARGE_INTEGER *)(v14 + 4) = *CommitTime;
          ++UoW->KeyControlBlock->SequenceNumber;
          UoW->KeyControlBlock->KcbLastWriteTime = v16;
          (*(void(__fastcall **)(UINT64, int *))(KeyHive + 16))(KeyHive, v17);
        }
        else
        {
          v3 = -1073741670;
        }
        HvUnlockHiveFlusherShared((INT64)UoW->KeyControlBlock->KeyHash.KeyHive);
        CmpUnlockKcb((UINT64)UoW->KeyControlBlock);
        goto LABEL_15;
      }
      if( ActionType != UoWRenameNewSubKey )
        goto LABEL_16;
      CmpLockRegistryExclusive();
      v10 = CmpCommitRenameKeyUoW((__int64)UoW, (__int64 *)CommitTime, (__int64)a1);
      goto LABEL_30;
    }
    CmpLockRegistryExclusive();
    v3 = CmpCommitSetSecurityUoW((__int64)UoW, (__int64 *)CommitTime);
    if( v3 < 0 )
      goto LABEL_15;
    v9 = 10i64;
LABEL_26:
    CmpReportNotify((INT64)UoW->KeyControlBlock, 0i64, v9, &v19);
    goto LABEL_15;
  }
LABEL_16:
  CmpSignalDeferredPosts(&v19);
  if( (unsigned int)dword_140C02130 > 5 && tlgKeywordOn((__int64)&dword_140C02130, 1i64) )
    tlgWriteTransfer_EtwWriteTransfer((__int64)&dword_140C02130, (unsigned __int8 *)byte_140022A8D, 0i64, 0i64, 2u, v20);
  return v3;
}

Referenced by:

CmpTransMgrCommit