- /* If new data size is <= current then overwrite current data */
- DataCell = CmiGetCell (RegistryHive, ValueCell->DataOffset,&pBin);
- RtlZeroMemory(DataCell->Data, ValueCell->DataSize);
- RtlCopyMemory(DataCell->Data, Data, DataSize);
- ValueCell->DataSize = DataSize;
- ValueCell->DataType = Type;
- CmiMarkBlockDirty(RegistryHive, ValueCell->DataOffset);
- CmiMarkBlockDirty(RegistryHive, ValueCellOffset);
- }
- else
- {
- /*
- * New data size is larger than the current, destroy current
- * data block and allocate a new one.
- */
- BLOCK_OFFSET NewOffset;
-
- DPRINT("ValueCell->DataSize %lu\n", ValueCell->DataSize);
+ if (DataSize > DataCellSize)
+ {
+ /*
+ * New data size is larger than the current, destroy current
+ * data block and allocate a new one.
+ */
+ BLOCK_OFFSET NewOffset;
+
+ DPRINT("ValueCell->DataSize %lu\n", ValueCell->DataSize);
+
+ Status = CmiAllocateCell (RegistryHive,
+ sizeof(CELL_HEADER) + DataSize,
+ (PVOID *)&NewDataCell,
+ &NewOffset);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("CmiAllocateBlock() failed (Status %lx)\n", Status);