2006-11-08 11:47:44 +00:00
|
|
|
/*
|
2016-01-09 23:42:45 +00:00
|
|
|
* PROJECT: Registry manipulation library
|
2006-11-08 11:47:44 +00:00
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* COPYRIGHT: Copyright 2005 Filip Navara <navaraf@reactos.org>
|
|
|
|
* Copyright 2001 - 2005 Eric Kohl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cmlib.h"
|
2008-08-27 17:54:27 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2007-12-14 13:02:39 +00:00
|
|
|
ULONG CmlibTraceLevel = 0;
|
|
|
|
|
2016-01-14 18:03:35 +00:00
|
|
|
// FIXME: This function must be replaced by CmpCreateRootNode from ntoskrnl/config/cmsysini.c
|
|
|
|
// (and CmpCreateRootNode be moved there).
|
2006-11-08 11:47:44 +00:00
|
|
|
BOOLEAN CMAPI
|
|
|
|
CmCreateRootNode(
|
2016-01-09 23:42:45 +00:00
|
|
|
PHHIVE Hive,
|
|
|
|
PCWSTR Name)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
2016-01-14 18:03:35 +00:00
|
|
|
UNICODE_STRING KeyName;
|
2016-01-09 23:42:45 +00:00
|
|
|
PCM_KEY_NODE KeyCell;
|
|
|
|
HCELL_INDEX RootCellIndex;
|
|
|
|
|
2016-01-14 18:03:35 +00:00
|
|
|
/* Initialize the node name and allocate it */
|
|
|
|
RtlInitUnicodeString(&KeyName, Name);
|
2016-01-09 23:42:45 +00:00
|
|
|
RootCellIndex = HvAllocateCell(Hive,
|
2016-01-14 18:03:35 +00:00
|
|
|
FIELD_OFFSET(CM_KEY_NODE, Name) +
|
|
|
|
CmpNameSize(Hive, &KeyName),
|
2016-01-09 23:42:45 +00:00
|
|
|
Stable,
|
|
|
|
HCELL_NIL);
|
|
|
|
if (RootCellIndex == HCELL_NIL) return FALSE;
|
|
|
|
|
|
|
|
/* Seutp the base block */
|
|
|
|
Hive->BaseBlock->RootCell = RootCellIndex;
|
|
|
|
Hive->BaseBlock->CheckSum = HvpHiveHeaderChecksum(Hive->BaseBlock);
|
|
|
|
|
|
|
|
/* Get the key cell */
|
|
|
|
KeyCell = (PCM_KEY_NODE)HvGetCell(Hive, RootCellIndex);
|
2016-01-17 02:12:37 +00:00
|
|
|
if (!KeyCell)
|
|
|
|
{
|
|
|
|
HvFreeCell(Hive, RootCellIndex);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2016-01-09 23:42:45 +00:00
|
|
|
|
|
|
|
/* Setup the cell */
|
2016-01-14 18:03:35 +00:00
|
|
|
KeyCell->Signature = CM_KEY_NODE_SIGNATURE;
|
2016-01-09 23:42:45 +00:00
|
|
|
KeyCell->Flags = KEY_HIVE_ENTRY | KEY_NO_DELETE;
|
2016-01-14 18:03:35 +00:00
|
|
|
// KeQuerySystemTime(&KeyCell->LastWriteTime);
|
|
|
|
KeyCell->LastWriteTime.QuadPart = 0ULL;
|
2016-01-09 23:42:45 +00:00
|
|
|
KeyCell->Parent = HCELL_NIL;
|
|
|
|
KeyCell->SubKeyCounts[Stable] = 0;
|
|
|
|
KeyCell->SubKeyCounts[Volatile] = 0;
|
|
|
|
KeyCell->SubKeyLists[Stable] = HCELL_NIL;
|
|
|
|
KeyCell->SubKeyLists[Volatile] = HCELL_NIL;
|
|
|
|
KeyCell->ValueList.Count = 0;
|
|
|
|
KeyCell->ValueList.List = HCELL_NIL;
|
|
|
|
KeyCell->Security = HCELL_NIL;
|
|
|
|
KeyCell->Class = HCELL_NIL;
|
|
|
|
KeyCell->ClassLength = 0;
|
|
|
|
KeyCell->MaxNameLen = 0;
|
|
|
|
KeyCell->MaxClassLen = 0;
|
|
|
|
KeyCell->MaxValueNameLen = 0;
|
|
|
|
KeyCell->MaxValueDataLen = 0;
|
2016-01-14 18:03:35 +00:00
|
|
|
KeyCell->NameLength = CmpCopyName(Hive, KeyCell->Name, &KeyName);
|
|
|
|
if (KeyCell->NameLength < KeyName.Length) KeyCell->Flags |= KEY_COMP_NAME;
|
2016-01-09 23:42:45 +00:00
|
|
|
|
|
|
|
/* Return success */
|
|
|
|
HvReleaseCell(Hive, RootCellIndex);
|
|
|
|
return TRUE;
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|