ReactOS  0.4.14-dev-49-gfb4591c
cminit.c File Reference
#include "cmlib.h"
#include <debug.h>
Include dependency graph for cminit.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN CMAPI CmCreateRootNode (PHHIVE Hive, PCWSTR Name)
 
static VOID CMAPI CmpPrepareKey (PHHIVE RegistryHive, PCM_KEY_NODE KeyCell)
 
static VOID CMAPI CmpPrepareIndexOfKeys (PHHIVE RegistryHive, PCM_KEY_INDEX IndexCell)
 
VOID CMAPI CmPrepareHive (PHHIVE RegistryHive)
 

Variables

ULONG CmlibTraceLevel = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 9 of file cminit.c.

Function Documentation

◆ CmCreateRootNode()

BOOLEAN CMAPI CmCreateRootNode ( PHHIVE  Hive,
PCWSTR  Name 
)

Definition at line 17 of file cminit.c.

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 */
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 }
#define KEY_COMP_NAME
Definition: cmdata.h:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
WCHAR Name[ANYSIZE_ARRAY]
Definition: cmdata.h:116
#define TRUE
Definition: types.h:120
HCELL_INDEX List
Definition: cmdata.h:75
ULONG CMAPI HvpHiveHeaderChecksum(PHBASE_BLOCK HiveHeader)
Definition: hivesum.c:17
ULONG MaxValueNameLen
Definition: cmdata.h:111
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:303
#define CM_KEY_NODE_SIGNATURE
Definition: cmdata.h:21
USHORT ClassLength
Definition: cmdata.h:115
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
#define HCELL_NIL
Definition: hivedata.h:85
HCELL_INDEX CMAPI HvAllocateCell(PHHIVE RegistryHive, ULONG Size, HSTORAGE_TYPE Storage, IN HCELL_INDEX Vicinity)
USHORT NameLength
Definition: cmdata.h:114
ULONG MaxNameLen
Definition: cmdata.h:109
HCELL_INDEX Class
Definition: cmdata.h:108
ULONG CheckSum
Definition: hivedata.h:158
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
HCELL_INDEX SubKeyLists[HTYPE_COUNT]
Definition: cmdata.h:102
struct _CM_KEY_NODE * PCM_KEY_NODE
#define ULL(a, b)
Definition: format_msg.c:27
CHILD_LIST ValueList
Definition: cmdata.h:103
USHORT NTAPI CmpCopyName(IN PHHIVE Hive, OUT PWCHAR Destination, IN PUNICODE_STRING Source)
Definition: cmname.c:21
HCELL_INDEX Parent
Definition: cmdata.h:96
ULONG HCELL_INDEX
Definition: hivedata.h:80
ULONG SubKeyCounts[HTYPE_COUNT]
Definition: cmdata.h:97
USHORT Signature
Definition: cmdata.h:92
VOID CMAPI HvFreeCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:441
USHORT NTAPI CmpNameSize(IN PHHIVE Hive, IN PUNICODE_STRING Name)
Definition: cmname.c:74
LARGE_INTEGER LastWriteTime
Definition: cmdata.h:94
#define KEY_NO_DELETE
Definition: cmdata.h:33
HCELL_INDEX RootCell
Definition: hivedata.h:143
ULONG Count
Definition: cmdata.h:74
HCELL_INDEX Security
Definition: cmdata.h:107
ULONG MaxClassLen
Definition: cmdata.h:110
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
ULONG MaxValueDataLen
Definition: cmdata.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
USHORT Flags
Definition: cmdata.h:93
LONGLONG QuadPart
Definition: typedefs.h:112
#define KEY_HIVE_ENTRY
Definition: cmdata.h:32

Referenced by CmiInitializeHive().

◆ CmpPrepareIndexOfKeys()

static VOID CMAPI CmpPrepareIndexOfKeys ( PHHIVE  RegistryHive,
PCM_KEY_INDEX  IndexCell 
)
static

Definition at line 79 of file cminit.c.

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 = 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 = 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 }
HCELL_INDEX Cell
Definition: cmdata.h:165
#define CM_KEY_NODE_SIGNATURE
Definition: cmdata.h:21
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
USHORT Signature
Definition: cmdata.h:178
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
static VOID CMAPI CmpPrepareIndexOfKeys(PHHIVE RegistryHive, PCM_KEY_INDEX IndexCell)
Definition: cminit.c:79
#define CM_KEY_HASH_LEAF
Definition: cmdata.h:16
CM_INDEX List[ANYSIZE_ARRAY]
Definition: cmdata.h:190
#define CM_KEY_INDEX_ROOT
Definition: cmdata.h:13
struct _CM_KEY_FAST_INDEX * PCM_KEY_FAST_INDEX
static VOID CMAPI CmpPrepareKey(PHHIVE RegistryHive, PCM_KEY_NODE KeyCell)
Definition: cminit.c:115
USHORT Count
Definition: cmdata.h:179
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
HCELL_INDEX List[ANYSIZE_ARRAY]
Definition: cmdata.h:180
#define CM_KEY_FAST_LEAF
Definition: cmdata.h:15
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define CM_KEY_INDEX_LEAF
Definition: cmdata.h:14

Referenced by CmpPrepareKey().

◆ CmpPrepareKey()

static VOID CMAPI CmpPrepareKey ( PHHIVE  RegistryHive,
PCM_KEY_NODE  KeyCell 
)
static

Definition at line 115 of file cminit.c.

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 = HvGetCell(RegistryHive, KeyCell->SubKeyLists[Stable]);
130  CmpPrepareIndexOfKeys(RegistryHive, IndexCell);
131  }
132 }
#define CM_KEY_NODE_SIGNATURE
Definition: cmdata.h:21
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
static VOID CMAPI CmpPrepareIndexOfKeys(PHHIVE RegistryHive, PCM_KEY_INDEX IndexCell)
Definition: cminit.c:79
HCELL_INDEX SubKeyLists[HTYPE_COUNT]
Definition: cmdata.h:102
ULONG SubKeyCounts[HTYPE_COUNT]
Definition: cmdata.h:97
USHORT Signature
Definition: cmdata.h:92
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by CmpPrepareIndexOfKeys(), and CmPrepareHive().

◆ CmPrepareHive()

VOID CMAPI CmPrepareHive ( PHHIVE  RegistryHive)

Definition at line 135 of file cminit.c.

137 {
138  PCM_KEY_NODE RootCell;
139 
140  RootCell = HvGetCell(RegistryHive, RegistryHive->BaseBlock->RootCell);
141  CmpPrepareKey(RegistryHive, RootCell);
142 }
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:303
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
static VOID CMAPI CmpPrepareKey(PHHIVE RegistryHive, PCM_KEY_NODE KeyCell)
Definition: cminit.c:115
HCELL_INDEX RootCell
Definition: hivedata.h:143

Referenced by BiInitializeAndValidateHive(), and HvInitialize().

Variable Documentation

◆ CmlibTraceLevel

ULONG CmlibTraceLevel = 0

Definition at line 12 of file cminit.c.