Fixed the growing of the dirty bitmap. This will fix the registry update bugs, if...
[reactos.git] / reactos / ntoskrnl / cm / regfile.c
index 5b4abda..1b1f466 100644 (file)
@@ -862,7 +862,7 @@ CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
                                   Filename);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT("RtlpCreateUnicodeString() failed (Status %lx)\n", Status);
+      DPRINT("RtlCreateUnicodeString() failed (Status %lx)\n", Status);
       return(Status);
     }
 
@@ -3033,7 +3033,6 @@ CmiAllocateHashTableCell (IN PREGISTRY_HIVE RegistryHive,
   else
     {
       ASSERT(SubKeyCount <= 0xffff); /* should really be USHORT_MAX or similar */
-      NewHashBlock->CellSize = -NewHashSize;
       NewHashBlock->Id = REG_HASH_TABLE_CELL_ID;
       NewHashBlock->HashTableSize = (USHORT)SubKeyCount;
       *HashBlock = NewHashBlock;
@@ -3236,6 +3235,7 @@ CmiAddBin(PREGISTRY_HIVE RegistryHive,
   PHBIN tmpBin;
   ULONG BinSize;
   ULONG i;
+  ULONG BitmapSize;
 
   DPRINT ("CmiAddBin (BlockCount %lu)\n", BlockCount);
 
@@ -3288,17 +3288,17 @@ CmiAddBin(PREGISTRY_HIVE RegistryHive,
   tmpBlock = (PCELL_HEADER)((ULONG_PTR) tmpBin + REG_HBIN_DATA_OFFSET);
   tmpBlock->CellSize = (BinSize - REG_HBIN_DATA_OFFSET);
 
+  /* Calculate bitmap size in bytes (always a multiple of 32 bits) */
+  BitmapSize = ROUND_UP(RegistryHive->BlockListSize, sizeof(ULONG) * 8) / 8;
+
   /* Grow bitmap if necessary */
-  if (IsNoFileHive(RegistryHive) &&
-      (RegistryHive->BlockListSize % (sizeof(ULONG) * 8) == 0))
+  if (!IsNoFileHive(RegistryHive) &&
+      BitmapSize > RegistryHive->DirtyBitMap.SizeOfBitMap)
     {
       PULONG BitmapBuffer;
-      ULONG BitmapSize;
 
       DPRINT("Grow hive bitmap\n");
 
-      /* Calculate bitmap size in bytes (always a multiple of 32 bits) */
-      BitmapSize = ROUND_UP(RegistryHive->BlockListSize, sizeof(ULONG) * 8) / 8;
       DPRINT("RegistryHive->BlockListSize: %lu\n", RegistryHive->BlockListSize);
       DPRINT("BitmapSize:  %lu Bytes  %lu Bits\n", BitmapSize, BitmapSize * 8);
       BitmapBuffer = (PULONG)ExAllocatePool(PagedPool,