ReactOS  0.4.13-dev-100-gc8611ae
cmsysini.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: ntoskrnl/config/cmsysini.c
5  * PURPOSE: Configuration Manager - System Initialization Code
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  * Alex Ionescu (alex.ionescu@reactos.org)
8  */
9 
10 /* INCLUDES *******************************************************************/
11 
12 #include "ntoskrnl.h"
13 #define NDEBUG
14 #include "debug.h"
15 
34 
36 extern BOOLEAN CmFirstTime;
37 
38 /* FUNCTIONS ******************************************************************/
39 
40 BOOLEAN
41 NTAPI
43  _In_z_ PCWSTR LinkKeyName,
44  _In_z_ PCWSTR TargetKeyName)
45 {
49  HANDLE LinkKeyHandle;
51 
52  PAGED_CODE();
53 
54  /* Initialize the object attributes */
55  RtlInitUnicodeString(&KeyName, LinkKeyName);
57  &KeyName,
59  NULL,
60  NULL);
61 
62  /* Create the link key */
63  Status = ZwCreateKey(&LinkKeyHandle,
66  0,
67  NULL,
69  &Disposition);
70  if (!NT_SUCCESS(Status))
71  {
72  DPRINT1("CM: CmpLinkKeyToHive: couldn't create %S, Status = 0x%lx\n",
73  LinkKeyName, Status);
74  return FALSE;
75  }
76 
77  /* Check if the new key was actually created */
79  {
80  DPRINT1("CM: CmpLinkKeyToHive: %S already exists!\n", LinkKeyName);
81  ZwClose(LinkKeyHandle);
82  return FALSE;
83  }
84 
85  /* Set the target key name as link target */
86  RtlInitUnicodeString(&KeyName, TargetKeyName);
87  Status = ZwSetValueKey(LinkKeyHandle,
89  0,
90  REG_LINK,
91  KeyName.Buffer,
92  KeyName.Length);
93 
94  /* Close the link key handle */
95  ObCloseHandle(LinkKeyHandle, KernelMode);
96 
97  if (!NT_SUCCESS(Status))
98  {
99  DPRINT1("CM: CmpLinkKeyToHive: couldn't create symbolic link for %S, Status = 0x%lx\n",
100  TargetKeyName, Status);
101  return FALSE;
102  }
103 
104  return TRUE;
105 }
106 
107 VOID
108 NTAPI
109 CmpDeleteKeyObject(PVOID DeletedObject)
110 {
111  PCM_KEY_BODY KeyBody = (PCM_KEY_BODY)DeletedObject;
113  REG_KEY_HANDLE_CLOSE_INFORMATION KeyHandleCloseInfo;
114  REG_POST_OPERATION_INFORMATION PostOperationInfo;
116  PAGED_CODE();
117 
118  /* First off, prepare the handle close information callback */
119  PostOperationInfo.Object = KeyBody;
120  KeyHandleCloseInfo.Object = KeyBody;
122  &KeyHandleCloseInfo);
123  if (!NT_SUCCESS(Status))
124  {
125  /* If we failed, notify the post routine */
126  PostOperationInfo.Status = Status;
128  return;
129  }
130 
131  /* Acquire hive lock */
132  CmpLockRegistry();
133 
134  /* Make sure this is a valid key body */
135  if (KeyBody->Type == CM_KEY_BODY_TYPE)
136  {
137  /* Get the KCB */
138  Kcb = KeyBody->KeyControlBlock;
139  if (Kcb)
140  {
141  /* Delist the key */
142  DelistKeyBodyFromKCB(KeyBody, FALSE);
143 
144  /* Dereference the KCB */
146  }
147  }
148 
149  /* Release the registry lock */
151 
152  /* Do the post callback */
153  PostOperationInfo.Status = STATUS_SUCCESS;
155 }
156 
157 VOID
158 NTAPI
160  IN PVOID Object,
163  IN ULONG SystemHandleCount)
164 {
165  PCM_KEY_BODY KeyBody = (PCM_KEY_BODY)Object;
166  PAGED_CODE();
167 
168  /* Don't do anything if we're not the last handle */
169  if (SystemHandleCount > 1) return;
170 
171  /* Make sure we're a valid key body */
172  if (KeyBody->Type == CM_KEY_BODY_TYPE)
173  {
174  /* Don't do anything if we don't have a notify block */
175  if (!KeyBody->NotifyBlock) return;
176 
177  /* This shouldn't happen yet */
178  ASSERT(FALSE);
179  }
180 }
181 
182 NTSTATUS
183 NTAPI
185  IN BOOLEAN HasName,
186  IN OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
187  IN ULONG Length,
190 {
194  PCM_KEY_BODY KeyBody = (PCM_KEY_BODY)ObjectBody;
195  PCM_KEY_CONTROL_BLOCK Kcb = KeyBody->KeyControlBlock;
196 
197  /* Acquire hive lock */
198  CmpLockRegistry();
199 
200  /* Lock KCB shared */
202 
203  /* Check if it's a deleted block */
204  if (Kcb->Delete)
205  {
206  /* Release the locks */
207  CmpReleaseKcbLock(Kcb);
209 
210  /* Let the caller know it's deleted */
211  return STATUS_KEY_DELETED;
212  }
213 
214  /* Get the name */
215  KeyName = CmpConstructName(Kcb);
216 
217  /* Release the locks */
218  CmpReleaseKcbLock(Kcb);
220 
221  /* Check if we got the name */
223 
224  /* Set the returned length */
225  *ReturnLength = KeyName->Length + sizeof(OBJECT_NAME_INFORMATION) + sizeof(WCHAR);
226 
227  /* Calculate amount of bytes to copy into the buffer */
228  BytesToCopy = KeyName->Length + sizeof(WCHAR);
229 
230  /* Check if the provided buffer is too small to fit even anything */
231  if ((Length <= sizeof(OBJECT_NAME_INFORMATION)) ||
232  ((Length < (*ReturnLength)) && (BytesToCopy < sizeof(WCHAR))))
233  {
234  /* Free the buffer allocated by CmpConstructName */
236 
237  /* Return buffer length failure without writing anything there because nothing fits */
239  }
240 
241  /* Check if the provided buffer can be partially written */
242  if (Length < (*ReturnLength))
243  {
244  /* Yes, indicate so in the return status */
246 
247  /* Calculate amount of bytes which the provided buffer could handle */
249  }
250 
251  /* Remove the null termination character from the size */
252  BytesToCopy -= sizeof(WCHAR);
253 
254  /* Fill in the result */
255  _SEH2_TRY
256  {
257  /* Return data to user */
258  ObjectNameInfo->Name.Buffer = (PWCHAR)(ObjectNameInfo + 1);
259  ObjectNameInfo->Name.MaximumLength = KeyName->Length;
260  ObjectNameInfo->Name.Length = KeyName->Length;
261 
262  /* Copy string content*/
263  RtlCopyMemory(ObjectNameInfo->Name.Buffer,
264  KeyName->Buffer,
265  BytesToCopy);
266 
267  /* Null terminate it */
268  ObjectNameInfo->Name.Buffer[BytesToCopy / sizeof(WCHAR)] = UNICODE_NULL;
269  }
271  {
272  /* Get the status */
274  }
275  _SEH2_END;
276 
277  /* Free the buffer allocated by CmpConstructName */
279 
280  /* Return status */
281  return Status;
282 }
283 
284 NTSTATUS
285 NTAPI
287  IN ULONG HiveFlags,
288  OUT PCMHIVE *Hive,
289  IN OUT PBOOLEAN New,
290  IN ULONG CheckFlags)
291 {
292  ULONG HiveDisposition, LogDisposition;
295  ULONG Operation, FileType;
296  PCMHIVE NewHive;
297  PAGED_CODE();
298 
299  /* Assume failure */
300  *Hive = NULL;
301 
302  /* Open or create the hive files */
303  Status = CmpOpenHiveFiles(HiveName,
304  L".LOG",
305  &FileHandle,
306  &LogHandle,
307  &HiveDisposition,
308  &LogDisposition,
309  *New,
310  FALSE,
311  TRUE,
312  NULL);
313  if (!NT_SUCCESS(Status)) return Status;
314 
315  /* Check if we have a log handle */
317 
318  /* Check if we created or opened the hive */
319  if (HiveDisposition == FILE_CREATED)
320  {
321  /* Do a create operation */
323  *New = TRUE;
324  }
325  else
326  {
327  /* Open it as a file */
329  *New = FALSE;
330  }
331 
332  /* Check if we're sharing hives */
334  {
335  /* Then force using the primary hive */
336  FileType = HFILE_TYPE_PRIMARY;
337  if (LogHandle)
338  {
339  /* Get rid of the log handle */
341  LogHandle = NULL;
342  }
343  }
344 
345  /* Check if we're too late */
346  if (HvShutdownComplete)
347  {
348  /* Fail */
351  return STATUS_TOO_LATE;
352  }
353 
354  /* Initialize the hive */
355  Status = CmpInitializeHive(&NewHive,
356  Operation,
357  HiveFlags,
358  FileType,
359  NULL,
360  FileHandle,
361  LogHandle,
362  NULL,
363  HiveName,
364  CheckFlags);
365  if (!NT_SUCCESS(Status))
366  {
367  /* Fail */
370  return Status;
371  }
372 
373  /* Success, return hive */
374  *Hive = NewHive;
375 
376  /* Duplicate the hive name */
378  HiveName->Length,
379  TAG_CM);
380  if (NewHive->FileFullPath.Buffer)
381  {
382  /* Copy the string */
384  HiveName->Buffer,
385  HiveName->Length);
386  NewHive->FileFullPath.Length = HiveName->Length;
387  NewHive->FileFullPath.MaximumLength = HiveName->Length;
388  }
389 
390  /* Return success */
391  return STATUS_SUCCESS;
392 }
393 
394 INIT_FUNCTION
395 NTSTATUS
396 NTAPI
398 {
402  UNICODE_STRING KeyName, ValueName = { 0, 0, NULL };
403 
404  ASSERT(LoaderBlock != NULL);
405 
406  /* Setup attributes for loader options */
408  L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\"
409  L"Control");
411  &KeyName,
413  NULL,
414  NULL);
416  if (!NT_SUCCESS(Status))
417  return Status;
418 
419  /* Setup the value for the system start options */
420  RtlInitUnicodeString(&KeyName, L"SystemStartOptions");
422  &KeyName,
423  0,
424  REG_SZ,
427  if (!NT_SUCCESS(Status))
428  goto Quit;
429 
430  /* Setup the value for the system boot device in ARC format */
431  RtlInitUnicodeString(&KeyName, L"SystemBootDevice");
432  RtlCreateUnicodeStringFromAsciiz(&ValueName, LoaderBlock->ArcBootDeviceName);
434  &KeyName,
435  0,
436  REG_SZ,
438  ValueName.Length);
439 
440  /* Free the temporary string */
442 
443 Quit:
444  /* Close the key and return */
446  return Status;
447 }
448 
449 INIT_FUNCTION
450 static
451 NTSTATUS
453 {
456  HANDLE ProfilesHandle = NULL;
457  HANDLE ProfileHandle = NULL;
460 
461  DPRINT("CmpCreateHardwareProfile()\n");
462 
463  /* Create the Hardware Profiles key */
464  RtlInitUnicodeString(&KeyName, L"Hardware Profiles");
466  &KeyName,
468  ControlSetHandle,
469  NULL);
470  Status = NtCreateKey(&ProfilesHandle,
473  0,
474  NULL,
475  0,
476  &Disposition);
477  if (!NT_SUCCESS(Status))
478  {
479  DPRINT1("Creating the Hardware Profile key failed\n");
480  goto done;
481  }
482 
483  /* Sanity check */
485 
486  /* Create the 0000 key */
487  RtlInitUnicodeString(&KeyName, L"0000");
489  &KeyName,
491  ProfilesHandle,
492  NULL);
493  Status = NtCreateKey(&ProfileHandle,
496  0,
497  NULL,
498  0,
499  &Disposition);
500  if (!NT_SUCCESS(Status))
501  {
502  DPRINT1("Creating the Hardware Profile\\0000 key failed\n");
503  goto done;
504  }
505 
506  /* Sanity check */
508 
509 done:
510  if (ProfilesHandle)
511  NtClose(ProfilesHandle);
512 
513  if (ProfileHandle)
514  NtClose(ProfileHandle);
515 
516  DPRINT("CmpCreateHardwareProfile() done\n");
517 
518  return Status;
519 }
520 
521 INIT_FUNCTION
522 NTSTATUS
523 NTAPI
525 {
526  UNICODE_STRING ConfigName = RTL_CONSTANT_STRING(L"Control\\IDConfigDB");
527  UNICODE_STRING SelectName =
528  RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\Select");
531  CHAR ValueInfoBuffer[128];
532  PKEY_VALUE_FULL_INFORMATION ValueInfo;
533  WCHAR UnicodeBuffer[128];
534  HANDLE SelectHandle = NULL;
536  HANDLE ConfigHandle = NULL;
537  HANDLE ProfileHandle = NULL;
538  HANDLE ParentHandle = NULL;
539  ULONG ControlSet, HwProfile;
542  PLOADER_PARAMETER_EXTENSION LoaderExtension;
543  PAGED_CODE();
544 
545  /* ReactOS Hack: Hard-code current to 001 for SetupLdr */
546  if (LoaderBlock->RegistryBase == NULL)
547  {
548  /* Build the ControlSet001 key */
550  L"\\Registry\\Machine\\System\\ControlSet001");
552  &KeyName,
554  NULL,
555  NULL);
559  0,
560  NULL,
561  0,
562  &Disposition);
563  if (!NT_SUCCESS(Status))
564  {
565  DPRINT1("Failed to create ControlSet001 key: 0x%lx\n", Status);
566  goto Cleanup;
567  }
568 
569  /* Create the Hardware Profile keys */
571  if (!NT_SUCCESS(Status))
572  {
573  DPRINT1("Failed to create Hardware profile keys: 0x%lx\n", Status);
574  goto Cleanup;
575  }
576 
577  /* Use hard-coded setting */
578  ControlSet = 1;
579  }
580  else
581  {
582  /* Open the select key */
584  &SelectName,
586  NULL,
587  NULL);
588  Status = NtOpenKey(&SelectHandle, KEY_READ, &ObjectAttributes);
589  if (!NT_SUCCESS(Status))
590  {
591  DPRINT1("Failed to open select key: 0x%lx\n", Status);
592  goto Cleanup;
593  }
594 
595  /* Open the current value */
596  RtlInitUnicodeString(&KeyName, L"Current");
597  Status = NtQueryValueKey(SelectHandle,
598  &KeyName,
600  ValueInfoBuffer,
601  sizeof(ValueInfoBuffer),
602  &ResultLength);
603  if (!NT_SUCCESS(Status))
604  {
605  DPRINT1("Failed to open the Current value: 0x%lx\n", Status);
606  goto Cleanup;
607  }
608 
609  /* Get the actual value pointer, and get the control set ID */
610  ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer;
611  ControlSet = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset);
612  }
613 
614  /* Create the current control set key */
616  L"\\Registry\\Machine\\System\\CurrentControlSet");
618  &KeyName,
620  NULL,
621  NULL);
625  0,
626  NULL,
628  &Disposition);
629  if (!NT_SUCCESS(Status))
630  goto Cleanup;
631 
632  /* Sanity check */
634 
635  /* Initialize the target link name */
636  Status = RtlStringCbPrintfW(UnicodeBuffer, sizeof(UnicodeBuffer),
637  L"\\Registry\\Machine\\System\\ControlSet%03ld",
638  ControlSet);
639  if (!NT_SUCCESS(Status))
640  goto Cleanup;
641 
642  RtlInitUnicodeString(&KeyName, UnicodeBuffer);
643 
644  /* Set the value */
647  0,
648  REG_LINK,
649  KeyName.Buffer,
650  KeyName.Length);
651  if (!NT_SUCCESS(Status))
652  goto Cleanup;
653 
654  /* Get the configuration database key */
656  &ConfigName,
658  KeyHandle,
659  NULL);
660  Status = NtOpenKey(&ConfigHandle, KEY_READ, &ObjectAttributes);
661 
662  /* Check if we don't have one */
663  if (!NT_SUCCESS(Status))
664  {
665  /* Cleanup and exit */
667  goto Cleanup;
668  }
669 
670  /* ReactOS Hack: Hard-code current to 001 for SetupLdr */
671  if (LoaderBlock->RegistryBase == NULL)
672  {
673  HwProfile = 0;
674  }
675  else
676  {
677  /* Now get the current config */
678  RtlInitUnicodeString(&KeyName, L"CurrentConfig");
679  Status = NtQueryValueKey(ConfigHandle,
680  &KeyName,
682  ValueInfoBuffer,
683  sizeof(ValueInfoBuffer),
684  &ResultLength);
685 
686  /* Set pointer to buffer */
687  ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer;
688 
689  /* Check if we failed or got a non DWORD-value */
690  if (!(NT_SUCCESS(Status)) || (ValueInfo->Type != REG_DWORD))
691  {
693  goto Cleanup;
694  }
695 
696  /* Get the hadware profile */
697  HwProfile = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset);
698  }
699 
700  /* Open the hardware profile key */
702  L"\\Registry\\Machine\\System\\CurrentControlSet"
703  L"\\Hardware Profiles");
705  &KeyName,
707  NULL,
708  NULL);
709  Status = NtOpenKey(&ParentHandle, KEY_READ, &ObjectAttributes);
710  if (!NT_SUCCESS(Status))
711  {
712  /* Exit and clean up */
714  goto Cleanup;
715  }
716 
717  /* Build the profile name */
718  RtlStringCbPrintfW(UnicodeBuffer, sizeof(UnicodeBuffer),
719  L"%04ld", HwProfile);
720  RtlInitUnicodeString(&KeyName, UnicodeBuffer);
721 
722  /* Open the associated key */
724  &KeyName,
726  ParentHandle,
727  NULL);
728  Status = NtOpenKey(&ProfileHandle,
731  if (!NT_SUCCESS (Status))
732  {
733  /* Cleanup and exit */
735  goto Cleanup;
736  }
737 
738  /* Check if we have a loader block extension */
739  LoaderExtension = LoaderBlock->Extension;
740  if (LoaderExtension)
741  {
742  DPRINT("ReactOS doesn't support NTLDR Profiles yet!\n");
743  }
744 
745  /* Create the current hardware profile key */
747  L"\\Registry\\Machine\\System\\CurrentControlSet\\"
748  L"Hardware Profiles\\Current");
750  &KeyName,
752  NULL,
753  NULL);
757  0,
758  NULL,
760  &Disposition);
761  if (NT_SUCCESS(Status))
762  {
763  /* Sanity check */
765 
766  /* Create the profile name */
767  RtlStringCbPrintfW(UnicodeBuffer, sizeof(UnicodeBuffer),
768  L"\\Registry\\Machine\\System\\CurrentControlSet\\"
769  L"Hardware Profiles\\%04ld",
770  HwProfile);
771  RtlInitUnicodeString(&KeyName, UnicodeBuffer);
772 
773  /* Set it */
776  0,
777  REG_LINK,
778  KeyName.Buffer,
779  KeyName.Length);
780  }
781 
783 
784 Cleanup:
785  /* Close every opened handle */
786  if (SelectHandle) NtClose(SelectHandle);
788  if (ConfigHandle) NtClose(ConfigHandle);
789  if (ProfileHandle) NtClose(ProfileHandle);
790  if (ParentHandle) NtClose(ParentHandle);
791 
792  DPRINT("CmpCreateControlSet() done\n");
793  return Status;
794 }
795 
796 NTSTATUS
797 NTAPI
800  IN PCMHIVE RegistryHive,
803 {
806  CM_PARSE_CONTEXT ParseContext = {0};
808  PCM_KEY_BODY KeyBody;
809  PAGED_CODE();
810 
811  /* Setup the object attributes */
813  LinkName,
817 
818  /* Setup the parse context */
819  ParseContext.CreateLink = TRUE;
820  ParseContext.CreateOperation = TRUE;
821  ParseContext.ChildHive.KeyHive = &RegistryHive->Hive;
822 
823  /* Check if we have a root keycell or if we need to create it */
824  if (Allocate)
825  {
826  /* Create it */
827  ParseContext.ChildHive.KeyCell = HCELL_NIL;
828  }
829  else
830  {
831  /* We have one */
832  ParseContext.ChildHive.KeyCell = RegistryHive->Hive.BaseBlock->RootCell;
833  }
834 
835  /* Create the link node */
838  KernelMode,
839  NULL,
841  (PVOID)&ParseContext,
842  &KeyHandle);
843  if (!NT_SUCCESS(Status)) return Status;
844 
845  /* Mark the hive as clean */
846  RegistryHive->Hive.DirtyFlag = FALSE;
847 
848  /* ReactOS Hack: Keep alive */
850  0,
852  KernelMode,
853  (PVOID*)&KeyBody,
854  NULL);
856 
857  /* Close the extra handle */
859  return STATUS_SUCCESS;
860 }
861 
862 INIT_FUNCTION
863 BOOLEAN
864 NTAPI
866 {
867  static const UNICODE_STRING HiveName = RTL_CONSTANT_STRING(L"SYSTEM");
868  PVOID HiveBase;
870  PVOID Buffer;
871  ULONG Length;
877 
878  PAGED_CODE();
879 
880  /* Setup the ansi string */
881  RtlInitAnsiString(&LoadString, LoaderBlock->LoadOptions);
882 
883  /* Allocate the unicode buffer */
884  Length = LoadString.Length * sizeof(WCHAR) + sizeof(UNICODE_NULL);
886  if (!Buffer)
887  {
888  /* Fail */
889  KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 3, 1, (ULONG_PTR)LoaderBlock, 0);
890  }
891 
892  /* Setup the unicode string */
893  RtlInitEmptyUnicodeString(&CmpLoadOptions, Buffer, (USHORT)Length);
894 
895  /* Add the load options and null-terminate */
897  if (!NT_SUCCESS(Status))
898  {
899  return FALSE;
900  }
901 
903  CmpLoadOptions.Length += sizeof(WCHAR);
904 
905  /* Get the System Hive base address */
906  HiveBase = LoaderBlock->RegistryBase;
907 
909  HiveBase ? HINIT_MEMORY : HINIT_CREATE,
912  HiveBase,
913  NULL,
914  NULL,
915  NULL,
916  &HiveName,
917  HiveBase ? 2 : 0);
918  if (!NT_SUCCESS(Status))
919  {
920  return FALSE;
921  }
922 
923  /* Set the hive filename */
925  L"\\SystemRoot\\System32\\Config\\SYSTEM");
926  if (!Success)
927  {
928  return FALSE;
929  }
930 
931  /* Manually set the hive as volatile, if in Live CD mode */
932  if (HiveBase && CmpShareSystemHives)
933  {
935  }
936 
937  /* Save the boot type */
939 
940  /* Are we in self-healing mode? */
941  if (!CmSelfHeal)
942  {
943  /* Disable self-healing internally and check if boot type wanted it */
944  CmpSelfHeal = FALSE;
945  if (CmpBootType & 4)
946  {
947  /* We're disabled, so bugcheck */
948  KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO,
949  3,
950  3,
952  0);
953  }
954  }
955 
956  /* Create the default security descriptor */
958 
959  /* Attach it to the system key */
960  /* Let CmpLinkHiveToMaster allocate a new hive if we got none from the LoaderBlock. */
961  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\SYSTEM");
963  NULL,
964  SystemHive,
965  !HiveBase,
967 
968  /* Free the security descriptor */
970  if (!NT_SUCCESS(Status)) return FALSE;
971 
972  /* Add the hive to the hive list */
974 
975  /* Success! */
976  return TRUE;
977 }
978 
979 INIT_FUNCTION
980 NTSTATUS
981 NTAPI
983 {
984  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
986  GENERIC_MAPPING CmpKeyMapping = {KEY_READ,
987  KEY_WRITE,
988  KEY_EXECUTE,
990  PAGED_CODE();
991 
992  /* Initialize the Key object type */
993  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
994  RtlInitUnicodeString(&Name, L"Key");
995  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
996  ObjectTypeInitializer.DefaultPagedPoolCharge = sizeof(CM_KEY_BODY);
997  ObjectTypeInitializer.GenericMapping = CmpKeyMapping;
998  ObjectTypeInitializer.PoolType = PagedPool;
999  ObjectTypeInitializer.ValidAccessMask = KEY_ALL_ACCESS;
1000  ObjectTypeInitializer.UseDefaultObject = TRUE;
1001  ObjectTypeInitializer.DeleteProcedure = CmpDeleteKeyObject;
1002  ObjectTypeInitializer.ParseProcedure = CmpParseKey;
1003  ObjectTypeInitializer.SecurityProcedure = CmpSecurityMethod;
1004  ObjectTypeInitializer.QueryNameProcedure = CmpQueryKeyName;
1005  ObjectTypeInitializer.CloseProcedure = CmpCloseKeyObject;
1006  ObjectTypeInitializer.SecurityRequired = TRUE;
1007  ObjectTypeInitializer.InvalidAttributes = OBJ_EXCLUSIVE | OBJ_PERMANENT;
1008 
1009  /* Create it */
1010  return ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &CmpKeyObjectType);
1011 }
1012 
1013 INIT_FUNCTION
1014 BOOLEAN
1015 NTAPI
1017  IN PCWSTR Name,
1019 {
1021  PCM_KEY_NODE KeyCell;
1022  PAGED_CODE();
1023 
1024  /* Initialize the node name and allocate it */
1026  *Index = HvAllocateCell(Hive,
1028  CmpNameSize(Hive, &KeyName),
1029  Stable,
1030  HCELL_NIL);
1031  if (*Index == HCELL_NIL) return FALSE;
1032 
1033  /* Set the cell index and get the data */
1034  Hive->BaseBlock->RootCell = *Index;
1035  KeyCell = (PCM_KEY_NODE)HvGetCell(Hive, *Index);
1036  if (!KeyCell) return FALSE;
1037 
1038  /* Setup the cell */
1039  KeyCell->Signature = CM_KEY_NODE_SIGNATURE;
1040  KeyCell->Flags = KEY_HIVE_ENTRY | KEY_NO_DELETE;
1041  KeQuerySystemTime(&KeyCell->LastWriteTime);
1042  KeyCell->Parent = HCELL_NIL;
1043  KeyCell->SubKeyCounts[Stable] = 0;
1044  KeyCell->SubKeyCounts[Volatile] = 0;
1045  KeyCell->SubKeyLists[Stable] = HCELL_NIL;
1046  KeyCell->SubKeyLists[Volatile] = HCELL_NIL;
1047  KeyCell->ValueList.Count = 0;
1048  KeyCell->ValueList.List = HCELL_NIL;
1049  KeyCell->Security = HCELL_NIL;
1050  KeyCell->Class = HCELL_NIL;
1051  KeyCell->ClassLength = 0;
1052  KeyCell->MaxNameLen = 0;
1053  KeyCell->MaxClassLen = 0;
1054  KeyCell->MaxValueNameLen = 0;
1055  KeyCell->MaxValueDataLen = 0;
1056 
1057  /* Copy the name (this will also set the length) */
1058  KeyCell->NameLength = CmpCopyName(Hive, KeyCell->Name, &KeyName);
1059 
1060  /* Check if the name was compressed and set the flag if so */
1061  if (KeyCell->NameLength < KeyName.Length)
1062  KeyCell->Flags |= KEY_COMP_NAME;
1063 
1064  /* Return success */
1065  HvReleaseCell(Hive, *Index);
1066  return TRUE;
1067 }
1068 
1069 INIT_FUNCTION
1070 BOOLEAN
1071 NTAPI
1073 {
1077  HCELL_INDEX RootIndex;
1078  NTSTATUS Status;
1079  PCM_KEY_NODE KeyCell;
1082  PAGED_CODE();
1083 
1084  /* Setup the root node */
1085  if (!CmpCreateRootNode(&CmiVolatileHive->Hive, L"REGISTRY", &RootIndex))
1086  {
1087  /* We failed */
1088  return FALSE;
1089  }
1090 
1091  /* Create '\Registry' key. */
1092  RtlInitUnicodeString(&KeyName, L"\\REGISTRY");
1095  &KeyName,
1097  NULL,
1102  KernelMode,
1103  NULL,
1104  sizeof(CM_KEY_BODY),
1105  0,
1106  0,
1107  (PVOID*)&RootKey);
1109  if (!NT_SUCCESS(Status)) return FALSE;
1110 
1111  /* Sanity check, and get the key cell */
1112  ASSERT((&CmiVolatileHive->Hive)->ReleaseCellRoutine == NULL);
1113  KeyCell = (PCM_KEY_NODE)HvGetCell(&CmiVolatileHive->Hive, RootIndex);
1114  if (!KeyCell) return FALSE;
1115 
1116  /* Create the KCB */
1117  RtlInitUnicodeString(&KeyName, L"\\REGISTRY");
1119  RootIndex,
1120  KeyCell,
1121  NULL,
1122  0,
1123  &KeyName);
1124  if (!Kcb)
1125  {
1127  return FALSE;
1128  }
1129 
1130  /* Initialize the object */
1131  RootKey->KeyControlBlock = Kcb;
1132  RootKey->Type = CM_KEY_BODY_TYPE;
1133  RootKey->NotifyBlock = NULL;
1134  RootKey->ProcessID = PsGetCurrentProcessId();
1135 
1136  /* Link with KCB */
1138 
1139  /* Insert the key into the namespace */
1141  NULL,
1143  0,
1144  NULL,
1146  if (!NT_SUCCESS(Status))
1147  {
1149  return FALSE;
1150  }
1151 
1152  /* Reference the key again so that we never lose it */
1154  KEY_READ,
1155  NULL,
1156  KernelMode,
1157  (PVOID*)&RootKey,
1158  NULL);
1159  if (!NT_SUCCESS(Status))
1160  {
1162  return FALSE;
1163  }
1164 
1165  /* Completely sucessful */
1166  return TRUE;
1167 }
1168 
1169 static NTSTATUS
1171 {
1172  /* Just use default path */
1173  wcscpy(ConfigPath, L"\\SystemRoot");
1174 
1175  /* Check if we are booted in setup */
1176  if (!ExpInTextModeSetup)
1177  {
1178  /* Add registry path */
1179 #if 0
1180  ResultSize = wcslen(ConfigPath);
1181  if (ResultSize && ConfigPath[ResultSize - 1] == L'\\')
1182  ConfigPath[ResultSize - 1] = UNICODE_NULL;
1183 #endif
1184  wcscat(ConfigPath, L"\\System32\\Config\\");
1185  }
1186  else
1187  {
1188  wcscat(ConfigPath, L"\\");
1189  }
1190 
1191  DPRINT1("CmpGetRegistryPath: ConfigPath = '%S'\n", ConfigPath);
1192 
1193  /* Done */
1194  return STATUS_SUCCESS;
1195 }
1196 
1197 _Function_class_(KSTART_ROUTINE)
1198 VOID
1199 NTAPI
1200 CmpLoadHiveThread(IN PVOID StartContext)
1201 {
1202  WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH];
1203  UNICODE_STRING TempName, FileName, RegName;
1204  ULONG i, ErrorResponse, WorkerCount, Length;
1205  USHORT FileStart;
1206  ULONG PrimaryDisposition, SecondaryDisposition, ClusterSize;
1207  PCMHIVE CmHive;
1208  HANDLE PrimaryHandle = NULL, LogHandle = NULL;
1210  PVOID ErrorParameters;
1211  PAGED_CODE();
1212 
1213  /* Get the hive index, make sure it makes sense */
1214  i = PtrToUlong(StartContext);
1216 
1217  /* We were started */
1219 
1220  /* Build the file name and registry name strings */
1221  RtlInitEmptyUnicodeString(&FileName, FileBuffer, sizeof(FileBuffer));
1222  RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
1223 
1224  /* Now build the system root path */
1225  CmpGetRegistryPath(ConfigPath);
1226  RtlInitUnicodeString(&TempName, ConfigPath);
1228  FileStart = FileName.Length;
1229 
1230  /* And build the registry root path */
1231  RtlInitUnicodeString(&TempName, L"\\REGISTRY\\");
1232  RtlAppendUnicodeStringToString(&RegName, &TempName);
1233 
1234  /* Build the base name */
1235  RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].BaseName);
1236  RtlAppendUnicodeStringToString(&RegName, &TempName);
1237 
1238  /* Check if this is a child of the root */
1239  if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == OBJ_NAME_PATH_SEPARATOR)
1240  {
1241  /* Then setup the whole name */
1243  RtlAppendUnicodeStringToString(&RegName, &TempName);
1244  }
1245 
1246  /* Now add the rest of the file name */
1248  FileName.Length = FileStart;
1250  if (!CmpMachineHiveList[i].CmHive)
1251  {
1252  /* We need to allocate a new hive structure */
1254 
1255  /* Load the hive file */
1257  CmpMachineHiveList[i].HHiveFlags,
1258  &CmHive,
1260  0);
1261  if (!(NT_SUCCESS(Status)) ||
1263  {
1264  /*
1265  * We failed, or could not get a log file (unless
1266  * the hive is shared), raise a hard error.
1267  */
1268  ErrorParameters = &FileName;
1270  1,
1271  1,
1272  (PULONG_PTR)&ErrorParameters,
1273  OptionOk,
1274  &ErrorResponse);
1275  }
1276 
1277  /* Set the hive flags and newly allocated hive pointer */
1280  }
1281  else
1282  {
1283  /* We already have a hive, is it volatile? */
1285  if (!(CmHive->Hive.HiveFlags & HIVE_VOLATILE))
1286  {
1287  /* It's now, open the hive file and log */
1289  L".LOG",
1290  &PrimaryHandle,
1291  &LogHandle,
1292  &PrimaryDisposition,
1293  &SecondaryDisposition,
1294  TRUE,
1295  TRUE,
1296  FALSE,
1297  &ClusterSize);
1298  if (!(NT_SUCCESS(Status)) || !(LogHandle))
1299  {
1300  /* Couldn't open the hive or its log file, raise a hard error */
1301  ErrorParameters = &FileName;
1303  1,
1304  1,
1305  (PULONG_PTR)&ErrorParameters,
1306  OptionOk,
1307  &ErrorResponse);
1308 
1309  /* And bugcheck for posterity's sake */
1310  KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 9, 0, i, Status);
1311  }
1312 
1313  /* Save the file handles. This should remove our sync hacks */
1315  CmHive->FileHandles[HFILE_TYPE_PRIMARY] = PrimaryHandle;
1316 
1317  /* Allow lazy flushing since the handles are there -- remove sync hacks */
1318  //ASSERT(CmHive->Hive.HiveFlags & HIVE_NOLAZYFLUSH);
1320 
1321  /* Get the real size of the hive */
1323 
1324  /* Check if the cluster size doesn't match */
1325  if (CmHive->Hive.Cluster != ClusterSize)
1326  {
1327  DPRINT1("FIXME: Support for CmHive->Hive.Cluster (%lu) != ClusterSize (%lu) is unimplemented!\n",
1329  }
1330 
1331  /* Set the file size */
1332  DPRINT("FIXME: Should set file size: %lu\n", Length);
1333  //if (!CmpFileSetSize((PHHIVE)CmHive, HFILE_TYPE_PRIMARY, Length, Length))
1334  //{
1335  /* This shouldn't fail */
1336  //ASSERT(FALSE);
1337  //}
1338 
1339  /* Another thing we don't support is NTLDR-recovery */
1341 
1342  /* Finally, set our allocated hive to the same hive we've had */
1345  }
1346  }
1347 
1348  /* We're done */
1350 
1351  /* Check if we're the last worker */
1353  if (WorkerCount == CM_NUMBER_OF_MACHINE_HIVES)
1354  {
1355  /* Signal the event */
1357  }
1358 
1359  /* Kill the thread */
1361 }
1362 
1363 VOID
1364 NTAPI
1366 {
1367  WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH];
1368  UNICODE_STRING TempName, FileName, RegName;
1369  HANDLE Thread;
1370  NTSTATUS Status;
1371  ULONG i;
1372  USHORT RegStart;
1374  PAGED_CODE();
1375 
1376  /* Allow writing for now */
1377  CmpNoWrite = FALSE;
1378 
1379  /* Build the file name and registry name strings */
1380  RtlInitEmptyUnicodeString(&FileName, FileBuffer, sizeof(FileBuffer));
1381  RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
1382 
1383  /* Now build the system root path */
1384  CmpGetRegistryPath(ConfigPath);
1385  RtlInitUnicodeString(&TempName, ConfigPath);
1387 
1388  /* And build the registry root path */
1389  RtlInitUnicodeString(&TempName, L"\\REGISTRY\\");
1390  RtlAppendUnicodeStringToString(&RegName, &TempName);
1391  RegStart = RegName.Length;
1392 
1393  /* Setup the event to synchronize workers */
1395 
1396  /* Enter special boot condition */
1398 
1399  /* Create the SD for the root hives */
1401 
1402  /* Loop every hive we care about */
1403  for (i = 0; i < CM_NUMBER_OF_MACHINE_HIVES; i++)
1404  {
1405  /* Make sure the list is set up */
1407 
1408  /* Load the hive as volatile, if in LiveCD mode */
1409  if (CmpShareSystemHives)
1411 
1412  /* Create a thread to handle this hive */
1415  NULL,
1416  0,
1417  NULL,
1418  CmpLoadHiveThread,
1419  UlongToPtr(i));
1420  if (NT_SUCCESS(Status))
1421  {
1422  /* We don't care about the handle -- the thread self-terminates */
1423  ZwClose(Thread);
1424  }
1425  else
1426  {
1427  /* Can't imagine this happening */
1428  KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 9, 3, i, Status);
1429  }
1430  }
1431 
1432  /* Make sure we've reached the end of the list */
1434 
1435  /* Wait for hive loading to finish */
1437  Executive,
1438  KernelMode,
1439  FALSE,
1440  NULL);
1441 
1442  /* Exit the special boot condition and make sure all workers completed */
1445 
1446  /* Loop hives again */
1447  for (i = 0; i < CM_NUMBER_OF_MACHINE_HIVES; i++)
1448  {
1449  /* Make sure the thread ran and finished */
1450  ASSERT(CmpMachineHiveList[i].ThreadFinished == TRUE);
1451  ASSERT(CmpMachineHiveList[i].ThreadStarted == TRUE);
1452 
1453  /* Check if this was a new hive */
1454  if (!CmpMachineHiveList[i].CmHive)
1455  {
1456  /* Make sure we allocated something */
1457  ASSERT(CmpMachineHiveList[i].CmHive2 != NULL);
1458 
1459  /* Build the base name */
1460  RegName.Length = RegStart;
1461  RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].BaseName);
1462  RtlAppendUnicodeStringToString(&RegName, &TempName);
1463 
1464  /* Check if this is a child of the root */
1465  if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == OBJ_NAME_PATH_SEPARATOR)
1466  {
1467  /* Then setup the whole name */
1469  RtlAppendUnicodeStringToString(&RegName, &TempName);
1470  }
1471 
1472  /* Now link the hive to its master */
1473  Status = CmpLinkHiveToMaster(&RegName,
1474  NULL,
1475  CmpMachineHiveList[i].CmHive2,
1478  if (Status != STATUS_SUCCESS)
1479  {
1480  /* Linking needs to work */
1481  KeBugCheckEx(CONFIG_LIST_FAILED, 11, Status, i, (ULONG_PTR)&RegName);
1482  }
1483 
1484  /* Check if we had to allocate a new hive */
1486  {
1487  /* Sync the new hive */
1488  //HvSyncHive((PHHIVE)(CmpMachineHiveList[i].CmHive2));
1489  }
1490  }
1491 
1492  /* Check if we created a new hive */
1493  if (CmpMachineHiveList[i].CmHive2)
1494  {
1495  /* Add to HiveList key */
1497  }
1498  }
1499 
1500  /* Get rid of the SD */
1502 
1503  /* Link SECURITY to SAM */
1504  CmpLinkKeyToHive(L"\\Registry\\Machine\\Security\\SAM",
1505  L"\\Registry\\Machine\\SAM\\SAM");
1506 
1507  /* Link S-1-5-18 to .Default */
1509  CmpLinkKeyToHive(L"\\Registry\\User\\S-1-5-18",
1510  L"\\Registry\\User\\.Default");
1512 }
1513 
1514 INIT_FUNCTION
1515 BOOLEAN
1516 NTAPI
1518 {
1521  HANDLE KeyHandle;
1522  NTSTATUS Status;
1523  PCMHIVE HardwareHive;
1525  PAGED_CODE();
1526 
1527  /* Check if this is PE-boot */
1528  if (InitIsWinPEMode)
1529  {
1530  /* Set registry to PE mode */
1531  CmpMiniNTBoot = TRUE;
1533  }
1534 
1535  /* Initialize the hive list and lock */
1539 
1540  /* Initialize registry lock */
1542 
1543  /* Initialize the cache */
1545 
1546  /* Initialize allocation and delayed dereferencing */
1550 
1551  /* Initialize callbacks */
1552  CmpInitCallback();
1553 
1554  /* Initialize self healing */
1557 
1558  /* Save the current process and lock the registry */
1560 
1561  /* Create the key object types */
1563  if (!NT_SUCCESS(Status))
1564  {
1565  /* Bugcheck */
1566  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 1, Status, 0);
1567  }
1568 
1569  /* Build the master hive */
1571  HINIT_CREATE,
1572  HIVE_VOLATILE,
1574  NULL,
1575  NULL,
1576  NULL,
1577  NULL,
1578  NULL,
1579  0);
1580  if (!NT_SUCCESS(Status))
1581  {
1582  /* Bugcheck */
1583  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 2, Status, 0);
1584  }
1585 
1586  /* Create the \REGISTRY key node */
1587  if (!CmpCreateRegistryRoot())
1588  {
1589  /* Bugcheck */
1590  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 3, 0, 0);
1591  }
1592 
1593  /* Create the default security descriptor */
1595 
1596  /* Create '\Registry\Machine' key */
1597  RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE");
1599  &KeyName,
1601  NULL,
1604  KEY_READ | KEY_WRITE,
1606  0,
1607  NULL,
1608  0,
1609  NULL);
1610  if (!NT_SUCCESS(Status))
1611  {
1612  /* Bugcheck */
1613  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 5, Status, 0);
1614  }
1615 
1616  /* Close the handle */
1617  NtClose(KeyHandle);
1618 
1619  /* Create '\Registry\User' key */
1620  RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\USER");
1622  &KeyName,
1624  NULL,
1627  KEY_READ | KEY_WRITE,
1629  0,
1630  NULL,
1631  0,
1632  NULL);
1633  if (!NT_SUCCESS(Status))
1634  {
1635  /* Bugcheck */
1636  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 6, Status, 0);
1637  }
1638 
1639  /* Close the handle */
1640  NtClose(KeyHandle);
1641 
1642  /* After this point, do not allow creating keys in the master hive */
1644 
1645  /* Initialize the system hive */
1647  {
1648  /* Bugcheck */
1649  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 7, 0, 0);
1650  }
1651 
1652  /* Create the 'CurrentControlSet' link */
1654  if (!NT_SUCCESS(Status))
1655  {
1656  /* Bugcheck */
1657  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 8, Status, 0);
1658  }
1659 
1660  /* Create the hardware hive */
1661  Status = CmpInitializeHive(&HardwareHive,
1662  HINIT_CREATE,
1663  HIVE_VOLATILE,
1665  NULL,
1666  NULL,
1667  NULL,
1668  NULL,
1669  NULL,
1670  0);
1671  if (!NT_SUCCESS(Status))
1672  {
1673  /* Bugcheck */
1674  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 11, Status, 0);
1675  }
1676 
1677  /* Add the hive to the hive list */
1678  CmpMachineHiveList[0].CmHive = HardwareHive;
1679 
1680  /* Attach it to the machine key */
1681  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE");
1683  NULL,
1684  HardwareHive,
1685  TRUE,
1687  if (!NT_SUCCESS(Status))
1688  {
1689  /* Bugcheck */
1690  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 12, Status, 0);
1691  }
1692 
1693  /* Add to HiveList key */
1694  CmpAddToHiveFileList(HardwareHive);
1695 
1696  /* Free the security descriptor */
1698 
1699  /* Fill out the Hardware key with the ARC Data from the Loader */
1701  if (!NT_SUCCESS(Status))
1702  {
1703  /* Bugcheck */
1704  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 13, Status, 0);
1705  }
1706 
1707  /* Initialize machine-dependent information into the registry */
1709  if (!NT_SUCCESS(Status))
1710  {
1711  /* Bugcheck */
1712  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 14, Status, 0);
1713  }
1714 
1715  /* Initialize volatile registry settings */
1717  if (!NT_SUCCESS(Status))
1718  {
1719  /* Bugcheck */
1720  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 15, Status, 0);
1721  }
1722 
1723  /* Free the load options */
1725 
1726  /* If we got here, all went well */
1727  return TRUE;
1728 }
1729 
1730 INIT_FUNCTION
1731 VOID
1732 NTAPI
1734  IN PLIST_ENTRY DriverList)
1735 {
1736  PLIST_ENTRY NextEntry, OldEntry;
1737  PBOOT_DRIVER_NODE DriverNode;
1738  PAGED_CODE();
1739 
1740  /* Parse the current list */
1741  NextEntry = DriverList->Flink;
1742  while (NextEntry != DriverList)
1743  {
1744  /* Get the driver node */
1745  DriverNode = CONTAINING_RECORD(NextEntry, BOOT_DRIVER_NODE, ListEntry.Link);
1746 
1747  /* Get the next entry now, since we're going to free it later */
1748  OldEntry = NextEntry;
1749  NextEntry = NextEntry->Flink;
1750 
1751  /* Was there a name? */
1752  if (DriverNode->Name.Buffer)
1753  {
1754  /* Free it */
1755  CmpFree(DriverNode->Name.Buffer, DriverNode->Name.Length);
1756  }
1757 
1758  /* Was there a registry path? */
1759  if (DriverNode->ListEntry.RegistryPath.Buffer)
1760  {
1761  /* Free it */
1762  CmpFree(DriverNode->ListEntry.RegistryPath.Buffer,
1763  DriverNode->ListEntry.RegistryPath.MaximumLength);
1764  }
1765 
1766  /* Was there a file path? */
1767  if (DriverNode->ListEntry.FilePath.Buffer)
1768  {
1769  /* Free it */
1770  CmpFree(DriverNode->ListEntry.FilePath.Buffer,
1771  DriverNode->ListEntry.FilePath.MaximumLength);
1772  }
1773 
1774  /* Now free the node, and move on */
1775  CmpFree(OldEntry, sizeof(BOOT_DRIVER_NODE));
1776  }
1777 }
1778 
1779 INIT_FUNCTION
1781 NTAPI
1783 {
1784  LIST_ENTRY DriverList;
1786  NTSTATUS Status;
1787  PCM_KEY_BODY KeyBody;
1788  PHHIVE Hive;
1789  HCELL_INDEX RootCell, ControlCell;
1790  HANDLE KeyHandle;
1792  PLIST_ENTRY NextEntry;
1793  ULONG i;
1794  PUNICODE_STRING* ServicePath = NULL;
1795  BOOLEAN Success, AutoSelect;
1797  PAGED_CODE();
1798 
1799  /* Initialize the driver list */
1800  InitializeListHead(&DriverList);
1801 
1802  /* Open the system hive key */
1803  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\System");
1805  &KeyName,
1807  NULL,
1808  NULL);
1810  if (!NT_SUCCESS(Status)) return NULL;
1811 
1812  /* Reference the key object to get the root hive/cell to access directly */
1816  KernelMode,
1817  (PVOID*)&KeyBody,
1818  NULL);
1819  if (!NT_SUCCESS(Status))
1820  {
1821  /* Fail */
1822  NtClose(KeyHandle);
1823  return NULL;
1824  }
1825 
1826  /* Do all this under the registry lock */
1828 
1829  /* Get the hive and key cell */
1830  Hive = KeyBody->KeyControlBlock->KeyHive;
1831  RootCell = KeyBody->KeyControlBlock->KeyCell;
1832 
1833  /* Open the current control set key */
1834  RtlInitUnicodeString(&KeyName, L"Current");
1835  ControlCell = CmpFindControlSet(Hive, RootCell, &KeyName, &AutoSelect);
1836  if (ControlCell == HCELL_NIL) goto EndPath;
1837 
1838  /* Find all system drivers */
1839  Success = CmpFindDrivers(Hive, ControlCell, SystemLoad, NULL, &DriverList);
1840  if (!Success) goto EndPath;
1841 
1842  /* Sort by group/tag */
1843  if (!CmpSortDriverList(Hive, ControlCell, &DriverList)) goto EndPath;
1844 
1845  /* Remove circular dependencies (cycles) and sort */
1846  if (!CmpResolveDriverDependencies(&DriverList)) goto EndPath;
1847 
1848  /* Loop the list to count drivers */
1849  for (i = 0, NextEntry = DriverList.Flink;
1850  NextEntry != &DriverList;
1851  i++, NextEntry = NextEntry->Flink);
1852 
1853  /* Allocate the array */
1854  ServicePath = ExAllocatePool(NonPagedPool, (i + 1) * sizeof(PUNICODE_STRING));
1855  if (!ServicePath) KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0);
1856 
1857  /* Loop the driver list */
1858  for (i = 0, NextEntry = DriverList.Flink;
1859  NextEntry != &DriverList;
1860  i++, NextEntry = NextEntry->Flink)
1861  {
1862  /* Get the entry */
1864 
1865  /* Allocate the path for the caller */
1866  ServicePath[i] = ExAllocatePool(NonPagedPool, sizeof(UNICODE_STRING));
1867  if (!ServicePath[i])
1868  {
1869  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0);
1870  }
1871 
1872  /* Duplicate the registry path */
1874  &DriverEntry->RegistryPath,
1875  ServicePath[i]);
1876  if (!NT_SUCCESS(Status))
1877  {
1878  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0);
1879  }
1880  }
1881 
1882  /* Terminate the list */
1883  ServicePath[i] = NULL;
1884 
1885 EndPath:
1886  /* Free the driver list if we had one */
1887  if (!IsListEmpty(&DriverList)) CmpFreeDriverList(Hive, &DriverList);
1888 
1889  /* Unlock the registry */
1891 
1892  /* Close the key handle and dereference the object, then return the path */
1893  ObDereferenceObject(KeyBody);
1894  NtClose(KeyHandle);
1895  return ServicePath;
1896 }
1897 
1898 VOID
1899 NTAPI
1901 {
1902  /* Enter a critical region and lock the registry */
1905 
1906  /* Sanity check */
1909 }
1910 
1911 VOID
1912 NTAPI
1914 {
1915  /* Enter a critical region */
1917 
1918  /* Check if we have to starve writers */
1920  {
1921  /* Starve exlusive waiters */
1923  }
1924  else
1925  {
1926  /* Just grab the lock */
1928  }
1929 }
1930 
1931 BOOLEAN
1932 NTAPI
1934 {
1935  /* Test the lock */
1937 }
1938 
1939 BOOLEAN
1940 NTAPI
1942 {
1943  /* Test the lock */
1945 }
1946 
1947 VOID
1948 NTAPI
1950 {
1951  /* Lock the flusher. We should already be in a critical section */
1953  ASSERT((ExIsResourceAcquiredShared(Hive->FlusherLock) == 0) &&
1954  (ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) == 0));
1955  ExAcquireResourceExclusiveLite(Hive->FlusherLock, TRUE);
1956 }
1957 
1958 VOID
1959 NTAPI
1961 {
1962  /* Lock the flusher. We should already be in a critical section */
1964  ASSERT((ExIsResourceAcquiredShared(Hive->FlusherLock) == 0) &&
1965  (ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) == 0));
1966  ExAcquireResourceSharedLite(Hive->FlusherLock, TRUE);
1967 }
1968 
1969 VOID
1970 NTAPI
1972 {
1973  /* Sanity check */
1975  CMP_ASSERT_FLUSH_LOCK(Hive);
1976 
1977  /* Release the lock */
1978  ExReleaseResourceLite(Hive->FlusherLock);
1979 }
1980 
1981 BOOLEAN
1982 NTAPI
1984 {
1985  /* Test the lock */
1986  return !ExIsResourceAcquiredSharedLite(Hive->FlusherLock) ? FALSE : TRUE;
1987 }
1988 
1989 BOOLEAN
1990 NTAPI
1992 {
1993  /* Test the lock */
1994  return !ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) ? FALSE : TRUE;
1995 }
1996 
1997 VOID
1998 NTAPI
2000 {
2001  /* Sanity check */
2003 
2004  /* Check if we should flush the registry */
2006  {
2007  /* The registry should be exclusively locked for this */
2009 
2010  /* Flush the registry */
2013  }
2014  else
2015  {
2016  /* Lazy flush the registry */
2017  CmpLazyFlush();
2018  }
2019 
2020  /* Release the lock and leave the critical region */
2023 }
2024 
2025 VOID
2026 NTAPI
2028  IN ULONG ConvKey2)
2029 {
2030  ULONG Index1, Index2;
2031 
2032  /* Sanity check */
2034 
2035  /* Get hash indexes */
2036  Index1 = GET_HASH_INDEX(ConvKey1);
2037  Index2 = GET_HASH_INDEX(ConvKey2);
2038 
2039  /* See which one is highest */
2040  if (Index1 < Index2)
2041  {
2042  /* Grab them in the proper order */
2045  }
2046  else
2047  {
2048  /* Grab the second one first, then the first */
2050  if (Index1 != Index2) CmpAcquireKcbLockExclusiveByKey(ConvKey1);
2051  }
2052 }
2053 
2054 VOID
2055 NTAPI
2057  IN ULONG ConvKey2)
2058 {
2059  ULONG Index1, Index2;
2060 
2061  /* Sanity check */
2063 
2064  /* Get hash indexes */
2065  Index1 = GET_HASH_INDEX(ConvKey1);
2066  Index2 = GET_HASH_INDEX(ConvKey2);
2069 
2070  /* See which one is highest */
2071  if (Index1 < Index2)
2072  {
2073  /* Grab them in the proper order */
2076  CmpReleaseKcbLockByKey(ConvKey2);
2077  CmpReleaseKcbLockByKey(ConvKey1);
2078  }
2079  else
2080  {
2081  /* Release the first one first, then the second */
2082  if (Index1 != Index2)
2083  {
2086  CmpReleaseKcbLockByKey(ConvKey1);
2087  }
2088  CmpReleaseKcbLockByKey(ConvKey2);
2089  }
2090 }
2091 
2092 VOID
2093 NTAPI
2095 {
2096  PLIST_ENTRY ListEntry;
2097  PCMHIVE Hive;
2098 
2099  /* Kill the workers */
2101 
2102  /* Flush all hives */
2105 
2106  /* Close all hive files */
2107  ListEntry = CmpHiveListHead.Flink;
2108  while (ListEntry != &CmpHiveListHead)
2109  {
2110  Hive = CONTAINING_RECORD(ListEntry, CMHIVE, HiveList);
2111 
2112  CmpCloseHiveFiles(Hive);
2113 
2114  ListEntry = ListEntry->Flink;
2115  }
2116 
2118 }
2119 
2120 VOID
2121 NTAPI
2123 {
2124  NTSTATUS Status;
2129  ANSI_STRING TempString;
2130  HANDLE SoftwareKeyHandle = NULL;
2131  HANDLE MicrosoftKeyHandle = NULL;
2132  HANDLE WindowsNtKeyHandle = NULL;
2133  HANDLE CurrentVersionKeyHandle = NULL;
2134  WCHAR Buffer[128]; // Buffer large enough to contain a full ULONG in decimal
2135  // representation, and the full 'CurrentType' string.
2136 
2137  /*
2138  * Open the 'HKLM\Software\Microsoft\Windows NT\CurrentVersion' key
2139  * (create the intermediate subkeys if needed).
2140  */
2141 
2142  RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE\\SOFTWARE");
2144  &KeyName,
2146  NULL,
2147  NULL);
2148  Status = NtCreateKey(&SoftwareKeyHandle,
2151  0,
2152  NULL,
2153  0,
2154  NULL);
2155  if (!NT_SUCCESS(Status))
2156  {
2157  DPRINT1("Failed to create key %wZ (Status: %08lx)\n", &KeyName, Status);
2158  return;
2159  }
2160 
2161  RtlInitUnicodeString(&KeyName, L"Microsoft");
2163  &KeyName,
2165  SoftwareKeyHandle,
2166  NULL);
2167  Status = NtCreateKey(&MicrosoftKeyHandle,
2170  0,
2171  NULL,
2172  0,
2173  NULL);
2174  if (!NT_SUCCESS(Status))
2175  {
2176  DPRINT1("Failed to create key %wZ (Status: %08lx)\n", &KeyName, Status);
2177  goto Quit;
2178  }
2179 
2180  RtlInitUnicodeString(&KeyName, L"Windows NT");
2182  &KeyName,
2184  MicrosoftKeyHandle,
2185  NULL);
2186  Status = NtCreateKey(&WindowsNtKeyHandle,
2189  0,
2190  NULL,
2191  0,
2192  NULL);
2193  if (!NT_SUCCESS(Status))
2194  {
2195  DPRINT1("Failed to create key %wZ (Status: %08lx)\n", &KeyName, Status);
2196  goto Quit;
2197  }
2198 
2199  RtlInitUnicodeString(&KeyName, L"CurrentVersion");
2201  &KeyName,
2203  WindowsNtKeyHandle,
2204  NULL);
2205  Status = NtCreateKey(&CurrentVersionKeyHandle,
2208  0,
2209  NULL,
2210  0,
2211  NULL);
2212  if (!NT_SUCCESS(Status))
2213  {
2214  DPRINT1("Failed to create key %wZ (Status: %08lx)\n", &KeyName, Status);
2215  goto Quit;
2216  }
2217 
2218  /* Set the 'CurrentVersion' value */
2219  RtlInitUnicodeString(&ValueName, L"CurrentVersion");
2220  NtSetValueKey(CurrentVersionKeyHandle,
2221  &ValueName,
2222  0,
2223  REG_SZ,
2225  CmVersionString.Length + sizeof(WCHAR));
2226 
2227  /* Set the 'CurrentBuildNumber' value */
2228  RtlInitUnicodeString(&ValueName, L"CurrentBuildNumber");
2229  RtlInitEmptyUnicodeString(&ValueData, Buffer, sizeof(Buffer));
2231  NtSetValueKey(CurrentVersionKeyHandle,
2232  &ValueName,
2233  0,
2234  REG_SZ,
2235  ValueData.Buffer,
2236  ValueData.Length + sizeof(WCHAR));
2237 
2238  /* Set the 'BuildLab' value */
2239  RtlInitUnicodeString(&ValueName, L"BuildLab");
2240  RtlInitAnsiString(&TempString, NtBuildLab);
2242  if (NT_SUCCESS(Status))
2243  {
2244  NtSetValueKey(CurrentVersionKeyHandle,
2245  &ValueName,
2246  0,
2247  REG_SZ,
2248  ValueData.Buffer,
2249  ValueData.Length + sizeof(WCHAR));
2250  }
2251 
2252  /* Set the 'CurrentType' value */
2253  RtlInitUnicodeString(&ValueName, L"CurrentType");
2254  RtlStringCbPrintfW(Buffer, sizeof(Buffer),
2255  L"%s %s",
2256 #ifdef CONFIG_SMP
2257  L"Multiprocessor"
2258 #else
2259  L"Uniprocessor"
2260 #endif
2261  ,
2262 #if (DBG == 1)
2263  L"Checked"
2264 #else
2265  L"Free"
2266 #endif
2267  );
2269  NtSetValueKey(CurrentVersionKeyHandle,
2270  &ValueName,
2271  0,
2272  REG_SZ,
2273  ValueData.Buffer,
2274  ValueData.Length + sizeof(WCHAR));
2275 
2276  /* Set the 'CSDVersion' value */
2277  RtlInitUnicodeString(&ValueName, L"CSDVersion");
2278  if (CmCSDVersionString.Length != 0)
2279  {
2280  NtSetValueKey(CurrentVersionKeyHandle,
2281  &ValueName,
2282  0,
2283  REG_SZ,
2285  CmCSDVersionString.Length + sizeof(WCHAR));
2286  }
2287  else
2288  {
2289  NtDeleteValueKey(CurrentVersionKeyHandle, &ValueName);
2290  }
2291 
2292  /* Set the 'CSDBuildNumber' value */
2293  RtlInitUnicodeString(&ValueName, L"CSDBuildNumber");
2294  if (CmNtSpBuildNumber != 0)
2295  {
2296  RtlInitEmptyUnicodeString(&ValueData, Buffer, sizeof(Buffer));
2298  NtSetValueKey(CurrentVersionKeyHandle,
2299  &ValueName,
2300  0,
2301  REG_SZ,
2302  ValueData.Buffer,
2303  ValueData.Length + sizeof(WCHAR));
2304  }
2305  else
2306  {
2307  NtDeleteValueKey(CurrentVersionKeyHandle, &ValueName);
2308  }
2309 
2310  /* Set the 'SystemRoot' value */
2311  RtlInitUnicodeString(&ValueName, L"SystemRoot");
2312  NtSetValueKey(CurrentVersionKeyHandle,
2313  &ValueName,
2314  0,
2315  REG_SZ,
2317  NtSystemRoot.Length + sizeof(WCHAR));
2318 
2319 Quit:
2320  /* Close the keys */
2321  if (CurrentVersionKeyHandle != NULL)
2322  NtClose(CurrentVersionKeyHandle);
2323 
2324  if (WindowsNtKeyHandle != NULL)
2325  NtClose(WindowsNtKeyHandle);
2326 
2327  if (MicrosoftKeyHandle != NULL)
2328  NtClose(MicrosoftKeyHandle);
2329 
2330  if (SoftwareKeyHandle != NULL)
2331  NtClose(SoftwareKeyHandle);
2332 }
2333 
2334 /* EOF */
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
NTSTATUS NTAPI ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN OUT PVOID ParseContext, OUT PHANDLE Handle)
Definition: obhandle.c:2529
VOID NTAPI CmpUnlockHiveFlusher(IN PCMHIVE Hive)
Definition: cmsysini.c:1971
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
INIT_FUNCTION VOID NTAPI CmpInitCmPrivateAlloc(VOID)
Definition: cmalloc.c:29
#define KEY_COMP_NAME
Definition: cmdata.h:35
VOID NTAPI CmpInitializeHiveList(VOID)
Definition: cmsysini.c:1365
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSYSAPI VOID NTAPI RtlGetCallersAddress(_Out_ PVOID *CallersAddress, _Out_ PVOID *CallersCaller)
Definition: except.c:22
INIT_FUNCTION BOOLEAN NTAPI CmpSortDriverList(IN PHHIVE Hive, IN HCELL_INDEX ControlSet, IN PLIST_ENTRY DriverListHead)
Definition: cmboot.c:562
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
Definition: cmtypes.h:856
VOID NTAPI CmpShutdownWorkers(VOID)
Definition: cmlazy.c:408
WCHAR Name[ANYSIZE_ARRAY]
Definition: cmdata.h:116
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1048
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define HBLOCK_SIZE
Definition: hivedata.h:41
ULONG CmHiveFlags
Definition: cm.h:470
BOOT_DRIVER_LIST_ENTRY ListEntry
Definition: io.h:426
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
NTSTATUS NTAPI CmpSecurityMethod(IN PVOID ObjectBody, IN SECURITY_OPERATION_CODE OperationCode, IN PSECURITY_INFORMATION SecurityInformation, IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, IN OUT PULONG BufferLength, IN OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor, IN POOL_TYPE PoolType, IN PGENERIC_MAPPING GenericMapping)
Definition: cmse.c:262
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
HCELL_INDEX List
Definition: cmdata.h:75
static PMEMKEY RootKey
Definition: registry.c:55
UNICODE_STRING NtSystemRoot
Definition: init.c:72
BOOLEAN CmpFlushOnLockRelease
Definition: cmsysini.c:27
WCHAR RootDirectory[MAX_PATH]
Definition: format.c:74
BOOLEAN ThreadStarted
Definition: cm.h:473
#define KEY_SET_VALUE
Definition: nt_native.h:1017
NTSTATUS NTAPI NtRaiseHardError(IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN ULONG UnicodeStringParameterMask, IN PULONG_PTR Parameters, IN ULONG ValidResponseOptions, OUT PULONG Response)
Definition: harderr.c:553
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4693
BOOLEAN NTAPI CmpTestHiveFlusherLockExclusive(IN PCMHIVE Hive)
Definition: cmsysini.c:1991
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG BootType
Definition: hivedata.h:161
#define KEY_READ
Definition: nt_native.h:1023
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
LIST_ENTRY CmpHiveListHead
Definition: cmsysini.c:18
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define HIVE_VOLATILE
Definition: hivedata.h:23
ULONG MaxValueNameLen
Definition: cmdata.h:111
#define CMP_ASSERT_REGISTRY_LOCK()
Definition: cm_x.h:46
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:303
#define CM_KEY_NODE_SIGNATURE
Definition: cmdata.h:21
USHORT ClassLength
Definition: cmdata.h:115
LONG CmpLoadWorkerIncrement
Definition: cmsysini.c:23
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
INIT_FUNCTION BOOLEAN NTAPI CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmsysini.c:865
BOOL WINAPI EndPath(_In_ HDC)
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
LONG NTSTATUS
Definition: precomp.h:26
#define CM_NUMBER_OF_MACHINE_HIVES
Definition: cm.h:119
INIT_FUNCTION BOOLEAN NTAPI CmpCreateRootNode(IN PHHIVE Hive, IN PCWSTR Name, OUT PHCELL_INDEX Index)
Definition: cmsysini.c:1016
#define HCELL_NIL
Definition: hivedata.h:85
PEPROCESS CmpSystemProcess
Definition: cmsysini.c:24
NTSTATUS NTAPI CmpLinkHiveToMaster(IN PUNICODE_STRING LinkName, IN HANDLE RootDirectory, IN PCMHIVE RegistryHive, IN BOOLEAN Allocate, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
Definition: cmsysini.c:798
BOOLEAN CmSelfHeal
Definition: cmdata.c:58
BOOLEAN NTAPI CmpTestRegistryLock(VOID)
Definition: cmsysini.c:1933
#define New(t)
Definition: rtf.h:1086
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
HIVE_LIST_ENTRY CmpMachineHiveList[]
Definition: cmdata.c:41
#define CM_KEY_BODY_TYPE
Definition: cm.h:66
PCMHIVE CmHive
Definition: cm.h:468
#define OBJ_PERMANENT
Definition: winternl.h:226
ULONG Flags
Definition: cm.h:430
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
INIT_FUNCTION BOOLEAN NTAPI CmInitSystem1(VOID)
Definition: cmsysini.c:1517
HCELL_INDEX CMAPI HvAllocateCell(PHHIVE RegistryHive, ULONG Size, HSTORAGE_TYPE Storage, IN HCELL_INDEX Vicinity)
HCELL_INDEX KeyCell
Definition: cmdata.h:83
INIT_FUNCTION BOOLEAN NTAPI CmpFindDrivers(IN PHHIVE Hive, IN HCELL_INDEX ControlSet, IN SERVICE_LOAD_TYPE LoadType, IN PWCHAR BootFileSystem OPTIONAL, IN PLIST_ENTRY DriverListHead)
Definition: cmboot.c:383
uint16_t * PWCHAR
Definition: typedefs.h:54
VOID NTAPI CmpDelayDerefKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmdelay.c:286
INIT_FUNCTION BOOLEAN NTAPI CmpResolveDriverDependencies(IN PLIST_ENTRY DriverListHead)
Definition: cmboot.c:674
struct _CM_NOTIFY_BLOCK * NotifyBlock
Definition: cm.h:230
FORCEINLINE VOID CmpAcquireKcbLockExclusiveByKey(IN ULONG ConvKey)
Definition: cm_x.h:112
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
UNICODE_STRING FilePath
Definition: arc.h:201
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
USHORT NameLength
Definition: cmdata.h:114
#define CmpAcquireKcbLockShared(k)
Definition: cm_x.h:121
VOID NTAPI CmpCloseKeyObject(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
Definition: cmsysini.c:159
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI CmpReleaseTwoKcbLockByKey(IN ULONG ConvKey1, IN ULONG ConvKey2)
Definition: cmsysini.c:2056
#define REG_OPTION_CREATE_LINK
Definition: nt_native.h:1063
static int Link(const char **args)
Definition: vfdcmd.c:2414
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:656
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
VOID NTAPI EnlistKeyBodyWithKCB(IN PCM_KEY_BODY KeyBody, IN ULONG Flags)
Definition: cmkcbncb.c:1043
#define PAGED_CODE()
Definition: video.h:57
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3149
PSECURITY_DESCRIPTOR NTAPI CmpHiveRootSecurityDescriptor(VOID)
Definition: cmse.c:22
_SEH2_TRY
Definition: create.c:4250
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
Definition: arc.h:198
ERESOURCE CmpRegistryLock
Definition: cmsysini.c:19
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
ULONG CmpBootType
Definition: cmdata.c:61
ULONG MaxNameLen
Definition: cmdata.h:109
INIT_FUNCTION PUNICODE_STRING *NTAPI CmGetSystemDriverList(VOID)
Definition: cmsysini.c:1782
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
HANDLE FileHandle
Definition: stats.c:38
HCELL_INDEX Class
Definition: cmdata.h:108
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
BOOLEAN CmpProfileLoaded
Definition: cmsysini.c:31
static NTSTATUS CmpGetRegistryPath(OUT PWCHAR ConfigPath)
Definition: cmsysini.c:1170
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
PVOID CmpRegistryLockCallerCaller
Definition: cmsysini.c:26
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
BOOLEAN ThreadFinished
Definition: cm.h:472
VOID NTAPI CmpCloseHiveFiles(IN PCMHIVE Hive)
Definition: cminit.c:631
#define UNICODE_NULL
NTSTATUS NTAPI CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName, IN PCWSTR Extension OPTIONAL, OUT PHANDLE Primary, OUT PHANDLE Log, OUT PULONG PrimaryDisposition, OUT PULONG LogDisposition, IN BOOLEAN CreateAllowed, IN BOOLEAN MarkAsSystemHive, IN BOOLEAN NoBuffering, OUT PULONG ClusterSize OPTIONAL)
Definition: cminit.c:266
CM_KEY_REFERENCE ChildHive
Definition: cm.h:486
#define CMP_ASSERT_FLUSH_LOCK(h)
Definition: cm_x.h:266
long LONG
Definition: pedump.c:60
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
#define HINIT_FILE
Definition: hivedata.h:15
BOOLEAN NTAPI CmpTestHiveFlusherLockShared(IN PCMHIVE Hive)
Definition: cmsysini.c:1983
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
LIST_ENTRY CmpSelfHealQueueListHead
Definition: cmsysini.c:21
BOOLEAN CmpSelfHeal
Definition: cmdata.c:59
struct NameRec_ * Name
Definition: cdprocs.h:464
#define PsGetCurrentProcess
Definition: psfuncs.h:17
PCM_KEY_CONTROL_BLOCK NTAPI CmpCreateKeyControlBlock(IN PHHIVE Hive, IN HCELL_INDEX Index, IN PCM_KEY_NODE Node, IN PCM_KEY_CONTROL_BLOCK Parent, IN ULONG Flags, IN PUNICODE_STRING KeyName)
Definition: cmkcbncb.c:655
HANDLE FileHandles[HFILE_TYPE_MAX]
Definition: cm.h:394
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HCELL_INDEX SubKeyLists[HTYPE_COUNT]
Definition: cmdata.h:102
unsigned char BOOLEAN
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
KEVENT CmpLoadWorkerEvent
Definition: cmsysini.c:22
UNICODE_STRING FileFullPath
Definition: cm.h:409
smooth NULL
Definition: ftsmooth.c:416
struct _CM_KEY_NODE * PCM_KEY_NODE
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
ULONG * PHCELL_INDEX
Definition: hivedata.h:80
HHIVE Hive
Definition: cm.h:393
#define OBJ_EXCLUSIVE
Definition: winternl.h:227
void DPRINT(...)
Definition: polytest.cpp:61
DUAL Storage[HTYPE_COUNT]
Definition: hivedata.h:331
VOID NTAPI CmpLockRegistryExclusive(VOID)
Definition: cmsysini.c:1900
#define ExInitializePushLock
Definition: ex.h:999
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
POBJECT_TYPE CmpKeyObjectType
Definition: cmsysini.c:16
ULONG CmpTraceLevel
Definition: cmsysini.c:33
Definition: bufpool.h:45
#define DBG(x)
Definition: moztest.c:12
#define STATUS_KEY_DELETED
Definition: ntstatus.h:599
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
FORCEINLINE VOID CmpReleaseKcbLock(PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cm_x.h:169
PCMHIVE CmiVolatileHive
Definition: cmsysini.c:17
OB_CLOSE_METHOD CloseProcedure
Definition: obtypes.h:368
ULONG BootRecover
Definition: hivedata.h:162
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define UlongToPtr(u)
Definition: config.h:106
#define PtrToUlong(u)
Definition: config.h:107
NTSTATUS NTAPI CmpQueryKeyName(IN PVOID ObjectBody, IN BOOLEAN HasName, IN OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength, IN KPROCESSOR_MODE PreviousMode)
Definition: cmsysini.c:184
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:952
ULONG CmNtSpBuildNumber
Definition: init.c:55
#define ExIsResourceAcquiredShared
Definition: exfuncs.h:348
FORCEINLINE VOID CmpReleaseKcbLockByKey(ULONG ConvKey)
Definition: cm_x.h:179
struct _CM_KEY_CONTROL_BLOCK * KeyControlBlock
Definition: cm.h:229
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
Definition: ntapi.c:994
CHILD_LIST ValueList
Definition: cmdata.h:103
#define KEY_WRITE
Definition: nt_native.h:1031
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
NTSTATUS Status
Definition: cmtypes.h:858
#define REG_LINK
Definition: nt_native.h:1500
UNICODE_STRING Name
Definition: io.h:428
NTSTATUS NTAPI CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmhardwr.c:21
USHORT NTAPI CmpCopyName(IN PHHIVE Hive, OUT PWCHAR Destination, IN PUNICODE_STRING Source)
Definition: cmname.c:21
#define GET_HASH_ENTRY(Table, ConvKey)
Definition: cm_x.h:20
static INIT_FUNCTION NTSTATUS CmpCreateHardwareProfile(HANDLE ControlSetHandle)
Definition: cmsysini.c:452
BOOLEAN CmpNoWrite
Definition: cmsysini.c:29
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HINIT_CREATE
Definition: hivedata.h:13
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define HFILE_TYPE_LOG
Definition: hivedata.h:34
VOID NTAPI CmpFree(_In_ PVOID Ptr, _In_ ULONG Quota)
Definition: bootreg.c:105
HCELL_INDEX Parent
Definition: cmdata.h:96
ULONG HCELL_INDEX
Definition: hivedata.h:80
ULONG SubKeyCounts[HTYPE_COUNT]
Definition: cmdata.h:97
VOID NTAPI CmpUnlockRegistry(VOID)
Definition: cmsysini.c:1999
#define CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK()
Definition: cm_x.h:61
USHORT Signature
Definition: cmdata.h:92
PUNICODE_STRING NTAPI CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmkcbncb.c:897
#define MAX_PATH
Definition: compat.h:26
DWORD ClusterSize
Definition: format.c:67
BOOLEAN CmpSpecialBootCondition
Definition: cmsysini.c:28
OB_PARSE_METHOD ParseProcedure
Definition: obtypes.h:370
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
INIT_FUNCTION VOID NTAPI CmpInitDelayDerefKCBEngine(VOID)
Definition: cmdelay.c:268
VOID NTAPI CmShutdownSystem(VOID)
Definition: cmsysini.c:2094
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
INIT_FUNCTION HCELL_INDEX NTAPI CmpFindControlSet(IN PHHIVE SystemHive, IN HCELL_INDEX RootCell, IN PUNICODE_STRING SelectKeyName, OUT PBOOLEAN AutoSelect)
Definition: cmboot.c:25
struct _CM_KEY_BODY CM_KEY_BODY
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
ULONG Cluster
Definition: hivedata.h:308
ULONG NtBuildNumber
Definition: init.c:47
static IUnknown Object
Definition: main.c:512
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
PCM_KEY_HASH_TABLE_ENTRY CmpCacheTable
Definition: cmkcbncb.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define STATUS_CANNOT_LOAD_REGISTRY_FILE
Definition: ntstatus.h:654
BOOLEAN CmpMiniNTBoot
Definition: cmdata.c:60
#define TAG_CM
Definition: cmlib.h:203
char * PBOOLEAN
Definition: retypes.h:11
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
static const WCHAR L[]
Definition: oid.c:1250
USHORT NTAPI CmpNameSize(IN PHHIVE Hive, IN PUNICODE_STRING Name)
Definition: cmname.c:74
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
UNICODE_STRING CmCSDVersionString
Definition: init.c:59
NTSTATUS NTAPI CmpInitHiveFromFile(IN PCUNICODE_STRING HiveName, IN ULONG HiveFlags, OUT PCMHIVE *Hive, IN OUT PBOOLEAN New, IN ULONG CheckFlags)
Definition: cmsysini.c:286
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
UNICODE_STRING CmVersionString
Definition: init.c:58
LARGE_INTEGER LastWriteTime
Definition: cmdata.h:94
#define HINIT_MEMORY
Definition: hivedata.h:14
Definition: typedefs.h:117
#define GET_HASH_INDEX(ConvKey)
Definition: cm_x.h:18
#define KEY_NO_DELETE
Definition: cmdata.h:33
static const WCHAR Cleanup[]
Definition: register.c:80
static __inline NTSTATUS RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1120
INIT_FUNCTION VOID NTAPI CmpInitializeCache(VOID)
Definition: cmkcbncb.c:26
EX_PUSH_LOCK CmpLoadHiveLock
Definition: cmdata.c:39
ULONG Count
Definition: cmdata.h:74
VOID NTAPI CmpLockHiveFlusherShared(IN PCMHIVE Hive)
Definition: cmsysini.c:1960
INIT_FUNCTION NTSTATUS NTAPI CmpCreateObjectTypes(VOID)
Definition: cmsysini.c:982
NTSTATUS NTAPI CmpInitializeHive(OUT PCMHIVE *CmHive, IN ULONG OperationType, IN ULONG HiveFlags, IN ULONG FileType, IN PVOID HiveData OPTIONAL, IN HANDLE Primary, IN HANDLE Log, IN HANDLE External, IN PCUNICODE_STRING FileName OPTIONAL, IN ULONG CheckFlags)
Definition: cminit.c:19
VOID NTAPI CmpDeleteKeyObject(PVOID DeletedObject)
Definition: cmsysini.c:109
UNICODE_STRING CmSymbolicLinkValueName
Definition: cmdata.c:52
INIT_FUNCTION NTSTATUS NTAPI CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmsysini.c:524
Status
Definition: gdiplustypes.h:24
HCELL_INDEX Security
Definition: cmdata.h:107
BOOLEAN NTAPI ExAcquireSharedStarveExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:1063
struct _FileName FileName
Definition: fatprocs.h:884
BOOLEAN ExpInTextModeSetup
Definition: init.c:66
_SEH2_END
Definition: create.c:4424
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2932
UNICODE_STRING RegistryPath
Definition: arc.h:202
EX_PUSH_LOCK CmpHiveListHeadLock
Definition: cmdata.c:39
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define InterlockedIncrement
Definition: armddk.h:53
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
BOOLEAN CmpWasSetupBoot
Definition: cmsysini.c:30
#define HFILE_TYPE_PRIMARY
Definition: hivedata.h:33
BOOLEAN CmpNoVolatileCreates
Definition: cmsysini.c:32
ULONG HiveFlags
Definition: hivedata.h:321
ULONG MaxClassLen
Definition: cmdata.h:110
unsigned short USHORT
Definition: pedump.c:61
#define _In_z_
Definition: no_sal2.h:239
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
INIT_FUNCTION VOID NTAPI CmpInitCallback(VOID)
Definition: cmhook.c:38
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define KEY_CREATE_LINK
Definition: nt_native.h:1021
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
OB_SECURITY_METHOD SecurityProcedure
Definition: obtypes.h:371
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
static PCMHIVE CmHive
Definition: registry.c:28
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define KEY_EXECUTE
Definition: nt_native.h:1037
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
unsigned int * PULONG
Definition: retypes.h:1
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
Definition: rtlfuncs.h:1557
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
BOOLEAN CmFirstTime
Definition: ntapi.c:17
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
#define HIVE_NOLAZYFLUSH
Definition: hivedata.h:24
#define TAG_CMSD
Definition: cmlib.h:206
ULONG Length
Definition: hivedata.h:276
VOID NTAPI CmpLockHiveFlusherExclusive(IN PCMHIVE Hive)
Definition: cmsysini.c:1949
ULONG MaxValueDataLen
Definition: cmdata.h:112
#define FILE_CREATED
Definition: nt_native.h:770
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
BOOLEAN HvShutdownComplete
Definition: cmsysini.c:25
static CMHIVE SystemHive
Definition: registry.c:57
#define DPRINT1
Definition: precomp.h:8
BOOLEAN Allocate
Definition: cm.h:474
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
NTSTATUS NTAPI CmpParseKey(IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
Definition: cmparse.c:1024
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
BOOLEAN NTAPI CmpDoFlushAll(IN BOOLEAN ForceFlush)
Definition: cmapi.c:82
#define OUT
Definition: typedefs.h:39
INIT_FUNCTION BOOLEAN NTAPI CmpCreateRegistryRoot(VOID)
Definition: cmsysini.c:1072
ULONG ERESOURCE
Definition: env_spec_w32.h:594
PVOID CmpRegistryLockCaller
Definition: cmsysini.c:26
unsigned int ULONG
Definition: retypes.h:1
OB_QUERYNAME_METHOD QueryNameProcedure
Definition: obtypes.h:372
BOOLEAN NTAPI CmpTestRegistryLockExclusive(VOID)
Definition: cmsysini.c:1941
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1658
VOID NTAPI DelistKeyBodyFromKCB(IN PCM_KEY_BODY KeyBody, IN BOOLEAN LockHeld)
Definition: cmkcbncb.c:1101
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
uint32_t * PULONG_PTR
Definition: typedefs.h:63
KGUARDED_MUTEX CmpSelfHealQueueLock
Definition: cmsysini.c:20
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
INIT_FUNCTION VOID NTAPI CmpInitCmPrivateDelayAlloc(VOID)
Definition: cmalloc.c:44
NTSTATUS CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1, IN PVOID Argument2)
Definition: cmhook.c:59
PCMHIVE CmHive2
Definition: cm.h:471
VOID NTAPI CmpLazyFlush(VOID)
Definition: cmlazy.c:158
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
HANDLE CmpRegistryRootHandle
Definition: cmdata.c:66
INIT_FUNCTION VOID NTAPI CmpFreeDriverList(IN PHHIVE Hive, IN PLIST_ENTRY DriverList)
Definition: cmsysini.c:1733
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
VOID NTAPI CmpSetVersionData(VOID)
Definition: cmsysini.c:2122
INIT_FUNCTION NTSTATUS NTAPI CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmsysini.c:397
_In_ UINT _Out_ PNDIS_HANDLE LogHandle
Definition: ndis.h:5363
PVOID Object
Definition: cmtypes.h:857
#define KeGetCurrentThread
Definition: hal.h:44
ULONG Type
Definition: cm.h:228
_In_ PSECURITY_SUBJECT_CONTEXT _In_ BOOLEAN _In_ ACCESS_MASK _In_ ACCESS_MASK _Outptr_opt_ PPRIVILEGE_SET _In_ PGENERIC_MAPPING _In_ KPROCESSOR_MODE _Out_ PACCESS_MASK GrantedAccess
Definition: sefuncs.h:13
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
struct _CM_KEY_BODY * PCM_KEY_BODY
BOOLEAN CreateLink
Definition: cm.h:488
return STATUS_SUCCESS
Definition: btrfs.c:2725
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
BOOLEAN NTAPI CmpLinkKeyToHive(_In_z_ PCWSTR LinkKeyName, _In_z_ PCWSTR TargetKeyName)
Definition: cmsysini.c:42
#define REG_DWORD
Definition: sdbapi.c:596
VOID NTAPI CmpLockRegistry(VOID)
Definition: cmsysini.c:1913
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
PHHIVE KeyHive
Definition: cmdata.h:84
ULONG HHiveFlags
Definition: cm.h:469
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(h)
Definition: cm_x.h:53
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOLEAN CreateOperation
Definition: cm.h:489
#define STATUS_TOO_LATE
Definition: ntstatus.h:612
ULONG ACCESS_MASK
Definition: nt_native.h:40
VOID NTAPI CmpAcquireTwoKcbLocksExclusiveByKey(IN ULONG ConvKey1, IN ULONG ConvKey2)
Definition: cmsysini.c:2027
_Function_class_(KSTART_ROUTINE)
Definition: cmsysini.c:1197
#define LoadString
Definition: winuser.h:5685
INIT_FUNCTION NTSTATUS NTAPI CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmconfig.c:328
UNICODE_STRING CmpLoadOptions
Definition: cmdata.c:55
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
struct _KEY_VALUE_FULL_INFORMATION * PKEY_VALUE_FULL_INFORMATION
NTSTATUS NTAPI CmpAddToHiveFileList(IN PCMHIVE Hive)
Definition: cmhvlist.c:130
BOOLEAN InitIsWinPEMode
Definition: init.c:69
Definition: cm.h:391
USHORT Flags
Definition: cmdata.h:93
CHAR NtBuildLab[]
Definition: init.c:61
LONG CmpFlushStarveWriters
Definition: cmlazy.c:28
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define KEY_HIVE_ENTRY
Definition: cmdata.h:32
BOOLEAN CmpShareSystemHives
Definition: cmdata.c:57
#define REG_SZ
Definition: layer.c:22
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68