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;
20 HCELL_INDEX RootCellIndex
;
23 /* Allocate the cell */
24 NameSize
= utf16_wcslen(Name
) * sizeof(WCHAR
);
25 RootCellIndex
= HvAllocateCell(Hive
,
26 FIELD_OFFSET(CM_KEY_NODE
, Name
) + NameSize
,
29 if (RootCellIndex
== HCELL_NIL
) return FALSE
;
31 /* Seutp the base block */
32 Hive
->BaseBlock
->RootCell
= RootCellIndex
;
33 Hive
->BaseBlock
->CheckSum
= HvpHiveHeaderChecksum(Hive
->BaseBlock
);
35 /* Get the key cell */
36 KeyCell
= (PCM_KEY_NODE
)HvGetCell(Hive
, RootCellIndex
);
37 if (!KeyCell
) return FALSE
;
40 KeyCell
->Signature
= (USHORT
)CM_KEY_NODE_SIGNATURE
;
41 KeyCell
->Flags
= KEY_HIVE_ENTRY
| KEY_NO_DELETE
;
42 KeyCell
->LastWriteTime
.QuadPart
= 0;
43 KeyCell
->Parent
= HCELL_NIL
;
44 KeyCell
->SubKeyCounts
[Stable
] = 0;
45 KeyCell
->SubKeyCounts
[Volatile
] = 0;
46 KeyCell
->SubKeyLists
[Stable
] = HCELL_NIL
;
47 KeyCell
->SubKeyLists
[Volatile
] = HCELL_NIL
;
48 KeyCell
->ValueList
.Count
= 0;
49 KeyCell
->ValueList
.List
= HCELL_NIL
;
50 KeyCell
->Security
= HCELL_NIL
;
51 KeyCell
->Class
= HCELL_NIL
;
52 KeyCell
->ClassLength
= 0;
53 KeyCell
->MaxNameLen
= 0;
54 KeyCell
->MaxClassLen
= 0;
55 KeyCell
->MaxValueNameLen
= 0;
56 KeyCell
->MaxValueDataLen
= 0;
59 KeyCell
->NameLength
= (USHORT
)NameSize
;
60 memcpy(KeyCell
->Name
, Name
, NameSize
);
63 HvReleaseCell(Hive
, RootCellIndex
);
70 PCM_KEY_NODE KeyCell
);
73 CmpPrepareIndexOfKeys(
75 PCM_KEY_INDEX IndexCell
)
79 if (IndexCell
->Signature
== CM_KEY_INDEX_ROOT
||
80 IndexCell
->Signature
== CM_KEY_INDEX_LEAF
)
82 for (i
= 0; i
< IndexCell
->Count
; i
++)
84 PCM_KEY_INDEX SubIndexCell
= HvGetCell(RegistryHive
, IndexCell
->List
[i
]);
85 if (SubIndexCell
->Signature
== CM_KEY_NODE_SIGNATURE
)
86 CmpPrepareKey(RegistryHive
, (PCM_KEY_NODE
)SubIndexCell
);
88 CmpPrepareIndexOfKeys(RegistryHive
, SubIndexCell
);
91 else if (IndexCell
->Signature
== CM_KEY_FAST_LEAF
||
92 IndexCell
->Signature
== CM_KEY_HASH_LEAF
)
94 PCM_KEY_FAST_INDEX HashCell
= (PCM_KEY_FAST_INDEX
)IndexCell
;
95 for (i
= 0; i
< HashCell
->Count
; i
++)
97 PCM_KEY_NODE SubKeyCell
= HvGetCell(RegistryHive
, HashCell
->List
[i
].Cell
);
98 CmpPrepareKey(RegistryHive
, SubKeyCell
);
103 DPRINT1("IndexCell->Signature %x\n", IndexCell
->Signature
);
111 PCM_KEY_NODE KeyCell
)
113 PCM_KEY_INDEX IndexCell
;
115 ASSERT(KeyCell
->Signature
== CM_KEY_NODE_SIGNATURE
);
117 KeyCell
->SubKeyLists
[Volatile
] = HCELL_NIL
;
118 KeyCell
->SubKeyCounts
[Volatile
] = 0;
120 /* Enumerate and add subkeys */
121 if (KeyCell
->SubKeyCounts
[Stable
] > 0)
123 IndexCell
= HvGetCell(RegistryHive
, KeyCell
->SubKeyLists
[Stable
]);
124 CmpPrepareIndexOfKeys(RegistryHive
, IndexCell
);
132 PCM_KEY_NODE RootCell
;
134 RootCell
= HvGetCell(RegistryHive
, RegistryHive
->BaseBlock
->RootCell
);
135 CmpPrepareKey(RegistryHive
, RootCell
);