ReactOS 0.4.15-dev-5863-g1fe3ab7
cminit.c
Go to the documentation of this file.
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
13
14// FIXME: This function must be replaced by CmpCreateRootNode from ntoskrnl/config/cmsysini.c
15// (and CmpCreateRootNode be moved there).
18 PHHIVE Hive,
20{
22 PCM_KEY_NODE KeyCell;
23 HCELL_INDEX RootCellIndex;
24
25 /* Initialize the node name and allocate it */
27 RootCellIndex = HvAllocateCell(Hive,
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;
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 */
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
73static VOID CMAPI
75 PHHIVE RegistryHive,
76 PCM_KEY_NODE KeyCell);
77
78static VOID CMAPI
80 PHHIVE RegistryHive,
81 PCM_KEY_INDEX IndexCell)
82{
83 ULONG i;
84
85 if (IndexCell->Signature == CM_KEY_INDEX_ROOT ||
86 IndexCell->Signature == CM_KEY_INDEX_LEAF)
87 {
88 for (i = 0; i < IndexCell->Count; i++)
89 {
90 PCM_KEY_INDEX SubIndexCell = (PCM_KEY_INDEX)HvGetCell(RegistryHive, IndexCell->List[i]);
91 if (SubIndexCell->Signature == CM_KEY_NODE_SIGNATURE)
92 CmpPrepareKey(RegistryHive, (PCM_KEY_NODE)SubIndexCell);
93 else
94 CmpPrepareIndexOfKeys(RegistryHive, SubIndexCell);
95 }
96 }
97 else if (IndexCell->Signature == CM_KEY_FAST_LEAF ||
98 IndexCell->Signature == CM_KEY_HASH_LEAF)
99 {
100 PCM_KEY_FAST_INDEX HashCell = (PCM_KEY_FAST_INDEX)IndexCell;
101 for (i = 0; i < HashCell->Count; i++)
102 {
103 PCM_KEY_NODE SubKeyCell = (PCM_KEY_NODE)HvGetCell(RegistryHive, HashCell->List[i].Cell);
104 CmpPrepareKey(RegistryHive, SubKeyCell);
105 }
106 }
107 else
108 {
109 DPRINT1("IndexCell->Signature %x\n", IndexCell->Signature);
110 ASSERT(FALSE);
111 }
112}
113
114static VOID CMAPI
116 PHHIVE RegistryHive,
117 PCM_KEY_NODE KeyCell)
118{
119 PCM_KEY_INDEX IndexCell;
120
122
123 KeyCell->SubKeyCounts[Volatile] = 0;
124 // KeyCell->SubKeyLists[Volatile] = HCELL_NIL; // FIXME! Done only on Windows < XP.
125
126 /* Enumerate and add subkeys */
127 if (KeyCell->SubKeyCounts[Stable] > 0)
128 {
129 IndexCell = (PCM_KEY_INDEX)HvGetCell(RegistryHive, KeyCell->SubKeyLists[Stable]);
130 CmpPrepareIndexOfKeys(RegistryHive, IndexCell);
131 }
132}
133
136 PHHIVE RegistryHive)
137{
138 PCM_KEY_NODE RootCell;
139
140 RootCell = (PCM_KEY_NODE)HvGetCell(RegistryHive, RegistryHive->BaseBlock->RootCell);
141 CmpPrepareKey(RegistryHive, RootCell);
142}
unsigned char BOOLEAN
#define DPRINT1
Definition: precomp.h:8
#define CMAPI
Definition: cfgmgr32.h:41
struct _CM_KEY_NODE * PCM_KEY_NODE
#define KEY_COMP_NAME
Definition: cmdata.h:35
#define KEY_NO_DELETE
Definition: cmdata.h:33
#define CM_KEY_INDEX_LEAF
Definition: cmdata.h:14
#define CM_KEY_NODE_SIGNATURE
Definition: cmdata.h:21
#define CM_KEY_INDEX_ROOT
Definition: cmdata.h:13
struct _CM_KEY_FAST_INDEX * PCM_KEY_FAST_INDEX
#define CM_KEY_FAST_LEAF
Definition: cmdata.h:15
#define KEY_HIVE_ENTRY
Definition: cmdata.h:32
struct _CM_KEY_INDEX * PCM_KEY_INDEX
#define CM_KEY_HASH_LEAF
Definition: cmdata.h:16
#define HvReleaseCell(Hive, Cell)
Definition: cmlib.h:384
USHORT NTAPI CmpCopyName(IN PHHIVE Hive, OUT PWCHAR Destination, IN PCUNICODE_STRING Source)
Definition: cmname.c:21
ULONG CMAPI HvpHiveHeaderChecksum(PHBASE_BLOCK HiveHeader)
Definition: hivesum.c:17
USHORT NTAPI CmpNameSize(IN PHHIVE Hive, IN PCUNICODE_STRING Name)
Definition: cmname.c:74
VOID CMAPI HvFreeCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:468
#define HvGetCell(Hive, Cell)
Definition: cmlib.h:381
HCELL_INDEX CMAPI HvAllocateCell(PHHIVE RegistryHive, ULONG Size, HSTORAGE_TYPE Storage, IN HCELL_INDEX Vicinity)
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ Volatile
Definition: hivedata.h:103
@ Stable
Definition: hivedata.h:102
#define HCELL_NIL
Definition: hivedata.h:85
ULONG HCELL_INDEX
Definition: hivedata.h:80
#define ASSERT(a)
Definition: mode.c:44
#define ULL(a, b)
Definition: format_msg.c:27
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
BOOLEAN CMAPI CmCreateRootNode(PHHIVE Hive, PCWSTR Name)
Definition: cminit.c:17
static VOID CMAPI CmpPrepareIndexOfKeys(PHHIVE RegistryHive, PCM_KEY_INDEX IndexCell)
Definition: cminit.c:79
VOID CMAPI CmPrepareHive(PHHIVE RegistryHive)
Definition: cminit.c:135
static VOID CMAPI CmpPrepareKey(PHHIVE RegistryHive, PCM_KEY_NODE KeyCell)
Definition: cminit.c:115
ULONG CmlibTraceLevel
Definition: cminit.c:12
HCELL_INDEX List
Definition: cmdata.h:75
ULONG Count
Definition: cmdata.h:74
HCELL_INDEX Cell
Definition: cmdata.h:165
CM_INDEX List[ANYSIZE_ARRAY]
Definition: cmdata.h:190
USHORT Signature
Definition: cmdata.h:178
USHORT Count
Definition: cmdata.h:179
HCELL_INDEX List[ANYSIZE_ARRAY]
Definition: cmdata.h:180
USHORT Signature
Definition: cmdata.h:92
HCELL_INDEX Parent
Definition: cmdata.h:96
WCHAR Name[ANYSIZE_ARRAY]
Definition: cmdata.h:116
HCELL_INDEX SubKeyLists[HTYPE_COUNT]
Definition: cmdata.h:102
ULONG MaxValueNameLen
Definition: cmdata.h:111
ULONG MaxNameLen
Definition: cmdata.h:109
ULONG SubKeyCounts[HTYPE_COUNT]
Definition: cmdata.h:97
HCELL_INDEX Security
Definition: cmdata.h:107
USHORT NameLength
Definition: cmdata.h:114
USHORT ClassLength
Definition: cmdata.h:115
ULONG MaxClassLen
Definition: cmdata.h:110
HCELL_INDEX Class
Definition: cmdata.h:108
ULONG MaxValueDataLen
Definition: cmdata.h:112
CHILD_LIST ValueList
Definition: cmdata.h:103
USHORT Flags
Definition: cmdata.h:93
LARGE_INTEGER LastWriteTime
Definition: cmdata.h:94
HCELL_INDEX RootCell
Definition: hivedata.h:143
ULONG CheckSum
Definition: hivedata.h:158
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:303
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699