[SDK][CMLIB] Purge volatile data of registry in a proper way with CmCheckRegistry

Thanks to CmCheckRegistry, the function can perform volatile data purging upon boot which this removes old hacky CmPrepareHive code. This also slightly refactors HvInitialize making it more proper.
This commit is contained in:
George Bișoc 2022-10-26 21:29:03 +02:00
parent cc63d8f4a2
commit 4db1b0fb62
No known key found for this signature in database
GPG key ID: 688C4FBE25D7DEF6
3 changed files with 0 additions and 83 deletions

View file

@ -69,74 +69,3 @@ CmCreateRootNode(
HvReleaseCell(Hive, RootCellIndex);
return TRUE;
}
static VOID CMAPI
CmpPrepareKey(
PHHIVE RegistryHive,
PCM_KEY_NODE KeyCell);
static VOID CMAPI
CmpPrepareIndexOfKeys(
PHHIVE RegistryHive,
PCM_KEY_INDEX IndexCell)
{
ULONG i;
if (IndexCell->Signature == CM_KEY_INDEX_ROOT ||
IndexCell->Signature == CM_KEY_INDEX_LEAF)
{
for (i = 0; i < IndexCell->Count; i++)
{
PCM_KEY_INDEX SubIndexCell = (PCM_KEY_INDEX)HvGetCell(RegistryHive, IndexCell->List[i]);
if (SubIndexCell->Signature == CM_KEY_NODE_SIGNATURE)
CmpPrepareKey(RegistryHive, (PCM_KEY_NODE)SubIndexCell);
else
CmpPrepareIndexOfKeys(RegistryHive, SubIndexCell);
}
}
else if (IndexCell->Signature == CM_KEY_FAST_LEAF ||
IndexCell->Signature == CM_KEY_HASH_LEAF)
{
PCM_KEY_FAST_INDEX HashCell = (PCM_KEY_FAST_INDEX)IndexCell;
for (i = 0; i < HashCell->Count; i++)
{
PCM_KEY_NODE SubKeyCell = (PCM_KEY_NODE)HvGetCell(RegistryHive, HashCell->List[i].Cell);
CmpPrepareKey(RegistryHive, SubKeyCell);
}
}
else
{
DPRINT1("IndexCell->Signature %x\n", IndexCell->Signature);
ASSERT(FALSE);
}
}
static VOID CMAPI
CmpPrepareKey(
PHHIVE RegistryHive,
PCM_KEY_NODE KeyCell)
{
PCM_KEY_INDEX IndexCell;
ASSERT(KeyCell->Signature == CM_KEY_NODE_SIGNATURE);
KeyCell->SubKeyCounts[Volatile] = 0;
// KeyCell->SubKeyLists[Volatile] = HCELL_NIL; // FIXME! Done only on Windows < XP.
/* Enumerate and add subkeys */
if (KeyCell->SubKeyCounts[Stable] > 0)
{
IndexCell = (PCM_KEY_INDEX)HvGetCell(RegistryHive, KeyCell->SubKeyLists[Stable]);
CmpPrepareIndexOfKeys(RegistryHive, IndexCell);
}
}
VOID CMAPI
CmPrepareHive(
PHHIVE RegistryHive)
{
PCM_KEY_NODE RootCell;
RootCell = (PCM_KEY_NODE)HvGetCell(RegistryHive, RegistryHive->BaseBlock->RootCell);
CmpPrepareKey(RegistryHive, RootCell);
}

View file

@ -637,11 +637,6 @@ CmCreateRootNode(
PHHIVE Hive,
PCWSTR Name);
VOID CMAPI
CmPrepareHive(
PHHIVE RegistryHive);
/* NT-style Public Cm functions */
//

View file

@ -1443,13 +1443,6 @@ HvInitialize(
}
}
if (!NT_SUCCESS(Status)) return Status;
/* HACK: ROS: Init root key cell and prepare the hive */
// r31253
// if (OperationType == HINIT_CREATE) CmCreateRootNode(Hive, L"");
if (OperationType != HINIT_CREATE) CmPrepareHive(Hive);
return Status;
}