xref: /reactos/sdk/lib/cmlib/cminit.c (revision 4db1b0fb)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * PROJECT:   Registry manipulation library
3*c2c66affSColin Finck  * LICENSE:   GPL - See COPYING in the top level directory
4*c2c66affSColin Finck  * COPYRIGHT: Copyright 2005 Filip Navara <navaraf@reactos.org>
5*c2c66affSColin Finck  *            Copyright 2001 - 2005 Eric Kohl
6*c2c66affSColin Finck  */
7*c2c66affSColin Finck 
8*c2c66affSColin Finck #include "cmlib.h"
9*c2c66affSColin Finck #define NDEBUG
10*c2c66affSColin Finck #include <debug.h>
11*c2c66affSColin Finck 
12*c2c66affSColin Finck ULONG CmlibTraceLevel = 0;
13*c2c66affSColin Finck 
14*c2c66affSColin Finck // FIXME: This function must be replaced by CmpCreateRootNode from ntoskrnl/config/cmsysini.c
15*c2c66affSColin Finck // (and CmpCreateRootNode be moved there).
16*c2c66affSColin Finck BOOLEAN CMAPI
CmCreateRootNode(PHHIVE Hive,PCWSTR Name)17*c2c66affSColin Finck CmCreateRootNode(
18*c2c66affSColin Finck     PHHIVE Hive,
19*c2c66affSColin Finck     PCWSTR Name)
20*c2c66affSColin Finck {
21*c2c66affSColin Finck     UNICODE_STRING KeyName;
22*c2c66affSColin Finck     PCM_KEY_NODE KeyCell;
23*c2c66affSColin Finck     HCELL_INDEX RootCellIndex;
24*c2c66affSColin Finck 
25*c2c66affSColin Finck     /* Initialize the node name and allocate it */
26*c2c66affSColin Finck     RtlInitUnicodeString(&KeyName, Name);
27*c2c66affSColin Finck     RootCellIndex = HvAllocateCell(Hive,
28*c2c66affSColin Finck                                    FIELD_OFFSET(CM_KEY_NODE, Name) +
29*c2c66affSColin Finck                                    CmpNameSize(Hive, &KeyName),
30*c2c66affSColin Finck                                    Stable,
31*c2c66affSColin Finck                                    HCELL_NIL);
32*c2c66affSColin Finck     if (RootCellIndex == HCELL_NIL) return FALSE;
33*c2c66affSColin Finck 
34*c2c66affSColin Finck     /* Seutp the base block */
35*c2c66affSColin Finck     Hive->BaseBlock->RootCell = RootCellIndex;
36*c2c66affSColin Finck     Hive->BaseBlock->CheckSum = HvpHiveHeaderChecksum(Hive->BaseBlock);
37*c2c66affSColin Finck 
38*c2c66affSColin Finck     /* Get the key cell */
39*c2c66affSColin Finck     KeyCell = (PCM_KEY_NODE)HvGetCell(Hive, RootCellIndex);
40*c2c66affSColin Finck     if (!KeyCell)
41*c2c66affSColin Finck     {
42*c2c66affSColin Finck         HvFreeCell(Hive, RootCellIndex);
43*c2c66affSColin Finck         return FALSE;
44*c2c66affSColin Finck     }
45*c2c66affSColin Finck 
46*c2c66affSColin Finck     /* Setup the cell */
47*c2c66affSColin Finck     KeyCell->Signature = CM_KEY_NODE_SIGNATURE;
48*c2c66affSColin Finck     KeyCell->Flags = KEY_HIVE_ENTRY | KEY_NO_DELETE;
49*c2c66affSColin Finck     // KeQuerySystemTime(&KeyCell->LastWriteTime);
50*c2c66affSColin Finck     KeyCell->LastWriteTime.QuadPart = 0ULL;
51*c2c66affSColin Finck     KeyCell->Parent = HCELL_NIL;
52*c2c66affSColin Finck     KeyCell->SubKeyCounts[Stable] = 0;
53*c2c66affSColin Finck     KeyCell->SubKeyCounts[Volatile] = 0;
54*c2c66affSColin Finck     KeyCell->SubKeyLists[Stable] = HCELL_NIL;
55*c2c66affSColin Finck     KeyCell->SubKeyLists[Volatile] = HCELL_NIL;
56*c2c66affSColin Finck     KeyCell->ValueList.Count = 0;
57*c2c66affSColin Finck     KeyCell->ValueList.List = HCELL_NIL;
58*c2c66affSColin Finck     KeyCell->Security = HCELL_NIL;
59*c2c66affSColin Finck     KeyCell->Class = HCELL_NIL;
60*c2c66affSColin Finck     KeyCell->ClassLength = 0;
61*c2c66affSColin Finck     KeyCell->MaxNameLen = 0;
62*c2c66affSColin Finck     KeyCell->MaxClassLen = 0;
63*c2c66affSColin Finck     KeyCell->MaxValueNameLen = 0;
64*c2c66affSColin Finck     KeyCell->MaxValueDataLen = 0;
65*c2c66affSColin Finck     KeyCell->NameLength = CmpCopyName(Hive, KeyCell->Name, &KeyName);
66*c2c66affSColin Finck     if (KeyCell->NameLength < KeyName.Length) KeyCell->Flags |= KEY_COMP_NAME;
67*c2c66affSColin Finck 
68*c2c66affSColin Finck     /* Return success */
69*c2c66affSColin Finck     HvReleaseCell(Hive, RootCellIndex);
70*c2c66affSColin Finck     return TRUE;
71*c2c66affSColin Finck }
72