mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 09:50:02 +00:00
- Replace hive locks and hive list lock by a global lock to make the registry thread-safe.
svn path=/trunk/; revision=12062
This commit is contained in:
parent
50a975cc08
commit
68f22d804d
5 changed files with 113 additions and 126 deletions
|
@ -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 @@ typedef struct _VALUE_CELL
|
|||
#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 @@ typedef struct _REGISTRY_HIVE
|
|||
ULONG FreeListMax;
|
||||
PCELL_HEADER *FreeList;
|
||||
BLOCK_OFFSET *FreeListOffset;
|
||||
ERESOURCE HiveResource;
|
||||
|
||||
PSECURITY_CELL RootSecurityCell;
|
||||
|
||||
PULONG BitmapBuffer;
|
||||
RTL_BITMAP DirtyBitMap;
|
||||
|
@ -354,7 +369,8 @@ extern POBJECT_TYPE CmiKeyType;
|
|||
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 @@ CmiDestroyCell(PREGISTRY_HIVE RegistryHive,
|
|||
PVOID Cell,
|
||||
BLOCK_OFFSET CellOffset);
|
||||
|
||||
PHBIN
|
||||
CmiGetBin (PREGISTRY_HIVE RegistryHive,
|
||||
BLOCK_OFFSET CellOffset);
|
||||
|
||||
PVOID
|
||||
CmiGetCell (PREGISTRY_HIVE RegistryHive,
|
||||
BLOCK_OFFSET CellOffset,
|
||||
|
|
|
@ -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 @@ CmImportBinaryHive (PCHAR ChunkBase,
|
|||
}
|
||||
}
|
||||
|
||||
/* 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 @@ CmImportSystemHive(PCHAR ChunkBase,
|
|||
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 @@ CmImportHardwareHive(PCHAR ChunkBase,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
|
||||
/* 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 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
{
|
||||
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 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
@ -240,23 +240,24 @@ NtDeleteKey(IN HANDLE KeyHandle)
|
|||
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 @@ NtDeleteKey(IN HANDLE KeyHandle)
|
|||
}
|
||||
|
||||
/* 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 @@ NtDeleteKey(IN HANDLE KeyHandle)
|
|||
* have been released.
|
||||
*/
|
||||
|
||||
return(Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
@ -339,7 +341,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -352,7 +354,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
/* 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 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
|
||||
if (i >= KeyObject->NumberOfSubKeys)
|
||||
{
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
DPRINT("No more non-volatile entries\n");
|
||||
|
@ -396,7 +398,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
{
|
||||
if (KeyCell->HashTableOffset == (BLOCK_OFFSET)-1)
|
||||
{
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
return STATUS_NO_MORE_ENTRIES;
|
||||
|
@ -406,7 +408,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
if (HashTableBlock == NULL)
|
||||
{
|
||||
DPRINT("CmiGetBlock() failed\n");
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
|
@ -419,7 +421,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
|
||||
if (SubKeyCell == NULL)
|
||||
{
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
DPRINT("No more entries\n");
|
||||
|
@ -634,7 +636,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
break;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
||||
|
@ -686,7 +688,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -702,7 +704,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
return Status;
|
||||
|
@ -883,7 +885,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
|
|||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
||||
|
@ -918,8 +920,7 @@ NtFlushKey(IN HANDLE KeyHandle)
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&RegistryHive->HiveResource,
|
||||
TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
if (IsNoFileHive(RegistryHive))
|
||||
{
|
||||
|
@ -931,7 +932,7 @@ NtFlushKey(IN HANDLE KeyHandle)
|
|||
Status = CmiFlushRegistryHive(RegistryHive);
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
@ -1039,7 +1040,7 @@ NtQueryKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -1192,7 +1193,7 @@ NtQueryKey(IN HANDLE KeyHandle,
|
|||
break;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
||||
|
@ -1238,7 +1239,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -1432,7 +1433,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
}
|
||||
|
||||
ByeBye:;
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
||||
|
@ -1478,7 +1479,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock exclucively */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&KeyObject->RegistryHive->HiveResource, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -1505,7 +1506,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
{
|
||||
DPRINT("Cannot add value. Status 0x%X\n", Status);
|
||||
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
return Status;
|
||||
|
@ -1570,7 +1571,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
{
|
||||
DPRINT("CmiAllocateBlock() failed (Status %lx)\n", Status);
|
||||
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
||||
|
@ -1595,7 +1596,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
NtQuerySystemTime (&KeyCell->LastWriteTime);
|
||||
CmiMarkBlockDirty (RegistryHive, KeyObject->KeyCellOffset);
|
||||
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
||||
|
@ -1628,7 +1629,7 @@ NtDeleteValueKey (IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&KeyObject->RegistryHive->HiveResource, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -1641,7 +1642,7 @@ NtDeleteValueKey (IN HANDLE KeyHandle,
|
|||
CmiMarkBlockDirty (KeyObject->RegistryHive, KeyObject->KeyCellOffset);
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite (&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ObDereferenceObject (KeyObject);
|
||||
|
@ -1765,6 +1766,10 @@ NtLoadKey2 (IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
|
||||
DPRINT ("Full name: '%wZ'\n", NamePointer);
|
||||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
Status = CmiLoadHive (KeyObjectAttributes,
|
||||
NamePointer,
|
||||
Flags);
|
||||
|
@ -1773,6 +1778,10 @@ NtLoadKey2 (IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
DPRINT1 ("CmiLoadHive() failed (Status %lx)\n", Status);
|
||||
}
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
if (Buffer != NULL)
|
||||
ExFreePool (Buffer);
|
||||
|
||||
|
@ -1830,7 +1839,7 @@ NtQueryMultipleValueKey (IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&KeyObject->RegistryHive->HiveResource, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -1904,7 +1913,7 @@ NtQueryMultipleValueKey (IN HANDLE KeyHandle,
|
|||
*ReturnLength = BufferLength;
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
@ -1964,14 +1973,13 @@ NtSaveKey (IN HANDLE KeyHandle,
|
|||
|
||||
/* 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 @@ NtSaveKey (IN HANDLE KeyHandle,
|
|||
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 @@ NtSaveKey (IN HANDLE KeyHandle,
|
|||
{
|
||||
DPRINT1 ("CmiCopyKey() failed (Status %lx)\n", Status);
|
||||
CmiRemoveRegistryHive (TempHive);
|
||||
ExReleaseResourceLite (&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject (KeyObject);
|
||||
return(Status);
|
||||
|
@ -2011,7 +2019,7 @@ NtSaveKey (IN HANDLE KeyHandle,
|
|||
CmiRemoveRegistryHive (TempHive);
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ObDereferenceObject (KeyObject);
|
||||
|
@ -2067,7 +2075,7 @@ NtSetInformationKey (IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite (&KeyObject->RegistryHive->HiveResource, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -2078,7 +2086,7 @@ NtSetInformationKey (IN HANDLE KeyHandle,
|
|||
KeyObject->KeyCellOffset);
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite (&KeyObject->RegistryHive->HiveResource);
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ObDereferenceObject (KeyObject);
|
||||
|
@ -2109,33 +2117,34 @@ NtUnloadKey (IN POBJECT_ATTRIBUTES KeyObjectAttributes)
|
|||
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;
|
||||
|
|
|
@ -1099,19 +1099,16 @@ CmiCreateVolatileHive(PREGISTRY_HIVE *RegistryHive)
|
|||
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 @@ CmiCreateTempHive(PREGISTRY_HIVE *RegistryHive)
|
|||
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 @@ CmiLoadHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
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 @@ CmiRemoveRegistryHive(PREGISTRY_HIVE RegistryHive)
|
|||
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 @@ CmiRemoveRegistryHive(PREGISTRY_HIVE RegistryHive)
|
|||
ExFreePool (RegistryHive->FreeList);
|
||||
ExFreePool (RegistryHive->FreeListOffset);
|
||||
|
||||
/* Release hive resource */
|
||||
ExDeleteResource (&RegistryHive->HiveResource);
|
||||
|
||||
/* Release bins and bin list */
|
||||
CmiFreeHiveBins (RegistryHive);
|
||||
ExFreePool (RegistryHive->BlockList);
|
||||
|
|
|
@ -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 @@ PREGISTRY_HIVE CmiVolatileHive = NULL;
|
|||
KSPIN_LOCK CmiKeyListLock;
|
||||
|
||||
LIST_ENTRY CmiHiveListHead;
|
||||
ERESOURCE CmiHiveListLock;
|
||||
|
||||
ERESOURCE CmiRegistryLock;
|
||||
|
||||
volatile BOOLEAN CmiHiveSyncEnabled = FALSE;
|
||||
volatile BOOLEAN CmiHiveSyncPending = FALSE;
|
||||
|
@ -279,7 +280,9 @@ CmInitializeRegistry(VOID)
|
|||
|
||||
/* Initialize the hive list */
|
||||
InitializeListHead(&CmiHiveListHead);
|
||||
ExInitializeResourceLite(&CmiHiveListLock);
|
||||
|
||||
/* Initialize registry lock */
|
||||
ExInitializeResourceLite(&CmiRegistryLock);
|
||||
|
||||
/* Build volatile registry store */
|
||||
Status = CmiCreateVolatileHive (&CmiVolatileHive);
|
||||
|
@ -1067,7 +1070,7 @@ CmShutdownRegistry(VOID)
|
|||
|
||||
/* Acquire hive list lock exclusively */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiHiveListLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
Entry = CmiHiveListHead.Flink;
|
||||
while (Entry != &CmiHiveListHead)
|
||||
|
@ -1076,22 +1079,15 @@ CmShutdownRegistry(VOID)
|
|||
|
||||
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 @@ CmiHiveSyncRoutine(PVOID DeferredContext)
|
|||
|
||||
/* Acquire hive list lock exclusively */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiHiveListLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
|
||||
Entry = CmiHiveListHead.Flink;
|
||||
while (Entry != &CmiHiveListHead)
|
||||
|
@ -1119,22 +1115,15 @@ CmiHiveSyncRoutine(PVOID DeferredContext)
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue