1 /* 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 6 */ 7 8 #include "cmlib.h" 9 #define NDEBUG 10 #include <debug.h> 11 12 ULONG CmlibTraceLevel = 0; 13 14 // FIXME: This function must be replaced by CmpCreateRootNode from ntoskrnl/config/cmsysini.c 15 // (and CmpCreateRootNode be moved there). 16 BOOLEAN CMAPI 17 CmCreateRootNode( 18 PHHIVE Hive, 19 PCWSTR Name) 20 { 21 UNICODE_STRING KeyName; 22 PCM_KEY_NODE KeyCell; 23 HCELL_INDEX RootCellIndex; 24 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), 30 Stable, 31 HCELL_NIL); 32 if (RootCellIndex == HCELL_NIL) return FALSE; 33 34 /* Seutp the base block */ 35 Hive->BaseBlock->RootCell = RootCellIndex; 36 Hive->BaseBlock->CheckSum = HvpHiveHeaderChecksum(Hive->BaseBlock); 37 38 /* Get the key cell */ 39 KeyCell = (PCM_KEY_NODE)HvGetCell(Hive, RootCellIndex); 40 if (!KeyCell) 41 { 42 HvFreeCell(Hive, RootCellIndex); 43 return FALSE; 44 } 45 46 /* Setup the cell */ 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; 67 68 /* Return success */ 69 HvReleaseCell(Hive, RootCellIndex); 70 return TRUE; 71 } 72