reactos/ntoskrnl/cm
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
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);