#include "chkdsk.h"
#include "cmdcons.h"
#include "format.h"
-#include "drivesup.h"
#include "settings.h"
#define NDEBUG
static UNICODE_STRING SourceRootPath;
static UNICODE_STRING SourceRootDir;
-/* static */ UNICODE_STRING SourcePath;
+static UNICODE_STRING SourcePath;
BOOLEAN IsUnattendedSetup = FALSE;
LONG UnattendDestinationDiskNumber;
static PFILE_SYSTEM_LIST FileSystemList = NULL;
+/*
+ * NOTE: Technically only used for the COPYCONTEXT InstallPath member
+ * for the filequeue functionality.
+ */
static UNICODE_STRING InstallPath;
/*
*/
static UNICODE_STRING SystemRootPath;
-/* Path to the install directory inside the ReactOS boot partition */
+/* Path to the installation directory inside the ReactOS boot partition */
static UNICODE_STRING DestinationPath;
static UNICODE_STRING DestinationArcPath;
static UNICODE_STRING DestinationRootPath;
}
/* Load 'unattend.inf' from install media. */
- UnattendInf = SetupOpenInfFileW(UnattendInfPath,
- NULL,
- INF_STYLE_WIN4,
- LanguageId,
- &ErrorLine);
+ UnattendInf = SetupOpenInfFileExW(UnattendInfPath,
+ NULL,
+ INF_STYLE_WIN4,
+ LanguageId,
+ &ErrorLine);
if (UnattendInf == INVALID_HANDLE_VALUE)
{
- DPRINT("SetupOpenInfFileW() failed\n");
+ DPRINT("SetupOpenInfFileExW() failed\n");
return;
}
}
+static NTSTATUS
+GetSourcePaths(
+ OUT PUNICODE_STRING SourcePath,
+ OUT PUNICODE_STRING SourceRootPath,
+ OUT PUNICODE_STRING SourceRootDir)
+{
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING LinkName = RTL_CONSTANT_STRING(L"\\SystemRoot");
+ UNICODE_STRING SourceName;
+ WCHAR SourceBuffer[MAX_PATH] = L"";
+ HANDLE Handle;
+ ULONG Length;
+ PWCHAR Ptr;
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &LinkName,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = NtOpenSymbolicLinkObject(&Handle,
+ SYMBOLIC_LINK_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ RtlInitEmptyUnicodeString(&SourceName, SourceBuffer, sizeof(SourceBuffer));
+
+ Status = NtQuerySymbolicLinkObject(Handle,
+ &SourceName,
+ &Length);
+ NtClose(Handle);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ RtlCreateUnicodeString(SourcePath,
+ SourceName.Buffer);
+
+ /* Strip trailing directory */
+ Ptr = wcsrchr(SourceName.Buffer, OBJ_NAME_PATH_SEPARATOR);
+ if (Ptr)
+ {
+ RtlCreateUnicodeString(SourceRootDir, Ptr);
+ *Ptr = UNICODE_NULL;
+ }
+ else
+ {
+ RtlCreateUnicodeString(SourceRootDir, L"");
+ }
+
+ RtlCreateUnicodeString(SourceRootPath,
+ SourceName.Buffer);
+
+ return STATUS_SUCCESS;
+}
+
+
/*
* Start page
*
/* Load txtsetup.sif from install media. */
CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2, SourcePath.Buffer, L"txtsetup.sif");
- SetupInf = SetupOpenInfFileW(FileNameBuffer,
- NULL,
- INF_STYLE_WIN4,
- LanguageId,
- &ErrorLine);
+ SetupInf = SetupOpenInfFileExW(FileNameBuffer,
+ NULL,
+ INF_STYLE_WIN4,
+ LanguageId,
+ &ErrorLine);
if (SetupInf == INVALID_HANDLE_VALUE)
{
RequiredPartitionDiskSpace = (ULONG)IntValue;
/* Start the PnP thread */
- if (hPnpThread != INVALID_HANDLE_VALUE)
+ if (hPnpThread != NULL)
{
NtResumeThread(hPnpThread, NULL);
- hPnpThread = INVALID_HANDLE_VALUE;
+ hPnpThread = NULL;
}
CheckUnattendedSetup();
ULONGLONG size;
size = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector;
- size = (size + 524288) / 1048576; /* in MBytes */
+ size = (size + (512 * KB)) / MB; /* in MBytes */
if (size < RequiredPartitionDiskSpace)
{
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (DiskSize >= 10737418240) /* 10 GB */
+ if (DiskSize >= 10 * GB) /* 10 GB */
{
- DiskSize = DiskSize / 1073741824;
+ DiskSize = DiskSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
if (DiskSize == 0)
DiskSize = 1;
#if 0
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
- PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / 1048576);
+ PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
#endif
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
PartEntry = PartitionList->CurrentPartition;
while (TRUE)
{
- MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / 1048576; /* in MBytes (rounded) */
+ MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
if (MaxSize > PARTITION_MAXSIZE)
MaxSize = PARTITION_MAXSIZE;
else
{
/* Calculate the sector count from the size in MB */
- SectorCount = PartSize * 1048576 / DiskEntry->BytesPerSector;
+ SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
/* But never get larger than the unpartitioned disk space */
if (SectorCount > PartEntry->SectorCount.QuadPart)
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (DiskSize >= 10737418240) /* 10 GB */
+ if (DiskSize >= 10 * GB) /* 10 GB */
{
- DiskSize = DiskSize / 1073741824;
+ DiskSize = DiskSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
if (DiskSize == 0)
DiskSize = 1;
#if 0
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
- PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / 1048576);
+ PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
#endif
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
PartEntry = PartitionList->CurrentPartition;
while (TRUE)
{
- MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / 1048576; /* in MBytes (rounded) */
+ MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
if (MaxSize > PARTITION_MAXSIZE)
MaxSize = PARTITION_MAXSIZE;
else
{
/* Calculate the sector count from the size in MB */
- SectorCount = PartSize * 1048576 / DiskEntry->BytesPerSector;
+ SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
/* But never get larger than the unpartitioned disk space */
if (SectorCount > PartEntry->SectorCount.QuadPart)
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (DiskSize >= 10737418240) /* 10 GB */
+ if (DiskSize >= 10 * GB) /* 10 GB */
{
- DiskSize = DiskSize / 1073741824;
+ DiskSize = DiskSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
if (DiskSize == 0)
DiskSize = 1;
#if 0
CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
- PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / 1048576);
+ PartitionList->CurrentPartition->SectorCount * DiskEntry->BytesPerSector / MB);
#endif
CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION));
PartEntry = PartitionList->CurrentPartition;
while (TRUE)
{
- MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / 1048576; /* in MBytes (rounded) */
+ MaxSize = (PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) / MB; /* in MBytes (rounded) */
if (MaxSize > PARTITION_MAXSIZE)
MaxSize = PARTITION_MAXSIZE;
else
{
/* Calculate the sector count from the size in MB */
- SectorCount = PartSize * 1048576 / DiskEntry->BytesPerSector;
+ SectorCount = PartSize * MB / DiskEntry->BytesPerSector;
/* But never get larger than the unpartitioned disk space */
if (SectorCount > PartEntry->SectorCount.QuadPart)
PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (PartSize >= 10737418240) /* 10 GB */
+ if (PartSize >= 10 * GB) /* 10 GB */
{
- PartSize = PartSize / 1073741824;
+ PartSize = PartSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
- if (PartSize >= 10485760) /* 10 MB */
+ if (PartSize >= 10 * MB) /* 10 MB */
{
- PartSize = PartSize / 1048576;
+ PartSize = PartSize / MB;
Unit = MUIGetString(STRING_MB);
}
else
{
- PartSize = PartSize / 1024;
+ PartSize = PartSize / KB;
Unit = MUIGetString(STRING_KB);
}
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
#if 0
- if (DiskSize >= 10737418240) /* 10 GB */
+ if (DiskSize >= 10 * GB) /* 10 GB */
{
- DiskSize = DiskSize / 1073741824;
+ DiskSize = DiskSize / GB;
Unit = MUIGetString(STRING_GB);
}
else
#endif
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
if (DiskSize == 0)
DiskSize = 1;
/* Adjust disk size */
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
- if (DiskSize >= 10737418240) /* 10 GB */
+ if (DiskSize >= 10 * GB) /* 10 GB */
{
- DiskSize = DiskSize / 1073741824;
+ DiskSize = DiskSize / GB;
DiskUnit = MUIGetString(STRING_GB);
}
else
{
- DiskSize = DiskSize / 1048576;
+ DiskSize = DiskSize / MB;
DiskUnit = MUIGetString(STRING_MB);
}
/* Adjust partition size */
PartSize = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
- if (PartSize >= 10737418240) /* 10 GB */
+ if (PartSize >= 10 * GB) /* 10 GB */
{
- PartSize = PartSize / 1073741824;
+ PartSize = PartSize / GB;
PartUnit = MUIGetString(STRING_GB);
}
else
{
- PartSize = PartSize / 1048576;
+ PartSize = PartSize / MB;
PartUnit = MUIGetString(STRING_MB);
}
{
WCHAR PathBuffer[MAX_PATH];
+/** Equivalent of 'NTOS_INSTALLATION::PathComponent' **/
/* Create 'InstallPath' string */
RtlFreeUnicodeString(&InstallPath);
RtlCreateUnicodeString(&InstallPath, InstallDir);
RtlCreateUnicodeString(&DestinationRootPath, PathBuffer);
DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath);
+/** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
/* Create 'DestinationPath' string */
RtlFreeUnicodeString(&DestinationPath);
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
DestinationRootPath.Buffer, InstallDir);
RtlCreateUnicodeString(&DestinationPath, PathBuffer);
+/** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
/* Create 'DestinationArcPath' */
RtlFreeUnicodeString(&DestinationArcPath);
StringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
WCHAR c;
ULONG Length, Pos;
- /* We do not need the filesystem list any more */
+ /* We do not need the filesystem list anymore */
if (FileSystemList != NULL)
{
DestroyFileSystemList(FileSystemList);
DiskEntry = PartitionList->CurrentDisk;
PartEntry = PartitionList->CurrentPartition;
- if (RepairUpdateFlag)
- {
- if (!IsValidPath(CurrentInstallation->PathComponent)) // SystemNtPath
- {
- /* FIXME: Log the error? */
- return QUIT_PAGE;
- }
-
- BuildInstallPaths(CurrentInstallation->PathComponent, // SystemNtPath
- DiskEntry,
- PartEntry);
-
- return PREPARE_COPY_PAGE;
- }
if (IsUnattendedSetup)
- {
- if (!IsValidPath(UnattendInstallationDirectory))
- {
- /* FIXME: Log the error? */
- return QUIT_PAGE;
- }
+ wcscpy(InstallDir, UnattendInstallationDirectory);
+ else if (RepairUpdateFlag)
+ wcscpy(InstallDir, CurrentInstallation->PathComponent); // SystemNtPath
+ else
+ wcscpy(InstallDir, L"\\ReactOS");
- BuildInstallPaths(UnattendInstallationDirectory,
+ /*
+ * Check the validity of the predefined 'InstallDir'. If we are either
+ * in unattended setup or in update/repair mode, and the installation path
+ * is valid, just perform the installation. Otherwise (either in the case
+ * of an invalid path, or we are in regular setup), display the UI and allow
+ * the user to specify a new installation path.
+ */
+ if ((RepairUpdateFlag || IsUnattendedSetup) && IsValidPath(InstallDir))
+ {
+ BuildInstallPaths(InstallDir,
DiskEntry,
PartEntry);
return PREPARE_COPY_PAGE;
}
- wcscpy(InstallDir, L"\\ReactOS");
-
Length = wcslen(InstallDir);
Pos = Length;
+
+ MUIDisplayPage(INSTALL_DIRECTORY_PAGE);
CONSOLE_SetInputTextXY(8, 11, 51, InstallDir);
CONSOLE_SetCursorXY(8 + Pos, 11);
CONSOLE_SetCursorType(TRUE, TRUE);
- MUIDisplayPage(INSTALL_DIRECTORY_PAGE);
while (TRUE)
{
return QUIT_PAGE;
}
- InfHandle = INF_OpenBufferedFileA((CHAR*) InfFileData,
+ InfHandle = INF_OpenBufferedFileA((PSTR)InfFileData,
InfFileSize,
- (const CHAR*) NULL,
+ NULL,
INF_STYLE_WIN4,
LanguageId,
&ErrorLine);
CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE), File);
- if (!ImportRegistryFile(File, Section, LanguageId, Delete))
+ if (!ImportRegistryFile(SourcePath.Buffer, File, Section, LanguageId, Delete))
{
DPRINT1("Importing %S failed\n", File);
MUIDisplayError(ERROR_IMPORT_HIVE, Ir, POPUP_WAIT_ENTER);
&hPnpThread,
NULL);
if (!NT_SUCCESS(Status))
- hPnpThread = INVALID_HANDLE_VALUE;
+ hPnpThread = NULL;
if (!CONSOLE_Init())
{