https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8ccd435eb0b3237c98d39…
commit 8ccd435eb0b3237c98d39f4a55f9bff669ff29a9
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Mar 27 17:30:52 2022 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Mar 27 18:37:16 2022 +0200
[SDK:CMLIB] HvGetCell is a macro calling the hive's GetCellRoutine callback.
In principle there should be different get-cell routines, depending
on the type of the hive (given by the OperationType parameter of
HvInitialize): for flat hives, memory-mapped hives, etc.
For now in ReactOS we only support a restricted subset of these,
therefore we are still happy with a single get-cell callback...
This may change in the future.
---
sdk/lib/cmlib/cmlib.h | 19 +++++++++++--------
sdk/lib/cmlib/hivecell.c | 17 ++++++++---------
sdk/lib/cmlib/hiveinit.c | 5 +++++
3 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/sdk/lib/cmlib/cmlib.h b/sdk/lib/cmlib/cmlib.h
index 1946ec5437b..6b65b73dc17 100644
--- a/sdk/lib/cmlib/cmlib.h
+++ b/sdk/lib/cmlib/cmlib.h
@@ -384,15 +384,13 @@ VOID CMAPI
HvFree(
PHHIVE RegistryHive);
-PVOID CMAPI
-HvGetCell(
- PHHIVE RegistryHive,
- HCELL_INDEX CellOffset);
+#define HvGetCell(Hive, Cell) \
+ (Hive)->GetCellRoutine(Hive, Cell)
-#define HvReleaseCell(h, c) \
-do { \
- if ((h)->ReleaseCellRoutine) \
- (h)->ReleaseCellRoutine(h, c); \
+#define HvReleaseCell(Hive, Cell) \
+do { \
+ if ((Hive)->ReleaseCellRoutine) \
+ (Hive)->ReleaseCellRoutine(Hive, Cell); \
} while(0)
LONG CMAPI
@@ -468,6 +466,11 @@ HvReleaseFreeCellRefArray(
* Private functions.
*/
+PCELL_DATA CMAPI
+HvpGetCellData(
+ _In_ PHHIVE Hive,
+ _In_ HCELL_INDEX CellIndex);
+
PHBIN CMAPI
HvpAddBin(
PHHIVE RegistryHive,
diff --git a/sdk/lib/cmlib/hivecell.c b/sdk/lib/cmlib/hivecell.c
index a267130e494..9820ab8de22 100644
--- a/sdk/lib/cmlib/hivecell.c
+++ b/sdk/lib/cmlib/hivecell.c
@@ -29,13 +29,13 @@ HvpGetCellHeader(
ASSERT(CellBlock < RegistryHive->Storage[CellType].Length);
Block =
(PVOID)RegistryHive->Storage[CellType].BlockList[CellBlock].BlockAddress;
ASSERT(Block != NULL);
- return (PVOID)((ULONG_PTR)Block + CellOffset);
+ return (PHCELL)((ULONG_PTR)Block + CellOffset);
}
else
{
ASSERT(HvGetCellType(CellIndex) == Stable);
- return (PVOID)((ULONG_PTR)RegistryHive->BaseBlock + HBLOCK_SIZE +
- CellIndex);
+ return (PHCELL)((ULONG_PTR)RegistryHive->BaseBlock + HBLOCK_SIZE +
+ CellIndex);
}
}
@@ -63,13 +63,12 @@ HvIsCellAllocated(IN PHHIVE RegistryHive,
return FALSE;
}
-PVOID CMAPI
-HvGetCell(
- PHHIVE RegistryHive,
- HCELL_INDEX CellIndex)
+PCELL_DATA CMAPI
+HvpGetCellData(
+ _In_ PHHIVE Hive,
+ _In_ HCELL_INDEX CellIndex)
{
- ASSERT(CellIndex != HCELL_NIL);
- return (PVOID)(HvpGetCellHeader(RegistryHive, CellIndex) + 1);
+ return (PCELL_DATA)(HvpGetCellHeader(Hive, CellIndex) + 1);
}
static __inline LONG CMAPI
diff --git a/sdk/lib/cmlib/hiveinit.c b/sdk/lib/cmlib/hiveinit.c
index fcbbe08961c..2b070fb4f7e 100644
--- a/sdk/lib/cmlib/hiveinit.c
+++ b/sdk/lib/cmlib/hiveinit.c
@@ -562,6 +562,11 @@ HvInitialize(
#endif
Hive->HiveFlags = HiveFlags & ~HIVE_NOLAZYFLUSH;
+ // TODO: The CellRoutines point to different callbacks
+ // depending on the OperationType.
+ Hive->GetCellRoutine = HvpGetCellData;
+ Hive->ReleaseCellRoutine = NULL;
+
switch (OperationType)
{
case HINIT_CREATE: