Use a 'secret' registry value to tell ntoskrnl where to create the registry hives.
authorEric Kohl <eric.kohl@reactos.org>
Tue, 26 Nov 2002 15:33:06 +0000 (15:33 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 26 Nov 2002 15:33:06 +0000 (15:33 +0000)
svn path=/trunk/; revision=3795

reactos/subsys/system/usetup/usetup.c

index 4dc0812..dc3af27 100644 (file)
@@ -1259,6 +1259,15 @@ FileCopyPage(PINPUT_RECORD Ir)
 static ULONG
 InitSystemPage(PINPUT_RECORD Ir)
 {
 static ULONG
 InitSystemPage(PINPUT_RECORD Ir)
 {
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  UNICODE_STRING KeyName;
+  HANDLE KeyHandle;
+  NTSTATUS Status;
+
+  WCHAR TargetPath[MAX_PATH];
+  UNICODE_STRING ValueName;
+
+
   SetTextXY(6, 8, "Initializing system settings");
 
 
   SetTextXY(6, 8, "Initializing system settings");
 
 
@@ -1271,14 +1280,55 @@ InitSystemPage(PINPUT_RECORD Ir)
   SetStatusText("   Please wait...");
 
 
   SetStatusText("   Please wait...");
 
 
-  /*
-   * Create registry hives
-   */
+  /* Create the 'secret' InstallPath key */
+  RtlInitUnicodeStringFromLiteral(&KeyName,
+                                 L"\\Registry\\Machine\\HARDWARE");
+  InitializeObjectAttributes(&ObjectAttributes,
+                            &KeyName,
+                            OBJ_CASE_INSENSITIVE,
+                            NULL,
+                            NULL);
+  Status =  NtOpenKey(&KeyHandle,
+                     KEY_ALL_ACCESS,
+                     &ObjectAttributes);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
+  }
 
 
+  RtlInitUnicodeStringFromLiteral(&ValueName,
+                                 L"InstallPath");
 
 
-  /*
-   * Update registry
-   */
+  swprintf(TargetPath,
+          L"\\Device\\Harddisk%lu\\Partition%lu",
+          PartData.DiskNumber,
+          PartData.PartNumber);
+  if (InstallDir[0] != L'\\')
+    wcscat(TargetPath, L"\\");
+  wcscat(TargetPath, InstallDir);
+
+  Status = NtSetValueKey(KeyHandle,
+                        &ValueName,
+                        0,
+                        REG_SZ,
+                        (PVOID)TargetPath,
+                        wcslen(TargetPath) * sizeof(WCHAR));
+  NtClose(KeyHandle);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
+  }
+
+  /* Create the standard hives */
+  Status = NtInitializeRegistry(TRUE);
+  if (!NT_SUCCESS(Status))
+  {
+    DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status);
+  }
+
+
+
+  /* Update registry */
 
   /* FIXME: Create key '\Registry\Machine\System\Setup' */
 
 
   /* FIXME: Create key '\Registry\Machine\System\Setup' */