Author: hbelusca
Date: Fri Aug 25 14:38:12 2017
New Revision: 75669
URL:
http://svn.reactos.org/svn/reactos?rev=75669&view=rev
Log:
[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!
Modified:
branches/setup_improvements/base/setup/usetup/usetup.c
Modified: branches/setup_improvements/base/setup/usetup/usetup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/usetup.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/usetup.c [iso-8859-1] Fri Aug 25
14:38:12 2017
@@ -1614,9 +1614,31 @@
}
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;
}
@@ -2591,6 +2613,8 @@
PartTypeString,
ARRAYSIZE(PartTypeString));
+ MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE);
+
if (PartEntry->AutoCreate == TRUE)
{
CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION));
@@ -2674,8 +2698,6 @@
&DiskEntry->DriverName,
DiskEntry->NoMbr ? "GPT" : "MBR");
}
-
- MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE);
if (FileSystemList == NULL)
{
@@ -3068,6 +3090,20 @@
/* Initialize DestinationDriveLetter */
DestinationDriveLetter = (WCHAR)PartEntry->DriveLetter;
+
+ /*
+ * 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))
+ {
+ INPUT_RECORD Ir;
+ 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;
}