CmpCommitSetValueKeyUoW

NTSTATUS __stdcall CmpCommitSetValueKeyUoW(_CM_KCB_UOW *UoW, _LARGE_INTEGER *CommitTime){
  INT64 v2; 
  VOID *p_Data; 
  _CM_KEY_CONTROL_BLOCK *KeyControlBlock; 
  INT64 v6; 
  __int64 NewValueCell; 
  PVOID v8; 
  UINT64 KeyHive; 
  __int64(__fastcall *v10)(UINT64, __int64, int *); 
  __int64 v11; 
  _CM_KEY_VALUE *v12; 
  unsigned int v13; 
  size_t Size; 
  VOID **PoolWithTag; 
  NTSTATUS v16; 
  unsigned __int16 Length; 
  _LARGE_INTEGER v18; 
  _CM_KEY_CONTROL_BLOCK *v19; 
  unsigned int v20; 
  bool ValueData; 
  unsigned int v23; 
  __int64 v24; 
  VOID *Src; 
  UINT64 Type; 
  UINT64 v27; 
  INT64 v28; 
  PVOID P; 
  unsigned int v30; 
  UINT64 v31; 
  int v32; 
  int v33[2]; 
  int v34[2]; 
  _UNICODE_STRING ValueName[5]; 
  char v36; 
  INT64 a2; 
  INT64 v39; 

  a2 = v2;
  v28 = 0i64;
  v34[1] = 0;
  v32 = 0;
  v33[1] = 0;
  v34[0] = -1;
  p_Data = 0i64;
  KeyControlBlock = UoW->KeyControlBlock;
  v6 = 0i64;
  NewValueCell = UoW->NewValueCell;
  v8 = 0i64;
  v33[0] = -1;
  KeyHive = (UINT64)KeyControlBlock->KeyHash.KeyHive;
  v36 = 0;
  LOBYTE(v39) = 0;
  ValueName[0] = 0i64;
  v10 = *(__int64(__fastcall **)(UINT64, __int64, int *))(KeyHive + 8);
  v31 = 0xFFFFFFFF00000000ui64;
  v30 = 0;
  v11 = v10(KeyHive, NewValueCell, v34);
  v12 = (_CM_KEY_VALUE *)v11;
  if( !v11 )
    return -1073741670;
  v13 = *(_DWORD *)(v11 + 4);
  Size = v13 + 0x80000000;
  if( v13 < 0x80000000 )
    Size = v13;
  LODWORD(P) = Size;
  if( Size )
  {
    if( v13 < 0x80000000 )
    {
      ValueData = CmpGetValueData(
                    (_HHIVE *)KeyHive,
                    UoW->NewValueCell,
                    v12,
                    (unsigned int *)&P,
                    (void **)&v28,
                    (unsigned __int8 *)&v39,
                    (_HV_GET_CELL_CONTEXT *)((char *)&v31 + 4));
      p_Data = (VOID *)v28;
      if( !ValueData )
        goto LABEL_36;
      Size = (unsigned int)P;
      v36 = 1;
    }
    else
    {
      p_Data = &v12->Data;
    }
  }
  v6 = (*(__int64(__fastcall **)(UINT64, _QWORD, int *))(KeyHive + 8))(
         KeyHive,
         UoW->KeyControlBlock->KeyHash.KeyCell,
         v33);
  if( !v6 )
  {
LABEL_36:
    v16 = -1073741670;
    goto LABEL_20;
  }
  if( HvMarkCellDirty((PVOID)KeyHive, (PVOID)UoW->KeyControlBlock->KeyHash.KeyCell, 0) )
  {
    UoW->StorageType = UoW->KeyControlBlock->KeyHash.KeyCell >> 31;
    PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x8000ui64, 1649626435i64);
    P = PoolWithTag;
    v8 = PoolWithTag;
    if( PoolWithTag )
    {
      CmpInitializeValueNameString(v12, ValueName, (_WCHAR *)PoolWithTag);
      if( CmpFindNameInList(KeyHive, (unsigned int *)(v6 + 36), (__int64)ValueName, 0, (unsigned int *)&v31, &v30) )
      {
        if( UoW->ActionType != UoWSetValueExisting || (v23 = v30, v30 == -1) )
        {
          LODWORD(v27) = UoW->StorageType;
          LODWORD(Type) = Size;
          LODWORD(Src) = v12->Type;
          v16 = CmpSetValueKeyNew(KeyHive, v6, ValueName, (unsigned int)v31, (INT64)Src, p_Data, Type, v27);
        }
        else
        {
          v28 = 0xFFFFFFFFi64;
          v24 = (*(__int64(__fastcall **)(UINT64, _QWORD, INT64 *))(KeyHive + 8))(KeyHive, v30, &v28);
          if( !v24 )
          {
            v16 = -1073741670;
LABEL_19:
            v8 = P;
            goto LABEL_20;
          }
          v16 = CmpSetValueKeyExisting(KeyHive, (void *)v23, v24, v12->Type, p_Data, Size, UoW->StorageType);
          (*(void(__fastcall **)(UINT64, INT64 *))(KeyHive + 16))(KeyHive, &v28);
        }
        if( v16 >= 0 )
        {
          HvMarkCellDirty((PVOID)KeyHive, (PVOID)UoW->NewValueCell, 0);
          Length = ValueName[0].Length;
          if( *(_DWORD *)(v6 + 60) < (unsigned int)ValueName[0].Length )
          {
            *(_DWORD *)(v6 + 60) = ValueName[0].Length;
            UoW->KeyControlBlock->KcbMaxValueNameLen = Length;
          }
          if( *(_DWORD *)(v6 + 64) < Size )
          {
            *(_DWORD *)(v6 + 64) = Size;
            UoW->KeyControlBlock->KcbMaxValueDataLen = Size;
          }
          ++UoW->KeyControlBlock->SequenceNumber;
          v18 = *CommitTime;
          *(_LARGE_INTEGER *)(v6 + 4) = *CommitTime;
          UoW->KeyControlBlock->KcbLastWriteTime = v18;
          CmpCleanUpKcbCachedSymlink((INT64)UoW->KeyControlBlock, a2);
          v19 = UoW->KeyControlBlock;
          v20 = *(_DWORD *)(v6 + 40);
          v19->ValueList.Count = *(_DWORD *)(v6 + 36);
          v19->ValueList.List = v20;
        }
        goto LABEL_19;
      }
    }
    goto LABEL_36;
  }
  v16 = -1073741443;
LABEL_20:
  if( p_Data && v36 )
  {
    if( (_BYTE)v39 )
      ExFreePoolWithTag(p_Data, 0);
    else(*(void(__fastcall **)(UINT64, char *))(KeyHive + 16))(KeyHive, (char *)&v31 + 4);
  }
  if( v8 )
    ExFreePoolWithTag(v8, 0);
  if( v6 )
    (*(void(__fastcall **)(UINT64, int *))(KeyHive + 16))(KeyHive, v33);
  (*(void(__fastcall **)(UINT64, int *))(KeyHive + 16))(KeyHive, v34);
  return v16;
}

Referenced by:

CmpTransMgrCommitUoW