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
16 HCELL_INDEX RootCellIndex
;
19 /* Allocate the cell */
20 NameSize
= wcslen(Name
) * sizeof(WCHAR
);
21 RootCellIndex
= HvAllocateCell(Hive
,
22 FIELD_OFFSET(CM_KEY_NODE
, Name
) + NameSize
,
25 if (RootCellIndex
== HCELL_NIL
) return FALSE
;
27 /* Seutp the base block */
28 Hive
->BaseBlock
->RootCell
= RootCellIndex
;
29 Hive
->BaseBlock
->CheckSum
= HvpHiveHeaderChecksum(Hive
->BaseBlock
);
31 /* Get the key cell */
32 KeyCell
= (PCM_KEY_NODE
)HvGetCell(Hive
, RootCellIndex
);
33 if (!KeyCell
) return FALSE
;
36 KeyCell
->Signature
= (USHORT
)CM_KEY_NODE_SIGNATURE
;
37 KeyCell
->Flags
= KEY_HIVE_ENTRY
| KEY_NO_DELETE
;
38 KeyCell
->LastWriteTime
.QuadPart
= 0;
39 KeyCell
->Parent
= HCELL_NIL
;
40 KeyCell
->SubKeyCounts
[Stable
] = 0;
41 KeyCell
->SubKeyCounts
[Volatile
] = 0;
42 KeyCell
->SubKeyLists
[Stable
] = HCELL_NIL
;
43 KeyCell
->SubKeyLists
[Volatile
] = HCELL_NIL
;
44 KeyCell
->ValueList
.Count
= 0;
45 KeyCell
->ValueList
.List
= HCELL_NIL
;
46 KeyCell
->Security
= HCELL_NIL
;
47 KeyCell
->Class
= HCELL_NIL
;
48 KeyCell
->ClassLength
= 0;
49 KeyCell
->MaxNameLen
= 0;
50 KeyCell
->MaxClassLen
= 0;
51 KeyCell
->MaxValueNameLen
= 0;
52 KeyCell
->MaxValueDataLen
= 0;
55 KeyCell
->NameLength
= (USHORT
)NameSize
;
56 memcpy(KeyCell
->Name
, Name
, NameSize
);
59 HvReleaseCell(Hive
, RootCellIndex
);
68 PCM_KEY_NODE SubKeyCell
;
69 PCM_KEY_FAST_INDEX HashCell
;
72 ASSERT(KeyCell
->Signature
== CM_KEY_NODE_SIGNATURE
);
74 KeyCell
->SubKeyLists
[Volatile
] = HCELL_NIL
;
75 KeyCell
->SubKeyCounts
[Volatile
] = 0;
77 /* Enumerate and add subkeys */
78 if (KeyCell
->SubKeyCounts
[Stable
] > 0)
80 HashCell
= HvGetCell(RegistryHive
, KeyCell
->SubKeyLists
[Stable
]);
82 for (i
= 0; i
< KeyCell
->SubKeyCounts
[Stable
]; i
++)
84 SubKeyCell
= HvGetCell(RegistryHive
, HashCell
->List
[i
].Cell
);
85 CmpPrepareKey(RegistryHive
, SubKeyCell
);
94 PCM_KEY_NODE RootCell
;
96 RootCell
= HvGetCell(RegistryHive
, RegistryHive
->BaseBlock
->RootCell
);
97 CmpPrepareKey(RegistryHive
, RootCell
);