Author: navaraf
Date: Thu Feb 7 06:32:47 2008
New Revision: 32175
URL:
http://svn.reactos.org/svn/reactos?rev=32175&view=rev
Log:
Make HvIsCellAllocated working.
Modified:
trunk/reactos/lib/cmlib/hivecell.c
trunk/reactos/lib/cmlib/hivedata.h
Modified: trunk/reactos/lib/cmlib/hivecell.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivecell.c?rev=3…
==============================================================================
--- trunk/reactos/lib/cmlib/hivecell.c (original)
+++ trunk/reactos/lib/cmlib/hivecell.c Thu Feb 7 06:32:47 2008
@@ -46,26 +46,24 @@
HvIsCellAllocated(IN PHHIVE RegistryHive,
IN HCELL_INDEX CellIndex)
{
- ULONG Type, Block;
-
- /* If it's a flat hive, the cell is always allocated */
- if (RegistryHive->Flat) return TRUE;
-
- /* Otherwise, get the type and make sure it's valid */
- Type = HvGetCellType(CellIndex);
- if (((CellIndex % ~HCELL_TYPE_MASK) > RegistryHive->Storage[Type].Length) ||
- (CellIndex % (RegistryHive->Version >= 2 ? 8 : 16)))
- {
- /* Invalid cell index */
- return FALSE;
- }
-
- /* Try to get the cell block */
- Block = (CellIndex & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT;
- if (RegistryHive->Storage[Type].BlockList[Block].BlockAddress) return TRUE;
-
- /* No valid block, fail */
- return FALSE;
+ ULONG Type, Block;
+
+ /* If it's a flat hive, the cell is always allocated */
+ if (RegistryHive->Flat)
+ return TRUE;
+
+ /* Otherwise, get the type and make sure it's valid */
+ Type = HvGetCellType(CellIndex);
+ Block = HvGetCellBlock(CellIndex);
+ if (Block >= RegistryHive->Storage[Type].Length)
+ return FALSE;
+
+ /* Try to get the cell block */
+ if (RegistryHive->Storage[Type].BlockList[Block].BlockAddress)
+ return TRUE;
+
+ /* No valid block, fail */
+ return FALSE;
}
PVOID CMAPI
@@ -88,13 +86,13 @@
HvGetCellSize(IN PHHIVE Hive,
IN PVOID Address)
{
- PHCELL CellHeader;
- LONG Size;
-
- CellHeader = (PHCELL)Address - 1;
- Size = CellHeader->Size * -1;
- Size -= sizeof(HCELL);
- return Size;
+ PHCELL CellHeader;
+ LONG Size;
+
+ CellHeader = (PHCELL)Address - 1;
+ Size = CellHeader->Size * -1;
+ Size -= sizeof(HCELL);
+ return Size;
}
BOOLEAN CMAPI
@@ -126,14 +124,15 @@
HvIsCellDirty(IN PHHIVE Hive,
IN HCELL_INDEX Cell)
{
- /* Sanity checks */
- ASSERT(Hive->ReadOnly == FALSE);
-
- /* Volatile cells are always "dirty" */
- if (HvGetCellType(Cell) == Volatile) return TRUE;
-
- /* Check if the dirty bit is set */
- return RtlCheckBit(&Hive->DirtyVector, Cell / HV_BLOCK_SIZE);
+ /* Sanity checks */
+ ASSERT(Hive->ReadOnly == FALSE);
+
+ /* Volatile cells are always "dirty" */
+ if (HvGetCellType(Cell) == Volatile)
+ return TRUE;
+
+ /* Check if the dirty bit is set */
+ return RtlCheckBit(&Hive->DirtyVector, Cell / HV_BLOCK_SIZE);
}
static ULONG __inline CMAPI
Modified: trunk/reactos/lib/cmlib/hivedata.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivedata.h?rev=3…
==============================================================================
--- trunk/reactos/lib/cmlib/hivedata.h (original)
+++ trunk/reactos/lib/cmlib/hivedata.h Thu Feb 7 06:32:47 2008
@@ -92,6 +92,8 @@
#define HvGetCellType(Cell) \
((ULONG)((Cell & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT))
+#define HvGetCellBlock(Cell) \
+ ((ULONG)((Cell & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT))
typedef enum
{