CmpAddValueToListEx

NTSTATUS __stdcall CmpAddValueToListEx(
        _HHIVE *Hive,
        UINT64 ValueCell,
        UINT64 Index,
        UINT64 Type,
        _CHILD_LIST *ChildList,
        UINT64 AllocationCount){
  int v7; 
  __int64 v8; 
  __int64 Count; 
  int v10; 
  unsigned int v11; 
  INT64 v12; 
  unsigned int Cell; 
  INT64 v14; 
  _DWORD *v16; 
  INT64 CellAddressContext; 
  INT64 v18[4]; 
  v18[0] = 0i64;
  CellAddressContext = 0xFFFFFFFFi64;
  v7 = ValueCell;
  v8 = (unsigned int)Index;
  Count = ChildList->Count;
  v10 = 1;
  v11 = Count + 1;
  if( (unsigned int)(Count + 1) <= 1 )
  {
    if( (_DWORD)AllocationCount )
      v10 = AllocationCount;
    Cell = HvAllocateCell(
             Hive,
             (unsigned int)(4 * v10),
             (HSTORAGE_TYPE)Type,
             (VOID **)v18,
             (_HV_GET_CELL_CONTEXT *)&CellAddressContext);
  }
  else
  {
    if( v11 >= 0x64 )
    {
      v12 = 4 * (((_DWORD)Count + 100) & 0xFFFFFF9C);
      if( (unsigned int)v12 > 0x1000 )
        v12 = ((_DWORD)v12 + 4095) & 0xFFFFF000;
    }
    else
    {
      v12 = 4 * v11;
    }
    Cell = HvReallocateCell((UINT64)Hive, ChildList->List, v12, 1, v18, &CellAddressContext);
  }
  if( Cell == -1 )
    return -1073741670;
  v14 = v18[0];
  ChildList->List = Cell;
  if( (unsigned int)Count > (unsigned int)v8 )
  {
    v16 = (_DWORD *)(v14 + 4 * Count);
    do
    {
      Count = (unsigned int)(Count - 1);
      *v16-- = *(_DWORD *)(v14 + 4 * Count);
    }
    while( (unsigned int)Count > (unsigned int)v8 );
  }
  *(_DWORD *)(v14 + 4 * v8) = v7;
  ChildList->Count = v11;
  Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&CellAddressContext);
  return 0;
}

Referenced by:

CmpAddValueToList
CmpCopyKeyPartial
CmpMergeKeyValues