mirror of
https://github.com/reactos/reactos.git
synced 2025-06-14 14:58:29 +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
|
@ -7,53 +7,53 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define REG_INIT_BLOCK_LIST_SIZE 32
|
#define REG_INIT_BLOCK_LIST_SIZE 32
|
||||||
#define REG_INIT_HASH_TABLE_SIZE 3
|
#define REG_INIT_HASH_TABLE_SIZE 3
|
||||||
#define REG_EXTEND_HASH_TABLE_SIZE 4
|
#define REG_EXTEND_HASH_TABLE_SIZE 4
|
||||||
#define REG_VALUE_LIST_CELL_MULTIPLE 4
|
#define REG_VALUE_LIST_CELL_MULTIPLE 4
|
||||||
#define REG_DATA_SIZE_MASK 0x7FFFFFFF
|
#define REG_DATA_SIZE_MASK 0x7FFFFFFF
|
||||||
#define REG_DATA_IN_OFFSET 0x80000000
|
#define REG_DATA_IN_OFFSET 0x80000000
|
||||||
|
|
||||||
//
|
//
|
||||||
// Key Types
|
// Key Types
|
||||||
//
|
//
|
||||||
#define CM_KEY_INDEX_ROOT 0x6972
|
#define CM_KEY_INDEX_ROOT 0x6972 // "ri"
|
||||||
#define CM_KEY_INDEX_LEAF 0x696c
|
#define CM_KEY_INDEX_LEAF 0x696c // "li"
|
||||||
#define CM_KEY_FAST_LEAF 0x666c
|
#define CM_KEY_FAST_LEAF 0x666c // "lf"
|
||||||
#define CM_KEY_HASH_LEAF 0x686c
|
#define CM_KEY_HASH_LEAF 0x686c // "lh"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Key Signatures
|
// Key Signatures
|
||||||
//
|
//
|
||||||
#define CM_KEY_NODE_SIGNATURE 0x6B6E
|
#define CM_KEY_NODE_SIGNATURE 0x6B6E // "nk"
|
||||||
#define CM_LINK_NODE_SIGNATURE 0x6B6C
|
#define CM_LINK_NODE_SIGNATURE 0x6B6C // "lk"
|
||||||
#define CM_KEY_VALUE_SIGNATURE 0x6B76
|
#define CM_KEY_VALUE_SIGNATURE 0x6B76 // "vk"
|
||||||
|
|
||||||
//
|
//
|
||||||
// CM_KEY_NODE Flags
|
// CM_KEY_NODE Flags
|
||||||
//
|
//
|
||||||
#define KEY_IS_VOLATILE 0x01
|
#define KEY_IS_VOLATILE 0x01
|
||||||
#define KEY_HIVE_EXIT 0x02
|
#define KEY_HIVE_EXIT 0x02
|
||||||
#define KEY_HIVE_ENTRY 0x04
|
#define KEY_HIVE_ENTRY 0x04
|
||||||
#define KEY_NO_DELETE 0x08
|
#define KEY_NO_DELETE 0x08
|
||||||
#define KEY_SYM_LINK 0x10
|
#define KEY_SYM_LINK 0x10
|
||||||
#define KEY_COMP_NAME 0x20
|
#define KEY_COMP_NAME 0x20
|
||||||
#define KEY_PREFEF_HANDLE 0x40
|
#define KEY_PREFEF_HANDLE 0x40
|
||||||
#define KEY_VIRT_MIRRORED 0x80
|
#define KEY_VIRT_MIRRORED 0x80
|
||||||
#define KEY_VIRT_TARGET 0x100
|
#define KEY_VIRT_TARGET 0x100
|
||||||
#define KEY_VIRTUAL_STORE 0x200
|
#define KEY_VIRTUAL_STORE 0x200
|
||||||
|
|
||||||
//
|
//
|
||||||
// CM_KEY_VALUE Flags
|
// CM_KEY_VALUE Flags
|
||||||
//
|
//
|
||||||
#define VALUE_COMP_NAME 0x0001
|
#define VALUE_COMP_NAME 0x0001
|
||||||
|
|
||||||
//
|
//
|
||||||
// CM_KEY_VALUE Types
|
// CM_KEY_VALUE Types
|
||||||
//
|
//
|
||||||
#define CM_KEY_VALUE_SMALL 0x4
|
#define CM_KEY_VALUE_SMALL 0x4
|
||||||
#define CM_KEY_VALUE_BIG 0x3FD8
|
#define CM_KEY_VALUE_BIG 0x3FD8
|
||||||
#define CM_KEY_VALUE_SPECIAL_SIZE 0x80000000
|
#define CM_KEY_VALUE_SPECIAL_SIZE 0x80000000
|
||||||
|
|
||||||
#include <pshpack1.h>
|
#include <pshpack1.h>
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ HvpAddBin(
|
||||||
ULONG OldBlockListSize;
|
ULONG OldBlockListSize;
|
||||||
PHCELL Block;
|
PHCELL Block;
|
||||||
|
|
||||||
BinSize = ROUND_UP(Size + sizeof(HBIN), HV_BLOCK_SIZE);
|
BinSize = ROUND_UP(Size + sizeof(HBIN), HBLOCK_SIZE);
|
||||||
BlockCount = (ULONG)(BinSize / HV_BLOCK_SIZE);
|
BlockCount = (ULONG)(BinSize / HBLOCK_SIZE);
|
||||||
|
|
||||||
Bin = RegistryHive->Allocate(BinSize, TRUE, TAG_CM);
|
Bin = RegistryHive->Allocate(BinSize, TRUE, TAG_CM);
|
||||||
if (Bin == NULL)
|
if (Bin == NULL)
|
||||||
|
@ -33,7 +33,7 @@ HvpAddBin(
|
||||||
|
|
||||||
Bin->Signature = HV_BIN_SIGNATURE;
|
Bin->Signature = HV_BIN_SIGNATURE;
|
||||||
Bin->FileOffset = RegistryHive->Storage[Storage].Length *
|
Bin->FileOffset = RegistryHive->Storage[Storage].Length *
|
||||||
HV_BLOCK_SIZE;
|
HBLOCK_SIZE;
|
||||||
Bin->Size = (ULONG)BinSize;
|
Bin->Size = (ULONG)BinSize;
|
||||||
|
|
||||||
/* Allocate new block list */
|
/* Allocate new block list */
|
||||||
|
@ -61,7 +61,7 @@ HvpAddBin(
|
||||||
for (i = 0; i < BlockCount; i++)
|
for (i = 0; i < BlockCount; i++)
|
||||||
{
|
{
|
||||||
RegistryHive->Storage[Storage].BlockList[OldBlockListSize + i].BlockAddress =
|
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;
|
RegistryHive->Storage[Storage].BlockList[OldBlockListSize + i].BinAddress = (ULONG_PTR)Bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ HvpAddBin(
|
||||||
|
|
||||||
/* Mark new bin dirty. */
|
/* Mark new bin dirty. */
|
||||||
RtlSetBits(&RegistryHive->DirtyVector,
|
RtlSetBits(&RegistryHive->DirtyVector,
|
||||||
Bin->FileOffset / HV_BLOCK_SIZE,
|
Bin->FileOffset / HBLOCK_SIZE,
|
||||||
BlockCount);
|
BlockCount);
|
||||||
|
|
||||||
/* Update size in the base block */
|
/* Update size in the base block */
|
||||||
|
|
|
@ -37,7 +37,7 @@ HvpGetCellHeader(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT((CellIndex & HCELL_TYPE_MASK) == Stable);
|
ASSERT((CellIndex & HCELL_TYPE_MASK) == Stable);
|
||||||
return (PVOID)((ULONG_PTR)RegistryHive->BaseBlock + HV_BLOCK_SIZE +
|
return (PVOID)((ULONG_PTR)RegistryHive->BaseBlock + HBLOCK_SIZE +
|
||||||
CellIndex);
|
CellIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ HvMarkCellDirty(
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
CellBlock = (CellIndex & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT;
|
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,
|
RtlSetBits(&RegistryHive->DirtyVector,
|
||||||
CellBlock, CellLastBlock - CellBlock);
|
CellBlock, CellLastBlock - CellBlock);
|
||||||
|
@ -139,7 +139,7 @@ HvIsCellDirty(IN PHHIVE Hive,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* Check if the dirty bit is set */
|
/* Check if the dirty bit is set */
|
||||||
if (RtlCheckBit(&Hive->DirtyVector, Cell / HV_BLOCK_SIZE))
|
if (RtlCheckBit(&Hive->DirtyVector, Cell / HBLOCK_SIZE))
|
||||||
IsDirty = TRUE;
|
IsDirty = TRUE;
|
||||||
|
|
||||||
/* Return result as boolean*/
|
/* Return result as boolean*/
|
||||||
|
@ -322,7 +322,7 @@ HvpCreateHiveFreeCellList(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockIndex += Bin->Size / HV_BLOCK_SIZE;
|
BlockIndex += Bin->Size / HBLOCK_SIZE;
|
||||||
BlockOffset += Bin->Size;
|
BlockOffset += Bin->Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,61 +10,60 @@
|
||||||
//
|
//
|
||||||
// Hive operations
|
// Hive operations
|
||||||
//
|
//
|
||||||
#define HINIT_CREATE 0
|
#define HINIT_CREATE 0
|
||||||
#define HINIT_MEMORY 1
|
#define HINIT_MEMORY 1
|
||||||
#define HINIT_FILE 2
|
#define HINIT_FILE 2
|
||||||
#define HINIT_MEMORY_INPLACE 3
|
#define HINIT_MEMORY_INPLACE 3
|
||||||
#define HINIT_FLAT 4
|
#define HINIT_FLAT 4
|
||||||
#define HINIT_MAPFILE 5
|
#define HINIT_MAPFILE 5
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hive flags
|
// Hive flags
|
||||||
//
|
//
|
||||||
#define HIVE_VOLATILE 1
|
#define HIVE_VOLATILE 1
|
||||||
#define HIVE_NOLAZYFLUSH 2
|
#define HIVE_NOLAZYFLUSH 2
|
||||||
#define HIVE_HAS_BEEN_REPLACED 4
|
#define HIVE_HAS_BEEN_REPLACED 4
|
||||||
#define HIVE_HAS_BEEN_FREED 8
|
#define HIVE_HAS_BEEN_FREED 8
|
||||||
#define HIVE_UNKNOWN 0x10
|
#define HIVE_UNKNOWN 0x10
|
||||||
#define HIVE_IS_UNLOADING 0x20
|
#define HIVE_IS_UNLOADING 0x20
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hive types
|
// Hive types
|
||||||
//
|
//
|
||||||
#define HFILE_TYPE_PRIMARY 0
|
#define HFILE_TYPE_PRIMARY 0
|
||||||
#define HFILE_TYPE_LOG 1
|
#define HFILE_TYPE_LOG 1
|
||||||
#define HFILE_TYPE_EXTERNAL 2
|
#define HFILE_TYPE_EXTERNAL 2
|
||||||
#define HFILE_TYPE_MAX 3
|
#define HFILE_TYPE_MAX 3
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hive sizes
|
// Hive sizes
|
||||||
//
|
//
|
||||||
#define HBLOCK_SIZE 0x1000
|
#define HBLOCK_SIZE 0x1000
|
||||||
#define HSECTOR_SIZE 0x200
|
#define HSECTOR_SIZE 0x200
|
||||||
#define HSECTOR_COUNT 8
|
#define HSECTOR_COUNT 8
|
||||||
|
|
||||||
#define HV_BLOCK_SIZE 4096
|
#define HV_LOG_HEADER_SIZE FIELD_OFFSET(HBASE_BLOCK, Reserved2)
|
||||||
#define HV_LOG_HEADER_SIZE FIELD_OFFSET(HBASE_BLOCK, Reserved2)
|
#define HV_SIGNATURE 0x66676572 // "regf"
|
||||||
#define HV_SIGNATURE 0x66676572
|
#define HV_BIN_SIGNATURE 0x6e696268 // "hbin"
|
||||||
#define HV_BIN_SIGNATURE 0x6e696268
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hive versions
|
// Hive versions
|
||||||
//
|
//
|
||||||
#define HSYS_MAJOR 1
|
#define HSYS_MAJOR 1
|
||||||
#define HSYS_MINOR 3
|
#define HSYS_MINOR 3
|
||||||
#define HSYS_WHISTLER_BETA1 4
|
#define HSYS_WHISTLER_BETA1 4
|
||||||
#define HSYS_WHISTLER 5
|
#define HSYS_WHISTLER 5
|
||||||
#define HSYS_MINOR_SUPPORTED HSYS_WHISTLER
|
#define HSYS_MINOR_SUPPORTED HSYS_WHISTLER
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hive formats
|
// Hive formats
|
||||||
//
|
//
|
||||||
#define HBASE_FORMAT_MEMORY 1
|
#define HBASE_FORMAT_MEMORY 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hive storage
|
// Hive storage
|
||||||
//
|
//
|
||||||
#define HTYPE_COUNT 2
|
#define HTYPE_COUNT 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name HCELL_INDEX
|
* @name HCELL_INDEX
|
||||||
|
@ -78,24 +77,24 @@ typedef ULONG HCELL_INDEX, *PHCELL_INDEX;
|
||||||
//
|
//
|
||||||
// Cell Magic Values
|
// Cell Magic Values
|
||||||
//
|
//
|
||||||
#define HCELL_NIL MAXULONG
|
#define HCELL_NIL MAXULONG
|
||||||
#define HCELL_CACHED 1
|
#define HCELL_CACHED 1
|
||||||
|
|
||||||
#define HCELL_TYPE_MASK 0x80000000
|
#define HCELL_TYPE_MASK 0x80000000
|
||||||
#define HCELL_BLOCK_MASK 0x7ffff000
|
#define HCELL_BLOCK_MASK 0x7ffff000
|
||||||
#define HCELL_OFFSET_MASK 0x00000fff
|
#define HCELL_OFFSET_MASK 0x00000fff
|
||||||
#define HCELL_TYPE_SHIFT 31
|
#define HCELL_TYPE_SHIFT 31
|
||||||
#define HCELL_BLOCK_SHIFT 12
|
#define HCELL_BLOCK_SHIFT 12
|
||||||
#define HCELL_OFFSET_SHIFT 0
|
#define HCELL_OFFSET_SHIFT 0
|
||||||
|
|
||||||
#define HvGetCellType(Cell) \
|
#define HvGetCellType(Cell) \
|
||||||
((ULONG)((Cell & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT))
|
((ULONG)(((Cell) & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT))
|
||||||
#define HvGetCellBlock(Cell) \
|
#define HvGetCellBlock(Cell) \
|
||||||
((ULONG)((Cell & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT))
|
((ULONG)(((Cell) & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT))
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
Stable = 0,
|
Stable = 0,
|
||||||
Volatile = 1
|
Volatile = 1
|
||||||
} HSTORAGE_TYPE;
|
} HSTORAGE_TYPE;
|
||||||
|
|
||||||
|
@ -107,127 +106,142 @@ typedef enum
|
||||||
* On-disk header for registry hive file.
|
* On-disk header for registry hive file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define HIVE_FILENAME_MAXLEN 31
|
#define HIVE_FILENAME_MAXLEN 31
|
||||||
|
|
||||||
typedef struct _HBASE_BLOCK
|
typedef struct _HBASE_BLOCK
|
||||||
{
|
{
|
||||||
/* Hive identifier "regf" (0x66676572) */
|
/* Hive identifier "regf" (0x66676572) */
|
||||||
ULONG Signature;
|
ULONG Signature;
|
||||||
|
|
||||||
/* Update counter */
|
/* Update counter */
|
||||||
ULONG Sequence1;
|
ULONG Sequence1;
|
||||||
|
|
||||||
/* Update counter */
|
/* Update counter */
|
||||||
ULONG Sequence2;
|
ULONG Sequence2;
|
||||||
|
|
||||||
/* When this hive file was last modified */
|
/* When this hive file was last modified */
|
||||||
LARGE_INTEGER TimeStamp;
|
LARGE_INTEGER TimeStamp;
|
||||||
|
|
||||||
/* Registry format major version (1) */
|
/* Registry format major version (1) */
|
||||||
ULONG Major;
|
ULONG Major;
|
||||||
|
|
||||||
/* Registry format minor version (3)
|
/* Registry format minor version (3)
|
||||||
Version 3 added fast indexes, version 5 has large value optimizations */
|
Version 3 added fast indexes, version 5 has large value optimizations */
|
||||||
ULONG Minor;
|
ULONG Minor;
|
||||||
|
|
||||||
/* Registry file type (0 - Primary, 1 - Log) */
|
/* Registry file type (0 - Primary, 1 - Log) */
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
|
|
||||||
/* Registry format (1 is the only defined value so far) */
|
/* Registry format (1 is the only defined value so far) */
|
||||||
ULONG Format;
|
ULONG Format;
|
||||||
|
|
||||||
/* Offset into file from the byte after the end of the base block.
|
/* Offset into file from the byte after the end of the base block.
|
||||||
If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
|
If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
|
||||||
HCELL_INDEX RootCell;
|
HCELL_INDEX RootCell;
|
||||||
|
|
||||||
/* Size of each hive block ? */
|
/* Size of each hive block ? */
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
|
|
||||||
/* (1?) */
|
/* (1?) */
|
||||||
ULONG Cluster;
|
ULONG Cluster;
|
||||||
|
|
||||||
/* Last 31 UNICODE characters, plus terminating NULL character,
|
/* Last 31 UNICODE characters, plus terminating NULL character,
|
||||||
of the full name of the hive file */
|
of the full name of the hive file */
|
||||||
WCHAR FileName[HIVE_FILENAME_MAXLEN + 1];
|
WCHAR FileName[HIVE_FILENAME_MAXLEN + 1];
|
||||||
|
|
||||||
ULONG Reserved1[99];
|
ULONG Reserved1[99];
|
||||||
|
|
||||||
/* Checksum of first 0x200 bytes */
|
/* Checksum of first 0x200 bytes */
|
||||||
ULONG CheckSum;
|
ULONG CheckSum;
|
||||||
|
|
||||||
ULONG Reserved2[0x37E];
|
ULONG Reserved2[0x37E];
|
||||||
ULONG BootType;
|
ULONG BootType;
|
||||||
ULONG BootRecover;
|
ULONG BootRecover;
|
||||||
} HBASE_BLOCK, *PHBASE_BLOCK;
|
} HBASE_BLOCK, *PHBASE_BLOCK;
|
||||||
|
|
||||||
typedef struct _HBIN
|
typedef struct _HBIN
|
||||||
{
|
{
|
||||||
/* Bin identifier "hbin" (0x6E696268) */
|
/* Bin identifier "hbin" (0x6E696268) */
|
||||||
ULONG Signature;
|
ULONG Signature;
|
||||||
|
|
||||||
/* Block offset of this bin */
|
/* Block offset of this bin */
|
||||||
HCELL_INDEX FileOffset;
|
HCELL_INDEX FileOffset;
|
||||||
|
|
||||||
/* Size in bytes, multiple of the block size (4KB) */
|
/* Size in bytes, multiple of the block size (4KB) */
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
|
|
||||||
ULONG Reserved1[2];
|
ULONG Reserved1[2];
|
||||||
|
|
||||||
/* When this bin was last modified */
|
/* When this bin was last modified */
|
||||||
LARGE_INTEGER TimeStamp;
|
LARGE_INTEGER TimeStamp;
|
||||||
|
|
||||||
/* ? (In-memory only) */
|
/* Unused (In-memory only) */
|
||||||
ULONG Spare;
|
ULONG Spare;
|
||||||
} HBIN, *PHBIN;
|
} HBIN, *PHBIN;
|
||||||
|
|
||||||
typedef struct _HCELL
|
typedef struct _HCELL
|
||||||
{
|
{
|
||||||
/* <0 if used, >0 if free */
|
/* <0 if used, >0 if free */
|
||||||
LONG Size;
|
LONG Size;
|
||||||
} HCELL, *PHCELL;
|
} HCELL, *PHCELL;
|
||||||
|
|
||||||
#include <poppack.h>
|
#include <poppack.h>
|
||||||
|
|
||||||
struct _HHIVE;
|
struct _HHIVE;
|
||||||
|
|
||||||
typedef struct _CELL_DATA* (CMAPI *PGET_CELL_ROUTINE)(
|
typedef struct _CELL_DATA*
|
||||||
struct _HHIVE *Hive,
|
(CMAPI *PGET_CELL_ROUTINE)(
|
||||||
HCELL_INDEX Cell);
|
struct _HHIVE *Hive,
|
||||||
|
HCELL_INDEX Cell
|
||||||
|
);
|
||||||
|
|
||||||
typedef VOID (CMAPI *PRELEASE_CELL_ROUTINE)(
|
typedef VOID
|
||||||
struct _HHIVE *Hive,
|
(CMAPI *PRELEASE_CELL_ROUTINE)(
|
||||||
HCELL_INDEX Cell);
|
struct _HHIVE *Hive,
|
||||||
|
HCELL_INDEX Cell
|
||||||
|
);
|
||||||
|
|
||||||
typedef PVOID (CMAPI *PALLOCATE_ROUTINE)(
|
typedef PVOID
|
||||||
SIZE_T Size,
|
(CMAPI *PALLOCATE_ROUTINE)(
|
||||||
BOOLEAN Paged,
|
SIZE_T Size,
|
||||||
ULONG Tag);
|
BOOLEAN Paged,
|
||||||
|
ULONG Tag
|
||||||
|
);
|
||||||
|
|
||||||
typedef VOID (CMAPI *PFREE_ROUTINE)(
|
typedef VOID
|
||||||
PVOID Ptr,
|
(CMAPI *PFREE_ROUTINE)(
|
||||||
ULONG Quota);
|
PVOID Ptr,
|
||||||
|
ULONG Quota
|
||||||
|
);
|
||||||
|
|
||||||
typedef BOOLEAN (CMAPI *PFILE_READ_ROUTINE)(
|
typedef BOOLEAN
|
||||||
struct _HHIVE *RegistryHive,
|
(CMAPI *PFILE_READ_ROUTINE)(
|
||||||
ULONG FileType,
|
struct _HHIVE *RegistryHive,
|
||||||
PULONG FileOffset,
|
ULONG FileType,
|
||||||
PVOID Buffer,
|
PULONG FileOffset,
|
||||||
SIZE_T BufferLength);
|
PVOID Buffer,
|
||||||
|
SIZE_T BufferLength
|
||||||
|
);
|
||||||
|
|
||||||
typedef BOOLEAN (CMAPI *PFILE_WRITE_ROUTINE)(
|
typedef BOOLEAN
|
||||||
struct _HHIVE *RegistryHive,
|
(CMAPI *PFILE_WRITE_ROUTINE)(
|
||||||
ULONG FileType,
|
struct _HHIVE *RegistryHive,
|
||||||
PULONG FileOffset,
|
ULONG FileType,
|
||||||
PVOID Buffer,
|
PULONG FileOffset,
|
||||||
SIZE_T BufferLength);
|
PVOID Buffer,
|
||||||
|
SIZE_T BufferLength
|
||||||
|
);
|
||||||
|
|
||||||
typedef BOOLEAN (CMAPI *PFILE_SET_SIZE_ROUTINE)(
|
typedef BOOLEAN
|
||||||
struct _HHIVE *RegistryHive,
|
(CMAPI *PFILE_SET_SIZE_ROUTINE)(
|
||||||
ULONG FileType,
|
struct _HHIVE *RegistryHive,
|
||||||
ULONG FileSize,
|
ULONG FileType,
|
||||||
ULONG OldfileSize);
|
ULONG FileSize,
|
||||||
|
ULONG OldfileSize
|
||||||
|
);
|
||||||
|
|
||||||
typedef BOOLEAN (CMAPI *PFILE_FLUSH_ROUTINE)(
|
typedef BOOLEAN
|
||||||
|
(CMAPI *PFILE_FLUSH_ROUTINE)(
|
||||||
struct _HHIVE *RegistryHive,
|
struct _HHIVE *RegistryHive,
|
||||||
ULONG FileType,
|
ULONG FileType,
|
||||||
PLARGE_INTEGER FileOffset,
|
PLARGE_INTEGER FileOffset,
|
||||||
|
@ -258,7 +272,7 @@ typedef struct _DUAL
|
||||||
PHMAP_DIRECTORY Map;
|
PHMAP_DIRECTORY Map;
|
||||||
PHMAP_ENTRY BlockList; // PHMAP_TABLE SmallDir;
|
PHMAP_ENTRY BlockList; // PHMAP_TABLE SmallDir;
|
||||||
ULONG Guard;
|
ULONG Guard;
|
||||||
HCELL_INDEX FreeDisplay[24]; //FREE_DISPLAY FreeDisplay[24];
|
HCELL_INDEX FreeDisplay[24]; // FREE_DISPLAY FreeDisplay[24];
|
||||||
ULONG FreeSummary;
|
ULONG FreeSummary;
|
||||||
LIST_ENTRY FreeBins;
|
LIST_ENTRY FreeBins;
|
||||||
} DUAL, *PDUAL;
|
} DUAL, *PDUAL;
|
||||||
|
@ -296,5 +310,5 @@ typedef struct _HHIVE
|
||||||
DUAL Storage[HTYPE_COUNT];
|
DUAL Storage[HTYPE_COUNT];
|
||||||
} HHIVE, *PHHIVE;
|
} HHIVE, *PHHIVE;
|
||||||
|
|
||||||
#define IsFreeCell(Cell)(Cell->Size >= 0)
|
#define IsFreeCell(Cell) ((Cell)->Size >= 0)
|
||||||
#define IsUsedCell(Cell)(Cell->Size < 0)
|
#define IsUsedCell(Cell) ((Cell)->Size < 0)
|
||||||
|
|
|
@ -193,7 +193,7 @@ HvpInitializeMemoryHive(
|
||||||
* we go.
|
* we go.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Hive->Storage[Stable].Length = (ULONG)(ChunkSize / HV_BLOCK_SIZE);
|
Hive->Storage[Stable].Length = (ULONG)(ChunkSize / HBLOCK_SIZE);
|
||||||
Hive->Storage[Stable].BlockList =
|
Hive->Storage[Stable].BlockList =
|
||||||
Hive->Allocate(Hive->Storage[Stable].Length *
|
Hive->Allocate(Hive->Storage[Stable].Length *
|
||||||
sizeof(HMAP_ENTRY), FALSE, TAG_CM);
|
sizeof(HMAP_ENTRY), FALSE, TAG_CM);
|
||||||
|
@ -206,9 +206,9 @@ HvpInitializeMemoryHive(
|
||||||
|
|
||||||
for (BlockIndex = 0; BlockIndex < Hive->Storage[Stable].Length; )
|
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 ||
|
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",
|
DPRINT1("Invalid bin at BlockIndex %lu, Signature 0x%x, Size 0x%x\n",
|
||||||
(unsigned long)BlockIndex, (unsigned)Bin->Signature, (unsigned)Bin->Size);
|
(unsigned long)BlockIndex, (unsigned)Bin->Signature, (unsigned)Bin->Size);
|
||||||
|
@ -230,17 +230,17 @@ HvpInitializeMemoryHive(
|
||||||
|
|
||||||
RtlCopyMemory(NewBin, Bin, Bin->Size);
|
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].BinAddress = (ULONG_PTR)NewBin;
|
||||||
Hive->Storage[Stable].BlockList[BlockIndex + i].BlockAddress =
|
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))
|
if (HvpCreateHiveFreeCellList(Hive))
|
||||||
|
@ -313,7 +313,7 @@ HvpGetHiveHeader(IN PHHIVE Hive,
|
||||||
ULONG Alignment;
|
ULONG Alignment;
|
||||||
ULONG Result;
|
ULONG Result;
|
||||||
ULONG Offset = 0;
|
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 */
|
/* Assume failure and allocate the buffer */
|
||||||
*HiveBaseBlock = 0;
|
*HiveBaseBlock = 0;
|
||||||
|
@ -321,7 +321,7 @@ HvpGetHiveHeader(IN PHHIVE Hive,
|
||||||
if (!BaseBlock) return NoMemory;
|
if (!BaseBlock) return NoMemory;
|
||||||
|
|
||||||
/* Check for, and enforce, alignment */
|
/* Check for, and enforce, alignment */
|
||||||
Alignment = Hive->Cluster * HV_BLOCK_SIZE -1;
|
Alignment = Hive->Cluster * HBLOCK_SIZE -1;
|
||||||
if ((ULONG_PTR)BaseBlock & Alignment)
|
if ((ULONG_PTR)BaseBlock & Alignment)
|
||||||
{
|
{
|
||||||
/* Free the old header */
|
/* Free the old header */
|
||||||
|
@ -338,7 +338,7 @@ HvpGetHiveHeader(IN PHHIVE Hive,
|
||||||
HFILE_TYPE_PRIMARY,
|
HFILE_TYPE_PRIMARY,
|
||||||
&Offset,
|
&Offset,
|
||||||
BaseBlock,
|
BaseBlock,
|
||||||
Hive->Cluster * HV_BLOCK_SIZE);
|
Hive->Cluster * HBLOCK_SIZE);
|
||||||
|
|
||||||
/* Couldn't read: assume it's not a hive */
|
/* Couldn't read: assume it's not a hive */
|
||||||
if (!Result) return NotHive;
|
if (!Result) return NotHive;
|
||||||
|
|
|
@ -32,7 +32,7 @@ HvpWriteLog(
|
||||||
|
|
||||||
ASSERT(RegistryHive->ReadOnly == FALSE);
|
ASSERT(RegistryHive->ReadOnly == FALSE);
|
||||||
ASSERT(RegistryHive->BaseBlock->Length ==
|
ASSERT(RegistryHive->BaseBlock->Length ==
|
||||||
RegistryHive->Storage[Stable].Length * HV_BLOCK_SIZE);
|
RegistryHive->Storage[Stable].Length * HBLOCK_SIZE);
|
||||||
|
|
||||||
DPRINT("HvpWriteLog called\n");
|
DPRINT("HvpWriteLog called\n");
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ HvpWriteLog(
|
||||||
|
|
||||||
BitmapSize = RegistryHive->DirtyVector.SizeOfBitMap;
|
BitmapSize = RegistryHive->DirtyVector.SizeOfBitMap;
|
||||||
BufferSize = HV_LOG_HEADER_SIZE + sizeof(ULONG) + BitmapSize;
|
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);
|
DPRINT("Bitmap size %u buffer size: %u\n", BitmapSize, BufferSize);
|
||||||
|
|
||||||
|
@ -95,14 +95,14 @@ HvpWriteLog(
|
||||||
/* Write hive block */
|
/* Write hive block */
|
||||||
Success = RegistryHive->FileWrite(RegistryHive, HFILE_TYPE_LOG,
|
Success = RegistryHive->FileWrite(RegistryHive, HFILE_TYPE_LOG,
|
||||||
&FileOffset, BlockPtr,
|
&FileOffset, BlockPtr,
|
||||||
HV_BLOCK_SIZE);
|
HBLOCK_SIZE);
|
||||||
if (!Success)
|
if (!Success)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockIndex++;
|
BlockIndex++;
|
||||||
FileOffset += HV_BLOCK_SIZE;
|
FileOffset += HBLOCK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Success = RegistryHive->FileSetSize(RegistryHive, HFILE_TYPE_LOG, FileOffset, FileOffset);
|
Success = RegistryHive->FileSetSize(RegistryHive, HFILE_TYPE_LOG, FileOffset, FileOffset);
|
||||||
|
@ -157,7 +157,7 @@ HvpWriteHive(
|
||||||
|
|
||||||
ASSERT(RegistryHive->ReadOnly == FALSE);
|
ASSERT(RegistryHive->ReadOnly == FALSE);
|
||||||
ASSERT(RegistryHive->BaseBlock->Length ==
|
ASSERT(RegistryHive->BaseBlock->Length ==
|
||||||
RegistryHive->Storage[Stable].Length * HV_BLOCK_SIZE);
|
RegistryHive->Storage[Stable].Length * HBLOCK_SIZE);
|
||||||
|
|
||||||
DPRINT("HvpWriteHive called\n");
|
DPRINT("HvpWriteHive called\n");
|
||||||
|
|
||||||
|
@ -197,12 +197,12 @@ HvpWriteHive(
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPtr = (PVOID)RegistryHive->Storage[Stable].BlockList[BlockIndex].BlockAddress;
|
BlockPtr = (PVOID)RegistryHive->Storage[Stable].BlockList[BlockIndex].BlockAddress;
|
||||||
FileOffset = (BlockIndex + 1) * HV_BLOCK_SIZE;
|
FileOffset = (BlockIndex + 1) * HBLOCK_SIZE;
|
||||||
|
|
||||||
/* Write hive block */
|
/* Write hive block */
|
||||||
Success = RegistryHive->FileWrite(RegistryHive, HFILE_TYPE_PRIMARY,
|
Success = RegistryHive->FileWrite(RegistryHive, HFILE_TYPE_PRIMARY,
|
||||||
&FileOffset, BlockPtr,
|
&FileOffset, BlockPtr,
|
||||||
HV_BLOCK_SIZE);
|
HBLOCK_SIZE);
|
||||||
if (!Success)
|
if (!Success)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue