* Removed CmiLockBlock() and CmiReleaseBlock().

* Added new hive flags to distinguish between volatile/non-volatile and pointer/offset hives.

svn path=/trunk/; revision=4525
This commit is contained in:
Eric Kohl 2003-04-12 15:09:57 +00:00
parent 01aebbdd9d
commit 4aa19f2392
5 changed files with 73 additions and 177 deletions

View file

@ -263,10 +263,17 @@ typedef struct _REGISTRY_HIVE
} REGISTRY_HIVE, *PREGISTRY_HIVE; } REGISTRY_HIVE, *PREGISTRY_HIVE;
/* REGISTRY_HIVE.Flags constants */ /* REGISTRY_HIVE.Flags constants */
/* When set, the hive is volatile. It will not be sync'ed to disk. */
#define HIVE_VOLATILE 0x00000001 #define HIVE_VOLATILE 0x00000001
/* When set, the hive uses pointers instead of offsets. */
#define HIVE_POINTER 0x00000002
/* When set, the hive is temporary. It will not be sync'ed to disk. */
#define HIVE_TEMPORARY 0x00000004
#define IsVolatileHive(Hive)(Hive->Flags & HIVE_VOLATILE) #define IsVolatileHive(Hive)(Hive->Flags & HIVE_VOLATILE)
#define IsPermanentHive(Hive)(!(Hive->Flags & HIVE_VOLATILE)) #define IsPointerHive(Hive)(Hive->Flags & HIVE_POINTER)
#define IsTemporaryHive(Hive)(Hive->Flags & HIVE_TEMPORARY)
#define IsFreeCell(Cell)(Cell->CellSize >= 0) #define IsFreeCell(Cell)(Cell->CellSize >= 0)
#define IsUsedCell(Cell)(Cell->CellSize < 0) #define IsUsedCell(Cell)(Cell->CellSize < 0)
@ -523,14 +530,6 @@ CmiGetBlock(PREGISTRY_HIVE RegistryHive,
BLOCK_OFFSET BlockOffset, BLOCK_OFFSET BlockOffset,
OUT PHBIN * ppBin); OUT PHBIN * ppBin);
VOID
CmiLockBlock(PREGISTRY_HIVE RegistryHive,
PVOID Block);
VOID
CmiReleaseBlock(PREGISTRY_HIVE RegistryHive,
PVOID Block);
VOID VOID
CmiMarkBlockDirty(PREGISTRY_HIVE RegistryHive, CmiMarkBlockDirty(PREGISTRY_HIVE RegistryHive,
BLOCK_OFFSET BlockOffset); BLOCK_OFFSET BlockOffset);

View file

@ -8,9 +8,6 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#ifdef WIN32_REGDBG
#include "cm_win32.h"
#else
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <roscfg.h> #include <roscfg.h>
#include <internal/ob.h> #include <internal/ob.h>
@ -23,7 +20,6 @@
#include <internal/debug.h> #include <internal/debug.h>
#include "cm.h" #include "cm.h"
#endif
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
@ -408,7 +404,6 @@ NtEnumerateKey(
wcsncpy(NodeInformation->Name + SubKeyCell->NameSize , wcsncpy(NodeInformation->Name + SubKeyCell->NameSize ,
(PWCHAR) pClassData->Data, (PWCHAR) pClassData->Data,
SubKeyCell->ClassSize); SubKeyCell->ClassSize);
CmiReleaseBlock(RegistryHive, pClassData);
} }
} }
break; break;
@ -449,12 +444,10 @@ NtEnumerateKey(
wcsncpy(FullInformation->Class, wcsncpy(FullInformation->Class,
(PWCHAR) pClassData->Data, (PWCHAR) pClassData->Data,
SubKeyCell->ClassSize); SubKeyCell->ClassSize);
CmiReleaseBlock(RegistryHive, pClassData);
} }
} }
break; break;
} }
CmiReleaseBlock(RegistryHive, SubKeyCell);
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource); ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
ObDereferenceObject(KeyObject); ObDereferenceObject(KeyObject);
@ -592,7 +585,6 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
RtlCopyMemory(ValuePartialInformation->Data, RtlCopyMemory(ValuePartialInformation->Data,
DataCell->Data, DataCell->Data,
ValueCell->DataSize & LONG_MAX); ValueCell->DataSize & LONG_MAX);
CmiReleaseBlock(RegistryHive, DataCell);
} }
else else
{ {
@ -659,7 +651,6 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
+ ValueFullInformation->DataOffset, + ValueFullInformation->DataOffset,
DataCell->Data, DataCell->Data,
ValueCell->DataSize & LONG_MAX); ValueCell->DataSize & LONG_MAX);
CmiReleaseBlock(RegistryHive, DataCell);
} }
else else
{ {
@ -713,14 +704,14 @@ NtFlushKey(IN HANDLE KeyHandle)
ExAcquireResourceExclusiveLite(&RegistryHive->HiveResource, ExAcquireResourceExclusiveLite(&RegistryHive->HiveResource,
TRUE); TRUE);
if (IsPermanentHive(RegistryHive)) if (IsVolatileHive(RegistryHive))
{ {
/* Flush non-volatile hive */ Status = STATUS_SUCCESS;
Status = CmiFlushRegistryHive(RegistryHive);
} }
else else
{ {
Status = STATUS_SUCCESS; /* Flush non-volatile hive */
Status = CmiFlushRegistryHive(RegistryHive);
} }
ExReleaseResourceLite(&RegistryHive->HiveResource); ExReleaseResourceLite(&RegistryHive->HiveResource);
@ -890,7 +881,6 @@ NtQueryKey(IN HANDLE KeyHandle,
wcsncpy(NodeInformation->Name + KeyObject->NameSize * sizeof(WCHAR), wcsncpy(NodeInformation->Name + KeyObject->NameSize * sizeof(WCHAR),
(PWCHAR)pClassData->Data, (PWCHAR)pClassData->Data,
KeyCell->ClassSize); KeyCell->ClassSize);
CmiReleaseBlock(RegistryHive, pClassData);
} }
*ResultLength = sizeof(KEY_NODE_INFORMATION) *ResultLength = sizeof(KEY_NODE_INFORMATION)
+ KeyObject->NameSize * sizeof(WCHAR) + KeyObject->NameSize * sizeof(WCHAR)
@ -931,7 +921,6 @@ NtQueryKey(IN HANDLE KeyHandle,
wcsncpy(FullInformation->Class, wcsncpy(FullInformation->Class,
(PWCHAR)pClassData->Data, (PWCHAR)pClassData->Data,
KeyCell->ClassSize); KeyCell->ClassSize);
CmiReleaseBlock(RegistryHive, pClassData);
} }
*ResultLength = sizeof(KEY_FULL_INFORMATION) + KeyCell->ClassSize; *ResultLength = sizeof(KEY_FULL_INFORMATION) + KeyCell->ClassSize;
} }
@ -1068,7 +1057,6 @@ NtQueryValueKey(IN HANDLE KeyHandle,
RtlCopyMemory(ValuePartialInformation->Data, RtlCopyMemory(ValuePartialInformation->Data,
DataCell->Data, DataCell->Data,
ValueCell->DataSize & LONG_MAX); ValueCell->DataSize & LONG_MAX);
CmiReleaseBlock(RegistryHive, DataCell);
} }
else else
{ {
@ -1133,7 +1121,6 @@ NtQueryValueKey(IN HANDLE KeyHandle,
+ ValueFullInformation->DataOffset, + ValueFullInformation->DataOffset,
DataCell->Data, DataCell->Data,
ValueCell->DataSize & LONG_MAX); ValueCell->DataSize & LONG_MAX);
CmiReleaseBlock(RegistryHive, DataCell);
} }
else else
{ {
@ -1267,12 +1254,11 @@ NtSetValueKey(IN HANDLE KeyHandle,
RtlCopyMemory(DataCell->Data, Data, DataSize); RtlCopyMemory(DataCell->Data, Data, DataSize);
ValueCell->DataSize = DataSize; ValueCell->DataSize = DataSize;
ValueCell->DataType = Type; ValueCell->DataType = Type;
CmiReleaseBlock(RegistryHive, DataCell);
/* Update time of heap */ /* Update time of heap */
if (IsPermanentHive(RegistryHive)) if (!IsVolatileHive(RegistryHive))
{ {
ZwQuerySystemTime((PTIME) &pBin->DateModified); NtQuerySystemTime((PTIME) &pBin->DateModified);
} }
CmiMarkBlockDirty(RegistryHive, ValueCell->DataOffset); CmiMarkBlockDirty(RegistryHive, ValueCell->DataOffset);
} }
@ -1312,7 +1298,6 @@ NtSetValueKey(IN HANDLE KeyHandle,
RtlCopyMemory(&NewDataCell->Data[0], Data, DataSize); RtlCopyMemory(&NewDataCell->Data[0], Data, DataSize);
ValueCell->DataSize = DataSize; ValueCell->DataSize = DataSize;
ValueCell->DataType = Type; ValueCell->DataType = Type;
CmiReleaseBlock(RegistryHive, NewDataCell);
ValueCell->DataOffset = NewOffset; ValueCell->DataOffset = NewOffset;
CmiMarkBlockDirty(RegistryHive, ValueCell->DataOffset); CmiMarkBlockDirty(RegistryHive, ValueCell->DataOffset);
} }
@ -1326,9 +1311,9 @@ NtSetValueKey(IN HANDLE KeyHandle,
} }
/* Update time of heap */ /* Update time of heap */
if (IsPermanentHive(RegistryHive) && CmiGetBlock(RegistryHive, VBOffset, &pBin)) if (!IsVolatileHive(RegistryHive) && CmiGetBlock(RegistryHive, VBOffset, &pBin))
{ {
ZwQuerySystemTime((PTIME) &pBin->DateModified); NtQuerySystemTime((PTIME) &pBin->DateModified);
} }
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource); ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
@ -1502,9 +1487,12 @@ NtQueryMultipleValueKey(IN HANDLE KeyHandle,
if (ValueCell->DataSize > 0) if (ValueCell->DataSize > 0)
{ {
DataCell = CmiGetBlock(RegistryHive, ValueCell->DataOffset, NULL); DataCell = CmiGetBlock(RegistryHive,
RtlCopyMemory(DataPtr, DataCell->Data, ValueCell->DataSize & LONG_MAX); ValueCell->DataOffset,
CmiReleaseBlock(RegistryHive, DataCell); NULL);
RtlCopyMemory(DataPtr,
DataCell->Data,
ValueCell->DataSize & LONG_MAX);
} }
else else
{ {

View file

@ -1036,7 +1036,7 @@ CmiInitVolatileRegistryHive(PREGISTRY_HIVE RegistryHive)
{ {
PKEY_CELL RootKeyCell; PKEY_CELL RootKeyCell;
RegistryHive->Flags |= HIVE_VOLATILE; RegistryHive->Flags |= (HIVE_VOLATILE | HIVE_POINTER);
CmiCreateDefaultHiveHeader(RegistryHive->HiveHeader); CmiCreateDefaultHiveHeader(RegistryHive->HiveHeader);
@ -1829,12 +1829,9 @@ CmiGetMaxNameLength(PREGISTRY_HIVE RegistryHive,
{ {
MaxName = CurSubKeyCell->NameSize; MaxName = CurSubKeyCell->NameSize;
} }
CmiReleaseBlock(RegistryHive, CurSubKeyCell);
} }
} }
CmiReleaseBlock(RegistryHive, HashBlock);
return MaxName; return MaxName;
} }
@ -1868,12 +1865,9 @@ CmiGetMaxClassLength(PREGISTRY_HIVE RegistryHive,
{ {
MaxClass = CurSubKeyCell->ClassSize; MaxClass = CurSubKeyCell->ClassSize;
} }
CmiReleaseBlock(RegistryHive, CurSubKeyCell);
} }
} }
CmiReleaseBlock(RegistryHive, HashBlock);
return MaxClass; return MaxClass;
} }
@ -1908,18 +1902,15 @@ CmiGetMaxValueNameLength(PREGISTRY_HIVE RegistryHive,
{ {
MaxValueName = CurValueCell->NameSize; MaxValueName = CurValueCell->NameSize;
} }
CmiReleaseBlock(RegistryHive, CurValueCell);
} }
CmiReleaseBlock(RegistryHive, ValueListCell);
return MaxValueName; return MaxValueName;
} }
ULONG ULONG
CmiGetMaxValueDataLength(PREGISTRY_HIVE RegistryHive, CmiGetMaxValueDataLength(PREGISTRY_HIVE RegistryHive,
PKEY_CELL KeyCell) PKEY_CELL KeyCell)
{ {
PVALUE_LIST_CELL ValueListCell; PVALUE_LIST_CELL ValueListCell;
PVALUE_CELL CurValueCell; PVALUE_CELL CurValueCell;
@ -1944,11 +1935,8 @@ CmiGetMaxValueDataLength(PREGISTRY_HIVE RegistryHive,
{ {
MaxValueData = CurValueCell->DataSize & LONG_MAX; MaxValueData = CurValueCell->DataSize & LONG_MAX;
} }
CmiReleaseBlock(RegistryHive, CurValueCell);
} }
CmiReleaseBlock(RegistryHive, ValueListCell);
return MaxValueData; return MaxValueData;
} }
@ -1973,10 +1961,10 @@ CmiScanForSubKey(IN PREGISTRY_HIVE RegistryHive,
assert(RegistryHive); assert(RegistryHive);
*SubKeyCell = NULL;
KeyLength = strlen(KeyName); KeyLength = strlen(KeyName);
HashBlock = CmiGetBlock(RegistryHive, KeyCell->HashTableOffset, NULL); HashBlock = CmiGetBlock(RegistryHive, KeyCell->HashTableOffset, NULL);
*SubKeyCell = NULL;
if (HashBlock == NULL) if (HashBlock == NULL)
{ {
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -2001,10 +1989,6 @@ CmiScanForSubKey(IN PREGISTRY_HIVE RegistryHive,
*BlockOffset = HashBlock->Table[i].KeyOffset; *BlockOffset = HashBlock->Table[i].KeyOffset;
break; break;
} }
else
{
CmiReleaseBlock(RegistryHive, CurSubKeyCell);
}
} }
} }
else else
@ -2022,16 +2006,10 @@ CmiScanForSubKey(IN PREGISTRY_HIVE RegistryHive,
*BlockOffset = HashBlock->Table[i].KeyOffset; *BlockOffset = HashBlock->Table[i].KeyOffset;
break; break;
} }
else
{
CmiReleaseBlock(RegistryHive, CurSubKeyCell);
}
} }
} }
} }
CmiReleaseBlock(RegistryHive, HashBlock);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -2119,8 +2097,8 @@ CmiAddSubKey(PREGISTRY_HIVE RegistryHive,
SubKey->KeyCell = NewKeyCell; SubKey->KeyCell = NewKeyCell;
SubKey->BlockOffset = NKBOffset; SubKey->BlockOffset = NKBOffset;
/* Don't modify hash table if key is volatile and parent is not */ /* Don't modify hash table if key is located in a pointer-based hive and parent key is not */
if (IsVolatileHive(RegistryHive) && (!IsVolatileHive(Parent->RegistryHive))) if (IsPointerHive(RegistryHive) && (!IsPointerHive(Parent->RegistryHive)))
{ {
return(Status); return(Status);
} }
@ -2327,10 +2305,9 @@ CmiScanKeyForValue(IN PREGISTRY_HIVE RegistryHive,
PVALUE_CELL CurValueCell; PVALUE_CELL CurValueCell;
ULONG i; ULONG i;
ValueListCell = CmiGetBlock(RegistryHive, KeyCell->ValuesOffset, NULL);
*ValueCell = NULL; *ValueCell = NULL;
ValueListCell = CmiGetBlock(RegistryHive, KeyCell->ValuesOffset, NULL);
if (ValueListCell == NULL) if (ValueListCell == NULL)
{ {
DPRINT("ValueListCell is NULL\n"); DPRINT("ValueListCell is NULL\n");
@ -2357,11 +2334,8 @@ CmiScanKeyForValue(IN PREGISTRY_HIVE RegistryHive,
//DPRINT("Found value %s\n", ValueName); //DPRINT("Found value %s\n", ValueName);
break; break;
} }
CmiReleaseBlock(RegistryHive, CurValueCell);
} }
CmiReleaseBlock(RegistryHive, ValueListCell);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -2375,10 +2349,9 @@ CmiGetValueFromKeyByIndex(IN PREGISTRY_HIVE RegistryHive,
PVALUE_LIST_CELL ValueListCell; PVALUE_LIST_CELL ValueListCell;
PVALUE_CELL CurValueCell; PVALUE_CELL CurValueCell;
ValueListCell = CmiGetBlock(RegistryHive, KeyCell->ValuesOffset, NULL);
*ValueCell = NULL; *ValueCell = NULL;
ValueListCell = CmiGetBlock(RegistryHive, KeyCell->ValuesOffset, NULL);
if (ValueListCell == NULL) if (ValueListCell == NULL)
{ {
return STATUS_NO_MORE_ENTRIES; return STATUS_NO_MORE_ENTRIES;
@ -2392,17 +2365,13 @@ CmiGetValueFromKeyByIndex(IN PREGISTRY_HIVE RegistryHive,
} }
CurValueCell = CmiGetBlock(RegistryHive, CurValueCell = CmiGetBlock(RegistryHive,
ValueListCell->Values[Index], ValueListCell->Values[Index],
NULL); NULL);
if (CurValueCell != NULL) if (CurValueCell != NULL)
{ {
*ValueCell = CurValueCell; *ValueCell = CurValueCell;
} }
CmiReleaseBlock(RegistryHive, CurValueCell);
CmiReleaseBlock(RegistryHive, ValueListCell);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -2421,12 +2390,12 @@ CmiAddValueToKey(IN PREGISTRY_HIVE RegistryHive,
BLOCK_OFFSET VBOffset; BLOCK_OFFSET VBOffset;
NTSTATUS Status; NTSTATUS Status;
*pVBOffset = VBOffset;
Status = CmiAllocateValueCell(RegistryHive, Status = CmiAllocateValueCell(RegistryHive,
&NewValueCell, &NewValueCell,
&VBOffset, &VBOffset,
ValueName); ValueName);
*pVBOffset = VBOffset;
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return Status; return Status;
@ -2478,8 +2447,7 @@ CmiAddValueToKey(IN PREGISTRY_HIVE RegistryHive,
ValueListCell->Values[KeyCell->NumberOfValues] = VBOffset; ValueListCell->Values[KeyCell->NumberOfValues] = VBOffset;
KeyCell->NumberOfValues++; KeyCell->NumberOfValues++;
CmiReleaseBlock(RegistryHive, ValueListCell);
CmiReleaseBlock(RegistryHive, NewValueCell);
*pValueCell = NewValueCell; *pValueCell = NewValueCell;
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -2517,25 +2485,22 @@ CmiDeleteValueFromKey(IN PREGISTRY_HIVE RegistryHive,
{ {
CmiDestroyValueCell(RegistryHive, CurValueCell, ValueListCell->Values[i]); CmiDestroyValueCell(RegistryHive, CurValueCell, ValueListCell->Values[i]);
if ((KeyCell->NumberOfValues - 1) < i) if ((KeyCell->NumberOfValues - 1) < i)
{ {
RtlCopyMemory(&ValueListCell->Values[i], RtlCopyMemory(&ValueListCell->Values[i],
&ValueListCell->Values[i + 1], &ValueListCell->Values[i + 1],
sizeof(BLOCK_OFFSET) * (KeyCell->NumberOfValues - 1 - i)); sizeof(BLOCK_OFFSET) * (KeyCell->NumberOfValues - 1 - i));
} }
else else
{ {
RtlZeroMemory(&ValueListCell->Values[i], sizeof(BLOCK_OFFSET)); RtlZeroMemory(&ValueListCell->Values[i], sizeof(BLOCK_OFFSET));
} }
KeyCell->NumberOfValues -= 1; KeyCell->NumberOfValues -= 1;
break; break;
} }
CmiReleaseBlock(RegistryHive, CurValueCell);
} }
CmiReleaseBlock(RegistryHive, ValueListCell);
if (KeyCell->NumberOfValues == 0) if (KeyCell->NumberOfValues == 0)
{ {
CmiDestroyBlock(RegistryHive, CmiDestroyBlock(RegistryHive,
@ -2600,7 +2565,7 @@ CmiGetKeyFromHashByIndex(PREGISTRY_HIVE RegistryHive,
if (HashBlock == NULL) if (HashBlock == NULL)
return NULL; return NULL;
if (IsVolatileHive(RegistryHive)) if (IsPointerHive(RegistryHive))
{ {
KeyCell = (PKEY_CELL) HashBlock->Table[Index].KeyOffset; KeyCell = (PKEY_CELL) HashBlock->Table[Index].KeyOffset;
} }
@ -2609,7 +2574,6 @@ CmiGetKeyFromHashByIndex(PREGISTRY_HIVE RegistryHive,
KeyOffset = HashBlock->Table[Index].KeyOffset; KeyOffset = HashBlock->Table[Index].KeyOffset;
KeyCell = CmiGetBlock(RegistryHive, KeyOffset, NULL); KeyCell = CmiGetBlock(RegistryHive, KeyOffset, NULL);
} }
CmiLockBlock(RegistryHive, KeyCell);
return KeyCell; return KeyCell;
} }
@ -2738,17 +2702,17 @@ CmiDestroyValueCell(PREGISTRY_HIVE RegistryHive,
} }
/* Update time of heap */ /* Update time of heap */
if (IsPermanentHive(RegistryHive)) if (!IsVolatileHive(RegistryHive))
ZwQuerySystemTime((PTIME) &pBin->DateModified); NtQuerySystemTime((PTIME) &pBin->DateModified);
} }
/* Destroy the value cell */ /* Destroy the value cell */
Status = CmiDestroyBlock(RegistryHive, ValueCell, VBOffset); Status = CmiDestroyBlock(RegistryHive, ValueCell, VBOffset);
/* Update time of heap */ /* Update time of heap */
if (IsPermanentHive(RegistryHive) && CmiGetBlock(RegistryHive, VBOffset, &pBin)) if (!IsVolatileHive(RegistryHive) && CmiGetBlock(RegistryHive, VBOffset, &pBin))
{ {
ZwQuerySystemTime((PTIME) &pBin->DateModified); NtQuerySystemTime((PTIME) &pBin->DateModified);
} }
return Status; return Status;
@ -2833,8 +2797,6 @@ CmiAddBin(PREGISTRY_HIVE RegistryHive,
if (NewBlockOffset) if (NewBlockOffset)
*NewBlockOffset = tmpBin->BlockOffset + REG_HBIN_DATA_OFFSET; *NewBlockOffset = tmpBin->BlockOffset + REG_HBIN_DATA_OFFSET;
/* FIXME: set first dword to block_offset of another free bloc */
/* Mark new bin dirty */ /* Mark new bin dirty */
CmiMarkBinDirty(RegistryHive, CmiMarkBinDirty(RegistryHive,
tmpBin->BlockOffset); tmpBin->BlockOffset);
@ -2859,7 +2821,7 @@ CmiAllocateBlock(PREGISTRY_HIVE RegistryHive,
BlockSize = (BlockSize + sizeof(DWORD) + 15) & 0xfffffff0; BlockSize = (BlockSize + sizeof(DWORD) + 15) & 0xfffffff0;
/* Handle volatile hives first */ /* Handle volatile hives first */
if (IsVolatileHive(RegistryHive)) if (IsPointerHive(RegistryHive))
{ {
NewBlock = ExAllocatePool(NonPagedPool, BlockSize); NewBlock = ExAllocatePool(NonPagedPool, BlockSize);
@ -2871,7 +2833,6 @@ CmiAllocateBlock(PREGISTRY_HIVE RegistryHive,
{ {
RtlZeroMemory(NewBlock, BlockSize); RtlZeroMemory(NewBlock, BlockSize);
NewBlock->CellSize = BlockSize; NewBlock->CellSize = BlockSize;
CmiLockBlock(RegistryHive, NewBlock);
*Block = NewBlock; *Block = NewBlock;
if (pBlockOffset) if (pBlockOffset)
*pBlockOffset = (BLOCK_OFFSET) NewBlock; *pBlockOffset = (BLOCK_OFFSET) NewBlock;
@ -2898,7 +2859,7 @@ CmiAllocateBlock(PREGISTRY_HIVE RegistryHive,
if (Temp) if (Temp)
{ {
ZwQuerySystemTime((PTIME) &pBin->DateModified); NtQuerySystemTime((PTIME) &pBin->DateModified);
CmiMarkBlockDirty(RegistryHive, RegistryHive->FreeListOffset[i]); CmiMarkBlockDirty(RegistryHive, RegistryHive->FreeListOffset[i]);
} }
@ -2948,7 +2909,6 @@ CmiAllocateBlock(PREGISTRY_HIVE RegistryHive,
RtlZeroMemory(*Block, BlockSize); RtlZeroMemory(*Block, BlockSize);
((PCELL_HEADER) (*Block))->CellSize = -BlockSize; ((PCELL_HEADER) (*Block))->CellSize = -BlockSize;
CmiLockBlock(RegistryHive, *Block);
} }
} }
@ -2958,17 +2918,16 @@ CmiAllocateBlock(PREGISTRY_HIVE RegistryHive,
NTSTATUS NTSTATUS
CmiDestroyBlock(PREGISTRY_HIVE RegistryHive, CmiDestroyBlock(PREGISTRY_HIVE RegistryHive,
PVOID Block, PVOID Block,
BLOCK_OFFSET Offset) BLOCK_OFFSET Offset)
{ {
NTSTATUS Status; NTSTATUS Status;
PHBIN pBin; PHBIN pBin;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
if (IsVolatileHive(RegistryHive)) if (IsPointerHive(RegistryHive))
{ {
CmiReleaseBlock(RegistryHive, Block);
ExFreePool(Block); ExFreePool(Block);
} }
else else
@ -2982,18 +2941,14 @@ CmiDestroyBlock(PREGISTRY_HIVE RegistryHive,
RtlZeroMemory(((PVOID)pFree) + sizeof(ULONG), RtlZeroMemory(((PVOID)pFree) + sizeof(ULONG),
pFree->CellSize - sizeof(ULONG)); pFree->CellSize - sizeof(ULONG));
/* add block to the list of free blocks */ /* Add block to the list of free blocks */
CmiAddFree(RegistryHive, Block, Offset, TRUE); CmiAddFree(RegistryHive, Block, Offset, TRUE);
CmiReleaseBlock(RegistryHive, Block);
/* Update time of heap */ /* Update time of heap */
if (IsPermanentHive(RegistryHive) && CmiGetBlock(RegistryHive, Offset,&pBin)) if (!IsVolatileHive(RegistryHive) && CmiGetBlock(RegistryHive, Offset,&pBin))
ZwQuerySystemTime((PTIME) &pBin->DateModified); NtQuerySystemTime((PTIME) &pBin->DateModified);
CmiMarkBlockDirty(RegistryHive, Offset); CmiMarkBlockDirty(RegistryHive, Offset);
/* FIXME: Set first dword to block_offset of another free block ? */
/* FIXME: Concatenate with previous and next block if free */
} }
return Status; return Status;
@ -3212,7 +3167,7 @@ CmiGetBlock(PREGISTRY_HIVE RegistryHive,
if ((BlockOffset == 0) || (BlockOffset == (ULONG_PTR) -1)) if ((BlockOffset == 0) || (BlockOffset == (ULONG_PTR) -1))
return NULL; return NULL;
if (IsVolatileHive(RegistryHive)) if (IsPointerHive(RegistryHive))
{ {
return (PVOID) BlockOffset; return (PVOID) BlockOffset;
} }
@ -3228,28 +3183,6 @@ CmiGetBlock(PREGISTRY_HIVE RegistryHive,
} }
VOID
CmiLockBlock(PREGISTRY_HIVE RegistryHive,
PVOID Block)
{
if (IsPermanentHive(RegistryHive))
{
/* FIXME: Implement */
}
}
VOID
CmiReleaseBlock(PREGISTRY_HIVE RegistryHive,
PVOID Block)
{
if (IsPermanentHive(RegistryHive))
{
/* FIXME: Implement */
}
}
VOID VOID
CmiMarkBlockDirty(PREGISTRY_HIVE RegistryHive, CmiMarkBlockDirty(PREGISTRY_HIVE RegistryHive,
BLOCK_OFFSET BlockOffset) BLOCK_OFFSET BlockOffset)
@ -3260,7 +3193,7 @@ CmiMarkBlockDirty(PREGISTRY_HIVE RegistryHive,
ULONG BlockCount; ULONG BlockCount;
if (IsVolatileHive(RegistryHive)) if (IsVolatileHive(RegistryHive))
return; return;
DPRINT("CmiMarkBlockDirty(Offset 0x%lx)\n", (ULONG)BlockOffset); DPRINT("CmiMarkBlockDirty(Offset 0x%lx)\n", (ULONG)BlockOffset);
@ -3298,7 +3231,7 @@ CmiMarkBinDirty(PREGISTRY_HIVE RegistryHive,
PHBIN Bin; PHBIN Bin;
if (IsVolatileHive(RegistryHive)) if (IsVolatileHive(RegistryHive))
return; return;
DPRINT("CmiMarkBinDirty(Offset 0x%lx)\n", (ULONG)BinOffset); DPRINT("CmiMarkBinDirty(Offset 0x%lx)\n", (ULONG)BinOffset);

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.91 2003/04/04 21:52:25 hbirr Exp $ /* $Id: registry.c,v 1.92 2003/04/12 15:09:57 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -1061,7 +1061,7 @@ CmShutdownRegistry(VOID)
{ {
Hive = CONTAINING_RECORD(Entry, REGISTRY_HIVE, HiveList); Hive = CONTAINING_RECORD(Entry, REGISTRY_HIVE, HiveList);
if (IsPermanentHive(Hive)) if (!IsVolatileHive(Hive))
{ {
/* Acquire hive resource exclusively */ /* Acquire hive resource exclusively */
ExAcquireResourceExclusiveLite(&Hive->HiveResource, ExAcquireResourceExclusiveLite(&Hive->HiveResource,
@ -1102,7 +1102,7 @@ CmiHiveSyncRoutine(PVOID DeferredContext)
{ {
Hive = CONTAINING_RECORD(Entry, REGISTRY_HIVE, HiveList); Hive = CONTAINING_RECORD(Entry, REGISTRY_HIVE, HiveList);
if (IsPermanentHive(Hive)) if (!IsVolatileHive(Hive))
{ {
/* Acquire hive resource exclusively */ /* Acquire hive resource exclusively */
ExAcquireResourceExclusiveLite(&Hive->HiveResource, ExAcquireResourceExclusiveLite(&Hive->HiveResource,

View file

@ -6,9 +6,6 @@
* UPDATE HISTORY: * UPDATE HISTORY:
*/ */
#ifdef WIN32_REGDBG
#include "cm_win32.h"
#else
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <roscfg.h> #include <roscfg.h>
#include <internal/ob.h> #include <internal/ob.h>
@ -22,7 +19,6 @@
#include <internal/debug.h> #include <internal/debug.h>
#include "cm.h" #include "cm.h"
#endif
static NTSTATUS static NTSTATUS
@ -209,16 +205,8 @@ CmiObjectParse(PVOID ParsedObject,
NULL, NULL,
UserMode); UserMode);
} }
#ifndef WIN32_REGDBG
DPRINT("CmiObjectParse: %s\n", FoundObject->Name); DPRINT("CmiObjectParse: %s\n", FoundObject->Name);
#else
{
char buffer[_BUFFER_LEN];
memset(buffer, 0, _BUFFER_LEN);
strncpy(buffer, FoundObject->Name, min(FoundObject->NameSize, _BUFFER_LEN - 1));
DPRINT("CmiObjectParse: %s\n", buffer);
}
#endif
*Path = EndPtr; *Path = EndPtr;
@ -283,12 +271,10 @@ CmiObjectDelete(PVOID DeletedObject)
KeyObject->ParentKey, KeyObject->ParentKey,
KeyObject); KeyObject);
if (IsPermanentHive(KeyObject->RegistryHive)) if (!IsVolatileHive(KeyObject->RegistryHive))
CmiSyncHives(); {
} CmiSyncHives();
else }
{
CmiReleaseBlock(KeyObject->RegistryHive, KeyObject->KeyCell);
} }
} }
@ -393,17 +379,8 @@ CmiScanKeyList(PKEY_OBJECT Parent,
WORD NameSize; WORD NameSize;
DWORD Index; DWORD Index;
#ifndef WIN32_REGDBG
DPRINT("Scanning key list for: %s (Parent: %s)\n", DPRINT("Scanning key list for: %s (Parent: %s)\n",
KeyName, Parent->Name); KeyName, Parent->Name);
#else
{
char buffer[_BUFFER_LEN];
memset(buffer, 0, _BUFFER_LEN);
strncpy(buffer, Parent->Name, min(Parent->NameSize, _BUFFER_LEN - 1));
DPRINT("Scanning key list for: %s (Parent: %s)\n", KeyName, buffer);
}
#endif
NameSize = strlen(KeyName); NameSize = strlen(KeyName);
KeAcquireSpinLock(&CmiKeyListLock, &OldIrql); KeAcquireSpinLock(&CmiKeyListLock, &OldIrql);
@ -431,7 +408,7 @@ CmiScanKeyList(PKEY_OBJECT Parent,
} }
} }
KeReleaseSpinLock(&CmiKeyListLock, OldIrql); KeReleaseSpinLock(&CmiKeyListLock, OldIrql);
return NULL; return NULL;
} }
@ -484,7 +461,6 @@ CmiGetLinkTarget(PREGISTRY_HIVE RegistryHive,
DataCell->Data, DataCell->Data,
TargetPath->Length); TargetPath->Length);
TargetPath->Buffer[TargetPath->Length / sizeof(WCHAR)] = 0; TargetPath->Buffer[TargetPath->Length / sizeof(WCHAR)] = 0;
CmiReleaseBlock(RegistryHive, DataCell);
} }
else else
{ {