[USETUP] Add few checks to forbid the user to attempt installing ReactOS in the installation source directory, or a subdirectory thereof, or to delete the partition containing the installation source.

This is needed because the ReactOS installer can also be present from within a HDD partition!

svn path=/branches/setup_improvements/; revision=75669
This commit is contained in:
Hermès Bélusca-Maïto 2017-08-25 14:38:12 +00:00
parent 959323902f
commit e2a92634e1
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -1662,12 +1662,34 @@ SelectPartitionPage(PINPUT_RECORD Ir)
}
else if (Ir->Event.KeyEvent.wVirtualKeyCode == 'D') /* D */
{
WCHAR PathBuffer[MAX_PATH];
UNICODE_STRING CurrentPartition;
if (PartitionList->CurrentPartition->IsPartitioned == FALSE)
{
MUIDisplayError(ERROR_DELETE_SPACE, Ir, POPUP_WAIT_ANY_KEY);
return SELECT_PARTITION_PAGE;
}
StringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
L"\\Device\\Harddisk%lu\\Partition%lu\\",
PartitionList->CurrentDisk->DiskNumber,
PartitionList->CurrentPartition->PartitionNumber);
RtlInitUnicodeString(&CurrentPartition, PathBuffer);
/*
* Check whether the user attempts to delete the partition on which
* the installation source is present. If so, fail with an error.
*/
// &USetupData.SourceRootPath
if (RtlPrefixUnicodeString(&CurrentPartition, &USetupData.SourcePath, TRUE))
{
PopupError("You cannot delete the partition containing the installation source!",
MUIGetString(STRING_CONTINUE),
Ir, POPUP_WAIT_ENTER);
return SELECT_PARTITION_PAGE;
}
if (PartitionList->CurrentPartition->BootIndicator ||
PartitionList->CurrentPartition == PartitionList->SystemPartition)
{
@ -2705,6 +2727,8 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
PartTypeString,
ARRAYSIZE(PartTypeString));
MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE);
if (PartEntry->AutoCreate)
{
CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION));
@ -2789,8 +2813,6 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
DiskEntry->NoMbr ? "GPT" : "MBR");
}
MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE);
if (FileSystemList == NULL)
{
/* Create the file system list, and by default select the "FAT" file system */
@ -3228,6 +3250,19 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
DiskEntry,
PartEntry);
/*
* Check whether the user attempts to install ReactOS within the
* installation source directory, or in a subdirectory thereof.
* If so, fail with an error.
*/
if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
{
PopupError("You cannot install ReactOS within the installation source directory!",
MUIGetString(STRING_CONTINUE),
Ir, POPUP_WAIT_ENTER);
return INSTALL_DIRECTORY_PAGE;
}
return PREPARE_COPY_PAGE;
}
@ -3317,6 +3352,19 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
DiskEntry,
PartEntry);
/*
* Check whether the user attempts to install ReactOS within the
* installation source directory, or in a subdirectory thereof.
* If so, fail with an error.
*/
if (RtlPrefixUnicodeString(&USetupData.SourcePath, &USetupData.DestinationPath, TRUE))
{
PopupError("You cannot install ReactOS within the installation source directory!",
MUIGetString(STRING_CONTINUE),
Ir, POPUP_WAIT_ENTER);
return INSTALL_DIRECTORY_PAGE;
}
return PREPARE_COPY_PAGE;
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */