https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e2a92634e11021378730d…
commit e2a92634e11021378730da7bfb55f52df185e2c5
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Fri Aug 25 14:38:12 2017 +0000
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sat Oct 27 18:13:43 2018 +0200
[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
---
base/setup/usetup/usetup.c | 52 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 50 insertions(+), 2 deletions(-)
diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c
index 8ce3ec5338..a053d90fd0 100644
--- a/base/setup/usetup/usetup.c
+++ b/base/setup/usetup/usetup.c
@@ -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 */