mirror of
https://github.com/reactos/reactos.git
synced 2025-04-19 12:08:55 +00:00
[CMLIB]
- HV_BLOCK_SIZE and HBLOCK_SIZE are the same thing; prefer the newly introduced HBLOCK_SIZE define. - Improve the HvGetCell* macros. - Add next to the defined hive signatures what their corresponding strings are (for documentation purpose). - Some whitespace fixes in the headers. svn path=/trunk/; revision=70561
This commit is contained in:
parent
496764ad58
commit
c55976dada
6 changed files with 189 additions and 175 deletions
|
@ -17,17 +17,17 @@
|
|||
//
|
||||
// Key Types
|
||||
//
|
||||
#define CM_KEY_INDEX_ROOT 0x6972
|
||||
#define CM_KEY_INDEX_LEAF 0x696c
|
||||
#define CM_KEY_FAST_LEAF 0x666c
|
||||
#define CM_KEY_HASH_LEAF 0x686c
|
||||
#define CM_KEY_INDEX_ROOT 0x6972 // "ri"
|
||||
#define CM_KEY_INDEX_LEAF 0x696c // "li"
|
||||
#define CM_KEY_FAST_LEAF 0x666c // "lf"
|
||||
#define CM_KEY_HASH_LEAF 0x686c // "lh"
|
||||
|
||||
//
|
||||
// Key Signatures
|
||||
//
|
||||
#define CM_KEY_NODE_SIGNATURE 0x6B6E
|
||||
#define CM_LINK_NODE_SIGNATURE 0x6B6C
|
||||
#define CM_KEY_VALUE_SIGNATURE 0x6B76
|
||||
#define CM_KEY_NODE_SIGNATURE 0x6B6E // "nk"
|
||||
#define CM_LINK_NODE_SIGNATURE 0x6B6C // "lk"
|
||||
#define CM_KEY_VALUE_SIGNATURE 0x6B76 // "vk"
|
||||
|
||||
//
|
||||
// CM_KEY_NODE Flags
|
||||
|
|
|
@ -23,8 +23,8 @@ HvpAddBin(
|
|||
ULONG OldBlockListSize;
|
||||
PHCELL Block;
|
||||
|
||||
BinSize = ROUND_UP(Size + sizeof(HBIN), HV_BLOCK_SIZE);
|
||||
BlockCount = (ULONG)(BinSize / HV_BLOCK_SIZE);
|
||||
BinSize = ROUND_UP(Size + sizeof(HBIN), HBLOCK_SIZE);
|
||||
BlockCount = (ULONG)(BinSize / HBLOCK_SIZE);
|
||||
|
||||
Bin = RegistryHive->Allocate(BinSize, TRUE, TAG_CM);
|
||||
if (Bin == NULL)
|
||||
|
@ -33,7 +33,7 @@ HvpAddBin(
|
|||
|
||||
Bin->Signature = HV_BIN_SIGNATURE;
|
||||
Bin->FileOffset = RegistryHive->Storage[Storage].Length *
|
||||
HV_BLOCK_SIZE;
|
||||
HBLOCK_SIZE;
|
||||
Bin->Size = (ULONG)BinSize;
|
||||
|
||||
/* Allocate new block list */
|
||||
|
@ -61,7 +61,7 @@ HvpAddBin(
|
|||
for (i = 0; i < BlockCount; i++)
|
||||
{
|
||||
RegistryHive->Storage[Storage].BlockList[OldBlockListSize + i].BlockAddress =
|
||||
((ULONG_PTR)Bin + (i * HV_BLOCK_SIZE));
|
||||
((ULONG_PTR)Bin + (i * HBLOCK_SIZE));
|
||||
RegistryHive->Storage[Storage].BlockList[OldBlockListSize + i].BinAddress = (ULONG_PTR)Bin;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ HvpAddBin(
|
|||
|
||||
/* Mark new bin dirty. */
|
||||
RtlSetBits(&RegistryHive->DirtyVector,
|
||||
Bin->FileOffset / HV_BLOCK_SIZE,
|
||||
Bin->FileOffset / HBLOCK_SIZE,
|
||||
BlockCount);
|
||||
|
||||
/* Update size in the base block */
|
||||
|
|
|
@ -37,7 +37,7 @@ HvpGetCellHeader(
|
|||
else
|
||||
{
|
||||
ASSERT((CellIndex & HCELL_TYPE_MASK) == Stable);
|
||||
return (PVOID)((ULONG_PTR)RegistryHive->BaseBlock + HV_BLOCK_SIZE +
|
||||
return (PVOID)((ULONG_PTR)RegistryHive->BaseBlock + HBLOCK_SIZE +
|
||||
CellIndex);
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ HvMarkCellDirty(
|
|||
return TRUE;
|
||||
|
||||
CellBlock = (CellIndex & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT;
|
||||
CellLastBlock = ((CellIndex + HV_BLOCK_SIZE - 1) & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT;
|
||||
CellLastBlock = ((CellIndex + HBLOCK_SIZE - 1) & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT;
|
||||
|
||||
RtlSetBits(&RegistryHive->DirtyVector,
|
||||
CellBlock, CellLastBlock - CellBlock);
|
||||
|
@ -139,7 +139,7 @@ HvIsCellDirty(IN PHHIVE Hive,
|
|||
return TRUE;
|
||||
|
||||
/* Check if the dirty bit is set */
|
||||
if (RtlCheckBit(&Hive->DirtyVector, Cell / HV_BLOCK_SIZE))
|
||||
if (RtlCheckBit(&Hive->DirtyVector, Cell / HBLOCK_SIZE))
|
||||
IsDirty = TRUE;
|
||||
|
||||
/* Return result as boolean*/
|
||||
|
@ -322,7 +322,7 @@ HvpCreateHiveFreeCellList(
|
|||
}
|
||||
}
|
||||
|
||||
BlockIndex += Bin->Size / HV_BLOCK_SIZE;
|
||||
BlockIndex += Bin->Size / HBLOCK_SIZE;
|
||||
BlockOffset += Bin->Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,10 +42,9 @@
|
|||
#define HSECTOR_SIZE 0x200
|
||||
#define HSECTOR_COUNT 8
|
||||
|
||||
#define HV_BLOCK_SIZE 4096
|
||||
#define HV_LOG_HEADER_SIZE FIELD_OFFSET(HBASE_BLOCK, Reserved2)
|
||||
#define HV_SIGNATURE 0x66676572
|
||||
#define HV_BIN_SIGNATURE 0x6e696268
|
||||
#define HV_SIGNATURE 0x66676572 // "regf"
|
||||
#define HV_BIN_SIGNATURE 0x6e696268 // "hbin"
|
||||
|
||||
//
|
||||
// Hive versions
|
||||
|
@ -89,9 +88,9 @@ typedef ULONG HCELL_INDEX, *PHCELL_INDEX;
|
|||
#define HCELL_OFFSET_SHIFT 0
|
||||
|
||||
#define HvGetCellType(Cell) \
|
||||
((ULONG)((Cell & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT))
|
||||
((ULONG)(((Cell) & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT))
|
||||
#define HvGetCellBlock(Cell) \
|
||||
((ULONG)((Cell & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT))
|
||||
((ULONG)(((Cell) & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -176,7 +175,7 @@ typedef struct _HBIN
|
|||
/* When this bin was last modified */
|
||||
LARGE_INTEGER TimeStamp;
|
||||
|
||||
/* ? (In-memory only) */
|
||||
/* Unused (In-memory only) */
|
||||
ULONG Spare;
|
||||
} HBIN, *PHBIN;
|
||||
|
||||
|
@ -190,44 +189,59 @@ typedef struct _HCELL
|
|||
|
||||
struct _HHIVE;
|
||||
|
||||
typedef struct _CELL_DATA* (CMAPI *PGET_CELL_ROUTINE)(
|
||||
typedef struct _CELL_DATA*
|
||||
(CMAPI *PGET_CELL_ROUTINE)(
|
||||
struct _HHIVE *Hive,
|
||||
HCELL_INDEX Cell);
|
||||
HCELL_INDEX Cell
|
||||
);
|
||||
|
||||
typedef VOID (CMAPI *PRELEASE_CELL_ROUTINE)(
|
||||
typedef VOID
|
||||
(CMAPI *PRELEASE_CELL_ROUTINE)(
|
||||
struct _HHIVE *Hive,
|
||||
HCELL_INDEX Cell);
|
||||
HCELL_INDEX Cell
|
||||
);
|
||||
|
||||
typedef PVOID (CMAPI *PALLOCATE_ROUTINE)(
|
||||
typedef PVOID
|
||||
(CMAPI *PALLOCATE_ROUTINE)(
|
||||
SIZE_T Size,
|
||||
BOOLEAN Paged,
|
||||
ULONG Tag);
|
||||
ULONG Tag
|
||||
);
|
||||
|
||||
typedef VOID (CMAPI *PFREE_ROUTINE)(
|
||||
typedef VOID
|
||||
(CMAPI *PFREE_ROUTINE)(
|
||||
PVOID Ptr,
|
||||
ULONG Quota);
|
||||
ULONG Quota
|
||||
);
|
||||
|
||||
typedef BOOLEAN (CMAPI *PFILE_READ_ROUTINE)(
|
||||
typedef BOOLEAN
|
||||
(CMAPI *PFILE_READ_ROUTINE)(
|
||||
struct _HHIVE *RegistryHive,
|
||||
ULONG FileType,
|
||||
PULONG FileOffset,
|
||||
PVOID Buffer,
|
||||
SIZE_T BufferLength);
|
||||
SIZE_T BufferLength
|
||||
);
|
||||
|
||||
typedef BOOLEAN (CMAPI *PFILE_WRITE_ROUTINE)(
|
||||
typedef BOOLEAN
|
||||
(CMAPI *PFILE_WRITE_ROUTINE)(
|
||||
struct _HHIVE *RegistryHive,
|
||||
ULONG FileType,
|
||||
PULONG FileOffset,
|
||||
PVOID Buffer,
|
||||
SIZE_T BufferLength);
|
||||
SIZE_T BufferLength
|
||||
);
|
||||
|
||||
typedef BOOLEAN (CMAPI *PFILE_SET_SIZE_ROUTINE)(
|
||||
typedef BOOLEAN
|
||||
(CMAPI *PFILE_SET_SIZE_ROUTINE)(
|
||||
struct _HHIVE *RegistryHive,
|
||||
ULONG FileType,
|
||||
ULONG FileSize,
|
||||
ULONG OldfileSize);
|
||||
ULONG OldfileSize
|
||||
);
|
||||
|
||||
typedef BOOLEAN (CMAPI *PFILE_FLUSH_ROUTINE)(
|
||||
typedef BOOLEAN
|
||||
(CMAPI *PFILE_FLUSH_ROUTINE)(
|
||||
struct _HHIVE *RegistryHive,
|
||||
ULONG FileType,
|
||||
PLARGE_INTEGER FileOffset,
|
||||
|
@ -296,5 +310,5 @@ typedef struct _HHIVE
|
|||
DUAL Storage[HTYPE_COUNT];
|
||||
} HHIVE, *PHHIVE;
|
||||
|
||||
#define IsFreeCell(Cell)(Cell->Size >= 0)
|
||||
#define IsUsedCell(Cell)(Cell->Size < 0)
|
||||
#define IsFreeCell(Cell) ((Cell)->Size >= 0)
|
||||
#define IsUsedCell(Cell) ((Cell)->Size < 0)
|
||||
|
|
|
@ -193,7 +193,7 @@ HvpInitializeMemoryHive(
|
|||
* we go.
|
||||
*/
|
||||
|
||||
Hive->Storage[Stable].Length = (ULONG)(ChunkSize / HV_BLOCK_SIZE);
|
||||
Hive->Storage[Stable].Length = (ULONG)(ChunkSize / HBLOCK_SIZE);
|
||||
Hive->Storage[Stable].BlockList =
|
||||
Hive->Allocate(Hive->Storage[Stable].Length *
|
||||
sizeof(HMAP_ENTRY), FALSE, TAG_CM);
|
||||
|
@ -206,9 +206,9 @@ HvpInitializeMemoryHive(
|
|||
|
||||
for (BlockIndex = 0; BlockIndex < Hive->Storage[Stable].Length; )
|
||||
{
|
||||
Bin = (PHBIN)((ULONG_PTR)ChunkBase + (BlockIndex + 1) * HV_BLOCK_SIZE);
|
||||
Bin = (PHBIN)((ULONG_PTR)ChunkBase + (BlockIndex + 1) * HBLOCK_SIZE);
|
||||
if (Bin->Signature != HV_BIN_SIGNATURE ||
|
||||
(Bin->Size % HV_BLOCK_SIZE) != 0)
|
||||
(Bin->Size % HBLOCK_SIZE) != 0)
|
||||
{
|
||||
DPRINT1("Invalid bin at BlockIndex %lu, Signature 0x%x, Size 0x%x\n",
|
||||
(unsigned long)BlockIndex, (unsigned)Bin->Signature, (unsigned)Bin->Size);
|
||||
|
@ -230,17 +230,17 @@ HvpInitializeMemoryHive(
|
|||
|
||||
RtlCopyMemory(NewBin, Bin, Bin->Size);
|
||||
|
||||
if (Bin->Size > HV_BLOCK_SIZE)
|
||||
if (Bin->Size > HBLOCK_SIZE)
|
||||
{
|
||||
for (i = 1; i < Bin->Size / HV_BLOCK_SIZE; i++)
|
||||
for (i = 1; i < Bin->Size / HBLOCK_SIZE; i++)
|
||||
{
|
||||
Hive->Storage[Stable].BlockList[BlockIndex + i].BinAddress = (ULONG_PTR)NewBin;
|
||||
Hive->Storage[Stable].BlockList[BlockIndex + i].BlockAddress =
|
||||
((ULONG_PTR)NewBin + (i * HV_BLOCK_SIZE));
|
||||
((ULONG_PTR)NewBin + (i * HBLOCK_SIZE));
|
||||
}
|
||||
}
|
||||
|
||||
BlockIndex += Bin->Size / HV_BLOCK_SIZE;
|
||||
BlockIndex += Bin->Size / HBLOCK_SIZE;
|
||||
}
|
||||
|
||||
if (HvpCreateHiveFreeCellList(Hive))
|
||||
|
@ -313,7 +313,7 @@ HvpGetHiveHeader(IN PHHIVE Hive,
|
|||
ULONG Alignment;
|
||||
ULONG Result;
|
||||
ULONG Offset = 0;
|
||||
ASSERT(sizeof(HBASE_BLOCK) >= (HV_BLOCK_SIZE * Hive->Cluster));
|
||||
ASSERT(sizeof(HBASE_BLOCK) >= (HBLOCK_SIZE * Hive->Cluster));
|
||||
|
||||
/* Assume failure and allocate the buffer */
|
||||
*HiveBaseBlock = 0;
|
||||
|
@ -321,7 +321,7 @@ HvpGetHiveHeader(IN PHHIVE Hive,
|
|||
if (!BaseBlock) return NoMemory;
|
||||
|
||||
/* Check for, and enforce, alignment */
|
||||
Alignment = Hive->Cluster * HV_BLOCK_SIZE -1;
|
||||
Alignment = Hive->Cluster * HBLOCK_SIZE -1;
|
||||
if ((ULONG_PTR)BaseBlock & Alignment)
|
||||
{
|
||||
/* Free the old header */
|
||||
|
@ -338,7 +338,7 @@ HvpGetHiveHeader(IN PHHIVE Hive,
|
|||
HFILE_TYPE_PRIMARY,
|
||||
&Offset,
|
||||
BaseBlock,
|
||||
Hive->Cluster * HV_BLOCK_SIZE);
|
||||
Hive->Cluster * HBLOCK_SIZE);
|
||||
|
||||
/* Couldn't read: assume it's not a hive */
|
||||
if (!Result) return NotHive;
|
||||
|
|
|
@ -32,7 +32,7 @@ HvpWriteLog(
|
|||
|
||||
ASSERT(RegistryHive->ReadOnly == FALSE);
|
||||
ASSERT(RegistryHive->BaseBlock->Length ==
|
||||
RegistryHive->Storage[Stable].Length * HV_BLOCK_SIZE);
|
||||
RegistryHive->Storage[Stable].Length * HBLOCK_SIZE);
|
||||
|
||||
DPRINT("HvpWriteLog called\n");
|
||||
|
||||
|
@ -44,7 +44,7 @@ HvpWriteLog(
|
|||
|
||||
BitmapSize = RegistryHive->DirtyVector.SizeOfBitMap;
|
||||
BufferSize = HV_LOG_HEADER_SIZE + sizeof(ULONG) + BitmapSize;
|
||||
BufferSize = ROUND_UP(BufferSize, HV_BLOCK_SIZE);
|
||||
BufferSize = ROUND_UP(BufferSize, HBLOCK_SIZE);
|
||||
|
||||
DPRINT("Bitmap size %u buffer size: %u\n", BitmapSize, BufferSize);
|
||||
|
||||
|
@ -95,14 +95,14 @@ HvpWriteLog(
|
|||
/* Write hive block */
|
||||
Success = RegistryHive->FileWrite(RegistryHive, HFILE_TYPE_LOG,
|
||||
&FileOffset, BlockPtr,
|
||||
HV_BLOCK_SIZE);
|
||||
HBLOCK_SIZE);
|
||||
if (!Success)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BlockIndex++;
|
||||
FileOffset += HV_BLOCK_SIZE;
|
||||
FileOffset += HBLOCK_SIZE;
|
||||
}
|
||||
|
||||
Success = RegistryHive->FileSetSize(RegistryHive, HFILE_TYPE_LOG, FileOffset, FileOffset);
|
||||
|
@ -157,7 +157,7 @@ HvpWriteHive(
|
|||
|
||||
ASSERT(RegistryHive->ReadOnly == FALSE);
|
||||
ASSERT(RegistryHive->BaseBlock->Length ==
|
||||
RegistryHive->Storage[Stable].Length * HV_BLOCK_SIZE);
|
||||
RegistryHive->Storage[Stable].Length * HBLOCK_SIZE);
|
||||
|
||||
DPRINT("HvpWriteHive called\n");
|
||||
|
||||
|
@ -197,12 +197,12 @@ HvpWriteHive(
|
|||
}
|
||||
|
||||
BlockPtr = (PVOID)RegistryHive->Storage[Stable].BlockList[BlockIndex].BlockAddress;
|
||||
FileOffset = (BlockIndex + 1) * HV_BLOCK_SIZE;
|
||||
FileOffset = (BlockIndex + 1) * HBLOCK_SIZE;
|
||||
|
||||
/* Write hive block */
|
||||
Success = RegistryHive->FileWrite(RegistryHive, HFILE_TYPE_PRIMARY,
|
||||
&FileOffset, BlockPtr,
|
||||
HV_BLOCK_SIZE);
|
||||
HBLOCK_SIZE);
|
||||
if (!Success)
|
||||
{
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in a new issue