Commit in reactos/ntoskrnl/cm on MAIN
cm.h+22-21.51 -> 1.52
import.c+5-81.30 -> 1.31
ntfunc.c+72-631.71 -> 1.72
regfile.c+4-321.84 -> 1.85
registry.c+10-211.128 -> 1.129
+113-126
5 modified files
- Replace hive locks and hive list lock by a global lock to make the registry thread-safe.

reactos/ntoskrnl/cm
cm.h 1.51 -> 1.52
diff -u -r1.51 -r1.52
--- cm.h	25 Aug 2004 15:08:29 -0000	1.51
+++ cm.h	12 Dec 2004 22:36:10 -0000	1.52
@@ -47,6 +47,7 @@
 #define  REG_KEY_CELL_ID               0x6b6e
 #define  REG_HASH_TABLE_CELL_ID        0x666c
 #define  REG_VALUE_CELL_ID             0x6b76
+#define  REG_SECURITY_CELL_ID          0x6b73
 
 
 // BLOCK_OFFSET = offset in file after header block
@@ -239,6 +240,19 @@
 #define REG_DATA_IN_OFFSET                 0x80000000
 
 
+typedef struct _SECURITY_CELL
+{
+  LONG  CellSize;
+  USHORT Id;	// "sk"
+  USHORT Reserved;
+  BLOCK_OFFSET PrevSecurityCell;
+  BLOCK_OFFSET NextSecurityCell;
+  ULONG RefCount;
+  ULONG SdSize;
+  UCHAR Data[0];
+} SECURITY_CELL, *PSECURITY_CELL;
+
+
 typedef struct _DATA_CELL
 {
   LONG  CellSize;
@@ -270,7 +284,8 @@
   ULONG  FreeListMax;
   PCELL_HEADER *FreeList;
   BLOCK_OFFSET *FreeListOffset;
-  ERESOURCE  HiveResource;
+
+  PSECURITY_CELL RootSecurityCell;
 
   PULONG BitmapBuffer;
   RTL_BITMAP  DirtyBitMap;
@@ -354,7 +369,8 @@
 extern KSPIN_LOCK CmiKeyListLock;
 
 extern LIST_ENTRY CmiHiveListHead;
-extern ERESOURCE CmiHiveListLock;
+
+extern ERESOURCE CmiRegistryLock;
 
 /* Registry Callback Function */
 typedef NTSTATUS (*PEX_CALLBACK_FUNCTION ) (
@@ -585,6 +601,10 @@
 	       PVOID Cell,
 	       BLOCK_OFFSET CellOffset);
 
+PHBIN
+CmiGetBin (PREGISTRY_HIVE RegistryHive,
+	   BLOCK_OFFSET CellOffset);
+
 PVOID
 CmiGetCell (PREGISTRY_HIVE RegistryHive,
 	    BLOCK_OFFSET CellOffset,

reactos/ntoskrnl/cm
import.c 1.30 -> 1.31
diff -u -r1.30 -r1.31
--- import.c	15 Aug 2004 16:39:00 -0000	1.30
+++ import.c	12 Dec 2004 22:36:10 -0000	1.31
@@ -1,4 +1,4 @@
-/* $Id: import.c,v 1.30 2004/08/15 16:39:00 chorns Exp $
+/* $Id: import.c,v 1.31 2004/12/12 22:36:10 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -134,18 +134,15 @@
 	}
     }
 
-  /* Initialize the hive's executive resource */
-  ExInitializeResourceLite(&Hive->HiveResource);
-
   /* Acquire hive list lock exclusively */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiHiveListLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   /* Add the new hive to the hive list */
   InsertTailList(&CmiHiveListHead, &Hive->HiveList);
 
   /* Release hive list lock */
-  ExReleaseResourceLite(&CmiHiveListLock);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   *RegistryHive = Hive;
@@ -192,7 +189,7 @@
 			   RegistryHive);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT1 ("CmiConnectHive() failed (Status %lx)\n", Status);
+      DPRINT1 ("CmiConnectHive(%wZ) failed (Status %lx)\n", &KeyName, Status);
 //      CmiRemoveRegistryHive(RegistryHive);
       return FALSE;
     }
@@ -344,7 +341,7 @@
 			   RegistryHive);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT1 ("CmiConnectHive() failed (Status %lx)\n", Status);
+      DPRINT1 ("CmiConnectHive(%wZ) failed (Status %lx)\n", &KeyName, Status);
 //      CmiRemoveRegistryHive(RegistryHive);
       return FALSE;
     }

reactos/ntoskrnl/cm
ntfunc.c 1.71 -> 1.72
diff -u -r1.71 -r1.72
--- ntfunc.c	8 Oct 2004 21:19:12 -0000	1.71
+++ ntfunc.c	12 Dec 2004 22:36:10 -0000	1.72
@@ -164,7 +164,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   /* add key to subkeys of parent if needed */
   Status = CmiAddSubKey(KeyObject->RegistryHive,
@@ -178,7 +178,7 @@
     {
       DPRINT("CmiAddSubKey() failed (Status %lx)\n", Status);
       /* Release hive lock */
-      ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+      ExReleaseResourceLite(&CmiRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject(KeyObject);
       ObDereferenceObject(Object);
@@ -219,7 +219,7 @@
   VERIFY_KEY_OBJECT(KeyObject);
 
   /* Release hive lock */
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   ObDereferenceObject(KeyObject);
@@ -240,23 +240,24 @@
   PKEY_OBJECT KeyObject;
   NTSTATUS Status;
 
-  DPRINT("KeyHandle %x\n", KeyHandle);
+  DPRINT1("NtDeleteKey(KeyHandle %x) called\n", KeyHandle);
 
   /* Verify that the handle is valid and is a registry key */
   Status = ObReferenceObjectByHandle(KeyHandle,
-				     KEY_WRITE,
+				     DELETE,
 				     CmiKeyType,
 				     UserMode,
 				     (PVOID *)&KeyObject,
 				     NULL);
   if (!NT_SUCCESS(Status))
     {
-      return(Status);
+      DPRINT1("ObReferenceObjectByHandle() failed (Status %lx)\n", Status);
+      return Status;
     }
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -273,17 +274,18 @@
     }
 
   /* Release hive lock */
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
-  DPRINT("PointerCount %lu\n", ObGetObjectPointerCount((PVOID)KeyObject));
+  DPRINT1("PointerCount %lu\n", ObGetObjectPointerCount((PVOID)KeyObject));
 
   /* Dereference the object */
   ObDereferenceObject(KeyObject);
-  if(KeyObject->RegistryHive != KeyObject->ParentKey->RegistryHive)
+  if (KeyObject->RegistryHive != KeyObject->ParentKey->RegistryHive)
     ObDereferenceObject(KeyObject);
 
   DPRINT("PointerCount %lu\n", ObGetObjectPointerCount((PVOID)KeyObject));
+  DPRINT("HandleCount %lu\n", ObGetObjectHandleCount((PVOID)KeyObject));
 
   /*
    * Note:
@@ -292,7 +294,7 @@
    * have been released.
    */
 
-  return(Status);
+  return Status;
 }
 
 
@@ -339,7 +341,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -352,7 +354,7 @@
   /* Check for hightest possible sub key index */
   if (Index >= KeyCell->NumberOfSubKeys + KeyObject->NumberOfSubKeys)
     {
-      ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+      ExReleaseResourceLite(&CmiRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject(KeyObject);
       DPRINT("No more volatile entries\n");
@@ -382,7 +384,7 @@
 
       if (i >= KeyObject->NumberOfSubKeys)
 	{
-	  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+	  ExReleaseResourceLite(&CmiRegistryLock);
 	  KeLeaveCriticalRegion();
 	  ObDereferenceObject(KeyObject);
 	  DPRINT("No more non-volatile entries\n");
@@ -396,7 +398,7 @@
     {
       if (KeyCell->HashTableOffset == (BLOCK_OFFSET)-1)
 	{
-	  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+	  ExReleaseResourceLite(&CmiRegistryLock);
 	  KeLeaveCriticalRegion();
 	  ObDereferenceObject(KeyObject);
 	  return STATUS_NO_MORE_ENTRIES;
@@ -406,7 +408,7 @@
       if (HashTableBlock == NULL)
 	{
 	  DPRINT("CmiGetBlock() failed\n");
-	  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+	  ExReleaseResourceLite(&CmiRegistryLock);
 	  KeLeaveCriticalRegion();
 	  ObDereferenceObject(KeyObject);
 	  return STATUS_UNSUCCESSFUL;
@@ -419,7 +421,7 @@
 
   if (SubKeyCell == NULL)
     {
-      ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+      ExReleaseResourceLite(&CmiRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject(KeyObject);
       DPRINT("No more entries\n");
@@ -634,7 +636,7 @@
 	break;
     }
 
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
   ObDereferenceObject(KeyObject);
 
@@ -686,7 +688,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -702,7 +704,7 @@
 
   if (!NT_SUCCESS(Status))
     {
-      ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+      ExReleaseResourceLite(&CmiRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject(KeyObject);
       return Status;
@@ -715,7 +717,7 @@
         case KeyValueBasicInformation:
 	  NameSize = ValueCell->NameSize;
 	  if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
-            {
+	    {
 	      NameSize *= sizeof(WCHAR);
 	    }
 
@@ -883,7 +885,7 @@
       Status = STATUS_UNSUCCESSFUL;
     }
 
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
   ObDereferenceObject(KeyObject);
 
@@ -918,8 +920,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&RegistryHive->HiveResource,
-				 TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   if (IsNoFileHive(RegistryHive))
     {
@@ -931,7 +932,7 @@
       Status = CmiFlushRegistryHive(RegistryHive);
     }
 
-  ExReleaseResourceLite(&RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   ObDereferenceObject(KeyObject);
@@ -1039,7 +1040,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -1192,7 +1193,7 @@
 	break;
     }
 
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
   ObDereferenceObject(KeyObject);
 
@@ -1238,7 +1239,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -1307,7 +1308,7 @@
 	break;
 
       case KeyValuePartialInformation:
-        DataSize = ValueCell->DataSize & REG_DATA_SIZE_MASK;
+	DataSize = ValueCell->DataSize & REG_DATA_SIZE_MASK;
 
 	*ResultLength = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]) +
 	                DataSize;
@@ -1324,14 +1325,14 @@
 	    ValuePartialInformation->Type = ValueCell->DataType;
 	    ValuePartialInformation->DataLength = DataSize;
 
-            if (Length - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]) <
-                DataSize)
-              {
-                DataSize = Length - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]);
-                Status = STATUS_BUFFER_OVERFLOW;
-                CHECKPOINT;
-              }
-	    
+	    if (Length - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]) <
+	        DataSize)
+	      {
+		DataSize = Length - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]);
+		Status = STATUS_BUFFER_OVERFLOW;
+		CHECKPOINT;
+	      }
+
 	    if (!(ValueCell->DataSize & REG_DATA_IN_OFFSET))
 	      {
 		DataCell = CmiGetCell (RegistryHive, ValueCell->DataOffset, NULL);
@@ -1432,7 +1433,7 @@
     }
 
 ByeBye:;
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
   ObDereferenceObject(KeyObject);
 
@@ -1478,7 +1479,7 @@
 
   /* Acquire hive lock exclucively */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -1505,7 +1506,7 @@
     {
       DPRINT("Cannot add value. Status 0x%X\n", Status);
 
-      ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+      ExReleaseResourceLite(&CmiRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject(KeyObject);
       return Status;
@@ -1570,7 +1571,7 @@
 	{
 	  DPRINT("CmiAllocateBlock() failed (Status %lx)\n", Status);
 
-	  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+	  ExReleaseResourceLite(&CmiRegistryLock);
 	  KeLeaveCriticalRegion();
 	  ObDereferenceObject(KeyObject);
 
@@ -1595,7 +1596,7 @@
   NtQuerySystemTime (&KeyCell->LastWriteTime);
   CmiMarkBlockDirty (RegistryHive, KeyObject->KeyCellOffset);
 
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
   ObDereferenceObject(KeyObject);
 
@@ -1628,7 +1629,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -1641,7 +1642,7 @@
   CmiMarkBlockDirty (KeyObject->RegistryHive, KeyObject->KeyCellOffset);
 
   /* Release hive lock */
-  ExReleaseResourceLite (&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   ObDereferenceObject (KeyObject);
@@ -1765,6 +1766,10 @@
 
   DPRINT ("Full name: '%wZ'\n", NamePointer);
 
+  /* Acquire hive lock */
+  KeEnterCriticalRegion();
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+
   Status = CmiLoadHive (KeyObjectAttributes,
 			NamePointer,
 			Flags);
@@ -1773,6 +1778,10 @@
       DPRINT1 ("CmiLoadHive() failed (Status %lx)\n", Status);
     }
 
+  /* Release hive lock */
+  ExReleaseResourceLite(&CmiRegistryLock);
+  KeLeaveCriticalRegion();
+
   if (Buffer != NULL)
     ExFreePool (Buffer);
 
@@ -1830,7 +1839,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -1904,7 +1913,7 @@
   *ReturnLength = BufferLength;
 
   /* Release hive lock */
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   ObDereferenceObject(KeyObject);
@@ -1964,14 +1973,13 @@
 
   /* Acquire hive lock exclucively */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite (&KeyObject->RegistryHive->HiveResource,
-				  TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   /* Refuse to save a volatile key */
   if (KeyObject->RegistryHive == CmiVolatileHive)
     {
       DPRINT1 ("Cannot save a volatile key\n");
-      ExReleaseResourceLite (&KeyObject->RegistryHive->HiveResource);
+      ExReleaseResourceLite(&CmiRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject (KeyObject);
       return STATUS_ACCESS_DENIED;
@@ -1981,7 +1989,7 @@
   if (!NT_SUCCESS(Status))
     {
       DPRINT1 ("CmiCreateTempHive() failed (Status %lx)\n", Status);
-      ExReleaseResourceLite (&KeyObject->RegistryHive->HiveResource);
+      ExReleaseResourceLite(&CmiRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject (KeyObject);
       return(Status);
@@ -1995,7 +2003,7 @@
     {
       DPRINT1 ("CmiCopyKey() failed (Status %lx)\n", Status);
       CmiRemoveRegistryHive (TempHive);
-      ExReleaseResourceLite (&KeyObject->RegistryHive->HiveResource);
+      ExReleaseResourceLite(&CmiRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject (KeyObject);
       return(Status);
@@ -2011,7 +2019,7 @@
   CmiRemoveRegistryHive (TempHive);
 
   /* Release hive lock */
-  ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   ObDereferenceObject (KeyObject);
@@ -2067,7 +2075,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite (&KeyObject->RegistryHive->HiveResource, TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -2078,7 +2086,7 @@
 		     KeyObject->KeyCellOffset);
 
   /* Release hive lock */
-  ExReleaseResourceLite (&KeyObject->RegistryHive->HiveResource);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   ObDereferenceObject (KeyObject);
@@ -2109,33 +2117,34 @@
     return STATUS_PRIVILEGE_NOT_HELD;
 #endif
 
+  /* Acquire registry lock exclusively */
+  KeEnterCriticalRegion();
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+
   Status = CmiDisconnectHive (KeyObjectAttributes,
 			      &RegistryHive);
   if (!NT_SUCCESS (Status))
     {
       DPRINT1 ("CmiDisconnectHive() failed (Status %lx)\n", Status);
+      ExReleaseResourceLite (&CmiRegistryLock);
+      KeLeaveCriticalRegion();
       return Status;
     }
 
   DPRINT ("RegistryHive %p\n", RegistryHive);
 
-  /* Acquire hive list lock exclusively */
-  KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite (&CmiHiveListLock,
-				  TRUE);
-
 #if 0
   /* Flush hive */
   if (!IsNoFileHive (RegistryHive))
     CmiFlushRegistryHive (RegistryHive);
 #endif
 
-  /* Release hive list lock */
-  ExReleaseResourceLite (&CmiHiveListLock);
-  KeLeaveCriticalRegion();
-
   CmiRemoveRegistryHive (RegistryHive);
 
+  /* Release registry lock */
+  ExReleaseResourceLite (&CmiRegistryLock);
+  KeLeaveCriticalRegion();
+
   DPRINT ("NtUnloadKey() done\n");
 
   return STATUS_SUCCESS;

reactos/ntoskrnl/cm
regfile.c 1.84 -> 1.85
diff -u -r1.84 -r1.85
--- regfile.c	6 Dec 2004 13:46:43 -0000	1.84
+++ regfile.c	12 Dec 2004 22:36:10 -0000	1.85
@@ -1099,19 +1099,16 @@
   CmiCreateDefaultRootKeyCell (RootKeyCell);
   Hive->HiveHeader->RootKeyOffset = (BLOCK_OFFSET)RootKeyCell;
 
-  ExInitializeResourceLite (&Hive->HiveResource);
-
   /* Acquire hive list lock exclusively */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite (&CmiHiveListLock,
-				  TRUE);
+  ExAcquireResourceExclusiveLite (&CmiRegistryLock, TRUE);
 
   /* Add the new hive to the hive list */
   InsertTailList (&CmiHiveListHead,
 		  &Hive->HiveList);
 
   /* Release hive list lock */
-  ExReleaseResourceLite (&CmiHiveListLock);
+  ExReleaseResourceLite (&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   VERIFY_REGISTRY_HIVE (Hive);
@@ -1223,20 +1220,16 @@
       return Status;
     }
 
-
-  ExInitializeResourceLite (&Hive->HiveResource);
-
   /* Acquire hive list lock exclusively */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite (&CmiHiveListLock,
-				  TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   /* Add the new hive to the hive list */
   InsertTailList (&CmiHiveListHead,
 		  &Hive->HiveList);
 
   /* Release hive list lock */
-  ExReleaseResourceLite (&CmiHiveListLock);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   VERIFY_REGISTRY_HIVE (Hive);
@@ -1295,21 +1288,12 @@
       return Status;
     }
 
-  ExInitializeResourceLite (&Hive->HiveResource);
-
   /* Add the new hive to the hive list */
-  KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite (&CmiHiveListLock,
-				  TRUE);
   InsertTailList (&CmiHiveListHead,
 		  &Hive->HiveList);
-  ExReleaseResourceLite (&CmiHiveListLock);
-  KeLeaveCriticalRegion();
-
 
   VERIFY_REGISTRY_HIVE(Hive);
 
-
   Status = CmiConnectHive (KeyObjectAttributes,
 			   Hive);
   if (!NT_SUCCESS(Status))
@@ -1330,18 +1314,9 @@
   if (RegistryHive->Flags & HIVE_POINTER)
     return STATUS_UNSUCCESSFUL;
 
-  /* Acquire hive list lock exclusively */
-  KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite (&CmiHiveListLock,
-				  TRUE);
-
   /* Remove hive from hive list */
   RemoveEntryList (&RegistryHive->HiveList);
 
-  /* Release hive list lock */
-  ExReleaseResourceLite (&CmiHiveListLock);
-  KeLeaveCriticalRegion();
-
   /* Release file names */
   RtlFreeUnicodeString (&RegistryHive->HiveFileName);
   RtlFreeUnicodeString (&RegistryHive->LogFileName);
@@ -1353,9 +1328,6 @@
   ExFreePool (RegistryHive->FreeList);
   ExFreePool (RegistryHive->FreeListOffset);
 
-  /* Release hive resource */
-  ExDeleteResource (&RegistryHive->HiveResource);
-
   /* Release bins and bin list */
   CmiFreeHiveBins (RegistryHive);
   ExFreePool (RegistryHive->BlockList);

reactos/ntoskrnl/cm
registry.c 1.128 -> 1.129
diff -u -r1.128 -r1.129
--- registry.c	20 Nov 2004 21:14:16 -0000	1.128
+++ registry.c	12 Dec 2004 22:36:10 -0000	1.129
@@ -1,4 +1,4 @@
-/* $Id: registry.c,v 1.128 2004/11/20 21:14:16 navaraf Exp $
+/* $Id: registry.c,v 1.129 2004/12/12 22:36:10 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -24,7 +24,8 @@
 KSPIN_LOCK  CmiKeyListLock;
 
 LIST_ENTRY CmiHiveListHead;
-ERESOURCE CmiHiveListLock;
+
+ERESOURCE CmiRegistryLock;
 
 volatile BOOLEAN CmiHiveSyncEnabled = FALSE;
 volatile BOOLEAN CmiHiveSyncPending = FALSE;
@@ -279,7 +280,9 @@
 
   /* Initialize the hive list */
   InitializeListHead(&CmiHiveListHead);
-  ExInitializeResourceLite(&CmiHiveListLock);
+
+  /* Initialize registry lock */
+  ExInitializeResourceLite(&CmiRegistryLock);
 
   /*  Build volatile registry store  */
   Status = CmiCreateVolatileHive (&CmiVolatileHive);
@@ -1067,7 +1070,7 @@
 
   /* Acquire hive list lock exclusively */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiHiveListLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   Entry = CmiHiveListHead.Flink;
   while (Entry != &CmiHiveListHead)
@@ -1076,22 +1079,15 @@
 
       if (!(IsNoFileHive(Hive) || IsNoSynchHive(Hive)))
 	{
-	  /* Acquire hive resource exclusively */
-	  ExAcquireResourceExclusiveLite(&Hive->HiveResource,
-					 TRUE);
-
 	  /* Flush non-volatile hive */
 	  CmiFlushRegistryHive(Hive);
-
-	  /* Release hive resource */
-	  ExReleaseResourceLite(&Hive->HiveResource);
 	}
 
       Entry = Entry->Flink;
     }
 
   /* Release hive list lock */
-  ExReleaseResourceLite(&CmiHiveListLock);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   DPRINT("CmShutdownRegistry() done\n");
@@ -1110,7 +1106,7 @@
 
   /* Acquire hive list lock exclusively */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiHiveListLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
 
   Entry = CmiHiveListHead.Flink;
   while (Entry != &CmiHiveListHead)
@@ -1119,22 +1115,15 @@
 
       if (!(IsNoFileHive(Hive) || IsNoSynchHive(Hive)))
 	{
-	  /* Acquire hive resource exclusively */
-	  ExAcquireResourceExclusiveLite(&Hive->HiveResource,
-					 TRUE);
-
 	  /* Flush non-volatile hive */
 	  CmiFlushRegistryHive(Hive);
-
-	  /* Release hive resource */
-	  ExReleaseResourceLite(&Hive->HiveResource);
 	}
 
       Entry = Entry->Flink;
     }
 
   /* Release hive list lock */
-  ExReleaseResourceLite(&CmiHiveListLock);
+  ExReleaseResourceLite(&CmiRegistryLock);
   KeLeaveCriticalRegion();
 
   DPRINT("DeferredContext %x\n", DeferredContext);
CVSspam 0.2.8