CmpAddValueKeyNew

INT64 __fastcall CmpAddValueKeyNew(UINT64 a1, _UNICODE_STRING *a2, INT64 a3, VOID *a4, UINT64 Size, UINT64 Type){
  int v8; 
  UINT16 v10; 
  ULONG_PTR v11; 
  _WORD *v12; 
  wchar_t *v13; 
  unsigned __int16 v14; 
  _HV_GET_CELL_CONTEXT CellAddressContext; 
  VOID *CellAddress; 

  CellAddressContext.Cell = -1;
  CellAddress = 0i64;
  v8 = a3;
  *(_DWORD *)&CellAddressContext.BinContext._bf_0 = 0;
  v10 = CmpNameSize(a2);
  v11 = HvAllocateCell(a1, (unsigned int)v10 + 20, Type, &CellAddress, &CellAddressContext);
  if( v11 != -1 )
  {
    v12 = CellAddress;
    v13 = (wchar_t *)((char *)CellAddress + 20);
    *(_WORD *)CellAddress = 27510;
    v14 = CmpCopyName(v13, a2);
    v12[1] = v14;
    v12[8] = v14 < a2->Length;
    if( (unsigned int)Size <= 4 )
    {
      *((_DWORD *)v12 + 1) = Size + 0x80000000;
      *((_DWORD *)v12 + 2) = 0;
      memmove(v12 + 4, a4, Size);
    }
    else
    {
      if( (int)CmpSetValueDataNew(a1, a4, Size, Type, (__int64)(v12 + 4)) < 0 )
      {
        HvFreeCell(a1, v11);
        v11 = -1;
        goto LABEL_8;
      }
      *((_DWORD *)v12 + 1) = Size;
    }
    *((_DWORD *)v12 + 3) = v8;
LABEL_8:
    (*(void(__fastcall **)(UINT64, _HV_GET_CELL_CONTEXT *))(a1 + 16))(a1, &CellAddressContext);
    return v11;
  }
  return 0xFFFFFFFFi64;
}

Referenced by:

CmSetValueKey
CmpLightWeightPrepareSetValueKeyUoW
CmpSetValueKeyNew