From a4cad7be6bc8251ae65ec46be2b36d8083e11205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 27 Mar 2022 17:41:16 +0200 Subject: [PATCH] [SDK:CMLIB][MKHIVE][BOOT:ENVIRON][NTOS:CONFIG] Add missing HvGetCell casts. Replace some ASSERT(FALSE). --- boot/environ/lib/misc/bootreg.c | 2 +- ntoskrnl/config/cmapi.c | 12 ++++++------ ntoskrnl/config/cmkcbncb.c | 3 +-- ntoskrnl/config/cmparse.c | 8 ++++---- sdk/lib/cmlib/cminit.c | 8 ++++---- sdk/lib/cmlib/cmkeydel.c | 25 +++++++++++++------------ sdk/lib/cmlib/cmse.c | 10 +++++----- sdk/tools/mkhive/registry.c | 4 ++-- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/boot/environ/lib/misc/bootreg.c b/boot/environ/lib/misc/bootreg.c index 957bb122f5f..0551e4c7884 100644 --- a/boot/environ/lib/misc/bootreg.c +++ b/boot/environ/lib/misc/bootreg.c @@ -826,7 +826,7 @@ BiEnumerateSubKeys ( } /* Get the cell data for it */ - Node = HvGetCell(Hive, CellIndex); + Node = (PCM_KEY_NODE)HvGetCell(Hive, CellIndex); if (!Node) { Status = STATUS_REGISTRY_CORRUPT; diff --git a/ntoskrnl/config/cmapi.c b/ntoskrnl/config/cmapi.c index 25daeb46c57..6555658435f 100644 --- a/ntoskrnl/config/cmapi.c +++ b/ntoskrnl/config/cmapi.c @@ -180,7 +180,7 @@ CmpSetValueKeyNew(IN PHHIVE Hive, /* Get the actual data for it */ CellData = HvGetCell(Hive, ValueCell); - if (!CellData) ASSERT(FALSE); + ASSERT(CellData); /* Now we can release it, make sure it's also dirty */ HvReleaseCell(Hive, ValueCell); @@ -355,7 +355,7 @@ CmpSetValueKeyExisting(IN PHHIVE Hive, /* Now get the actual data for our data cell */ CellData = HvGetCell(Hive, NewCell); - if (!CellData) ASSERT(FALSE); + ASSERT(CellData); /* Release it immediately */ HvReleaseCell(Hive, NewCell); @@ -1378,7 +1378,7 @@ CmpQueryKeyDataFromCache( #if DBG /* Get the cell node */ - Node = HvGetCell(KeyHive, KeyCell); + Node = (PCM_KEY_NODE)HvGetCell(KeyHive, KeyCell); if (Node != NULL) { ULONG SubKeyCount; @@ -1457,7 +1457,7 @@ CmpQueryKeyDataFromCache( DPRINT1("Kcb cache incoherency detected, kcb = %p\n", Kcb); /* Get the cell node */ - Node = HvGetCell(KeyHive, KeyCell); + Node = (PCM_KEY_NODE)HvGetCell(KeyHive, KeyCell); if (Node == NULL) { return STATUS_INSUFFICIENT_RESOURCES; @@ -2468,7 +2468,7 @@ CmpDeepCopyKeyInternal(IN PHHIVE SourceHive, DestKeyCell); /* Get the source cell node */ - SrcNode = HvGetCell(SourceHive, SrcKeyCell); + SrcNode = (PCM_KEY_NODE)HvGetCell(SourceHive, SrcKeyCell); ASSERT(SrcNode); /* Sanity check */ @@ -2487,7 +2487,7 @@ CmpDeepCopyKeyInternal(IN PHHIVE SourceHive, } /* Get the destination cell node */ - DestNode = HvGetCell(DestinationHive, NewKeyCell); + DestNode = (PCM_KEY_NODE)HvGetCell(DestinationHive, NewKeyCell); ASSERT(DestNode); /* Set the parent and copy the flags */ diff --git a/ntoskrnl/config/cmkcbncb.c b/ntoskrnl/config/cmkcbncb.c index cb4035f75cc..2241d530ae8 100644 --- a/ntoskrnl/config/cmkcbncb.c +++ b/ntoskrnl/config/cmkcbncb.c @@ -961,8 +961,7 @@ CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb) if the key is not deleted */ if (!DeletedKey && !MyKcb->Delete) { - KeyNode = HvGetCell(MyKcb->KeyHive, MyKcb->KeyCell); - + KeyNode = (PCM_KEY_NODE)HvGetCell(MyKcb->KeyHive, MyKcb->KeyCell); if (!KeyNode) { /* Failure */ diff --git a/ntoskrnl/config/cmparse.c b/ntoskrnl/config/cmparse.c index 2fb6a997f71..52a3219babb 100644 --- a/ntoskrnl/config/cmparse.c +++ b/ntoskrnl/config/cmparse.c @@ -845,7 +845,7 @@ CmpCreateLinkNode(IN PHHIVE Hive, HvMarkCellDirty(Context->ChildHive.KeyHive, ChildCell, FALSE); /* Get the key node */ - KeyNode = HvGetCell(Context->ChildHive.KeyHive, ChildCell); + KeyNode = (PCM_KEY_NODE)HvGetCell(Context->ChildHive.KeyHive, ChildCell); if (!KeyNode) { /* Fail */ @@ -862,7 +862,7 @@ CmpCreateLinkNode(IN PHHIVE Hive, KeyNode->Flags |= KEY_HIVE_ENTRY | KEY_NO_DELETE; /* Get the link node */ - KeyNode = HvGetCell(Hive, LinkCell); + KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, LinkCell); if (!KeyNode) { /* Fail */ @@ -895,7 +895,7 @@ CmpCreateLinkNode(IN PHHIVE Hive, HvReleaseCell(Hive, LinkCell); /* Get the parent node */ - KeyNode = HvGetCell(Hive, Cell); + KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Cell); if (!KeyNode) { /* Fail */ @@ -1183,7 +1183,7 @@ CmpParseKey(IN PVOID ParseObject, /* Get the new node */ Cell = NextCell; Node = (PCM_KEY_NODE)HvGetCell(Hive, Cell); - if (!Node) ASSERT(FALSE); + ASSERT(Node); /* Check if this was the last key */ if (Last) diff --git a/sdk/lib/cmlib/cminit.c b/sdk/lib/cmlib/cminit.c index 699376e75d9..d7c7d208797 100644 --- a/sdk/lib/cmlib/cminit.c +++ b/sdk/lib/cmlib/cminit.c @@ -87,7 +87,7 @@ CmpPrepareIndexOfKeys( { for (i = 0; i < IndexCell->Count; i++) { - PCM_KEY_INDEX SubIndexCell = HvGetCell(RegistryHive, IndexCell->List[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 @@ -100,7 +100,7 @@ CmpPrepareIndexOfKeys( PCM_KEY_FAST_INDEX HashCell = (PCM_KEY_FAST_INDEX)IndexCell; for (i = 0; i < HashCell->Count; i++) { - PCM_KEY_NODE SubKeyCell = HvGetCell(RegistryHive, HashCell->List[i].Cell); + PCM_KEY_NODE SubKeyCell = (PCM_KEY_NODE)HvGetCell(RegistryHive, HashCell->List[i].Cell); CmpPrepareKey(RegistryHive, SubKeyCell); } } @@ -126,7 +126,7 @@ CmpPrepareKey( /* Enumerate and add subkeys */ if (KeyCell->SubKeyCounts[Stable] > 0) { - IndexCell = HvGetCell(RegistryHive, KeyCell->SubKeyLists[Stable]); + IndexCell = (PCM_KEY_INDEX)HvGetCell(RegistryHive, KeyCell->SubKeyLists[Stable]); CmpPrepareIndexOfKeys(RegistryHive, IndexCell); } } @@ -137,6 +137,6 @@ CmPrepareHive( { PCM_KEY_NODE RootCell; - RootCell = HvGetCell(RegistryHive, RegistryHive->BaseBlock->RootCell); + RootCell = (PCM_KEY_NODE)HvGetCell(RegistryHive, RegistryHive->BaseBlock->RootCell); CmpPrepareKey(RegistryHive, RootCell); } diff --git a/sdk/lib/cmlib/cmkeydel.c b/sdk/lib/cmlib/cmkeydel.c index 9baeaa886a7..6a2f9d52214 100644 --- a/sdk/lib/cmlib/cmkeydel.c +++ b/sdk/lib/cmlib/cmkeydel.c @@ -26,7 +26,7 @@ CmpMarkKeyDirty(IN PHHIVE Hive, ULONG i; /* Get the cell data for our target */ - CellData = HvGetCell(Hive, Cell); + CellData = (PCM_KEY_NODE)HvGetCell(Hive, Cell); if (!CellData) return FALSE; /* Check if sanity checks requested */ @@ -63,8 +63,8 @@ CmpMarkKeyDirty(IN PHHIVE Hive, HvMarkCellDirty(Hive, CellData->Security, FALSE); /* Get the security data and release it */ - SecurityData = HvGetCell(Hive, CellData->Security); - if (!SecurityData) ASSERT(FALSE); + SecurityData = (PCM_KEY_SECURITY)HvGetCell(Hive, CellData->Security); + ASSERT(SecurityData); HvReleaseCell(Hive, CellData->Security); /* Mark the security links dirty too */ @@ -81,7 +81,7 @@ CmpMarkKeyDirty(IN PHHIVE Hive, /* Get the list data itself, and release it */ ListData = HvGetCell(Hive, CellData->ValueList.List); - if (!ListData) ASSERT(FALSE); + ASSERT(ListData); HvReleaseCell(Hive, CellData->ValueList.List); /* Loop all values */ @@ -127,8 +127,8 @@ CmpFreeKeyBody(IN PHHIVE Hive, PCM_KEY_NODE CellData; /* Get the key node */ - CellData = HvGetCell(Hive, Cell); - if (!CellData) ASSERT(FALSE); + CellData = (PCM_KEY_NODE)HvGetCell(Hive, Cell); + ASSERT(CellData); /* Check if we can delete the child cells */ if (!(CellData->Flags & KEY_HIVE_EXIT)) @@ -169,8 +169,8 @@ CmpFreeKeyByCell(IN PHHIVE Hive, CmpMarkKeyDirty(Hive, Cell, TRUE); /* Get the target node and release it */ - CellData = HvGetCell(Hive, Cell); - if (!CellData) ASSERT(FALSE); + CellData = (PCM_KEY_NODE)HvGetCell(Hive, Cell); + ASSERT(CellData); HvReleaseCell(Hive, Cell); /* Make sure we don't have subkeys */ @@ -184,8 +184,8 @@ CmpFreeKeyByCell(IN PHHIVE Hive, if (!Result) return STATUS_INSUFFICIENT_RESOURCES; /* Get the parent node and release it */ - ParentData = HvGetCell(Hive, CellData->Parent); - if (!ParentData) ASSERT(FALSE); + ParentData = (PCM_KEY_NODE)HvGetCell(Hive, CellData->Parent); + ASSERT(ParentData); HvReleaseCell(Hive, CellData->Parent); /* Check if the parent node has no more subkeys */ @@ -206,14 +206,15 @@ CmpFreeKeyByCell(IN PHHIVE Hive, { /* Get the value list and release it */ ListData = HvGetCell(Hive, CellData->ValueList.List); - if (!ListData) ASSERT(FALSE); + ASSERT(ListData); HvReleaseCell(Hive, CellData->ValueList.List); /* Loop every value */ for (i = 0; i < CellData->ValueList.Count; i++) { /* Free it */ - if (!CmpFreeValue(Hive, ListData->u.KeyList[i])) ASSERT(FALSE); + Result = CmpFreeValue(Hive, ListData->u.KeyList[i]); + ASSERT(Result); } /* Free the value list */ diff --git a/sdk/lib/cmlib/cmse.c b/sdk/lib/cmlib/cmse.c index 6b3a8c18b65..98a1e035936 100644 --- a/sdk/lib/cmlib/cmse.c +++ b/sdk/lib/cmlib/cmse.c @@ -25,17 +25,17 @@ CmpRemoveSecurityCellList(IN PHHIVE Hive, // ASSERT( (((PCMHIVE)Hive)->HiveSecurityLockOwner == KeGetCurrentThread()) || (CmpTestRegistryLockExclusive() == TRUE) ); - SecurityData = HvGetCell(Hive, SecurityCell); + SecurityData = (PCM_KEY_SECURITY)HvGetCell(Hive, SecurityCell); if (!SecurityData) return; - FlinkCell = HvGetCell(Hive, SecurityData->Flink); + FlinkCell = (PCM_KEY_SECURITY)HvGetCell(Hive, SecurityData->Flink); if (!FlinkCell) { HvReleaseCell(Hive, SecurityCell); return; } - BlinkCell = HvGetCell(Hive, SecurityData->Blink); + BlinkCell = (PCM_KEY_SECURITY)HvGetCell(Hive, SecurityData->Blink); if (!BlinkCell) { HvReleaseCell(Hive, SecurityData->Flink); @@ -72,7 +72,7 @@ CmpFreeSecurityDescriptor(IN PHHIVE Hive, // ASSERT( (((PCMHIVE)Hive)->HiveSecurityLockOwner == KeGetCurrentThread()) || (CmpTestRegistryLockExclusive() == TRUE) ); - CellData = HvGetCell(Hive, Cell); + CellData = (PCM_KEY_NODE)HvGetCell(Hive, Cell); if (!CellData) return; ASSERT(CellData->Signature == CM_KEY_NODE_SIGNATURE); @@ -89,7 +89,7 @@ CmpFreeSecurityDescriptor(IN PHHIVE Hive, return; } - SecurityData = HvGetCell(Hive, CellData->Security); + SecurityData = (PCM_KEY_SECURITY)HvGetCell(Hive, CellData->Security); if (!SecurityData) { HvReleaseCell(Hive, Cell); diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index 9628f67573a..99823e33839 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -733,7 +733,7 @@ RegSetValueExW( else { /* The value already exists, use it. Get the value cell. */ - ValueCell = HvGetCell(&Key->RegistryHive->Hive, CellIndex); + ValueCell = (PCM_KEY_VALUE)HvGetCell(&Key->RegistryHive->Hive, CellIndex); ASSERT(ValueCell != NULL); Status = STATUS_SUCCESS; } @@ -887,7 +887,7 @@ RegQueryValueExW( return ERROR_FILE_NOT_FOUND; // STATUS_OBJECT_NAME_NOT_FOUND; /* Get the value cell */ - ValueCell = HvGetCell(Hive, CellIndex); + ValueCell = (PCM_KEY_VALUE)HvGetCell(Hive, CellIndex); ASSERT(ValueCell != NULL); RepGetValueData(Hive, ValueCell, lpType, lpData, lpcbData);