3 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: base/setup/usetup/usetup.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
25 * Hervé Poussineau (hpoussin@reactos.org)
40 /* GLOBALS & LOCALS *********************************************************/
43 BOOLEAN IsUnattendedSetup
= FALSE
;
45 static USETUP_DATA USetupData
;
47 // FIXME: Is it really useful?? Just used for SetDefaultPagefile...
48 static WCHAR DestinationDriveLetter
;
53 PCWSTR SelectedLanguageId
;
54 static WCHAR DefaultLanguage
[20]; // Copy of string inside LanguageList
55 static WCHAR DefaultKBLayout
[20]; // Copy of string inside KeyboardList
57 static BOOLEAN RepairUpdateFlag
= FALSE
;
59 static HANDLE hPnpThread
= NULL
;
61 static PPARTLIST PartitionList
= NULL
;
62 static PPARTENTRY TempPartition
= NULL
;
63 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
64 static FORMATMACHINESTATE FormatState
= Start
;
66 /*****************************************************/
68 static PNTOS_INSTALLATION CurrentInstallation
= NULL
;
69 static PGENERIC_LIST NtOsInstallsList
= NULL
;
72 /* FUNCTIONS ****************************************************************/
75 PrintString(char* fmt
,...)
79 UNICODE_STRING UnicodeString
;
80 ANSI_STRING AnsiString
;
83 vsprintf(buffer
, fmt
, ap
);
86 RtlInitAnsiString(&AnsiString
, buffer
);
87 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
88 NtDisplayString(&UnicodeString
);
89 RtlFreeUnicodeString(&UnicodeString
);
94 DrawBox(IN SHORT xLeft
,
102 /* Draw upper left corner */
105 FillConsoleOutputCharacterA(StdOutput
,
111 /* Draw upper edge */
114 FillConsoleOutputCharacterA(StdOutput
,
120 /* Draw upper right corner */
121 coPos
.X
= xLeft
+ Width
- 1;
123 FillConsoleOutputCharacterA(StdOutput
,
129 /* Draw right edge, inner space and left edge */
130 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
133 FillConsoleOutputCharacterA(StdOutput
,
140 FillConsoleOutputCharacterA(StdOutput
,
146 coPos
.X
= xLeft
+ Width
- 1;
147 FillConsoleOutputCharacterA(StdOutput
,
154 /* Draw lower left corner */
156 coPos
.Y
= yTop
+ Height
- 1;
157 FillConsoleOutputCharacterA(StdOutput
,
163 /* Draw lower edge */
165 coPos
.Y
= yTop
+ Height
- 1;
166 FillConsoleOutputCharacterA(StdOutput
,
172 /* Draw lower right corner */
173 coPos
.X
= xLeft
+ Width
- 1;
174 coPos
.Y
= yTop
+ Height
- 1;
175 FillConsoleOutputCharacterA(StdOutput
,
184 PopupError(PCCH Text
,
202 /* Count text lines and longest line */
209 p
= strchr(pnext
, '\n');
213 Length
= strlen(pnext
);
218 Length
= (ULONG
)(p
- pnext
);
224 if (Length
> MaxLength
)
233 /* Check length of status line */
236 Length
= strlen(Status
);
238 if (Length
> MaxLength
)
242 Width
= MaxLength
+ 4;
248 yTop
= (yScreen
- Height
) / 2;
249 xLeft
= (xScreen
- Width
) / 2;
252 /* Set screen attributes */
254 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
256 FillConsoleOutputAttribute(StdOutput
,
257 FOREGROUND_RED
| BACKGROUND_WHITE
,
263 DrawBox(xLeft
, yTop
, Width
, Height
);
265 /* Print message text */
270 p
= strchr(pnext
, '\n');
274 Length
= strlen(pnext
);
279 Length
= (ULONG
)(p
- pnext
);
286 WriteConsoleOutputCharacterA(StdOutput
,
300 /* Print separator line and status text */
303 coPos
.Y
= yTop
+ Height
- 3;
305 FillConsoleOutputCharacterA(StdOutput
,
312 FillConsoleOutputCharacterA(StdOutput
,
318 coPos
.X
= xLeft
+ Width
- 1;
319 FillConsoleOutputCharacterA(StdOutput
,
327 WriteConsoleOutputCharacterA(StdOutput
,
329 min(strlen(Status
), (SIZE_T
)Width
- 4),
334 if (WaitEvent
== POPUP_WAIT_NONE
)
339 CONSOLE_ConInKey(Ir
);
341 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
342 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
354 * FALSE: Don't quit setup.
357 ConfirmQuit(PINPUT_RECORD Ir
)
360 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
364 CONSOLE_ConInKey(Ir
);
366 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
367 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
372 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
386 PGENERIC_LIST_ENTRY ListEntry
;
389 pszNewLayout
= MUIDefaultKeyboardLayout(SelectedLanguageId
);
391 if (USetupData
.LayoutList
== NULL
)
393 USetupData
.LayoutList
= CreateKeyboardLayoutList(USetupData
.SetupInf
, SelectedLanguageId
, DefaultKBLayout
);
394 if (USetupData
.LayoutList
== NULL
)
396 /* FIXME: Handle error! */
401 /* Search for default layout (if provided) */
402 if (pszNewLayout
!= NULL
)
404 for (ListEntry
= GetFirstListEntry(USetupData
.LayoutList
); ListEntry
;
405 ListEntry
= GetNextListEntry(ListEntry
))
407 if (!wcscmp(pszNewLayout
, ((PGENENTRY
)GetListEntryData(ListEntry
))->Id
))
409 SetCurrentListEntry(USetupData
.LayoutList
, ListEntry
);
419 GetSettingDescription(
420 IN PGENERIC_LIST_ENTRY Entry
,
422 IN SIZE_T cchBufferSize
)
424 return RtlStringCchPrintfA(Buffer
, cchBufferSize
, "%S",
425 ((PGENENTRY
)GetListEntryData(Entry
))->Value
);
430 GetNTOSInstallationName(
431 IN PGENERIC_LIST_ENTRY Entry
,
433 IN SIZE_T cchBufferSize
)
435 PNTOS_INSTALLATION NtOsInstall
= (PNTOS_INSTALLATION
)GetListEntryData(Entry
);
436 PPARTENTRY PartEntry
= NtOsInstall
->PartEntry
;
438 if (PartEntry
&& PartEntry
->DriveLetter
)
440 /* We have retrieved a partition that is mounted */
441 return RtlStringCchPrintfA(Buffer
, cchBufferSize
,
443 PartEntry
->DriveLetter
,
444 NtOsInstall
->PathComponent
,
445 NtOsInstall
->InstallationName
);
449 /* We failed somewhere, just show the NT path */
450 return RtlStringCchPrintfA(Buffer
, cchBufferSize
,
452 &NtOsInstall
->SystemNtPath
,
453 NtOsInstall
->InstallationName
);
459 * Displays the LanguagePage.
461 * Next pages: WelcomePage, QuitPage
464 * Init SelectedLanguageId
465 * Init USetupData.LanguageId
468 * Number of the next page.
471 LanguagePage(PINPUT_RECORD Ir
)
473 GENERIC_LIST_UI ListUi
;
474 PCWSTR NewLanguageId
;
475 BOOL RefreshPage
= FALSE
;
477 /* Initialize the computer settings list */
478 if (USetupData
.LanguageList
== NULL
)
480 USetupData
.LanguageList
= CreateLanguageList(USetupData
.SetupInf
, DefaultLanguage
);
481 if (USetupData
.LanguageList
== NULL
)
483 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
488 SelectedLanguageId
= DefaultLanguage
;
489 USetupData
.LanguageId
= 0;
492 SetConsoleCodePage();
496 * If there is no language or just a single one in the list,
497 * skip the language selection process altogether.
499 if (GetNumberOfListEntries(USetupData
.LanguageList
) <= 1)
501 USetupData
.LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
505 InitGenericListUi(&ListUi
, USetupData
.LanguageList
, GetSettingDescription
);
506 DrawGenericList(&ListUi
,
511 ScrollToPositionGenericList(&ListUi
, GetDefaultLanguageIndex());
513 MUIDisplayPage(LANGUAGE_PAGE
);
517 CONSOLE_ConInKey(Ir
);
519 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
520 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
522 ScrollDownGenericList(&ListUi
);
525 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
526 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
528 ScrollUpGenericList(&ListUi
);
531 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
532 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
534 ScrollPageDownGenericList(&ListUi
);
537 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
538 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
540 ScrollPageUpGenericList(&ListUi
);
543 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
544 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
549 RedrawGenericList(&ListUi
);
551 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
553 ASSERT(GetNumberOfListEntries(USetupData
.LanguageList
) >= 1);
556 ((PGENENTRY
)GetListEntryData(GetCurrentListEntry(USetupData
.LanguageList
)))->Id
;
558 USetupData
.LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
560 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
566 SetConsoleCodePage();
570 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
573 GenericListKeyPress(&ListUi
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
579 ASSERT(GetNumberOfListEntries(USetupData
.LanguageList
) >= 1);
582 ((PGENENTRY
)GetListEntryData(GetCurrentListEntry(USetupData
.LanguageList
)))->Id
;
584 if (wcscmp(SelectedLanguageId
, NewLanguageId
))
586 /* Clear the language page */
587 MUIClearPage(LANGUAGE_PAGE
);
589 SelectedLanguageId
= NewLanguageId
;
592 SetConsoleCodePage();
594 /* Redraw language selection page in native language */
595 MUIDisplayPage(LANGUAGE_PAGE
);
610 * LanguagePage (at once, default)
611 * InstallIntroPage (at once, if unattended)
616 * Init USetupData.SourcePath
617 * Init USetupData.SourceRootPath
618 * Init USetupData.SourceRootDir
619 * Init USetupData.SetupInf
620 * Init USetupData.RequiredPartitionDiskSpace
621 * Init IsUnattendedSetup
622 * If unattended, init *List and sets the Codepage
623 * If unattended, init SelectedLanguageId
624 * If unattended, init USetupData.LanguageId
627 * Number of the next page.
630 SetupStartPage(PINPUT_RECORD Ir
)
633 PGENERIC_LIST_ENTRY ListEntry
;
636 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
638 /* Initialize Setup, phase 1 */
639 Error
= InitializeSetup(&USetupData
, 1);
640 if (Error
!= ERROR_SUCCESS
)
642 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ENTER
);
646 /* Start the PnP thread */
647 if (hPnpThread
!= NULL
)
649 NtResumeThread(hPnpThread
, NULL
);
653 CheckUnattendedSetup(&USetupData
);
655 if (IsUnattendedSetup
)
657 // TODO: Read options from inf
658 /* Load the hardware, language and keyboard layout lists */
660 USetupData
.ComputerList
= CreateComputerTypeList(USetupData
.SetupInf
);
661 USetupData
.DisplayList
= CreateDisplayDriverList(USetupData
.SetupInf
);
662 USetupData
.KeyboardList
= CreateKeyboardDriverList(USetupData
.SetupInf
);
664 USetupData
.LanguageList
= CreateLanguageList(USetupData
.SetupInf
, DefaultLanguage
);
667 SelectedLanguageId
= DefaultLanguage
;
668 wcscpy(DefaultLanguage
, USetupData
.LocaleID
);
669 USetupData
.LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
671 USetupData
.LayoutList
= CreateKeyboardLayoutList(USetupData
.SetupInf
, SelectedLanguageId
, DefaultKBLayout
);
673 /* first we hack LanguageList */
674 for (ListEntry
= GetFirstListEntry(USetupData
.LanguageList
); ListEntry
;
675 ListEntry
= GetNextListEntry(ListEntry
))
677 LocaleId
= ((PGENENTRY
)GetListEntryData(ListEntry
))->Id
;
678 if (!wcsicmp(USetupData
.LocaleID
, LocaleId
))
680 DPRINT("found %S in LanguageList\n", LocaleId
);
681 SetCurrentListEntry(USetupData
.LanguageList
, ListEntry
);
687 for (ListEntry
= GetFirstListEntry(USetupData
.LayoutList
); ListEntry
;
688 ListEntry
= GetNextListEntry(ListEntry
))
690 LocaleId
= ((PGENENTRY
)GetListEntryData(ListEntry
))->Id
;
691 if (!wcsicmp(USetupData
.LocaleID
, LocaleId
))
693 DPRINT("found %S in LayoutList\n", LocaleId
);
694 SetCurrentListEntry(USetupData
.LayoutList
, ListEntry
);
699 SetConsoleCodePage();
701 return INSTALL_INTRO_PAGE
;
704 return LANGUAGE_PAGE
;
709 * Displays the WelcomePage.
712 * InstallIntroPage (default)
719 * Number of the next page.
722 WelcomePage(PINPUT_RECORD Ir
)
724 MUIDisplayPage(WELCOME_PAGE
);
728 CONSOLE_ConInKey(Ir
);
730 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
731 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
738 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
740 return INSTALL_INTRO_PAGE
;
742 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
744 return RECOVERY_PAGE
; // REPAIR_INTRO_PAGE;
746 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* L */
757 * Displays the License page.
760 * WelcomePage (default)
763 * Number of the next page.
766 LicensePage(PINPUT_RECORD Ir
)
768 MUIDisplayPage(LICENSE_PAGE
);
772 CONSOLE_ConInKey(Ir
);
774 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
785 * Displays the RepairIntroPage.
788 * RebootPage (default)
794 * Number of the next page.
797 RepairIntroPage(PINPUT_RECORD Ir
)
799 MUIDisplayPage(REPAIR_INTRO_PAGE
);
803 CONSOLE_ConInKey(Ir
);
805 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
809 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
811 RepairUpdateFlag
= TRUE
;
812 return INSTALL_INTRO_PAGE
;
814 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
816 return RECOVERY_PAGE
;
818 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
819 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
825 return REPAIR_INTRO_PAGE
;
829 * Displays the UpgradeRepairPage.
832 * RebootPage (default)
838 * Number of the next page.
841 UpgradeRepairPage(PINPUT_RECORD Ir
)
843 GENERIC_LIST_UI ListUi
;
846 if (PartitionList
== NULL
)
848 PartitionList
= CreatePartitionList();
849 if (PartitionList
== NULL
)
851 /* FIXME: show an error dialog */
852 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
855 else if (IsListEmpty(&PartitionList
->DiskListHead
))
857 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
861 TempPartition
= NULL
;
866 NtOsInstallsList
= CreateNTOSInstallationsList(PartitionList
);
867 if (!NtOsInstallsList
)
868 DPRINT1("Failed to get a list of NTOS installations; continue installation...\n");
871 * If there is no available installation (or just a single one??) that can
872 * be updated in the list, just continue with the regular installation.
874 if (!NtOsInstallsList
|| GetNumberOfListEntries(NtOsInstallsList
) == 0)
876 RepairUpdateFlag
= FALSE
;
878 // return INSTALL_INTRO_PAGE;
879 return DEVICE_SETTINGS_PAGE
;
880 // return SCSI_CONTROLLER_PAGE;
883 MUIDisplayPage(UPGRADE_REPAIR_PAGE
);
885 InitGenericListUi(&ListUi
, NtOsInstallsList
, GetNTOSInstallationName
);
886 DrawGenericList(&ListUi
,
891 // return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
894 CONSOLE_ConInKey(Ir
);
896 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00)
898 switch (Ir
->Event
.KeyEvent
.wVirtualKeyCode
)
900 case VK_DOWN
: /* DOWN */
901 ScrollDownGenericList(&ListUi
);
904 ScrollUpGenericList(&ListUi
);
906 case VK_NEXT
: /* PAGE DOWN */
907 ScrollPageDownGenericList(&ListUi
);
909 case VK_PRIOR
: /* PAGE UP */
910 ScrollPageUpGenericList(&ListUi
);
917 RedrawGenericList(&ListUi
);
920 case VK_ESCAPE
: /* ESC */
922 RestoreGenericListUiState(&ListUi
);
923 // return nextPage; // prevPage;
925 // return INSTALL_INTRO_PAGE;
926 return DEVICE_SETTINGS_PAGE
;
927 // return SCSI_CONTROLLER_PAGE;
933 // switch (toupper(Ir->Event.KeyEvent.uChar.AsciiChar))
934 // if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
935 if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
937 /* Retrieve the current installation */
938 ASSERT(GetNumberOfListEntries(NtOsInstallsList
) >= 1);
940 CurrentInstallation
=
941 (PNTOS_INSTALLATION
)GetListEntryData(GetCurrentListEntry(NtOsInstallsList
));
943 DPRINT1("Selected installation for repair: \"%S\" ; DiskNumber = %d , PartitionNumber = %d\n",
944 CurrentInstallation
->InstallationName
, CurrentInstallation
->DiskNumber
, CurrentInstallation
->PartitionNumber
);
946 RepairUpdateFlag
= TRUE
;
949 /***/return INSTALL_INTRO_PAGE
;/***/
951 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) &&
952 (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b)) /* a-z */
954 GenericListKeyPress(&ListUi
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
959 return UPGRADE_REPAIR_PAGE
;
964 * Displays the InstallIntroPage.
967 * DeviceSettingsPage (At once if repair or update is selected)
968 * SelectPartitionPage (At once if unattended setup)
969 * DeviceSettingsPage (default)
973 * Number of the next page.
976 InstallIntroPage(PINPUT_RECORD Ir
)
978 if (RepairUpdateFlag
)
980 #if 1 /* Old code that looks good */
982 // return SELECT_PARTITION_PAGE;
983 return DEVICE_SETTINGS_PAGE
;
985 #else /* Possible new code? */
987 return DEVICE_SETTINGS_PAGE
;
988 // return SCSI_CONTROLLER_PAGE;
993 if (IsUnattendedSetup
)
994 return SELECT_PARTITION_PAGE
;
996 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1000 CONSOLE_ConInKey(Ir
);
1002 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1003 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1005 if (ConfirmQuit(Ir
))
1010 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1012 return UPGRADE_REPAIR_PAGE
;
1016 return INSTALL_INTRO_PAGE
;
1022 ScsiControllerPage(PINPUT_RECORD Ir
)
1024 // MUIDisplayPage(SCSI_CONTROLLER_PAGE);
1026 CONSOLE_SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1028 /* FIXME: print loaded mass storage driver descriptions */
1030 CONSOLE_SetTextXY(8, 10, "TEST device");
1033 CONSOLE_SetStatusText(" ENTER = Continue F3 = Quit");
1037 CONSOLE_ConInKey(Ir
);
1039 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1040 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1042 if (ConfirmQuit(Ir
))
1047 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1049 return DEVICE_SETTINGS_PAGE
;
1053 return SCSI_CONTROLLER_PAGE
;
1057 OemDriverPage(PINPUT_RECORD Ir
)
1059 // MUIDisplayPage(OEM_DRIVER_PAGE);
1061 CONSOLE_SetTextXY(6, 8, "This is the OEM driver page!");
1063 /* FIXME: Implement!! */
1065 CONSOLE_SetStatusText(" ENTER = Continue F3 = Quit");
1069 CONSOLE_ConInKey(Ir
);
1071 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1072 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1074 if (ConfirmQuit(Ir
))
1079 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1081 return DEVICE_SETTINGS_PAGE
;
1085 return OEM_DRIVER_PAGE
;
1091 * Displays the DeviceSettingsPage.
1094 * SelectPartitionPage (At once if repair or update is selected)
1095 * ComputerSettingsPage
1096 * DisplaySettingsPage
1097 * KeyboardSettingsPage
1098 * LayoutsettingsPage
1099 * SelectPartitionPage
1103 * Init USetupData.ComputerList
1104 * Init USetupData.DisplayList
1105 * Init USetupData.KeyboardList
1106 * Init USetupData.LayoutList
1109 * Number of the next page.
1112 DeviceSettingsPage(PINPUT_RECORD Ir
)
1114 static ULONG Line
= 16;
1116 /* Initialize the computer settings list */
1117 if (USetupData
.ComputerList
== NULL
)
1119 USetupData
.ComputerList
= CreateComputerTypeList(USetupData
.SetupInf
);
1120 if (USetupData
.ComputerList
== NULL
)
1122 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1127 /* Initialize the display settings list */
1128 if (USetupData
.DisplayList
== NULL
)
1130 USetupData
.DisplayList
= CreateDisplayDriverList(USetupData
.SetupInf
);
1131 if (USetupData
.DisplayList
== NULL
)
1133 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1138 /* Initialize the keyboard settings list */
1139 if (USetupData
.KeyboardList
== NULL
)
1141 USetupData
.KeyboardList
= CreateKeyboardDriverList(USetupData
.SetupInf
);
1142 if (USetupData
.KeyboardList
== NULL
)
1144 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1149 /* Initialize the keyboard layout list */
1150 if (USetupData
.LayoutList
== NULL
)
1152 USetupData
.LayoutList
= CreateKeyboardLayoutList(USetupData
.SetupInf
, SelectedLanguageId
, DefaultKBLayout
);
1153 if (USetupData
.LayoutList
== NULL
)
1155 /* FIXME: report error */
1156 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1161 if (RepairUpdateFlag
)
1162 return SELECT_PARTITION_PAGE
;
1164 // if (IsUnattendedSetup)
1165 // return SELECT_PARTITION_PAGE;
1167 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1169 DrawGenericListCurrentItem(USetupData
.ComputerList
, GetSettingDescription
, 25, 11);
1170 DrawGenericListCurrentItem(USetupData
.DisplayList
, GetSettingDescription
, 25, 12);
1171 DrawGenericListCurrentItem(USetupData
.KeyboardList
, GetSettingDescription
, 25, 13);
1172 DrawGenericListCurrentItem(USetupData
.LayoutList
, GetSettingDescription
, 25, 14);
1174 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1178 CONSOLE_ConInKey(Ir
);
1180 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1181 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1183 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1187 else if (Line
== 16)
1192 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1194 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1195 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1197 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1201 else if (Line
== 16)
1206 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1208 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1209 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1211 if (ConfirmQuit(Ir
))
1216 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1219 return COMPUTER_SETTINGS_PAGE
;
1220 else if (Line
== 12)
1221 return DISPLAY_SETTINGS_PAGE
;
1222 else if (Line
== 13)
1223 return KEYBOARD_SETTINGS_PAGE
;
1224 else if (Line
== 14)
1225 return LAYOUT_SETTINGS_PAGE
;
1226 else if (Line
== 16)
1227 return SELECT_PARTITION_PAGE
;
1231 return DEVICE_SETTINGS_PAGE
;
1236 * Handles generic selection lists.
1239 * GenericList: The list to handle.
1240 * nextPage: The page it needs to jump to after this page.
1241 * Ir: The PINPUT_RECORD
1244 HandleGenericList(PGENERIC_LIST_UI ListUi
,
1245 PAGE_NUMBER nextPage
,
1250 CONSOLE_ConInKey(Ir
);
1252 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1253 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1255 ScrollDownGenericList(ListUi
);
1257 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1258 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1260 ScrollUpGenericList(ListUi
);
1262 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1263 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1265 ScrollPageDownGenericList(ListUi
);
1267 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1268 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1270 ScrollPageUpGenericList(ListUi
);
1272 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1273 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1275 if (ConfirmQuit(Ir
))
1278 RedrawGenericList(ListUi
);
1280 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1281 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1283 RestoreGenericListUiState(ListUi
);
1284 return nextPage
; // Use some "prevPage;" instead?
1286 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1290 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1293 GenericListKeyPress(ListUi
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1300 * Displays the ComputerSettingsPage.
1303 * DeviceSettingsPage
1307 * Number of the next page.
1310 ComputerSettingsPage(PINPUT_RECORD Ir
)
1312 GENERIC_LIST_UI ListUi
;
1313 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1315 InitGenericListUi(&ListUi
, USetupData
.ComputerList
, GetSettingDescription
);
1316 DrawGenericList(&ListUi
,
1321 return HandleGenericList(&ListUi
, DEVICE_SETTINGS_PAGE
, Ir
);
1326 * Displays the DisplaySettingsPage.
1329 * DeviceSettingsPage
1333 * Number of the next page.
1336 DisplaySettingsPage(PINPUT_RECORD Ir
)
1338 GENERIC_LIST_UI ListUi
;
1339 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1341 InitGenericListUi(&ListUi
, USetupData
.DisplayList
, GetSettingDescription
);
1342 DrawGenericList(&ListUi
,
1347 return HandleGenericList(&ListUi
, DEVICE_SETTINGS_PAGE
, Ir
);
1352 * Displays the KeyboardSettingsPage.
1355 * DeviceSettingsPage
1359 * Number of the next page.
1362 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1364 GENERIC_LIST_UI ListUi
;
1365 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1367 InitGenericListUi(&ListUi
, USetupData
.KeyboardList
, GetSettingDescription
);
1368 DrawGenericList(&ListUi
,
1373 return HandleGenericList(&ListUi
, DEVICE_SETTINGS_PAGE
, Ir
);
1378 * Displays the LayoutSettingsPage.
1381 * DeviceSettingsPage
1385 * Number of the next page.
1388 LayoutSettingsPage(PINPUT_RECORD Ir
)
1390 GENERIC_LIST_UI ListUi
;
1391 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1393 InitGenericListUi(&ListUi
, USetupData
.LayoutList
, GetSettingDescription
);
1394 DrawGenericList(&ListUi
,
1399 return HandleGenericList(&ListUi
, DEVICE_SETTINGS_PAGE
, Ir
);
1404 IsDiskSizeValid(PPARTENTRY PartEntry
)
1408 size
= PartEntry
->SectorCount
.QuadPart
* PartEntry
->DiskEntry
->BytesPerSector
;
1409 size
= (size
+ (512 * KB
)) / MB
; /* in MBytes */
1411 if (size
< USetupData
.RequiredPartitionDiskSpace
)
1413 /* Partition is too small so ask for another one */
1414 DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size
, USetupData
.RequiredPartitionDiskSpace
);
1425 * Displays the SelectPartitionPage.
1428 * SelectFileSystemPage (At once if unattended)
1429 * SelectFileSystemPage (Default if free space is selected)
1430 * CreatePrimaryPartitionPage
1431 * CreateExtendedPartitionPage
1432 * CreateLogicalPartitionPage
1433 * ConfirmDeleteSystemPartitionPage (if the selected partition is the system partition, aka with the boot flag set)
1434 * DeletePartitionPage
1438 * Set InstallShortcut (only if not unattended + free space is selected)
1441 * Number of the next page.
1444 SelectPartitionPage(PINPUT_RECORD Ir
)
1449 if (PartitionList
== NULL
)
1451 PartitionList
= CreatePartitionList();
1452 if (PartitionList
== NULL
)
1454 /* FIXME: show an error dialog */
1455 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
1458 else if (IsListEmpty(&PartitionList
->DiskListHead
))
1460 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
1464 TempPartition
= NULL
;
1465 FormatState
= Start
;
1468 if (RepairUpdateFlag
)
1470 /* Determine the selected installation disk & partition */
1471 if (!SelectPartition(PartitionList
,
1472 CurrentInstallation
->DiskNumber
,
1473 CurrentInstallation
->PartitionNumber
))
1475 DPRINT1("RepairUpdateFlag == TRUE, SelectPartition() returned FALSE, assert!\n");
1479 return SELECT_FILE_SYSTEM_PAGE
;
1482 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1484 InitPartitionListUi(&ListUi
, PartitionList
,
1489 DrawPartitionList(&ListUi
);
1491 if (IsUnattendedSetup
)
1493 if (!SelectPartition(PartitionList
,
1494 USetupData
.DestinationDiskNumber
,
1495 USetupData
.DestinationPartitionNumber
))
1497 if (USetupData
.AutoPartition
)
1499 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1501 CreateLogicalPartition(PartitionList
,
1502 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1507 CreatePrimaryPartition(PartitionList
,
1508 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1512 // FIXME?? Aren't we going to enter an infinite loop, if this test fails??
1513 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1515 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1516 USetupData
.RequiredPartitionDiskSpace
);
1517 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1520 return SELECT_FILE_SYSTEM_PAGE
;
1525 DrawPartitionList(&ListUi
);
1527 // FIXME?? Aren't we going to enter an infinite loop, if this test fails??
1528 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1530 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1531 USetupData
.RequiredPartitionDiskSpace
);
1532 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1535 return SELECT_FILE_SYSTEM_PAGE
;
1541 /* Update status text */
1542 if (PartitionList
->CurrentPartition
== NULL
)
1544 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1546 else if (PartitionList
->CurrentPartition
->LogicalPartition
)
1548 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1550 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1554 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL
));
1559 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1561 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1563 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1567 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1572 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1576 CONSOLE_ConInKey(Ir
);
1578 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1579 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1581 if (ConfirmQuit(Ir
))
1583 DestroyPartitionList(PartitionList
);
1584 PartitionList
= NULL
;
1590 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1591 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1593 ScrollDownPartitionList(&ListUi
);
1595 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1596 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1598 ScrollUpPartitionList(&ListUi
);
1600 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1602 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1603 continue; // return SELECT_PARTITION_PAGE;
1605 if (PartitionList
->CurrentPartition
== NULL
||
1606 PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1608 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1610 CreateLogicalPartition(PartitionList
,
1616 CreatePrimaryPartition(PartitionList
,
1622 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1624 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1625 USetupData
.RequiredPartitionDiskSpace
);
1626 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1629 return SELECT_FILE_SYSTEM_PAGE
;
1631 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'P') /* P */
1633 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1635 Error
= PrimaryPartitionCreationChecks(PartitionList
);
1636 if (Error
!= NOT_AN_ERROR
)
1638 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1639 return SELECT_PARTITION_PAGE
;
1642 return CREATE_PRIMARY_PARTITION_PAGE
;
1645 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'E') /* E */
1647 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1649 Error
= ExtendedPartitionCreationChecks(PartitionList
);
1650 if (Error
!= NOT_AN_ERROR
)
1652 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1653 return SELECT_PARTITION_PAGE
;
1656 return CREATE_EXTENDED_PARTITION_PAGE
;
1659 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'L') /* L */
1661 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1663 Error
= LogicalPartitionCreationChecks(PartitionList
);
1664 if (Error
!= NOT_AN_ERROR
)
1666 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1667 return SELECT_PARTITION_PAGE
;
1670 return CREATE_LOGICAL_PARTITION_PAGE
;
1673 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1675 WCHAR PathBuffer
[MAX_PATH
];
1676 UNICODE_STRING CurrentPartition
;
1678 if (PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1680 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1681 return SELECT_PARTITION_PAGE
;
1684 RtlStringCchPrintfW(PathBuffer
, ARRAYSIZE(PathBuffer
),
1685 L
"\\Device\\Harddisk%lu\\Partition%lu\\",
1686 PartitionList
->CurrentDisk
->DiskNumber
,
1687 PartitionList
->CurrentPartition
->PartitionNumber
);
1688 RtlInitUnicodeString(&CurrentPartition
, PathBuffer
);
1691 * Check whether the user attempts to delete the partition on which
1692 * the installation source is present. If so, fail with an error.
1694 // &USetupData.SourceRootPath
1695 if (RtlPrefixUnicodeString(&CurrentPartition
, &USetupData
.SourcePath
, TRUE
))
1697 PopupError("You cannot delete the partition containing the installation source!",
1698 MUIGetString(STRING_CONTINUE
),
1699 Ir
, POPUP_WAIT_ENTER
);
1700 return SELECT_PARTITION_PAGE
;
1703 if (PartitionList
->CurrentPartition
->BootIndicator
||
1704 PartitionList
->CurrentPartition
== PartitionList
->SystemPartition
)
1706 return CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
;
1709 return DELETE_PARTITION_PAGE
;
1713 return SELECT_PARTITION_PAGE
;
1717 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 9
1718 /* Restriction for MaxSize: pow(10, (PARTITION_SIZE_INPUT_FIELD_LENGTH - 1)) - 1 */
1719 #define PARTITION_MAXSIZE (pow(10, (PARTITION_SIZE_INPUT_FIELD_LENGTH - 1)) - 1)
1722 ShowPartitionSizeInputBox(SHORT Left
,
1746 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1751 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1752 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1755 WriteConsoleOutputCharacterA(StdOutput
,
1761 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1762 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1764 WriteConsoleOutputCharacterA(StdOutput
,
1770 swprintf(InputBuffer
, L
"%lu", MaxSize
);
1771 Length
= wcslen(InputBuffer
);
1773 CONSOLE_SetInputTextXY(iLeft
,
1775 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1777 CONSOLE_SetCursorXY(iLeft
+ Length
, iTop
);
1778 CONSOLE_SetCursorType(TRUE
, TRUE
);
1782 CONSOLE_ConInKey(&Ir
);
1784 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1785 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1790 InputBuffer
[0] = UNICODE_NULL
;
1791 CONSOLE_SetCursorType(TRUE
, FALSE
);
1794 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1796 CONSOLE_SetCursorType(TRUE
, FALSE
);
1799 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1804 InputBuffer
[0] = UNICODE_NULL
;
1805 CONSOLE_SetCursorType(TRUE
, FALSE
);
1808 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1809 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_HOME
)) /* HOME */
1812 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1814 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1815 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_END
)) /* END */
1818 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1820 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1821 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_LEFT
)) /* LEFT */
1826 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1829 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1830 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RIGHT
)) /* RIGHT */
1835 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1838 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1839 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_DELETE
)) /* DEL */
1843 memmove(&InputBuffer
[Pos
],
1844 &InputBuffer
[Pos
+ 1],
1845 (Length
- Pos
- 1) * sizeof(WCHAR
));
1846 InputBuffer
[Length
- 1] = UNICODE_NULL
;
1849 CONSOLE_SetInputTextXY(iLeft
,
1851 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1853 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1856 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) /* BACKSPACE */
1861 memmove(&InputBuffer
[Pos
- 1],
1863 (Length
- Pos
) * sizeof(WCHAR
));
1864 InputBuffer
[Length
- 1] = UNICODE_NULL
;
1868 CONSOLE_SetInputTextXY(iLeft
,
1870 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1872 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1875 else if (Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00)
1877 if (Length
< PARTITION_SIZE_INPUT_FIELD_LENGTH
- 1)
1879 ch
= (WCHAR
)Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1881 if ((ch
>= L
'0') && (ch
<= L
'9'))
1884 memmove(&InputBuffer
[Pos
+ 1],
1886 (Length
- Pos
) * sizeof(WCHAR
));
1887 InputBuffer
[Length
+ 1] = UNICODE_NULL
;
1888 InputBuffer
[Pos
] = ch
;
1892 CONSOLE_SetInputTextXY(iLeft
,
1894 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1896 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1905 * Displays the CreatePrimaryPartitionPage.
1908 * SelectPartitionPage
1909 * SelectFileSystemPage (default)
1913 * Number of the next page.
1916 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1918 PDISKENTRY DiskEntry
;
1919 PPARTENTRY PartEntry
;
1922 WCHAR InputBuffer
[50];
1926 ULONGLONG SectorCount
;
1929 if (PartitionList
== NULL
||
1930 PartitionList
->CurrentDisk
== NULL
||
1931 PartitionList
->CurrentPartition
== NULL
)
1933 /* FIXME: show an error dialog */
1937 DiskEntry
= PartitionList
->CurrentDisk
;
1938 PartEntry
= PartitionList
->CurrentPartition
;
1940 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1942 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1944 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1946 if (DiskSize
>= 10 * GB
) /* 10 GB */
1948 DiskSize
= DiskSize
/ GB
;
1949 Unit
= MUIGetString(STRING_GB
);
1954 DiskSize
= DiskSize
/ MB
;
1958 Unit
= MUIGetString(STRING_MB
);
1961 if (DiskEntry
->DriverName
.Length
> 0)
1963 CONSOLE_PrintTextXY(6, 10,
1964 MUIGetString(STRING_HDINFOPARTCREATE_1
),
1967 DiskEntry
->DiskNumber
,
1971 &DiskEntry
->DriverName
,
1972 DiskEntry
->NoMbr
? "GPT" : "MBR");
1976 CONSOLE_PrintTextXY(6, 10,
1977 MUIGetString(STRING_HDINFOPARTCREATE_2
),
1980 DiskEntry
->DiskNumber
,
1984 DiskEntry
->NoMbr
? "GPT" : "MBR");
1987 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1990 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1991 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ MB
);
1994 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1996 PartEntry
= PartitionList
->CurrentPartition
;
1999 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / MB
; /* in MBytes (rounded) */
2001 if (MaxSize
> PARTITION_MAXSIZE
)
2002 MaxSize
= PARTITION_MAXSIZE
;
2004 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2005 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2009 if (ConfirmQuit(Ir
))
2016 return SELECT_PARTITION_PAGE
;
2020 PartSize
= _wcstoui64(InputBuffer
, NULL
, 10);
2028 if (PartSize
> MaxSize
)
2034 /* Convert to bytes */
2035 if (PartSize
== MaxSize
)
2037 /* Use all of the unpartitioned disk space */
2038 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2042 /* Calculate the sector count from the size in MB */
2043 SectorCount
= PartSize
* MB
/ DiskEntry
->BytesPerSector
;
2045 /* But never get larger than the unpartitioned disk space */
2046 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2047 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2050 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2052 CreatePrimaryPartition(PartitionList
,
2056 return SELECT_PARTITION_PAGE
;
2060 return CREATE_PRIMARY_PARTITION_PAGE
;
2065 * Displays the CreateExtendedPartitionPage.
2068 * SelectPartitionPage (default)
2072 * Number of the next page.
2075 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
2077 PDISKENTRY DiskEntry
;
2078 PPARTENTRY PartEntry
;
2081 WCHAR InputBuffer
[50];
2085 ULONGLONG SectorCount
;
2088 if (PartitionList
== NULL
||
2089 PartitionList
->CurrentDisk
== NULL
||
2090 PartitionList
->CurrentPartition
== NULL
)
2092 /* FIXME: show an error dialog */
2096 DiskEntry
= PartitionList
->CurrentDisk
;
2097 PartEntry
= PartitionList
->CurrentPartition
;
2099 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2101 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
2103 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2105 if (DiskSize
>= 10 * GB
) /* 10 GB */
2107 DiskSize
= DiskSize
/ GB
;
2108 Unit
= MUIGetString(STRING_GB
);
2113 DiskSize
= DiskSize
/ MB
;
2117 Unit
= MUIGetString(STRING_MB
);
2120 if (DiskEntry
->DriverName
.Length
> 0)
2122 CONSOLE_PrintTextXY(6, 10,
2123 MUIGetString(STRING_HDINFOPARTCREATE_1
),
2126 DiskEntry
->DiskNumber
,
2130 &DiskEntry
->DriverName
,
2131 DiskEntry
->NoMbr
? "GPT" : "MBR");
2135 CONSOLE_PrintTextXY(6, 10,
2136 MUIGetString(STRING_HDINFOPARTCREATE_2
),
2139 DiskEntry
->DiskNumber
,
2143 DiskEntry
->NoMbr
? "GPT" : "MBR");
2146 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2149 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2150 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ MB
);
2153 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2155 PartEntry
= PartitionList
->CurrentPartition
;
2158 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / MB
; /* in MBytes (rounded) */
2160 if (MaxSize
> PARTITION_MAXSIZE
)
2161 MaxSize
= PARTITION_MAXSIZE
;
2163 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2164 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2168 if (ConfirmQuit(Ir
))
2175 return SELECT_PARTITION_PAGE
;
2179 PartSize
= _wcstoui64(InputBuffer
, NULL
, 10);
2187 if (PartSize
> MaxSize
)
2193 /* Convert to bytes */
2194 if (PartSize
== MaxSize
)
2196 /* Use all of the unpartitioned disk space */
2197 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2201 /* Calculate the sector count from the size in MB */
2202 SectorCount
= PartSize
* MB
/ DiskEntry
->BytesPerSector
;
2204 /* But never get larger than the unpartitioned disk space */
2205 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2206 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2209 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2211 CreateExtendedPartition(PartitionList
,
2214 return SELECT_PARTITION_PAGE
;
2218 return CREATE_EXTENDED_PARTITION_PAGE
;
2223 * Displays the CreateLogicalPartitionPage.
2226 * SelectFileSystemPage (default)
2230 * Number of the next page.
2233 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2235 PDISKENTRY DiskEntry
;
2236 PPARTENTRY PartEntry
;
2239 WCHAR InputBuffer
[50];
2243 ULONGLONG SectorCount
;
2246 if (PartitionList
== NULL
||
2247 PartitionList
->CurrentDisk
== NULL
||
2248 PartitionList
->CurrentPartition
== NULL
)
2250 /* FIXME: show an error dialog */
2254 DiskEntry
= PartitionList
->CurrentDisk
;
2255 PartEntry
= PartitionList
->CurrentPartition
;
2257 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2259 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2261 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2263 if (DiskSize
>= 10 * GB
) /* 10 GB */
2265 DiskSize
= DiskSize
/ GB
;
2266 Unit
= MUIGetString(STRING_GB
);
2271 DiskSize
= DiskSize
/ MB
;
2275 Unit
= MUIGetString(STRING_MB
);
2278 if (DiskEntry
->DriverName
.Length
> 0)
2280 CONSOLE_PrintTextXY(6, 10,
2281 MUIGetString(STRING_HDINFOPARTCREATE_1
),
2284 DiskEntry
->DiskNumber
,
2288 &DiskEntry
->DriverName
,
2289 DiskEntry
->NoMbr
? "GPT" : "MBR");
2293 CONSOLE_PrintTextXY(6, 10,
2294 MUIGetString(STRING_HDINFOPARTCREATE_2
),
2297 DiskEntry
->DiskNumber
,
2301 DiskEntry
->NoMbr
? "GPT" : "MBR");
2304 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2307 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2308 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ MB
);
2311 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2313 PartEntry
= PartitionList
->CurrentPartition
;
2316 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / MB
; /* in MBytes (rounded) */
2318 if (MaxSize
> PARTITION_MAXSIZE
)
2319 MaxSize
= PARTITION_MAXSIZE
;
2321 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2322 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2326 if (ConfirmQuit(Ir
))
2333 return SELECT_PARTITION_PAGE
;
2337 PartSize
= _wcstoui64(InputBuffer
, NULL
, 10);
2345 if (PartSize
> MaxSize
)
2351 /* Convert to bytes */
2352 if (PartSize
== MaxSize
)
2354 /* Use all of the unpartitioned disk space */
2355 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2359 /* Calculate the sector count from the size in MB */
2360 SectorCount
= PartSize
* MB
/ DiskEntry
->BytesPerSector
;
2362 /* But never get larger than the unpartitioned disk space */
2363 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2364 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2367 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2369 CreateLogicalPartition(PartitionList
,
2373 return SELECT_PARTITION_PAGE
;
2377 return CREATE_LOGICAL_PARTITION_PAGE
;
2382 * Displays the ConfirmDeleteSystemPartitionPage.
2385 * DeletePartitionPage (default)
2386 * SelectPartitionPage
2389 * Number of the next page.
2392 ConfirmDeleteSystemPartitionPage(PINPUT_RECORD Ir
)
2394 MUIDisplayPage(CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
);
2398 CONSOLE_ConInKey(Ir
);
2400 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2401 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2403 if (ConfirmQuit(Ir
))
2408 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2410 return DELETE_PARTITION_PAGE
;
2412 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2414 return SELECT_PARTITION_PAGE
;
2418 return CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
;
2423 * Displays the DeletePartitionPage.
2426 * SelectPartitionPage (default)
2430 * Number of the next page.
2433 DeletePartitionPage(PINPUT_RECORD Ir
)
2435 PDISKENTRY DiskEntry
;
2436 PPARTENTRY PartEntry
;
2440 CHAR PartTypeString
[32];
2442 if (PartitionList
== NULL
||
2443 PartitionList
->CurrentDisk
== NULL
||
2444 PartitionList
->CurrentPartition
== NULL
)
2446 /* FIXME: show an error dialog */
2450 DiskEntry
= PartitionList
->CurrentDisk
;
2451 PartEntry
= PartitionList
->CurrentPartition
;
2453 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2455 GetPartTypeStringFromPartitionType(PartEntry
->PartitionType
,
2457 ARRAYSIZE(PartTypeString
));
2459 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2461 if (PartSize
>= 10 * GB
) /* 10 GB */
2463 PartSize
= PartSize
/ GB
;
2464 Unit
= MUIGetString(STRING_GB
);
2468 if (PartSize
>= 10 * MB
) /* 10 MB */
2470 PartSize
= PartSize
/ MB
;
2471 Unit
= MUIGetString(STRING_MB
);
2475 PartSize
= PartSize
/ KB
;
2476 Unit
= MUIGetString(STRING_KB
);
2479 if (*PartTypeString
== '\0') // STRING_FORMATUNKNOWN ??
2481 CONSOLE_PrintTextXY(6, 10,
2482 MUIGetString(STRING_HDDINFOUNK2
),
2483 (PartEntry
->DriveLetter
== 0) ? '-' : (CHAR
)PartEntry
->DriveLetter
,
2484 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2485 PartEntry
->PartitionType
,
2491 CONSOLE_PrintTextXY(6, 10,
2492 " %c%c %s %I64u %s",
2493 (PartEntry
->DriveLetter
== 0) ? '-' : (CHAR
)PartEntry
->DriveLetter
,
2494 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2500 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2502 if (DiskSize
>= 10 * GB
) /* 10 GB */
2504 DiskSize
= DiskSize
/ GB
;
2505 Unit
= MUIGetString(STRING_GB
);
2510 DiskSize
= DiskSize
/ MB
;
2514 Unit
= MUIGetString(STRING_MB
);
2517 if (DiskEntry
->DriverName
.Length
> 0)
2519 CONSOLE_PrintTextXY(6, 12,
2520 MUIGetString(STRING_HDINFOPARTDELETE_1
),
2523 DiskEntry
->DiskNumber
,
2527 &DiskEntry
->DriverName
,
2528 DiskEntry
->NoMbr
? "GPT" : "MBR");
2532 CONSOLE_PrintTextXY(6, 12,
2533 MUIGetString(STRING_HDINFOPARTDELETE_2
),
2536 DiskEntry
->DiskNumber
,
2540 DiskEntry
->NoMbr
? "GPT" : "MBR");
2545 CONSOLE_ConInKey(Ir
);
2547 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2548 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2550 if (ConfirmQuit(Ir
))
2555 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2557 return SELECT_PARTITION_PAGE
;
2559 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2561 DeleteCurrentPartition(PartitionList
);
2563 return SELECT_PARTITION_PAGE
;
2567 return DELETE_PARTITION_PAGE
;
2572 * Displays the SelectFileSystemPage.
2575 * CheckFileSystemPage (At once if RepairUpdate is selected)
2576 * CheckFileSystemPage (At once if Unattended and not USetupData.FormatPartition)
2577 * FormatPartitionPage (At once if Unattended and USetupData.FormatPartition)
2578 * SelectPartitionPage (If the user aborts)
2579 * FormatPartitionPage (Default)
2583 * Sets PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType (via UpdatePartitionType)
2584 * Calls CheckActiveSystemPartition()
2587 * Number of the next page.
2590 SelectFileSystemPage(PINPUT_RECORD Ir
)
2592 PDISKENTRY DiskEntry
;
2593 PPARTENTRY PartEntry
;
2598 CHAR PartTypeString
[32];
2599 FORMATMACHINESTATE PreviousFormatState
;
2601 DPRINT("SelectFileSystemPage()\n");
2603 if (PartitionList
== NULL
||
2604 PartitionList
->CurrentDisk
== NULL
||
2605 PartitionList
->CurrentPartition
== NULL
)
2607 /* FIXME: show an error dialog */
2611 /* Find or set the active system partition */
2612 CheckActiveSystemPartition(PartitionList
);
2613 if (PartitionList
->SystemPartition
== NULL
)
2615 /* FIXME: show an error dialog */
2617 // Error dialog should say that we cannot find a suitable
2618 // system partition and create one on the system. At this point,
2619 // it may be nice to ask the user whether he wants to continue,
2620 // or use an external drive as the system drive/partition
2621 // (e.g. floppy, USB drive, etc...)
2626 PreviousFormatState
= FormatState
;
2627 switch (FormatState
)
2631 if (PartitionList
->CurrentPartition
!= PartitionList
->SystemPartition
)
2633 TempPartition
= PartitionList
->SystemPartition
;
2634 TempPartition
->NeedsCheck
= TRUE
;
2636 FormatState
= FormatSystemPartition
;
2637 DPRINT1("FormatState: Start --> FormatSystemPartition\n");
2641 TempPartition
= PartitionList
->CurrentPartition
;
2642 TempPartition
->NeedsCheck
= TRUE
;
2644 FormatState
= FormatInstallPartition
;
2645 DPRINT1("FormatState: Start --> FormatInstallPartition\n");
2650 case FormatSystemPartition
:
2652 TempPartition
= PartitionList
->CurrentPartition
;
2653 TempPartition
->NeedsCheck
= TRUE
;
2655 FormatState
= FormatInstallPartition
;
2656 DPRINT1("FormatState: FormatSystemPartition --> FormatInstallPartition\n");
2660 case FormatInstallPartition
:
2662 if (GetNextUnformattedPartition(PartitionList
,
2666 FormatState
= FormatOtherPartition
;
2667 TempPartition
->NeedsCheck
= TRUE
;
2668 DPRINT1("FormatState: FormatInstallPartition --> FormatOtherPartition\n");
2672 FormatState
= FormatDone
;
2673 DPRINT1("FormatState: FormatInstallPartition --> FormatDone\n");
2674 return CHECK_FILE_SYSTEM_PAGE
;
2679 case FormatOtherPartition
:
2681 if (GetNextUnformattedPartition(PartitionList
,
2685 FormatState
= FormatOtherPartition
;
2686 TempPartition
->NeedsCheck
= TRUE
;
2687 DPRINT1("FormatState: FormatOtherPartition --> FormatOtherPartition\n");
2691 FormatState
= FormatDone
;
2692 DPRINT1("FormatState: FormatOtherPartition --> FormatDone\n");
2693 return CHECK_FILE_SYSTEM_PAGE
;
2700 DPRINT1("FormatState: Invalid value %ld\n", FormatState
);
2701 /* FIXME: show an error dialog */
2706 PartEntry
= TempPartition
;
2707 DiskEntry
= PartEntry
->DiskEntry
;
2709 /* Adjust disk size */
2710 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2711 if (DiskSize
>= 10 * GB
) /* 10 GB */
2713 DiskSize
= DiskSize
/ GB
;
2714 DiskUnit
= MUIGetString(STRING_GB
);
2718 DiskSize
= DiskSize
/ MB
;
2719 DiskUnit
= MUIGetString(STRING_MB
);
2722 /* Adjust partition size */
2723 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2724 if (PartSize
>= 10 * GB
) /* 10 GB */
2726 PartSize
= PartSize
/ GB
;
2727 PartUnit
= MUIGetString(STRING_GB
);
2731 PartSize
= PartSize
/ MB
;
2732 PartUnit
= MUIGetString(STRING_MB
);
2735 /* Adjust partition type */
2736 GetPartTypeStringFromPartitionType(PartEntry
->PartitionType
,
2738 ARRAYSIZE(PartTypeString
));
2740 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2742 if (PartEntry
->AutoCreate
)
2744 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2747 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2748 PartEntry
->PartitionNumber
,
2754 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED_1
),
2755 DiskEntry
->DiskNumber
,
2761 &DiskEntry
->DriverName
,
2762 DiskEntry
->NoMbr
? "GPT" : "MBR");
2764 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2766 PartEntry
->AutoCreate
= FALSE
;
2768 else if (PartEntry
->New
)
2770 switch (FormatState
)
2772 case FormatSystemPartition
:
2773 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2776 case FormatInstallPartition
:
2777 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2780 case FormatOtherPartition
:
2781 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2788 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2792 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2794 if (*PartTypeString
== '\0') // STRING_FORMATUNKNOWN ??
2796 CONSOLE_PrintTextXY(8, 10,
2797 MUIGetString(STRING_HDDINFOUNK4
),
2798 (PartEntry
->DriveLetter
== 0) ? '-' : (CHAR
)PartEntry
->DriveLetter
,
2799 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2800 PartEntry
->PartitionType
,
2806 CONSOLE_PrintTextXY(8, 10,
2808 (PartEntry
->DriveLetter
== 0) ? '-' : (CHAR
)PartEntry
->DriveLetter
,
2809 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2815 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS_1
),
2816 DiskEntry
->DiskNumber
,
2822 &DiskEntry
->DriverName
,
2823 DiskEntry
->NoMbr
? "GPT" : "MBR");
2826 if (FileSystemList
== NULL
)
2828 /* Create the file system list, and by default select the "FAT" file system */
2829 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2830 if (FileSystemList
== NULL
)
2832 /* FIXME: show an error dialog */
2837 if (RepairUpdateFlag
)
2839 return CHECK_FILE_SYSTEM_PAGE
;
2840 //return SELECT_PARTITION_PAGE;
2843 if (IsUnattendedSetup
)
2845 if (USetupData
.FormatPartition
)
2848 * We use whatever currently selected file system we have
2849 * (by default, this is "FAT", as per the initialization
2850 * performed above). Note that it may be interesting to specify
2851 * which file system to use in unattended installations, in the
2852 * txtsetup.sif file.
2854 return FORMAT_PARTITION_PAGE
;
2857 return CHECK_FILE_SYSTEM_PAGE
;
2860 DrawFileSystemList(FileSystemList
);
2864 CONSOLE_ConInKey(Ir
);
2866 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2867 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2869 if (ConfirmQuit(Ir
))
2874 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2875 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2877 FormatState
= Start
;
2878 return SELECT_PARTITION_PAGE
;
2880 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2881 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2883 ScrollDownFileSystemList(FileSystemList
);
2885 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2886 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2888 ScrollUpFileSystemList(FileSystemList
);
2890 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2892 if (!FileSystemList
->Selected
->FileSystem
)
2893 return SELECT_FILE_SYSTEM_PAGE
;
2895 return FORMAT_PARTITION_PAGE
;
2899 FormatState
= PreviousFormatState
;
2901 return SELECT_FILE_SYSTEM_PAGE
;
2906 * Displays the FormatPartitionPage.
2909 * InstallDirectoryPage (At once if IsUnattendedSetup or InstallShortcut)
2910 * SelectPartitionPage (At once)
2914 * Sets PartitionList->CurrentPartition->FormatState
2915 * Sets USetupData.DestinationRootPath
2918 * Number of the next page.
2921 FormatPartitionPage(PINPUT_RECORD Ir
)
2924 PDISKENTRY DiskEntry
;
2925 PPARTENTRY PartEntry
;
2926 PFILE_SYSTEM_ITEM SelectedFileSystem
;
2927 UNICODE_STRING PartitionRootPath
;
2928 WCHAR PathBuffer
[MAX_PATH
];
2929 CHAR Buffer
[MAX_PATH
];
2934 PPARTITION_INFORMATION PartitionInfo
;
2937 DPRINT("FormatPartitionPage()\n");
2939 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2941 if (PartitionList
== NULL
|| TempPartition
== NULL
)
2943 /* FIXME: show an error dialog */
2947 PartEntry
= TempPartition
;
2948 DiskEntry
= PartEntry
->DiskEntry
;
2950 SelectedFileSystem
= FileSystemList
->Selected
;
2954 if (!IsUnattendedSetup
)
2956 CONSOLE_ConInKey(Ir
);
2959 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2960 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2962 if (ConfirmQuit(Ir
))
2967 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2969 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2971 if (!PreparePartitionForFormatting(PartEntry
, SelectedFileSystem
->FileSystem
))
2973 /* FIXME: show an error dialog */
2978 CONSOLE_PrintTextXY(6, 12,
2979 "Cylinders: %I64u Tracks/Cyl: %lu Sectors/Trk: %lu Bytes/Sec: %lu %c",
2980 DiskEntry
->Cylinders
,
2981 DiskEntry
->TracksPerCylinder
,
2982 DiskEntry
->SectorsPerTrack
,
2983 DiskEntry
->BytesPerSector
,
2984 DiskEntry
->Dirty
? '*' : ' ');
2988 for (i
= 0; i
< DiskEntry
->LayoutBuffer
->PartitionCount
; i
++)
2990 PartitionInfo
= &DiskEntry
->LayoutBuffer
->PartitionEntry
[i
];
2992 CONSOLE_PrintTextXY(6, Line
,
2993 "%2u: %2lu %c %12I64u %12I64u %02x",
2995 PartitionInfo
->PartitionNumber
,
2996 PartitionInfo
->BootIndicator
? 'A' : '-',
2997 PartitionInfo
->StartingOffset
.QuadPart
/ DiskEntry
->BytesPerSector
,
2998 PartitionInfo
->PartitionLength
.QuadPart
/ DiskEntry
->BytesPerSector
,
2999 PartitionInfo
->PartitionType
);
3004 /* Commit the partition changes to the disk */
3005 if (!WritePartitionsToDisk(PartitionList
))
3007 DPRINT("WritePartitionsToDisk() failed\n");
3008 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
3012 /* Set PartitionRootPath */
3013 RtlStringCchPrintfW(PathBuffer
, ARRAYSIZE(PathBuffer
),
3014 L
"\\Device\\Harddisk%lu\\Partition%lu",
3015 DiskEntry
->DiskNumber
,
3016 PartEntry
->PartitionNumber
);
3017 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
3018 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3020 /* Format the partition */
3021 if (SelectedFileSystem
->FileSystem
)
3023 Status
= FormatPartition(&PartitionRootPath
,
3024 SelectedFileSystem
);
3025 if (Status
== STATUS_NOT_SUPPORTED
)
3028 "Setup is currently unable to format a partition in %S.\n"
3030 " \x07 Press ENTER to continue Setup.\n"
3031 " \x07 Press F3 to quit Setup.",
3032 SelectedFileSystem
->FileSystem
->FileSystemName
);
3035 MUIGetString(STRING_QUITCONTINUE
),
3036 NULL
, POPUP_WAIT_NONE
);
3040 CONSOLE_ConInKey(Ir
);
3042 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3043 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3045 if (ConfirmQuit(Ir
))
3048 return SELECT_FILE_SYSTEM_PAGE
;
3050 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3052 return SELECT_FILE_SYSTEM_PAGE
;
3056 else if (!NT_SUCCESS(Status
))
3058 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
3059 MUIDisplayError(ERROR_FORMATTING_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
, PathBuffer
);
3063 PartEntry
->FormatState
= Formatted
;
3064 // PartEntry->FileSystem = FileSystem;
3065 PartEntry
->New
= FALSE
;
3069 CONSOLE_SetStatusText(" Done. Press any key ...");
3070 CONSOLE_ConInKey(Ir
);
3073 return SELECT_FILE_SYSTEM_PAGE
;
3077 return FORMAT_PARTITION_PAGE
;
3082 * Displays the CheckFileSystemPage.
3085 * InstallDirectoryPage (At once)
3089 * Inits or reloads FileSystemList
3092 * Number of the next page.
3095 CheckFileSystemPage(PINPUT_RECORD Ir
)
3098 PDISKENTRY DiskEntry
;
3099 PPARTENTRY PartEntry
;
3100 PFILE_SYSTEM CurrentFileSystem
;
3101 UNICODE_STRING PartitionRootPath
;
3102 WCHAR PathBuffer
[MAX_PATH
];
3103 CHAR Buffer
[MAX_PATH
];
3105 if (PartitionList
== NULL
)
3107 /* FIXME: show an error dialog */
3111 if (!GetNextUncheckedPartition(PartitionList
, &DiskEntry
, &PartEntry
))
3113 return INSTALL_DIRECTORY_PAGE
;
3116 /* Set PartitionRootPath */
3117 RtlStringCchPrintfW(PathBuffer
, ARRAYSIZE(PathBuffer
),
3118 L
"\\Device\\Harddisk%lu\\Partition%lu",
3119 DiskEntry
->DiskNumber
,
3120 PartEntry
->PartitionNumber
);
3121 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
3122 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3124 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
3126 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3128 CurrentFileSystem
= PartEntry
->FileSystem
;
3129 DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystemName: %S\n",
3130 PartEntry
->PartitionType
, (CurrentFileSystem
? CurrentFileSystem
->FileSystemName
: L
"n/a"));
3132 /* HACK: Do not try to check a partition with an unknown filesystem */
3133 if (CurrentFileSystem
== NULL
)
3135 PartEntry
->NeedsCheck
= FALSE
;
3136 return CHECK_FILE_SYSTEM_PAGE
;
3139 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3140 if (Status
== STATUS_NOT_SUPPORTED
)
3143 "Setup is currently unable to check a partition formatted in %S.\n"
3145 " \x07 Press ENTER to continue Setup.\n"
3146 " \x07 Press F3 to quit Setup.",
3147 CurrentFileSystem
->FileSystemName
);
3150 MUIGetString(STRING_QUITCONTINUE
),
3151 NULL
, POPUP_WAIT_NONE
);
3155 CONSOLE_ConInKey(Ir
);
3157 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3158 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3160 if (ConfirmQuit(Ir
))
3163 return CHECK_FILE_SYSTEM_PAGE
;
3165 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3167 PartEntry
->NeedsCheck
= FALSE
;
3168 return CHECK_FILE_SYSTEM_PAGE
;
3172 else if (!NT_SUCCESS(Status
))
3174 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3175 // sprintf(Buffer, "Setup failed to verify the selected partition.\n"
3176 sprintf(Buffer
, "ChkDsk detected some disk errors.\n"
3177 "(Status 0x%08lx).\n", Status
);
3179 // MUIGetString(STRING_REBOOTCOMPUTER),
3180 MUIGetString(STRING_CONTINUE
),
3181 Ir
, POPUP_WAIT_ENTER
);
3183 // return QUIT_PAGE;
3186 PartEntry
->NeedsCheck
= FALSE
;
3187 return CHECK_FILE_SYSTEM_PAGE
;
3192 BuildInstallPaths(PWSTR InstallDir
,
3193 PDISKENTRY DiskEntry
,
3194 PPARTENTRY PartEntry
)
3198 Status
= InitDestinationPaths(&USetupData
, InstallDir
, DiskEntry
, PartEntry
);
3199 // TODO: Check Status
3200 UNREFERENCED_PARAMETER(Status
);
3202 /* Initialize DestinationDriveLetter */
3203 DestinationDriveLetter
= PartEntry
->DriveLetter
;
3209 IN PCWSTR InstallDir
)
3213 Length
= wcslen(InstallDir
);
3215 // TODO: Add check for 8.3 too.
3217 /* Path must be at least 2 characters long */
3221 /* Path must start with a backslash */
3222 // if (InstallDir[0] != L'\\')
3225 /* Path must not end with a backslash */
3226 if (InstallDir
[Length
- 1] == L
'\\')
3229 /* Path must not contain whitespace characters */
3230 for (i
= 0; i
< Length
; i
++)
3232 if (iswspace(InstallDir
[i
]))
3236 /* Path component must not end with a dot */
3237 for (i
= 0; i
< Length
; i
++)
3239 if (InstallDir
[i
] == L
'\\' && i
> 0)
3241 if (InstallDir
[i
- 1] == L
'.')
3246 if (InstallDir
[Length
- 1] == L
'.')
3254 * Displays the InstallDirectoryPage.
3261 * Number of the next page.
3264 InstallDirectoryPage(PINPUT_RECORD Ir
)
3266 PDISKENTRY DiskEntry
;
3267 PPARTENTRY PartEntry
;
3268 WCHAR InstallDir
[MAX_PATH
];
3272 /* We do not need the filesystem list anymore */
3273 if (FileSystemList
!= NULL
)
3275 DestroyFileSystemList(FileSystemList
);
3276 FileSystemList
= NULL
;
3279 if (PartitionList
== NULL
||
3280 PartitionList
->CurrentDisk
== NULL
||
3281 PartitionList
->CurrentPartition
== NULL
)
3283 /* FIXME: show an error dialog */
3287 DiskEntry
= PartitionList
->CurrentDisk
;
3288 PartEntry
= PartitionList
->CurrentPartition
;
3290 // if (IsUnattendedSetup)
3291 if (RepairUpdateFlag
)
3292 wcscpy(InstallDir
, CurrentInstallation
->PathComponent
); // SystemNtPath
3293 else if (USetupData
.InstallationDirectory
[0])
3294 wcscpy(InstallDir
, USetupData
.InstallationDirectory
);
3296 wcscpy(InstallDir
, L
"\\ReactOS");
3299 * Check the validity of the predefined 'InstallDir'. If we are either
3300 * in unattended setup or in update/repair mode, and the installation path
3301 * is valid, just perform the installation. Otherwise (either in the case
3302 * of an invalid path, or we are in regular setup), display the UI and allow
3303 * the user to specify a new installation path.
3305 if ((RepairUpdateFlag
|| IsUnattendedSetup
) && IsValidPath(InstallDir
))
3307 BuildInstallPaths(InstallDir
,
3312 * Check whether the user attempts to install ReactOS within the
3313 * installation source directory, or in a subdirectory thereof.
3314 * If so, fail with an error.
3316 if (RtlPrefixUnicodeString(&USetupData
.SourcePath
, &USetupData
.DestinationPath
, TRUE
))
3318 PopupError("You cannot install ReactOS within the installation source directory!",
3319 MUIGetString(STRING_CONTINUE
),
3320 Ir
, POPUP_WAIT_ENTER
);
3321 return INSTALL_DIRECTORY_PAGE
;
3324 return PREPARE_COPY_PAGE
;
3327 Length
= wcslen(InstallDir
);
3330 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3331 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3332 CONSOLE_SetCursorXY(8 + Pos
, 11);
3333 CONSOLE_SetCursorType(TRUE
, TRUE
);
3337 CONSOLE_ConInKey(Ir
);
3339 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3340 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3342 CONSOLE_SetCursorType(TRUE
, FALSE
);
3344 if (ConfirmQuit(Ir
))
3347 CONSOLE_SetCursorType(TRUE
, TRUE
);
3350 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3351 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DELETE
)) /* DEL */
3355 memmove(&InstallDir
[Pos
],
3356 &InstallDir
[Pos
+ 1],
3357 (Length
- Pos
- 1) * sizeof(WCHAR
));
3358 InstallDir
[Length
- 1] = UNICODE_NULL
;
3361 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3362 CONSOLE_SetCursorXY(8 + Pos
, 11);
3365 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3366 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_HOME
)) /* HOME */
3369 CONSOLE_SetCursorXY(8 + Pos
, 11);
3371 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3372 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_END
)) /* END */
3375 CONSOLE_SetCursorXY(8 + Pos
, 11);
3377 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3378 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_LEFT
)) /* LEFT */
3383 CONSOLE_SetCursorXY(8 + Pos
, 11);
3386 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3387 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RIGHT
)) /* RIGHT */
3392 CONSOLE_SetCursorXY(8 + Pos
, 11);
3395 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3397 CONSOLE_SetCursorType(TRUE
, FALSE
);
3400 * Check for the validity of the installation directory and pop up
3401 * an error if it is not the case. Then the user can fix its input.
3403 if (!IsValidPath(InstallDir
))
3405 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3406 return INSTALL_DIRECTORY_PAGE
;
3409 BuildInstallPaths(InstallDir
,
3414 * Check whether the user attempts to install ReactOS within the
3415 * installation source directory, or in a subdirectory thereof.
3416 * If so, fail with an error.
3418 if (RtlPrefixUnicodeString(&USetupData
.SourcePath
, &USetupData
.DestinationPath
, TRUE
))
3420 PopupError("You cannot install ReactOS within the installation source directory!",
3421 MUIGetString(STRING_CONTINUE
),
3422 Ir
, POPUP_WAIT_ENTER
);
3423 return INSTALL_DIRECTORY_PAGE
;
3426 return PREPARE_COPY_PAGE
;
3428 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3433 memmove(&InstallDir
[Pos
- 1],
3435 (Length
- Pos
) * sizeof(WCHAR
));
3436 InstallDir
[Length
- 1] = UNICODE_NULL
;
3440 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3441 CONSOLE_SetCursorXY(8 + Pos
, 11);
3444 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3448 c
= (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3449 if (iswalpha(c
) || iswdigit(c
) || c
== '.' || c
== '\\' || c
== '-' || c
== '_')
3452 memmove(&InstallDir
[Pos
+ 1],
3454 (Length
- Pos
) * sizeof(WCHAR
));
3455 InstallDir
[Length
+ 1] = UNICODE_NULL
;
3456 InstallDir
[Pos
] = c
;
3460 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3461 CONSOLE_SetCursorXY(8 + Pos
, 11);
3467 return INSTALL_DIRECTORY_PAGE
;
3471 // PSETUP_ERROR_ROUTINE
3475 IN PUSETUP_DATA pSetupData
,
3481 va_start(arg_ptr
, pSetupData
);
3483 if (pSetupData
->LastErrorNumber
>= ERROR_SUCCESS
&&
3484 pSetupData
->LastErrorNumber
< ERROR_LAST_ERROR_CODE
)
3486 // Note: the "POPUP_WAIT_ENTER" actually depends on the LastErrorNumber...
3487 MUIDisplayErrorV(pSetupData
->LastErrorNumber
, &Ir
, POPUP_WAIT_ENTER
, arg_ptr
);
3494 * Displays the PrepareCopyPage.
3497 * FileCopyPage(At once)
3501 * Calls PrepareFileCopy
3504 * Number of the next page.
3507 PrepareCopyPage(PINPUT_RECORD Ir
)
3509 // ERROR_NUMBER ErrorNumber;
3512 MUIDisplayPage(PREPARE_COPY_PAGE
);
3514 /* ErrorNumber = */ Success
= PrepareFileCopy(&USetupData
, NULL
);
3515 if (/*ErrorNumber != ERROR_SUCCESS*/ !Success
)
3517 // MUIDisplayError(ErrorNumber, Ir, POPUP_WAIT_ENTER);
3521 return FILE_COPY_PAGE
;
3524 typedef struct _COPYCONTEXT
3526 ULONG TotalOperations
;
3527 ULONG CompletedOperations
;
3528 PPROGRESSBAR ProgressBar
;
3529 PPROGRESSBAR MemoryBars
[4];
3530 } COPYCONTEXT
, *PCOPYCONTEXT
;
3533 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3536 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3538 /* Get the memory information from the system */
3539 NtQuerySystemInformation(SystemPerformanceInformation
,
3544 /* Check if this is initial setup */
3547 /* Set maximum limits to be total RAM pages */
3548 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3549 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3550 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3553 /* Set current values */
3554 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3555 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3556 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3561 FileCopyCallback(PVOID Context
,
3566 PCOPYCONTEXT CopyContext
= (PCOPYCONTEXT
)Context
;
3567 PFILEPATHS_W FilePathInfo
;
3568 PCWSTR SrcFileName
, DstFileName
;
3570 switch (Notification
)
3572 case SPFILENOTIFY_STARTSUBQUEUE
:
3574 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3575 CopyContext
->CompletedOperations
= 0;
3576 ProgressSetStepCount(CopyContext
->ProgressBar
,
3577 CopyContext
->TotalOperations
);
3578 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3582 case SPFILENOTIFY_STARTDELETE
:
3583 case SPFILENOTIFY_STARTRENAME
:
3584 case SPFILENOTIFY_STARTCOPY
:
3586 FilePathInfo
= (PFILEPATHS_W
)Param1
;
3588 if (Notification
== SPFILENOTIFY_STARTDELETE
)
3590 /* Display delete message */
3591 ASSERT(Param2
== FILEOP_DELETE
);
3593 DstFileName
= wcsrchr(FilePathInfo
->Target
, L
'\\');
3594 if (DstFileName
) ++DstFileName
;
3595 else DstFileName
= FilePathInfo
->Target
;
3597 CONSOLE_SetStatusText(MUIGetString(STRING_DELETING
),
3600 else if (Notification
== SPFILENOTIFY_STARTRENAME
)
3602 /* Display move/rename message */
3603 ASSERT(Param2
== FILEOP_RENAME
);
3605 SrcFileName
= wcsrchr(FilePathInfo
->Source
, L
'\\');
3606 if (SrcFileName
) ++SrcFileName
;
3607 else SrcFileName
= FilePathInfo
->Source
;
3609 DstFileName
= wcsrchr(FilePathInfo
->Target
, L
'\\');
3610 if (DstFileName
) ++DstFileName
;
3611 else DstFileName
= FilePathInfo
->Target
;
3613 if (!wcsicmp(SrcFileName
, DstFileName
))
3614 Param2
= STRING_MOVING
;
3616 Param2
= STRING_RENAMING
;
3618 CONSOLE_SetStatusText(MUIGetString(Param2
),
3619 SrcFileName
, DstFileName
);
3621 else if (Notification
== SPFILENOTIFY_STARTCOPY
)
3623 /* Display copy message */
3624 ASSERT(Param2
== FILEOP_COPY
);
3626 /* NOTE: When extracting from CABs the Source is the CAB name */
3627 DstFileName
= wcsrchr(FilePathInfo
->Target
, L
'\\');
3628 if (DstFileName
) ++DstFileName
;
3629 else DstFileName
= FilePathInfo
->Target
;
3631 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
),
3635 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3639 case SPFILENOTIFY_COPYERROR
:
3641 FilePathInfo
= (PFILEPATHS_W
)Param1
;
3643 DPRINT1("An error happened while trying to copy file '%S' (error 0x%08lx), skipping it...\n",
3644 FilePathInfo
->Target
, FilePathInfo
->Win32Error
);
3648 case SPFILENOTIFY_ENDDELETE
:
3649 case SPFILENOTIFY_ENDRENAME
:
3650 case SPFILENOTIFY_ENDCOPY
:
3652 CopyContext
->CompletedOperations
++;
3654 /* SYSREG checkpoint */
3655 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3656 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3658 ProgressNextStep(CopyContext
->ProgressBar
);
3659 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3669 * Displays the FileCopyPage.
3672 * RegistryPage(At once)
3678 * Number of the next page.
3681 FileCopyPage(PINPUT_RECORD Ir
)
3683 COPYCONTEXT CopyContext
;
3686 MUIDisplayPage(FILE_COPY_PAGE
);
3688 /* Create context for the copy process */
3689 CopyContext
.TotalOperations
= 0;
3690 CopyContext
.CompletedOperations
= 0;
3692 /* Create the progress bar as well */
3693 CopyContext
.ProgressBar
= CreateProgressBar(13,
3700 MUIGetString(STRING_SETUPCOPYINGFILES
));
3702 // fit memory bars to screen width, distribute them uniform
3703 MemBarWidth
= (xScreen
- 26) / 5;
3704 MemBarWidth
-= MemBarWidth
% 2; // make even
3705 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3706 /* Create the paged pool progress bar */
3707 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3716 /* Create the non paged pool progress bar */
3717 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (MemBarWidth
/ 2),
3719 (xScreen
/ 2) + (MemBarWidth
/ 2),
3721 (xScreen
/ 2)- (MemBarWidth
/ 2),
3726 /* Create the global memory progress bar */
3727 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - MemBarWidth
,
3731 xScreen
- 13 - MemBarWidth
,
3736 /* Do the file copying */
3737 DoFileCopy(&USetupData
, FileCopyCallback
, &CopyContext
);
3739 /* If we get here, we're done, so cleanup the progress bar */
3740 DestroyProgressBar(CopyContext
.ProgressBar
);
3741 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3742 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3743 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3745 /* Create the $winnt$.inf file */
3746 InstallSetupInfFile(&USetupData
);
3748 /* Go display the next page */
3749 return REGISTRY_PAGE
;
3755 RegistryStatus(IN REGISTRY_STATUS RegStatus
, ...)
3757 /* WARNING: Please keep this lookup table in sync with the resources! */
3758 static const UINT StringIDs
[] =
3760 STRING_DONE
, /* Success */
3761 STRING_REGHIVEUPDATE
, /* RegHiveUpdate */
3762 STRING_IMPORTFILE
, /* ImportRegHive */
3763 STRING_DISPLAYSETTINGSUPDATE
, /* DisplaySettingsUpdate */
3764 STRING_LOCALESETTINGSUPDATE
, /* LocaleSettingsUpdate */
3765 STRING_ADDKBLAYOUTS
, /* KeybLayouts */
3766 STRING_KEYBOARDSETTINGSUPDATE
, /* KeybSettingsUpdate */
3767 STRING_CODEPAGEINFOUPDATE
, /* CodePageInfoUpdate */
3772 if (RegStatus
< ARRAYSIZE(StringIDs
))
3774 va_start(args
, RegStatus
);
3775 CONSOLE_SetStatusTextV(MUIGetString(StringIDs
[RegStatus
]), args
);
3780 CONSOLE_SetStatusText("Unknown status %d", RegStatus
);
3785 * Displays the RegistryPage.
3788 * SuccessPage (if RepairUpdate)
3789 * BootLoaderPage (default)
3793 * Calls UpdateRegistry
3796 * Number of the next page.
3799 RegistryPage(PINPUT_RECORD Ir
)
3803 MUIDisplayPage(REGISTRY_PAGE
);
3805 Error
= UpdateRegistry(&USetupData
,
3808 DestinationDriveLetter
,
3811 if (Error
!= ERROR_SUCCESS
)
3813 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ENTER
);
3818 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3819 return BOOT_LOADER_PAGE
;
3825 * Displays the BootLoaderPage.
3828 * SuccessPage (if RepairUpdate)
3829 * BootLoaderHarddiskMbrPage
3830 * BootLoaderHarddiskVbrPage
3831 * BootLoaderFloppyPage
3836 * Calls RegInitializeRegistry
3837 * Calls ImportRegistryFile
3838 * Calls SetDefaultPagefile
3839 * Calls SetMountedDeviceValues
3842 * Number of the next page.
3845 BootLoaderPage(PINPUT_RECORD Ir
)
3847 UCHAR PartitionType
;
3848 BOOLEAN InstallOnFloppy
;
3850 WCHAR PathBuffer
[MAX_PATH
];
3852 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3854 RtlFreeUnicodeString(&USetupData
.SystemRootPath
);
3855 RtlStringCchPrintfW(PathBuffer
, ARRAYSIZE(PathBuffer
),
3856 L
"\\Device\\Harddisk%lu\\Partition%lu\\",
3857 PartitionList
->SystemPartition
->DiskEntry
->DiskNumber
,
3858 PartitionList
->SystemPartition
->PartitionNumber
);
3859 RtlCreateUnicodeString(&USetupData
.SystemRootPath
, PathBuffer
);
3860 DPRINT1("SystemRootPath: %wZ\n", &USetupData
.SystemRootPath
);
3862 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
3864 /* For unattended setup, skip MBR installation or install on floppy if needed */
3865 if (IsUnattendedSetup
)
3867 if ((USetupData
.MBRInstallType
== 0) ||
3868 (USetupData
.MBRInstallType
== 1))
3875 * We may install an MBR or VBR, but before that, check whether
3876 * we need to actually install the VBR on floppy.
3878 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3880 DPRINT("Error: system partition invalid (unused)\n");
3881 InstallOnFloppy
= TRUE
;
3883 else if (PartitionType
== PARTITION_OS2BOOTMGR
)
3885 /* OS/2 boot manager partition */
3886 DPRINT("Found OS/2 boot manager partition\n");
3887 InstallOnFloppy
= TRUE
;
3889 else if (PartitionType
== PARTITION_LINUX
)
3891 /* Linux partition */
3892 DPRINT("Found Linux native partition (ext2/ext3/ReiserFS/BTRFS/etc)\n");
3893 InstallOnFloppy
= FALSE
;
3895 else if (PartitionType
== PARTITION_IFS
)
3897 /* NTFS partition */
3898 DPRINT("Found NTFS partition\n");
3900 // FIXME: Make it FALSE when we'll support NTFS installation!
3901 InstallOnFloppy
= TRUE
;
3903 else if ((PartitionType
== PARTITION_FAT_12
) ||
3904 (PartitionType
== PARTITION_FAT_16
) ||
3905 (PartitionType
== PARTITION_HUGE
) ||
3906 (PartitionType
== PARTITION_XINT13
) ||
3907 (PartitionType
== PARTITION_FAT32
) ||
3908 (PartitionType
== PARTITION_FAT32_XINT13
))
3910 DPRINT("Found FAT partition\n");
3911 InstallOnFloppy
= FALSE
;
3915 /* Unknown partition */
3916 DPRINT("Unknown partition found\n");
3917 InstallOnFloppy
= TRUE
;
3920 /* We should install on floppy */
3921 if (InstallOnFloppy
)
3923 USetupData
.MBRInstallType
= 1;
3927 /* Is it an unattended install on hdd? */
3928 if (IsUnattendedSetup
)
3930 if ((USetupData
.MBRInstallType
== 2) ||
3931 (USetupData
.MBRInstallType
== 3))
3937 MUIDisplayPage(BOOT_LOADER_PAGE
);
3938 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3942 CONSOLE_ConInKey(Ir
);
3944 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3945 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3947 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3956 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3958 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3959 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3961 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3970 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3972 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3973 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3975 if (ConfirmQuit(Ir
))
3980 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3984 /* Install on both MBR and VBR */
3985 USetupData
.MBRInstallType
= 2;
3988 else if (Line
== 13)
3990 /* Install on VBR only */
3991 USetupData
.MBRInstallType
= 3;
3994 else if (Line
== 14)
3996 /* Install on floppy */
3997 USetupData
.MBRInstallType
= 1;
4000 else if (Line
== 15)
4002 /* Skip MBR installation */
4003 USetupData
.MBRInstallType
= 0;
4007 return BOOT_LOADER_PAGE
;
4012 switch (USetupData
.MBRInstallType
)
4014 /* Skip MBR installation */
4016 return SUCCESS_PAGE
;
4018 /* Install on floppy */
4020 return BOOT_LOADER_FLOPPY_PAGE
;
4022 /* Install on both MBR and VBR */
4024 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4026 /* Install on VBR only */
4028 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4031 return BOOT_LOADER_PAGE
;
4036 * Displays the BootLoaderFloppyPage.
4039 * SuccessPage (At once)
4043 * Calls InstallFatBootcodeToFloppy()
4046 * Number of the next page.
4049 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4053 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4055 // CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
4059 CONSOLE_ConInKey(Ir
);
4061 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4062 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4064 if (ConfirmQuit(Ir
))
4069 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4071 Status
= InstallFatBootcodeToFloppy(&USetupData
.SourceRootPath
,
4072 &USetupData
.DestinationArcPath
);
4073 if (!NT_SUCCESS(Status
))
4075 if (Status
== STATUS_DEVICE_NOT_READY
)
4076 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4078 /* TODO: Print error message */
4079 return BOOT_LOADER_FLOPPY_PAGE
;
4082 return SUCCESS_PAGE
;
4086 return BOOT_LOADER_FLOPPY_PAGE
;
4091 * Displays the BootLoaderHarddiskVbrPage.
4094 * SuccessPage (At once)
4098 * Calls InstallVBRToPartition()
4101 * Number of the next page.
4104 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4108 Status
= InstallVBRToPartition(&USetupData
.SystemRootPath
,
4109 &USetupData
.SourceRootPath
,
4110 &USetupData
.DestinationArcPath
,
4111 PartitionList
->SystemPartition
->PartitionType
);
4112 if (!NT_SUCCESS(Status
))
4114 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4118 return SUCCESS_PAGE
;
4123 * Displays the BootLoaderHarddiskMbrPage.
4126 * SuccessPage (At once)
4130 * Calls InstallVBRToPartition()
4131 * Calls InstallMbrBootCodeToDisk()
4134 * Number of the next page.
4137 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4140 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4142 /* Step 1: Write the VBR */
4143 Status
= InstallVBRToPartition(&USetupData
.SystemRootPath
,
4144 &USetupData
.SourceRootPath
,
4145 &USetupData
.DestinationArcPath
,
4146 PartitionList
->SystemPartition
->PartitionType
);
4147 if (!NT_SUCCESS(Status
))
4149 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4153 /* Step 2: Write the MBR */
4154 RtlStringCchPrintfW(DestinationDevicePathBuffer
, ARRAYSIZE(DestinationDevicePathBuffer
),
4155 L
"\\Device\\Harddisk%d\\Partition0",
4156 PartitionList
->SystemPartition
->DiskEntry
->DiskNumber
);
4157 Status
= InstallMbrBootCodeToDisk(&USetupData
.SystemRootPath
,
4158 &USetupData
.SourceRootPath
,
4159 DestinationDevicePathBuffer
);
4160 if (!NT_SUCCESS(Status
))
4162 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n", Status
);
4163 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4167 return SUCCESS_PAGE
;
4172 * @name ProgressTimeOutStringHandler
4174 * Handles the generation (displaying) of the timeout
4175 * countdown to the screen dynamically.
4178 * A pointer to a progress bar.
4180 * @param AlwaysUpdate
4181 * Constantly update the progress bar (boolean type).
4184 * A pointer to a string buffer.
4186 * @param cchBufferSize
4187 * The buffer's size in number of characters.
4190 * TRUE or FALSE on function termination.
4195 ProgressTimeOutStringHandler(
4196 IN PPROGRESSBAR Bar
,
4197 IN BOOLEAN AlwaysUpdate
,
4199 IN SIZE_T cchBufferSize
)
4201 ULONG OldProgress
= Bar
->Progress
;
4203 if (Bar
->StepCount
== 0)
4209 Bar
->Progress
= Bar
->StepCount
- Bar
->CurrentStep
;
4212 /* Build the progress string if it has changed */
4213 if (Bar
->ProgressFormatText
&&
4214 (AlwaysUpdate
|| (Bar
->Progress
!= OldProgress
)))
4216 RtlStringCchPrintfA(Buffer
, cchBufferSize
,
4217 Bar
->ProgressFormatText
, Bar
->Progress
/ max(1, Bar
->Width
) + 1);
4226 * @name ProgressCountdown
4228 * Displays and draws a red-coloured progress bar with a countdown.
4229 * When the timeout is reached, the flush page is displayed for reboot.
4232 * A pointer to an input keyboard record.
4235 * Initial countdown value in seconds.
4243 IN PINPUT_RECORD Ir
,
4247 ULONG StartTime
, BarWidth
, TimerDiv
;
4249 LONG TimerValue
, OldTimerValue
;
4250 LARGE_INTEGER Timeout
;
4251 PPROGRESSBAR ProgressBar
;
4252 BOOLEAN RefreshProgress
= TRUE
;
4254 /* Bail out if the timeout is already zero */
4258 /* Create the timeout progress bar and set it up */
4259 ProgressBar
= CreateProgressBarEx(13,
4266 FOREGROUND_RED
| BACKGROUND_BLUE
,
4269 MUIGetString(STRING_REBOOTPROGRESSBAR
),
4270 ProgressTimeOutStringHandler
);
4272 BarWidth
= max(1, ProgressBar
->Width
);
4273 TimerValue
= TimeOut
* BarWidth
;
4274 ProgressSetStepCount(ProgressBar
, TimerValue
);
4276 StartTime
= NtGetTickCount();
4279 TimerDiv
= 1000 / BarWidth
;
4280 TimerDiv
= max(1, TimerDiv
);
4281 OldTimerValue
= TimerValue
;
4284 /* Decrease the timer */
4287 * Compute how much time the previous operations took.
4288 * This allows us in particular to take account for any time
4289 * elapsed if something slowed down.
4291 TimeElapsed
= NtGetTickCount() - StartTime
;
4292 if (TimeElapsed
>= TimerDiv
)
4294 /* Increase StartTime by steps of 1 / ProgressBar->Width seconds */
4295 TimeElapsed
/= TimerDiv
;
4296 StartTime
+= (TimerDiv
* TimeElapsed
);
4298 if (TimeElapsed
<= TimerValue
)
4299 TimerValue
-= TimeElapsed
;
4303 RefreshProgress
= TRUE
;
4306 if (RefreshProgress
)
4308 ProgressSetStep(ProgressBar
, OldTimerValue
- TimerValue
);
4309 RefreshProgress
= FALSE
;
4312 /* Stop when the timer reaches zero */
4313 if (TimerValue
<= 0)
4316 /* Check for user key presses */
4319 * If the timer is used, use a passive wait of maximum 1 second
4320 * while monitoring for incoming console input events, so that
4321 * we are still able to display the timing count.
4324 /* Wait a maximum of 1 second for input events */
4325 TimeElapsed
= NtGetTickCount() - StartTime
;
4326 if (TimeElapsed
< TimerDiv
)
4328 /* Convert the time to NT Format */
4329 Timeout
.QuadPart
= (TimerDiv
- TimeElapsed
) * -10000LL;
4330 Status
= NtWaitForSingleObject(StdInput
, FALSE
, &Timeout
);
4334 Status
= STATUS_TIMEOUT
;
4337 /* Check whether the input event has been signaled, or a timeout happened */
4338 if (Status
== STATUS_TIMEOUT
)
4342 if (Status
!= STATUS_WAIT_0
)
4344 /* An error happened, bail out */
4345 DPRINT1("NtWaitForSingleObject() failed, Status 0x%08lx\n", Status
);
4349 /* Check for an ENTER key press */
4350 while (CONSOLE_ConInKeyPeek(Ir
))
4352 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4354 /* Found it, stop waiting */
4361 /* Destroy the progress bar and quit */
4362 DestroyProgressBar(ProgressBar
);
4367 * Displays the QuitPage.
4370 * FlushPage (At once)
4376 * Number of the next page.
4379 QuitPage(PINPUT_RECORD Ir
)
4381 MUIDisplayPage(QUIT_PAGE
);
4383 /* Destroy the NTOS installations list */
4384 if (NtOsInstallsList
!= NULL
)
4386 DestroyGenericList(NtOsInstallsList
, TRUE
);
4387 NtOsInstallsList
= NULL
;
4390 /* Destroy the partition list */
4391 if (PartitionList
!= NULL
)
4393 DestroyPartitionList(PartitionList
);
4394 PartitionList
= NULL
;
4397 TempPartition
= NULL
;
4398 FormatState
= Start
;
4400 /* Destroy the filesystem list */
4401 if (FileSystemList
!= NULL
)
4403 DestroyFileSystemList(FileSystemList
);
4404 FileSystemList
= NULL
;
4407 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4409 /* Wait for maximum 15 seconds or an ENTER key before quitting */
4410 ProgressCountdown(Ir
, 15);
4416 * Displays the SuccessPage.
4419 * FlushPage (At once)
4425 * Number of the next page.
4428 SuccessPage(PINPUT_RECORD Ir
)
4430 MUIDisplayPage(SUCCESS_PAGE
);
4432 if (IsUnattendedSetup
)
4435 /* Wait for maximum 15 seconds or an ENTER key before quitting */
4436 ProgressCountdown(Ir
, 15);
4442 * Displays the FlushPage.
4445 * RebootPage (At once)
4448 * Number of the next page.
4451 FlushPage(PINPUT_RECORD Ir
)
4453 MUIDisplayPage(FLUSH_PAGE
);
4459 PnpEventThread(IN LPVOID lpParameter
);
4463 * The start routine and page management
4473 InfSetHeap(ProcessHeap
);
4475 /* Tell the Cm this is a setup boot, and it has to behave accordingly */
4476 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
4477 if (!NT_SUCCESS(Status
))
4478 DPRINT1("NtInitializeRegistry() failed (Status 0x%08lx)\n", Status
);
4480 /* Create the PnP thread in suspended state */
4481 Status
= RtlCreateUserThread(NtCurrentProcess(),
4488 &USetupData
.SetupInf
,
4491 if (!NT_SUCCESS(Status
))
4494 if (!CONSOLE_Init())
4496 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4497 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4498 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4500 /* We failed to initialize the video, just quit the installer */
4501 return STATUS_APP_INIT_FAILURE
;
4504 /* Initialize Setup, phase 0 */
4505 InitializeSetup(&USetupData
, 0);
4506 USetupData
.ErrorRoutine
= USetupErrorRoutine
;
4508 /* Hide the cursor */
4509 CONSOLE_SetCursorType(TRUE
, FALSE
);
4511 /* Global Initialization page */
4512 CONSOLE_ClearScreen();
4514 Page
= SetupStartPage(&Ir
);
4516 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4518 CONSOLE_ClearScreen();
4521 // CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4528 Page
= LanguagePage(&Ir
);
4533 Page
= WelcomePage(&Ir
);
4538 Page
= LicensePage(&Ir
);
4542 case INSTALL_INTRO_PAGE
:
4543 Page
= InstallIntroPage(&Ir
);
4547 case SCSI_CONTROLLER_PAGE
:
4548 Page
= ScsiControllerPage(&Ir
);
4551 case OEM_DRIVER_PAGE
:
4552 Page
= OemDriverPage(&Ir
);
4556 case DEVICE_SETTINGS_PAGE
:
4557 Page
= DeviceSettingsPage(&Ir
);
4560 case COMPUTER_SETTINGS_PAGE
:
4561 Page
= ComputerSettingsPage(&Ir
);
4564 case DISPLAY_SETTINGS_PAGE
:
4565 Page
= DisplaySettingsPage(&Ir
);
4568 case KEYBOARD_SETTINGS_PAGE
:
4569 Page
= KeyboardSettingsPage(&Ir
);
4572 case LAYOUT_SETTINGS_PAGE
:
4573 Page
= LayoutSettingsPage(&Ir
);
4576 case SELECT_PARTITION_PAGE
:
4577 Page
= SelectPartitionPage(&Ir
);
4580 case CREATE_PRIMARY_PARTITION_PAGE
:
4581 Page
= CreatePrimaryPartitionPage(&Ir
);
4584 case CREATE_EXTENDED_PARTITION_PAGE
:
4585 Page
= CreateExtendedPartitionPage(&Ir
);
4588 case CREATE_LOGICAL_PARTITION_PAGE
:
4589 Page
= CreateLogicalPartitionPage(&Ir
);
4592 case CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
:
4593 Page
= ConfirmDeleteSystemPartitionPage(&Ir
);
4596 case DELETE_PARTITION_PAGE
:
4597 Page
= DeletePartitionPage(&Ir
);
4600 case SELECT_FILE_SYSTEM_PAGE
:
4601 Page
= SelectFileSystemPage(&Ir
);
4604 case FORMAT_PARTITION_PAGE
:
4605 Page
= FormatPartitionPage(&Ir
);
4608 case CHECK_FILE_SYSTEM_PAGE
:
4609 Page
= CheckFileSystemPage(&Ir
);
4612 case INSTALL_DIRECTORY_PAGE
:
4613 Page
= InstallDirectoryPage(&Ir
);
4616 case PREPARE_COPY_PAGE
:
4617 Page
= PrepareCopyPage(&Ir
);
4620 case FILE_COPY_PAGE
:
4621 Page
= FileCopyPage(&Ir
);
4625 Page
= RegistryPage(&Ir
);
4628 case BOOT_LOADER_PAGE
:
4629 Page
= BootLoaderPage(&Ir
);
4632 case BOOT_LOADER_FLOPPY_PAGE
:
4633 Page
= BootLoaderFloppyPage(&Ir
);
4636 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4637 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4640 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4641 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4645 case REPAIR_INTRO_PAGE
:
4646 Page
= RepairIntroPage(&Ir
);
4649 case UPGRADE_REPAIR_PAGE
:
4650 Page
= UpgradeRepairPage(&Ir
);
4654 Page
= SuccessPage(&Ir
);
4658 Page
= FlushPage(&Ir
);
4662 Page
= QuitPage(&Ir
);
4671 /* Setup has finished */
4672 FinishSetup(&USetupData
);
4674 if (Page
== RECOVERY_PAGE
)
4680 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4681 NtShutdownSystem(ShutdownReboot
);
4682 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4684 return STATUS_SUCCESS
;
4689 NtProcessStartup(PPEB Peb
)
4694 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4696 ProcessHeap
= Peb
->ProcessHeap
;
4698 NtQuerySystemTime(&Time
);
4700 Status
= RunUSetup();
4702 if (NT_SUCCESS(Status
))
4705 * Avoid a bugcheck if RunUSetup() finishes too quickly by implementing
4706 * a protective waiting.
4707 * This wait is needed because, since we are started as SMSS.EXE,
4708 * the NT kernel explicitly waits 5 seconds for the initial process
4709 * SMSS.EXE to initialize (as a protective measure), and otherwise
4710 * bugchecks with the code SESSION5_INITIALIZATION_FAILED.
4712 Time
.QuadPart
+= 50000000;
4713 NtDelayExecution(FALSE
, &Time
);
4717 /* The installer failed to start: raise a hard error (crash the system/BSOD) */
4718 Status
= NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4719 0, 0, NULL
, 0, NULL
);
4722 NtTerminateProcess(NtCurrentProcess(), Status
);