Add a default pagefile entry to the registry.

svn path=/trunk/; revision=62697
This commit is contained in:
Eric Kohl 2014-04-09 21:49:30 +00:00
parent b3d69a19ac
commit 32f9115048
3 changed files with 44 additions and 0 deletions

View 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);

View 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 */

View file

@ -38,4 +38,7 @@ SetInstallPathValue(PUNICODE_STRING InstallPath);
BOOLEAN
SetMountedDeviceValue(CHAR Letter, ULONG Signature, LARGE_INTEGER StartingOffset);
VOID
SetDefaultPagefile(WCHAR Drive);
/* EOF */