[USETUP]
authorEric Kohl <eric.kohl@reactos.org>
Wed, 9 Apr 2014 21:49:30 +0000 (21:49 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Wed, 9 Apr 2014 21:49:30 +0000 (21:49 +0000)
Add a default pagefile entry to the registry.

svn path=/trunk/; revision=62697

reactos/base/setup/usetup/interface/usetup.c
reactos/base/setup/usetup/registry.c
reactos/base/setup/usetup/registry.h

index 717bad1..b1a09be 100644 (file)
@@ -70,6 +70,8 @@ static UNICODE_STRING DestinationPath;
 static UNICODE_STRING DestinationArcPath;
 static UNICODE_STRING DestinationRootPath;
 
+static WCHAR DestinationDriveLetter;
+
 /* Path to the active partition (boot manager) */
 static UNICODE_STRING SystemRootPath;
 
@@ -1589,6 +1591,8 @@ SelectPartitionPage(PINPUT_RECORD Ir)
                                    TRUE);
             }
 
+            DestinationDriveLetter = (WCHAR)PartitionList->CurrentPartition->DriveLetter[0];
+
             return SELECT_FILE_SYSTEM_PAGE;
         }
         else if (Ir->Event.KeyEvent.wVirtualKeyCode == 'C')  /* C */
@@ -3335,6 +3339,9 @@ RegistryPage(PINPUT_RECORD Ir)
         return QUIT_PAGE;
     }
 
+    /* Set the default pagefile entry */
+    SetDefaultPagefile(DestinationDriveLetter);
+
     /* Update the mounted devices list */
     SetMountedDeviceValues(PartitionList);
 
index 0ae7ab7..493a17a 100644 (file)
@@ -763,4 +763,38 @@ SetMountedDeviceValue(CHAR Letter, ULONG Signature, LARGE_INTEGER StartingOffset
   return TRUE;
 }
 
+
+VOID
+SetDefaultPagefile(WCHAR Drive)
+{
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management");
+    UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"PagingFiles");
+    WCHAR ValueBuffer[] = L"?:\\pagefile.sys 0 0\0";
+    HANDLE KeyHandle;
+    NTSTATUS Status;
+
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               NULL,
+                               NULL);
+    Status = NtOpenKey(&KeyHandle,
+                       KEY_ALL_ACCESS,
+                       &ObjectAttributes);
+    if (!NT_SUCCESS(Status))
+        return;
+
+    ValueBuffer[0] = Drive;
+
+    NtSetValueKey(KeyHandle,
+                  &ValueName,
+                  0,
+                  REG_MULTI_SZ,
+                  (PVOID)&ValueBuffer,
+                  sizeof(ValueBuffer));
+
+    NtClose(KeyHandle);
+}
+
 /* EOF */
index 0d62ac9..2b23cd8 100644 (file)
@@ -38,4 +38,7 @@ SetInstallPathValue(PUNICODE_STRING InstallPath);
 BOOLEAN
 SetMountedDeviceValue(CHAR Letter, ULONG Signature, LARGE_INTEGER StartingOffset);
 
+VOID
+SetDefaultPagefile(WCHAR Drive);
+
 /* EOF */