14#if !defined(CMLIB_HOST) && !defined(_BLDR_)
56 MoveCount = FastIndex->Count -
Index - 1;
61 &FastIndex->List[
Index + 1],
91 MoveCount = KeyIndex->Count -
Index - 1;
96 &KeyIndex->List[
Index + 1],
127 ASSERT(Index < ValueListNode->ValueList.Count);
130 MoveCount = ValueListNode->ValueList.Count -
Index - 1;
135 &ValueListData->u.KeyList[
Index + 1],
140 ValueListNode->ValueList.Count--;
172 ULONG RootCountIndex;
173 ULONG LeafCountIndex;
180 for (RootCountIndex = 0; RootCountIndex < RootIndex->Count; RootCountIndex++)
190 ASSERT(LeafCell == RootIndex->List[RootCountIndex - 1]);
195 LeafCell = RootIndex->List[RootCountIndex];
199 DPRINT1(
"Couldn't get the leaf from cell\n");
204 for (LeafCountIndex = 0; LeafCountIndex < Leaf->
Count; LeafCountIndex++)
218 if (FastIndex->
List[LeafCountIndex].
Cell == TargetKey)
223 DPRINT1(
"The offending key cell has BEEN FOUND in fast index (fast index 0x%p, index %u)\n",
224 FastIndex, LeafCountIndex);
235 if (Leaf->
List[LeafCountIndex] == TargetKey)
240 DPRINT1(
"The offending key cell has BEEN FOUND in leaf (leaf 0x%p, index %u)\n",
241 Leaf, LeafCountIndex);
252 DPRINT1(
"No target key has been found to remove\n");
291 for (LeafIndex = 0; LeafIndex < Leaf->Count; LeafIndex++)
308 if (FastIndex->
List[LeafIndex].
Cell == TargetKey)
319 DPRINT1(
"The offending key cell has BEEN FOUND in fast index (fast index 0x%p, leaf index %u)\n",
320 FastIndex, LeafIndex);
331 if (Leaf->List[LeafIndex] == TargetKey)
335 DPRINT1(
"The offending key cell has BEEN FOUND in leaf (leaf 0x%p, index %u)\n",
346 DPRINT1(
"No target key has been found to remove\n");
377#if !defined(CMLIB_HOST) && !defined(_BLDR_)
425 ParentRepaired =
FALSE;
430 DPRINT1(
"Self healing not possible\n");
431 return ParentRepaired;
438 DPRINT1(
"Couldn't get the parent key node\n");
439 return ParentRepaired;
446 DPRINT1(
"Couldn't get the key index from parent node\n");
448 return ParentRepaired;
480 DPRINT1(
"The key index signature is invalid (KeyIndex->Signature == %u)",
496 DPRINT1(
"The subkey has been removed, the parent is now repaired\n");
501 return ParentRepaired;
545 DPRINT1(
"Self healing not possible\n");
554 CellData->u.KeyNode.Parent = ParentCell;
597 DPRINT1(
"Self healing not possible\n");
649 DPRINT1(
"Self healing not possible\n");
660 CellData->u.KeyNode.ClassLength = 0;
711 DPRINT1(
"Self healing not possible\n");
723 DPRINT1(
"Could not get a node from the current cell\n");
778 DPRINT1(
"Self healing not possible\n");
786 DPRINT1(
"Could not get a node from the current cell\n");
842 DPRINT1(
"Self healing not possible\n");
895 DPRINT1(
"Self healing not possible\n");
906 CellData->u.KeyNode.SubKeyCounts[
Stable] = 0;
struct _CM_KEY_NODE * PCM_KEY_NODE
#define CM_KEY_INDEX_LEAF
#define CM_KEY_NODE_SIGNATURE
#define CM_KEY_INDEX_ROOT
struct _CM_KEY_FAST_INDEX * PCM_KEY_FAST_INDEX
struct _CM_KEY_INDEX * PCM_KEY_INDEX
static VOID CmpRemoveFastIndexKeyCell(_Inout_ PCM_KEY_FAST_INDEX FastIndex, _In_ ULONG Index, _In_ BOOLEAN UpdateCount)
Removes a cell from a fast key index.
static BOOLEAN CmpRemoveSubKeyInLeaf(_In_ PHHIVE Hive, _In_ PCM_KEY_NODE KeyNode, _In_ PCM_KEY_INDEX Leaf, _In_ HCELL_INDEX TargetKey)
Removes the offending subkey from a leaf index.
BOOLEAN CMAPI CmpRepairValueList(_Inout_ PHHIVE Hive, _In_ HCELL_INDEX CurrentCell, _In_ BOOLEAN FixHive)
Repairs the value list due to corruption. The process involes by purging the whole damaged list.
static VOID CmpRemoveIndexKeyCell(_Inout_ PCM_KEY_INDEX KeyIndex, _In_ ULONG Index)
Removes a cell from a normal key index.
BOOLEAN CMAPI CmIsSelfHealEnabled(_In_ BOOLEAN FixHive)
Checks if self healing is permitted by the kernel and/or bootloader. Self healing is also triggered i...
BOOLEAN CMAPI CmpRepairClassOfNodeKey(_Inout_ PHHIVE Hive, _In_ HCELL_INDEX CurrentCell, _Inout_ PCELL_DATA CellData, _In_ BOOLEAN FixHive)
Repairs the class from damage due to class corruption within the node key.
static VOID CmpRemoveValueFromValueList(_Inout_ PCM_KEY_NODE ValueListNode, _Inout_ PCELL_DATA ValueListData, _In_ ULONG Index)
Removes a cell from a key value list node.
static BOOLEAN CmpRemoveSubkeyInRoot(_In_ PHHIVE Hive, _In_ PCM_KEY_INDEX RootIndex, _In_ HCELL_INDEX TargetKey)
Removes the offending subkey from a root index.
BOOLEAN CMAPI CmpRepairParentNode(_Inout_ PHHIVE Hive, _In_ HCELL_INDEX CurrentCell, _In_ HCELL_INDEX ParentCell, _Inout_ PCELL_DATA CellData, _In_ BOOLEAN FixHive)
Repairs the parent of the node from damage due to parent cell and parent node incosistency.
BOOLEAN CMAPI CmpRepairValueListCount(_Inout_ PHHIVE Hive, _In_ HCELL_INDEX CurrentCell, _In_ ULONG ListCountIndex, _Inout_ PCELL_DATA ValueListData, _In_ BOOLEAN FixHive)
Repairs the value list count of key due to corruption. The process involves by removing one damaged v...
BOOLEAN CMAPI CmpRepairKeyNodeSignature(_Inout_ PHHIVE Hive, _In_ HCELL_INDEX CurrentCell, _Inout_ PCELL_DATA CellData, _In_ BOOLEAN FixHive)
Repairs the key node signature from damage due to signature corruption.
BOOLEAN CMAPI CmpRepairSubKeyCounts(_Inout_ PHHIVE Hive, _In_ HCELL_INDEX CurrentCell, _In_ ULONG Count, _Inout_ PCELL_DATA CellData, _In_ BOOLEAN FixHive)
Repairs the subkey list count due to corruption. The process involves by fixing the count itself with...
BOOLEAN CMAPI CmpRepairSubKeyList(_Inout_ PHHIVE Hive, _In_ HCELL_INDEX CurrentCell, _Inout_ PCELL_DATA CellData, _In_ BOOLEAN FixHive)
Repairs the subkey list due to corruption. The process involves by purging the whole damaged subkeys ...
BOOLEAN CMAPI CmpRepairParentKey(_Inout_ PHHIVE Hive, _In_ HCELL_INDEX TargetKey, _In_ HCELL_INDEX ParentKey, _In_ BOOLEAN FixHive)
Repairs the parent key from damage by removing the offending subkey cell.
#define HvReleaseCell(Hive, Cell)
BOOLEAN CMAPI HvMarkCellDirty(PHHIVE RegistryHive, HCELL_INDEX CellOffset, BOOLEAN HoldingLock)
#define HvGetCell(Hive, Cell)
#define HBOOT_TYPE_SELF_HEAL
CM_INDEX List[ANYSIZE_ARRAY]
HCELL_INDEX List[ANYSIZE_ARRAY]
HCELL_INDEX SubKeyLists[HTYPE_COUNT]
ULONG SubKeyCounts[HTYPE_COUNT]
#define RtlMoveMemory(Destination, Source, Length)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey