ReactOS  0.4.14-dev-614-gbfd8a84
cmi.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VERIFY_KEY_CELL(key)
 

Functions

NTSTATUS CmiInitializeHive (IN OUT PCMHIVE Hive, IN PCWSTR Name)
 
NTSTATUS CmiCreateSecurityKey (IN PHHIVE Hive, IN HCELL_INDEX Cell, IN PUCHAR Descriptor, IN ULONG DescriptorLength)
 
NTSTATUS CmiAddSubKey (IN PCMHIVE RegistryHive, IN HCELL_INDEX ParentKeyCellOffset, IN PCUNICODE_STRING SubKeyName, IN BOOLEAN VolatileKey, OUT HCELL_INDEX *pBlockOffset)
 
NTSTATUS CmiAddValueKey (IN PCMHIVE RegistryHive, IN PCM_KEY_NODE Parent, IN ULONG ChildIndex, IN PCUNICODE_STRING ValueName, OUT PCM_KEY_VALUE *pValueCell, OUT HCELL_INDEX *pValueCellOffset)
 

Macro Definition Documentation

◆ VERIFY_KEY_CELL

#define VERIFY_KEY_CELL (   key)

Definition at line 29 of file cmi.h.

Function Documentation

◆ CmiAddSubKey()

NTSTATUS CmiAddSubKey ( IN PCMHIVE  RegistryHive,
IN HCELL_INDEX  ParentKeyCellOffset,
IN PCUNICODE_STRING  SubKeyName,
IN BOOLEAN  VolatileKey,
OUT HCELL_INDEX pBlockOffset 
)

Definition at line 297 of file cmi.c.

303 {
304  PCM_KEY_NODE ParentKeyCell;
305  HCELL_INDEX NKBOffset;
307 
308  /* Create the new key */
309  Status = CmiCreateSubKey(RegistryHive, ParentKeyCellOffset, SubKeyName, VolatileKey, &NKBOffset);
310  if (!NT_SUCCESS(Status))
311  return Status;
312 
313  /* Mark the parent cell as dirty */
314  HvMarkCellDirty(&RegistryHive->Hive, ParentKeyCellOffset, FALSE);
315 
316  if (!CmpAddSubKey(&RegistryHive->Hive, ParentKeyCellOffset, NKBOffset))
317  {
318  /* FIXME: delete newly created cell */
319  // CmpFreeKeyByCell(&RegistryHive->Hive, NewCell /*NKBOffset*/, FALSE);
320  ASSERT(FALSE);
321  return STATUS_UNSUCCESSFUL;
322  }
323 
324  /* Get the parent node */
325  ParentKeyCell = (PCM_KEY_NODE)HvGetCell(&RegistryHive->Hive, ParentKeyCellOffset);
326  if (!ParentKeyCell)
327  {
328  /* FIXME: delete newly created cell */
329  return STATUS_UNSUCCESSFUL;
330  }
331  VERIFY_KEY_CELL(ParentKeyCell);
332 
333  /* Update the timestamp */
334  KeQuerySystemTime(&ParentKeyCell->LastWriteTime);
335 
336  /* Check if we need to update name maximum, update it if so */
337  if (ParentKeyCell->MaxNameLen < SubKeyName->Length)
338  ParentKeyCell->MaxNameLen = SubKeyName->Length;
339 
340  /* Release the cell */
341  HvReleaseCell(&RegistryHive->Hive, ParentKeyCellOffset);
342 
343  *pBlockOffset = NKBOffset;
344  return STATUS_SUCCESS;
345 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
BOOLEAN NTAPI CmpAddSubKey(IN PHHIVE Hive, IN HCELL_INDEX Parent, IN HCELL_INDEX Child)
Definition: cmindex.c:1467
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4723
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
LONG NTSTATUS
Definition: precomp.h:26
#define VERIFY_KEY_CELL(key)
Definition: cmi.h:29
static NTSTATUS CmiCreateSubKey(IN PCMHIVE RegistryHive, IN HCELL_INDEX ParentKeyCellOffset, IN PCUNICODE_STRING SubKeyName, IN BOOLEAN VolatileKey, OUT HCELL_INDEX *pNKBOffset)
Definition: cmi.c:198
ULONG MaxNameLen
Definition: cmdata.h:109
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
struct _CM_KEY_NODE * PCM_KEY_NODE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG HCELL_INDEX
Definition: hivedata.h:80
BOOLEAN CMAPI HvMarkCellDirty(PHHIVE RegistryHive, HCELL_INDEX CellOffset, BOOLEAN HoldingLock)
Definition: hivecell.c:100
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
LARGE_INTEGER LastWriteTime
Definition: cmdata.h:94
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by RegpCreateOrOpenKey().

◆ CmiAddValueKey()

NTSTATUS CmiAddValueKey ( IN PCMHIVE  RegistryHive,
IN PCM_KEY_NODE  Parent,
IN ULONG  ChildIndex,
IN PCUNICODE_STRING  ValueName,
OUT PCM_KEY_VALUE pValueCell,
OUT HCELL_INDEX pValueCellOffset 
)

Definition at line 348 of file cmi.c.

355 {
358  PCM_KEY_VALUE NewValueCell;
359  HCELL_INDEX NewValueCellOffset;
360 
361  Storage = (Parent->Flags & KEY_IS_VOLATILE) ? Volatile : Stable;
362 
363  NewValueCellOffset = HvAllocateCell(&RegistryHive->Hive,
365  CmpNameSize(&RegistryHive->Hive, (PUNICODE_STRING)ValueName),
366  Storage,
367  HCELL_NIL);
368  if (NewValueCellOffset == HCELL_NIL)
369  {
371  }
372 
373  NewValueCell = (PCM_KEY_VALUE)HvGetCell(&RegistryHive->Hive, NewValueCellOffset);
374  if (NewValueCell == NULL)
375  {
376  HvFreeCell(&RegistryHive->Hive, NewValueCellOffset);
378  }
379 
380  NewValueCell->Signature = CM_KEY_VALUE_SIGNATURE;
381  NewValueCell->NameLength = CmpCopyName(&RegistryHive->Hive,
382  NewValueCell->Name,
384 
385  /* Check for compressed name */
386  if (NewValueCell->NameLength < ValueName->Length)
387  {
388  /* This is a compressed name */
389  NewValueCell->Flags = VALUE_COMP_NAME;
390  }
391  else
392  {
393  /* No flags to set */
394  NewValueCell->Flags = 0;
395  }
396 
397  NewValueCell->Type = 0;
398  NewValueCell->DataLength = 0;
399  NewValueCell->Data = HCELL_NIL;
400 
401  HvMarkCellDirty(&RegistryHive->Hive, NewValueCellOffset, FALSE);
402 
403  /* Check if we already have a value list */
404  if (Parent->ValueList.Count)
405  {
406  /* Then make sure it's valid and dirty it */
407  ASSERT(Parent->ValueList.List != HCELL_NIL);
408  HvMarkCellDirty(&RegistryHive->Hive, Parent->ValueList.List, FALSE);
409  }
410 
411  /* Add this value cell to the child list */
412  Status = CmpAddValueToList(&RegistryHive->Hive,
413  NewValueCellOffset,
414  ChildIndex,
415  Storage,
416  &Parent->ValueList);
417 
418  /* If we failed, free the entire cell, including the data */
419  if (!NT_SUCCESS(Status))
420  {
421  /* Overwrite the status with a known one */
422  CmpFreeValue(&RegistryHive->Hive, NewValueCellOffset);
424  }
425  else
426  {
427  *pValueCell = NewValueCell;
428  *pValueCellOffset = NewValueCellOffset;
430  }
431 
432  return Status;
433 }
#define CM_KEY_VALUE_SIGNATURE
Definition: cmdata.h:24
HCELL_INDEX Data
Definition: cmdata.h:127
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT Flags
Definition: cmdata.h:129
LONG NTSTATUS
Definition: precomp.h:26
#define KEY_IS_VOLATILE
Definition: cmdata.h:30
#define HCELL_NIL
Definition: hivedata.h:85
HCELL_INDEX CMAPI HvAllocateCell(PHHIVE RegistryHive, ULONG Size, HSTORAGE_TYPE Storage, IN HCELL_INDEX Vicinity)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
NTSTATUS NTAPI CmpAddValueToList(IN PHHIVE Hive, IN HCELL_INDEX ValueCell, IN ULONG Index, IN HSTORAGE_TYPE StorageType, IN OUT PCHILD_LIST ChildList)
Definition: cmvalue.c:207
ULONG DataLength
Definition: cmdata.h:126
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
BOOLEAN NTAPI CmpFreeValue(IN PHHIVE Hive, IN HCELL_INDEX Cell)
Definition: cmvalue.c:73
USHORT NameLength
Definition: cmdata.h:125
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
WCHAR Name[ANYSIZE_ARRAY]
Definition: cmdata.h:131
smooth NULL
Definition: ftsmooth.c:416
USHORT NTAPI CmpCopyName(IN PHHIVE Hive, OUT PWCHAR Destination, IN PUNICODE_STRING Source)
Definition: cmname.c:21
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG HCELL_INDEX
Definition: hivedata.h:80
#define VALUE_COMP_NAME
Definition: cmdata.h:44
BOOLEAN CMAPI HvMarkCellDirty(PHHIVE RegistryHive, HCELL_INDEX CellOffset, BOOLEAN HoldingLock)
Definition: hivecell.c:100
USHORT Signature
Definition: cmdata.h:124
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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
Status
Definition: gdiplustypes.h:24
struct _CM_KEY_VALUE * PCM_KEY_VALUE
ULONG Type
Definition: cmdata.h:128
HSTORAGE_TYPE
Definition: hivedata.h:100
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
return STATUS_SUCCESS
Definition: btrfs.c:2938
static IStorage Storage
Definition: ole2.c:3548

Referenced by RegSetValueExW().

◆ CmiCreateSecurityKey()

NTSTATUS CmiCreateSecurityKey ( IN PHHIVE  Hive,
IN HCELL_INDEX  Cell,
IN PUCHAR  Descriptor,
IN ULONG  DescriptorLength 
)

Definition at line 157 of file cmi.c.

162 {
163  HCELL_INDEX SecurityCell;
165  PCM_KEY_SECURITY Security;
166 
167  Node = (PCM_KEY_NODE)HvGetCell(Hive, Cell);
168  SecurityCell = HvAllocateCell(Hive,
170  DescriptorLength,
171  Stable,
172  HCELL_NIL);
173  if (SecurityCell == HCELL_NIL)
174  {
175  HvReleaseCell(Hive, Cell);
177  }
178 
179  Node->Security = SecurityCell;
180  Security = (PCM_KEY_SECURITY)HvGetCell(Hive, SecurityCell);
182  Security->ReferenceCount = 1;
183  Security->DescriptorLength = DescriptorLength;
184 
185  RtlMoveMemory(&Security->Descriptor,
186  Descriptor,
187  DescriptorLength);
188 
189  Security->Flink = Security->Blink = SecurityCell;
190 
191  HvReleaseCell(Hive, SecurityCell);
192  HvReleaseCell(Hive, Cell);
193 
194  return STATUS_SUCCESS;
195 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define CM_KEY_SECURITY_SIGNATURE
Definition: cmdata.h:23
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
#define HCELL_NIL
Definition: hivedata.h:85
HCELL_INDEX Flink
Definition: cmdata.h:141
SECURITY_DESCRIPTOR_RELATIVE Descriptor
Definition: cmdata.h:145
HCELL_INDEX CMAPI HvAllocateCell(PHHIVE RegistryHive, ULONG Size, HSTORAGE_TYPE Storage, IN HCELL_INDEX Vicinity)
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
struct _CM_KEY_SECURITY * PCM_KEY_SECURITY
union node Node
Definition: types.h:1255
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
struct _CM_KEY_NODE * PCM_KEY_NODE
ULONG ReferenceCount
Definition: cmdata.h:143
ULONG HCELL_INDEX
Definition: hivedata.h:80
ULONG DescriptorLength
Definition: cmdata.h:144
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
USHORT Signature
Definition: cmdata.h:139
return STATUS_SUCCESS
Definition: btrfs.c:2938
HCELL_INDEX Blink
Definition: cmdata.h:142
Definition: dlist.c:348
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by ConnectRegistry().

◆ CmiInitializeHive()

NTSTATUS CmiInitializeHive ( IN OUT PCMHIVE  Hive,
IN PCWSTR  Name 
)

Definition at line 114 of file cmi.c.

117 {
119 
120  RtlZeroMemory(Hive, sizeof(*Hive));
121 
122  DPRINT("Hive 0x%p\n", Hive);
123 
124  Status = HvInitialize(&Hive->Hive,
125  HINIT_CREATE,
128  0,
129  CmpAllocate,
130  CmpFree,
132  CmpFileWrite,
133  CmpFileRead,
134  CmpFileFlush,
135  1,
136  NULL);
137  if (!NT_SUCCESS(Status))
138  {
139  return Status;
140  }
141 
142  // HACK: See the HACK from r31253
143  if (!CmCreateRootNode(&Hive->Hive, Name))
144  {
145  HvFree(&Hive->Hive);
147  }
148 
149  /* Add the new hive to the hive list */
151  &Hive->HiveList);
152 
153  return STATUS_SUCCESS;
154 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static BOOLEAN NTAPI CmpFileRead(IN PHHIVE RegistryHive, IN ULONG FileType, IN PULONG FileOffset, OUT PVOID Buffer, IN SIZE_T BufferLength)
Definition: cmi.c:56
NTSTATUS CMAPI HvInitialize(PHHIVE RegistryHive, ULONG OperationType, ULONG HiveFlags, ULONG FileType, PVOID HiveData OPTIONAL, PALLOCATE_ROUTINE Allocate, PFREE_ROUTINE Free, PFILE_SET_SIZE_ROUTINE FileSetSize, PFILE_WRITE_ROUTINE FileWrite, PFILE_READ_ROUTINE FileRead, PFILE_FLUSH_ROUTINE FileFlush, ULONG Cluster OPTIONAL, PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:522
LIST_ENTRY CmiHiveListHead
Definition: registry.c:385
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
static BOOLEAN NTAPI CmpFileFlush(IN PHHIVE RegistryHive, IN ULONG FileType, PLARGE_INTEGER FileOffset, ULONG Length)
Definition: cmi.c:102
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
VOID CMAPI HvFree(PHHIVE RegistryHive)
Definition: hiveinit.c:623
BOOLEAN CMAPI CmCreateRootNode(PHHIVE Hive, PCWSTR Name)
Definition: cminit.c:17
#define HINIT_CREATE
Definition: hivedata.h:13
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI CmpFree(IN PVOID Ptr, IN ULONG Quota)
Definition: cmi.c:47
Status
Definition: gdiplustypes.h:24
static BOOLEAN NTAPI CmpFileSetSize(IN PHHIVE RegistryHive, IN ULONG FileType, IN ULONG FileSize, IN ULONG OldFileSize)
Definition: cmi.c:90
static BOOLEAN NTAPI CmpFileWrite(IN PHHIVE RegistryHive, IN ULONG FileType, IN PULONG FileOffset, IN PVOID Buffer, IN SIZE_T BufferLength)
Definition: cmi.c:73
#define HFILE_TYPE_PRIMARY
Definition: hivedata.h:33
#define HIVE_NOLAZYFLUSH
Definition: hivedata.h:24
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
PVOID NTAPI CmpAllocate(IN SIZE_T Size, IN BOOLEAN Paged, IN ULONG Tag)
Definition: cmi.c:37

Referenced by ConnectRegistry(), and RegInitializeRegistry().