* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: partlist.c,v 1.23 2003/08/29 11:27:16 ekohl Exp $
+/* $Id: partlist.c,v 1.24 2003/10/06 19:22:42 chorns Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/partlist.c
}
+VOID
+SelectPartition(PPARTLIST List, ULONG DiskNumber, ULONG PartitionNumber)
+{
+ PDISKENTRY DiskEntry;
+ PPARTENTRY PartEntry;
+ PLIST_ENTRY Entry1;
+ PLIST_ENTRY Entry2;
+ ULONG i;
+
+ /* Check for empty disks */
+ if (IsListEmpty (&List->DiskListHead))
+ return;
+
+ /* Check for first usable entry on next disk */
+ Entry1 = List->CurrentDisk->ListEntry.Flink;
+ while (Entry1 != &List->DiskListHead)
+ {
+ DiskEntry = CONTAINING_RECORD (Entry1, DISKENTRY, ListEntry);
+
+ if (DiskEntry->DiskNumber == DiskNumber)
+ {
+ Entry2 = DiskEntry->PartListHead.Flink;
+ while (Entry2 != &DiskEntry->PartListHead)
+ {
+ PartEntry = CONTAINING_RECORD (Entry2, PARTENTRY, ListEntry);
+
+ for (i = 0; i < 4; i++)
+ {
+ if (PartEntry->PartInfo[i].PartitionNumber == PartitionNumber)
+ {
+ List->CurrentDisk = DiskEntry;
+ List->CurrentPartition = PartEntry;
+ DrawPartitionList (List);
+ return;
+ }
+ }
+ Entry2 = Entry2->Flink;
+ }
+ return;
+ }
+ Entry1 = Entry1->Flink;
+ }
+}
+
+
VOID
ScrollDownPartitionList (PPARTLIST List)
{
HANDLE ProcessHeap;
UNICODE_STRING SourceRootPath;
-
+BOOLEAN IsUnattendedSetup;
+LONG UnattendDestinationDiskNumber;
+LONG UnattendDestinationPartitionNumber;
+WCHAR UnattendInstallationDirectory[MAX_PATH];
/* LOCALS *******************************************************************/
}
+VOID
+CheckUnattendedSetup()
+{
+ WCHAR UnattendInfPath[MAX_PATH];
+ UNICODE_STRING FileName;
+ INFCONTEXT Context;
+ HINF UnattendInf;
+ ULONG ErrorLine;
+ NTSTATUS Status;
+ LONG IntValue;
+ PWCHAR Value;
+
+ if (DoesFileExist(SourcePath.Buffer, L"unattend.inf") == FALSE)
+ {
+ DPRINT("Does not exist: %S\\%S\n", SourcePath.Buffer, L"unattend.inf");
+ IsUnattendedSetup = FALSE;
+ return;
+ }
+
+ wcscpy(UnattendInfPath, SourcePath.Buffer);
+ wcscat(UnattendInfPath, L"\\unattend.inf");
+
+ RtlInitUnicodeString(&FileName,
+ UnattendInfPath);
+
+ /* Load txtsetup.sif from install media. */
+
+ Status = InfOpenFile(&UnattendInf,
+ &FileName,
+ &ErrorLine);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("InfOpenFile() failed with status 0x%x\n", Status);
+ return;
+ }
+
+ /* Open 'Unattend' section */
+ if (!InfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context))
+ {
+ DPRINT("InfFindFirstLine() failed for section 'Unattend'\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+
+ /* Get pointer 'Signature' key */
+ if (!InfGetData(&Context, NULL, &Value))
+ {
+ DPRINT("InfGetData() failed for key 'Signature'\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+
+ /* Check 'Signature' string */
+ if (_wcsicmp(Value, L"$ReactOS$") != 0)
+ {
+ DPRINT("Signature not $ReactOS$\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+
+ /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
+ if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context))
+ {
+ DPRINT("InfFindFirstLine() failed for key 'DestinationDiskNumber'\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+ if (!InfGetIntField(&Context, 0, &IntValue))
+ {
+ DPRINT("InfGetIntField() failed for key 'DestinationDiskNumber'\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+ UnattendDestinationDiskNumber = IntValue;
+
+ /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
+ if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
+ {
+ DPRINT("InfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+ if (!InfGetIntField(&Context, 0, &IntValue))
+ {
+ DPRINT("InfGetIntField() failed for key 'DestinationPartitionNumber'\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+ UnattendDestinationPartitionNumber = IntValue;
+
+ /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
+ if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
+ {
+ DPRINT("InfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+ /* Get pointer 'InstallationDirectory' key */
+ if (!InfGetData(&Context, NULL, &Value))
+ {
+ DPRINT("InfGetData() failed for key 'InstallationDirectory'\n");
+ InfCloseFile(UnattendInf);
+ return;
+ }
+ wcscpy(UnattendInstallationDirectory, Value);
+
+ InfCloseFile(UnattendInf);
+
+ IsUnattendedSetup = TRUE;
+
+ DPRINT("Running unattended setup\n");
+}
+
/*
* Start page
}
}
+ CheckUnattendedSetup();
+
return(INTRO_PAGE);
}
SetStatusText(" ENTER = Continue F3 = Quit");
+ if (IsUnattendedSetup)
+ {
+ return(INSTALL_INTRO_PAGE);
+ }
+
while(TRUE)
{
ConInKey(Ir);
SetStatusText(" ENTER = Continue F3 = Quit");
+ if (IsUnattendedSetup)
+ {
+ return(SELECT_PARTITION_PAGE);
+ }
+
while(TRUE)
{
ConInKey(Ir);
}
}
+ if (IsUnattendedSetup)
+ {
+ SelectPartition(PartitionList,
+ UnattendDestinationDiskNumber,
+ UnattendDestinationPartitionNumber);
+ return(SELECT_FILE_SYSTEM_PAGE);
+ }
+
while(TRUE)
{
/* Update status text */
SetStatusText (" ENTER = Continue ESC = Cancel F3 = Quit");
+ if (IsUnattendedSetup)
+ {
+ return(CHECK_FILE_SYSTEM_PAGE);
+ }
+
while (TRUE)
{
ConInKey (Ir);
}
}
-
/* Set DestinationRootPath */
RtlFreeUnicodeString (&DestinationRootPath);
swprintf (PathBuffer,
DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath);
+ if (IsUnattendedSetup)
+ {
+ return(INSTALL_DIRECTORY_PAGE);
+ }
+
while(TRUE)
{
ConInKey(Ir);
}
+static PAGE_NUMBER
+InstallDirectoryPage1(PWCHAR InstallDir, PDISKENTRY DiskEntry, PPARTENTRY PartEntry)
+{
+ WCHAR PathBuffer[MAX_PATH];
+
+ /* Create 'InstallPath' string */
+ RtlFreeUnicodeString(&InstallPath);
+ RtlCreateUnicodeString(&InstallPath,
+ InstallDir);
+
+ /* Create 'DestinationPath' string */
+ RtlFreeUnicodeString(&DestinationPath);
+ wcscpy(PathBuffer,
+ DestinationRootPath.Buffer);
+ if (InstallDir[0] != L'\\')
+ wcscat(PathBuffer,
+ L"\\");
+ wcscat(PathBuffer, InstallDir);
+ RtlCreateUnicodeString(&DestinationPath,
+ PathBuffer);
+
+ /* Create 'DestinationArcPath' */
+ RtlFreeUnicodeString(&DestinationArcPath);
+ swprintf(PathBuffer,
+ L"multi(0)disk(0)rdisk(%lu)partition(%lu)",
+ DiskEntry->DiskNumber,
+ PartEntry->PartInfo[0].PartitionNumber);
+ if (InstallDir[0] != L'\\')
+ wcscat(PathBuffer,
+ L"\\");
+ wcscat(PathBuffer, InstallDir);
+ RtlCreateUnicodeString(&DestinationArcPath,
+ PathBuffer);
+
+ return(PREPARE_COPY_PAGE);
+}
+
+
static PAGE_NUMBER
InstallDirectoryPage(PINPUT_RECORD Ir)
{
SetStatusText(" ENTER = Continue F3 = Quit");
+ if (IsUnattendedSetup)
+ {
+ return(InstallDirectoryPage1 (InstallDir, DiskEntry, PartEntry));
+ }
+
while(TRUE)
{
ConInKey(Ir);
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
- /* Create 'InstallPath' string */
- RtlFreeUnicodeString(&InstallPath);
- RtlCreateUnicodeString(&InstallPath,
- InstallDir);
-
- /* Create 'DestinationPath' string */
- RtlFreeUnicodeString(&DestinationPath);
- wcscpy(PathBuffer,
- DestinationRootPath.Buffer);
- if (InstallDir[0] != L'\\')
- wcscat(PathBuffer,
- L"\\");
- wcscat(PathBuffer, InstallDir);
- RtlCreateUnicodeString(&DestinationPath,
- PathBuffer);
-
- /* Create 'DestinationArcPath' */
- RtlFreeUnicodeString(&DestinationArcPath);
- swprintf(PathBuffer,
- L"multi(0)disk(0)rdisk(%lu)partition(%lu)",
- DiskEntry->DiskNumber,
- PartEntry->PartInfo[0].PartitionNumber);
- if (InstallDir[0] != L'\\')
- wcscat(PathBuffer,
- L"\\");
- wcscat(PathBuffer, InstallDir);
- RtlCreateUnicodeString(&DestinationArcPath,
- PathBuffer);
-
- return(PREPARE_COPY_PAGE);
+ return (InstallDirectoryPage1 (InstallDir, DiskEntry, PartEntry));
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
{
SetStatusText(" ENTER = Reboot computer");
+ if (IsUnattendedSetup)
+ {
+ return(REBOOT_PAGE);
+ }
+
while(TRUE)
{
ConInKey(Ir);