2 * PROJECT: Registry manipulation library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * COPYRIGHT: Copyright 2005 Filip Navara <navaraf@reactos.org>
5 * Copyright 2001 - 2005 Eric Kohl
12 ULONG CmlibTraceLevel
= 0;
14 // FIXME: This function must be replaced by CmpCreateRootNode from ntoskrnl/config/cmsysini.c
15 // (and CmpCreateRootNode be moved there).
21 UNICODE_STRING KeyName
;
23 HCELL_INDEX RootCellIndex
;
25 /* Initialize the node name and allocate it */
26 RtlInitUnicodeString(&KeyName
, Name
);
27 RootCellIndex
= HvAllocateCell(Hive
,
28 FIELD_OFFSET(CM_KEY_NODE
, Name
) +
29 CmpNameSize(Hive
, &KeyName
),
32 if (RootCellIndex
== HCELL_NIL
) return FALSE
;
34 /* Seutp the base block */
35 Hive
->BaseBlock
->RootCell
= RootCellIndex
;
36 Hive
->BaseBlock
->CheckSum
= HvpHiveHeaderChecksum(Hive
->BaseBlock
);
38 /* Get the key cell */
39 KeyCell
= (PCM_KEY_NODE
)HvGetCell(Hive
, RootCellIndex
);
42 HvFreeCell(Hive
, RootCellIndex
);
47 KeyCell
->Signature
= CM_KEY_NODE_SIGNATURE
;
48 KeyCell
->Flags
= KEY_HIVE_ENTRY
| KEY_NO_DELETE
;
49 // KeQuerySystemTime(&KeyCell->LastWriteTime);
50 KeyCell
->LastWriteTime
.QuadPart
= 0ULL;
51 KeyCell
->Parent
= HCELL_NIL
;
52 KeyCell
->SubKeyCounts
[Stable
] = 0;
53 KeyCell
->SubKeyCounts
[Volatile
] = 0;
54 KeyCell
->SubKeyLists
[Stable
] = HCELL_NIL
;
55 KeyCell
->SubKeyLists
[Volatile
] = HCELL_NIL
;
56 KeyCell
->ValueList
.Count
= 0;
57 KeyCell
->ValueList
.List
= HCELL_NIL
;
58 KeyCell
->Security
= HCELL_NIL
;
59 KeyCell
->Class
= HCELL_NIL
;
60 KeyCell
->ClassLength
= 0;
61 KeyCell
->MaxNameLen
= 0;
62 KeyCell
->MaxClassLen
= 0;
63 KeyCell
->MaxValueNameLen
= 0;
64 KeyCell
->MaxValueDataLen
= 0;
65 KeyCell
->NameLength
= CmpCopyName(Hive
, KeyCell
->Name
, &KeyName
);
66 if (KeyCell
->NameLength
< KeyName
.Length
) KeyCell
->Flags
|= KEY_COMP_NAME
;
69 HvReleaseCell(Hive
, RootCellIndex
);
76 PCM_KEY_NODE KeyCell
);
79 CmpPrepareIndexOfKeys(
81 PCM_KEY_INDEX IndexCell
)
85 if (IndexCell
->Signature
== CM_KEY_INDEX_ROOT
||
86 IndexCell
->Signature
== CM_KEY_INDEX_LEAF
)
88 for (i
= 0; i
< IndexCell
->Count
; i
++)
90 PCM_KEY_INDEX SubIndexCell
= HvGetCell(RegistryHive
, IndexCell
->List
[i
]);
91 if (SubIndexCell
->Signature
== CM_KEY_NODE_SIGNATURE
)
92 CmpPrepareKey(RegistryHive
, (PCM_KEY_NODE
)SubIndexCell
);
94 CmpPrepareIndexOfKeys(RegistryHive
, SubIndexCell
);
97 else if (IndexCell
->Signature
== CM_KEY_FAST_LEAF
||
98 IndexCell
->Signature
== CM_KEY_HASH_LEAF
)
100 PCM_KEY_FAST_INDEX HashCell
= (PCM_KEY_FAST_INDEX
)IndexCell
;
101 for (i
= 0; i
< HashCell
->Count
; i
++)
103 PCM_KEY_NODE SubKeyCell
= HvGetCell(RegistryHive
, HashCell
->List
[i
].Cell
);
104 CmpPrepareKey(RegistryHive
, SubKeyCell
);
109 DPRINT1("IndexCell->Signature %x\n", IndexCell
->Signature
);
117 PCM_KEY_NODE KeyCell
)
119 PCM_KEY_INDEX IndexCell
;
121 ASSERT(KeyCell
->Signature
== CM_KEY_NODE_SIGNATURE
);
123 KeyCell
->SubKeyLists
[Volatile
] = HCELL_NIL
;
124 KeyCell
->SubKeyCounts
[Volatile
] = 0;
126 /* Enumerate and add subkeys */
127 if (KeyCell
->SubKeyCounts
[Stable
] > 0)
129 IndexCell
= HvGetCell(RegistryHive
, KeyCell
->SubKeyLists
[Stable
]);
130 CmpPrepareIndexOfKeys(RegistryHive
, IndexCell
);
138 PCM_KEY_NODE RootCell
;
140 RootCell
= HvGetCell(RegistryHive
, RegistryHive
->BaseBlock
->RootCell
);
141 CmpPrepareKey(RegistryHive
, RootCell
);