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 * PROGRAMMER: Eric Kohl
25 * Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * Hervé Poussineau (hpoussin@reactos.org)
43 /* GLOBALS ******************************************************************/
46 UNICODE_STRING SourceRootPath
;
47 UNICODE_STRING SourceRootDir
;
48 UNICODE_STRING SourcePath
;
49 BOOLEAN IsUnattendedSetup
= FALSE
;
50 LONG UnattendDestinationDiskNumber
;
51 LONG UnattendDestinationPartitionNumber
;
52 LONG UnattendMBRInstallType
= -1;
53 LONG UnattendFormatPartition
= 0;
54 LONG AutoPartition
= 0;
55 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
56 PWCHAR SelectedLanguageId
;
58 WCHAR DefaultLanguage
[20];
59 WCHAR DefaultKBLayout
[20];
60 BOOLEAN RepairUpdateFlag
= FALSE
;
61 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
62 PPARTLIST PartitionList
= NULL
;
64 /* LOCALS *******************************************************************/
66 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
68 static UNICODE_STRING InstallPath
;
71 * Path to the system partition, where the boot manager resides.
72 * On x86 PCs, this is usually the active partition.
73 * On ARC, (u)EFI, ... platforms, this is a dedicated partition.
75 * For more information, see:
76 * https://en.wikipedia.org/wiki/System_partition_and_boot_partition
77 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/boot-and-system-volumes.html
78 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/arc-boot-process.html
79 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html
80 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-system-volume.html
81 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-boot-volume.html
83 static UNICODE_STRING SystemRootPath
;
85 /* Path to the install directory inside the ReactOS boot partition */
86 static UNICODE_STRING DestinationPath
;
87 static UNICODE_STRING DestinationArcPath
;
88 static UNICODE_STRING DestinationRootPath
;
90 static WCHAR DestinationDriveLetter
;
94 static HSPFILEQ SetupFileQueue
= NULL
;
96 static PGENERIC_LIST ComputerList
= NULL
;
97 static PGENERIC_LIST DisplayList
= NULL
;
98 static PGENERIC_LIST KeyboardList
= NULL
;
99 static PGENERIC_LIST LayoutList
= NULL
;
100 static PGENERIC_LIST LanguageList
= NULL
;
102 static LANGID LanguageId
= 0;
104 static ULONG RequiredPartitionDiskSpace
= ~0;
106 /* FUNCTIONS ****************************************************************/
109 PrintString(char* fmt
,...)
113 UNICODE_STRING UnicodeString
;
114 ANSI_STRING AnsiString
;
117 vsprintf(buffer
, fmt
, ap
);
120 RtlInitAnsiString(&AnsiString
, buffer
);
121 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
122 NtDisplayString(&UnicodeString
);
123 RtlFreeUnicodeString(&UnicodeString
);
128 DrawBox(IN SHORT xLeft
,
136 /* draw upper left corner */
139 FillConsoleOutputCharacterA(StdOutput
,
145 /* draw upper edge */
148 FillConsoleOutputCharacterA(StdOutput
,
154 /* draw upper right corner */
155 coPos
.X
= xLeft
+ Width
- 1;
157 FillConsoleOutputCharacterA(StdOutput
,
163 /* Draw right edge, inner space and left edge */
164 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
167 FillConsoleOutputCharacterA(StdOutput
,
174 FillConsoleOutputCharacterA(StdOutput
,
180 coPos
.X
= xLeft
+ Width
- 1;
181 FillConsoleOutputCharacterA(StdOutput
,
188 /* draw lower left corner */
190 coPos
.Y
= yTop
+ Height
- 1;
191 FillConsoleOutputCharacterA(StdOutput
,
197 /* draw lower edge */
199 coPos
.Y
= yTop
+ Height
- 1;
200 FillConsoleOutputCharacterA(StdOutput
,
206 /* draw lower right corner */
207 coPos
.X
= xLeft
+ Width
- 1;
208 coPos
.Y
= yTop
+ Height
- 1;
209 FillConsoleOutputCharacterA(StdOutput
,
218 PopupError(PCCH Text
,
236 /* Count text lines and longest line */
243 p
= strchr(pnext
, '\n');
247 Length
= strlen(pnext
);
252 Length
= (ULONG
)(p
- pnext
);
258 if (Length
> MaxLength
)
261 if (LastLine
!= FALSE
)
267 /* Check length of status line */
270 Length
= strlen(Status
);
272 if (Length
> MaxLength
)
276 Width
= MaxLength
+ 4;
282 yTop
= (yScreen
- Height
) / 2;
283 xLeft
= (xScreen
- Width
) / 2;
286 /* Set screen attributes */
288 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
290 FillConsoleOutputAttribute(StdOutput
,
291 FOREGROUND_RED
| BACKGROUND_WHITE
,
297 DrawBox(xLeft
, yTop
, Width
, Height
);
299 /* Print message text */
304 p
= strchr(pnext
, '\n');
308 Length
= strlen(pnext
);
313 Length
= (ULONG
)(p
- pnext
);
320 WriteConsoleOutputCharacterA(StdOutput
,
327 if (LastLine
!= FALSE
)
334 /* Print separator line and status text */
337 coPos
.Y
= yTop
+ Height
- 3;
339 FillConsoleOutputCharacterA(StdOutput
,
346 FillConsoleOutputCharacterA(StdOutput
,
352 coPos
.X
= xLeft
+ Width
- 1;
353 FillConsoleOutputCharacterA(StdOutput
,
361 WriteConsoleOutputCharacterA(StdOutput
,
363 min(strlen(Status
), (SIZE_T
)Width
- 4),
368 if (WaitEvent
== POPUP_WAIT_NONE
)
373 CONSOLE_ConInKey(Ir
);
375 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
376 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
388 * FALSE: Don't quit setup.
391 ConfirmQuit(PINPUT_RECORD Ir
)
394 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
398 CONSOLE_ConInKey(Ir
);
400 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
401 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
406 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
418 CheckUnattendedSetup(VOID
)
420 WCHAR UnattendInfPath
[MAX_PATH
];
427 if (DoesFileExist(NULL
, SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
429 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
433 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
434 wcscat(UnattendInfPath
, L
"\\unattend.inf");
436 /* Load 'unattend.inf' from install media. */
437 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
443 if (UnattendInf
== INVALID_HANDLE_VALUE
)
445 DPRINT("SetupOpenInfFileW() failed\n");
449 /* Open 'Unattend' section */
450 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
452 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
453 SetupCloseInfFile(UnattendInf
);
457 /* Get pointer 'Signature' key */
458 if (!INF_GetData(&Context
, NULL
, &Value
))
460 DPRINT("INF_GetData() failed for key 'Signature'\n");
461 SetupCloseInfFile(UnattendInf
);
465 /* Check 'Signature' string */
466 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
468 DPRINT("Signature not $ReactOS$\n");
469 SetupCloseInfFile(UnattendInf
);
473 /* Check if Unattend setup is enabled */
474 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
476 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
477 SetupCloseInfFile(UnattendInf
);
481 if (!INF_GetData(&Context
, NULL
, &Value
))
483 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
484 SetupCloseInfFile(UnattendInf
);
488 if (_wcsicmp(Value
, L
"yes") != 0)
490 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
491 SetupCloseInfFile(UnattendInf
);
495 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
496 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
498 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
499 SetupCloseInfFile(UnattendInf
);
503 if (!SetupGetIntField(&Context
, 1, &IntValue
))
505 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
506 SetupCloseInfFile(UnattendInf
);
510 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
512 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
513 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
515 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
516 SetupCloseInfFile(UnattendInf
);
520 if (!SetupGetIntField(&Context
, 1, &IntValue
))
522 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
523 SetupCloseInfFile(UnattendInf
);
527 UnattendDestinationPartitionNumber
= IntValue
;
529 /* Search for 'InstallationDirectory' in the 'Unattend' section */
530 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"InstallationDirectory", &Context
))
532 DPRINT("SetupFindFirstLine() failed for key 'InstallationDirectory'\n");
533 SetupCloseInfFile(UnattendInf
);
537 /* Get pointer 'InstallationDirectory' key */
538 if (!INF_GetData(&Context
, NULL
, &Value
))
540 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
541 SetupCloseInfFile(UnattendInf
);
545 wcscpy(UnattendInstallationDirectory
, Value
);
547 IsUnattendedSetup
= TRUE
;
549 /* Search for 'MBRInstallType' in the 'Unattend' section */
550 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
552 if (SetupGetIntField(&Context
, 1, &IntValue
))
554 UnattendMBRInstallType
= IntValue
;
558 /* Search for 'FormatPartition' in the 'Unattend' section */
559 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
561 if (SetupGetIntField(&Context
, 1, &IntValue
))
563 UnattendFormatPartition
= IntValue
;
567 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
569 if (SetupGetIntField(&Context
, 1, &IntValue
))
571 AutoPartition
= IntValue
;
575 /* search for LocaleID in the 'Unattend' section*/
576 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"LocaleID", &Context
))
578 if (INF_GetData(&Context
, NULL
, &Value
))
580 LONG Id
= wcstol(Value
, NULL
, 16);
581 swprintf(LocaleID
,L
"%08lx", Id
);
585 SetupCloseInfFile(UnattendInf
);
587 DPRINT("Running unattended setup\n");
594 PGENERIC_LIST_ENTRY ListEntry
;
595 LPCWSTR pszNewLayout
;
597 pszNewLayout
= MUIDefaultKeyboardLayout();
599 if (LayoutList
== NULL
)
601 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
602 if (LayoutList
== NULL
)
604 /* FIXME: Handle error! */
609 ListEntry
= GetFirstListEntry(LayoutList
);
611 /* Search for default layout (if provided) */
612 if (pszNewLayout
!= NULL
)
614 while (ListEntry
!= NULL
)
616 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
618 SetCurrentListEntry(LayoutList
, ListEntry
);
622 ListEntry
= GetNextListEntry(ListEntry
);
629 * Displays the LanguagePage.
631 * Next pages: IntroPage, QuitPage
634 * Init SelectedLanguageId
638 * Number of the next page.
641 LanguagePage(PINPUT_RECORD Ir
)
643 PWCHAR NewLanguageId
;
644 BOOL RefreshPage
= FALSE
;
646 /* Initialize the computer settings list */
647 if (LanguageList
== NULL
)
649 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
651 if (LanguageList
== NULL
)
653 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
659 SelectedLanguageId
= DefaultLanguage
;
660 SetConsoleCodePage();
663 /* If there's just a single language in the list skip
664 * the language selection process altogether! */
665 if (GenericListHasSingleEntry(LanguageList
))
667 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
671 DrawGenericList(LanguageList
,
677 ScrollToPositionGenericList(LanguageList
, GetDefaultLanguageIndex());
679 MUIDisplayPage(LANGUAGE_PAGE
);
683 CONSOLE_ConInKey(Ir
);
685 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
686 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
688 ScrollDownGenericList(LanguageList
);
691 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
692 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
694 ScrollUpGenericList(LanguageList
);
697 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
698 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
700 ScrollPageDownGenericList(LanguageList
);
703 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
704 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
706 ScrollPageUpGenericList(LanguageList
);
709 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
710 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
712 if (ConfirmQuit(Ir
) != FALSE
)
715 RedrawGenericList(LanguageList
);
717 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
719 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
721 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
723 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
729 SetConsoleCodePage();
733 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
736 GenericListKeyPress(LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
742 NewLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
744 if (SelectedLanguageId
!= NewLanguageId
)
746 /* Clear the language page */
747 MUIClearPage(LANGUAGE_PAGE
);
749 SelectedLanguageId
= NewLanguageId
;
752 SetConsoleCodePage();
754 /* Redraw language selection page in native language */
755 MUIDisplayPage(LANGUAGE_PAGE
);
770 * LanguagePage (at once, default)
771 * InstallIntroPage (at once, if unattended)
777 * Init SourceRootPath
780 * Init RequiredPartitionDiskSpace
781 * Init IsUnattendedSetup
782 * If unattended, init *List and sets the Codepage
783 * If unattended, init SelectedLanguageId
784 * If unattended, init LanguageId
787 * Number of the next page.
790 SetupStartPage(PINPUT_RECORD Ir
)
792 //SYSTEM_DEVICE_INFORMATION Sdi;
794 WCHAR FileNameBuffer
[MAX_PATH
];
799 PGENERIC_LIST_ENTRY ListEntry
;
802 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
805 /* Check whether a harddisk is available */
806 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
808 sizeof(SYSTEM_DEVICE_INFORMATION
),
811 if (!NT_SUCCESS(Status
))
813 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
814 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
818 if (Sdi
.NumberOfDisks
== 0)
820 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
825 /* Get the source path and source root path */
826 Status
= GetSourcePaths(&SourcePath
,
830 if (!NT_SUCCESS(Status
))
832 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
833 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
839 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
840 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
841 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
845 /* Load txtsetup.sif from install media. */
846 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
847 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
849 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
855 if (SetupInf
== INVALID_HANDLE_VALUE
)
857 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
861 /* Open 'Version' section */
862 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
864 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
868 /* Get pointer 'Signature' key */
869 if (!INF_GetData(&Context
, NULL
, &Value
))
871 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
875 /* Check 'Signature' string */
876 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
878 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
882 /* Open 'DiskSpaceRequirements' section */
883 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
885 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
889 /* Get the 'FreeSysPartDiskSpace' value */
890 if (!SetupGetIntField(&Context
, 1, &IntValue
))
892 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
896 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
898 /* Start PnP thread */
899 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
901 NtResumeThread(hPnpThread
, NULL
);
902 hPnpThread
= INVALID_HANDLE_VALUE
;
905 CheckUnattendedSetup();
907 if (IsUnattendedSetup
)
910 //read options from inf
911 ComputerList
= CreateComputerTypeList(SetupInf
);
912 DisplayList
= CreateDisplayDriverList(SetupInf
);
913 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
914 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
915 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
918 wcscpy(SelectedLanguageId
,LocaleID
);
919 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
921 /* first we hack LanguageList */
922 ListEntry
= GetFirstListEntry(LanguageList
);
924 while (ListEntry
!= NULL
)
926 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
928 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
929 SetCurrentListEntry(LanguageList
, ListEntry
);
933 ListEntry
= GetNextListEntry(ListEntry
);
937 ListEntry
= GetFirstListEntry(LayoutList
);
939 while (ListEntry
!= NULL
)
941 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
943 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
944 SetCurrentListEntry(LayoutList
, ListEntry
);
948 ListEntry
= GetNextListEntry(ListEntry
);
951 SetConsoleCodePage();
953 return INSTALL_INTRO_PAGE
;
956 return LANGUAGE_PAGE
;
961 * Displays the IntroPage.
964 * InstallIntroPage (default)
970 * Number of the next page.
973 IntroPage(PINPUT_RECORD Ir
)
975 MUIDisplayPage(START_PAGE
);
979 CONSOLE_ConInKey(Ir
);
981 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
982 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
984 if (ConfirmQuit(Ir
) != FALSE
)
989 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
991 return INSTALL_INTRO_PAGE
;
993 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
995 return REPAIR_INTRO_PAGE
;
997 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
1008 * Displays the License page.
1011 * IntroPage (default)
1014 * Number of the next page.
1017 LicensePage(PINPUT_RECORD Ir
)
1019 MUIDisplayPage(LICENSE_PAGE
);
1023 CONSOLE_ConInKey(Ir
);
1025 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1031 return LICENSE_PAGE
;
1036 * Displays the RepairIntroPage.
1039 * RebootPage (default)
1045 * Number of the next page.
1048 RepairIntroPage(PINPUT_RECORD Ir
)
1050 MUIDisplayPage(REPAIR_INTRO_PAGE
);
1054 CONSOLE_ConInKey(Ir
);
1056 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1060 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
1062 RepairUpdateFlag
= TRUE
;
1063 return INSTALL_INTRO_PAGE
;
1065 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
1067 return RECOVERY_PAGE
;
1069 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1070 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1076 return REPAIR_INTRO_PAGE
;
1080 * Displays the InstallIntroPage.
1083 * DeviceSettingsPage (At once if repair or update is selected)
1084 * SelectPartitionPage (At once if unattended setup)
1085 * DeviceSettingsPage (default)
1089 * Number of the next page.
1092 InstallIntroPage(PINPUT_RECORD Ir
)
1094 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1096 if (RepairUpdateFlag
)
1098 //return SELECT_PARTITION_PAGE;
1099 return DEVICE_SETTINGS_PAGE
;
1102 if (IsUnattendedSetup
)
1104 return SELECT_PARTITION_PAGE
;
1109 CONSOLE_ConInKey(Ir
);
1111 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1112 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1114 if (ConfirmQuit(Ir
) != FALSE
)
1119 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1121 return DEVICE_SETTINGS_PAGE
;
1122 // return SCSI_CONTROLLER_PAGE;
1126 return INSTALL_INTRO_PAGE
;
1132 ScsiControllerPage(PINPUT_RECORD Ir
)
1134 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1136 /* FIXME: print loaded mass storage driver descriptions */
1138 SetTextXY(8, 10, "TEST device");
1142 SetStatusText(" ENTER = Continue F3 = Quit");
1148 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1149 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1151 if (ConfirmQuit(Ir
) != FALSE
)
1156 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1158 return DEVICE_SETTINGS_PAGE
;
1162 return SCSI_CONTROLLER_PAGE
;
1168 * Displays the DeviceSettingsPage.
1171 * SelectPartitionPage (At once if repair or update is selected)
1172 * ComputerSettingsPage
1173 * DisplaySettingsPage
1174 * KeyboardSettingsPage
1175 * LayoutsettingsPage
1176 * SelectPartitionPage
1186 * Number of the next page.
1189 DeviceSettingsPage(PINPUT_RECORD Ir
)
1191 static ULONG Line
= 16;
1192 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1194 /* Initialize the computer settings list */
1195 if (ComputerList
== NULL
)
1197 ComputerList
= CreateComputerTypeList(SetupInf
);
1198 if (ComputerList
== NULL
)
1200 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1205 /* Initialize the display settings list */
1206 if (DisplayList
== NULL
)
1208 DisplayList
= CreateDisplayDriverList(SetupInf
);
1209 if (DisplayList
== NULL
)
1211 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1216 /* Initialize the keyboard settings list */
1217 if (KeyboardList
== NULL
)
1219 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1220 if (KeyboardList
== NULL
)
1222 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1227 /* Initialize the keyboard layout list */
1228 if (LayoutList
== NULL
)
1230 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1231 if (LayoutList
== NULL
)
1233 /* FIXME: report error */
1234 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1239 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1242 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1243 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1244 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1245 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1247 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1249 if (RepairUpdateFlag
)
1251 return SELECT_PARTITION_PAGE
;
1256 CONSOLE_ConInKey(Ir
);
1258 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1259 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1261 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1265 else if (Line
== 16)
1270 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1272 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1273 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1275 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1279 else if (Line
== 16)
1284 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1286 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1287 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1289 if (ConfirmQuit(Ir
) != FALSE
)
1294 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1297 return COMPUTER_SETTINGS_PAGE
;
1298 else if (Line
== 12)
1299 return DISPLAY_SETTINGS_PAGE
;
1300 else if (Line
== 13)
1301 return KEYBOARD_SETTINGS_PAGE
;
1302 else if (Line
== 14)
1303 return LAYOUT_SETTINGS_PAGE
;
1304 else if (Line
== 16)
1305 return SELECT_PARTITION_PAGE
;
1309 return DEVICE_SETTINGS_PAGE
;
1314 * Handles generic selection lists.
1317 * GenericList: The list to handle.
1318 * nextPage: The page it needs to jump to after this page.
1319 * Ir: The PINPUT_RECORD
1322 HandleGenericList(PGENERIC_LIST GenericList
,
1323 PAGE_NUMBER nextPage
,
1328 CONSOLE_ConInKey(Ir
);
1330 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1331 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1333 ScrollDownGenericList(GenericList
);
1335 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1336 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1338 ScrollUpGenericList(GenericList
);
1340 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1341 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1343 ScrollPageDownGenericList(GenericList
);
1345 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1346 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1348 ScrollPageUpGenericList(GenericList
);
1350 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1351 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1353 if (ConfirmQuit(Ir
) != FALSE
)
1358 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1359 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1361 RestoreGenericListState(GenericList
);
1364 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1368 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1371 GenericListKeyPress(GenericList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1378 * Displays the ComputerSettingsPage.
1381 * DeviceSettingsPage
1385 * Number of the next page.
1388 ComputerSettingsPage(PINPUT_RECORD Ir
)
1390 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1392 DrawGenericList(ComputerList
,
1398 SaveGenericListState(ComputerList
);
1400 return HandleGenericList(ComputerList
, DEVICE_SETTINGS_PAGE
, Ir
);
1405 * Displays the DisplaySettingsPage.
1408 * DeviceSettingsPage
1412 * Number of the next page.
1415 DisplaySettingsPage(PINPUT_RECORD Ir
)
1417 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1419 DrawGenericList(DisplayList
,
1425 SaveGenericListState(DisplayList
);
1427 return HandleGenericList(DisplayList
, DEVICE_SETTINGS_PAGE
, Ir
);
1432 * Displays the KeyboardSettingsPage.
1435 * DeviceSettingsPage
1439 * Number of the next page.
1442 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1444 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1446 DrawGenericList(KeyboardList
,
1452 SaveGenericListState(KeyboardList
);
1454 return HandleGenericList(KeyboardList
, DEVICE_SETTINGS_PAGE
, Ir
);
1459 * Displays the LayoutSettingsPage.
1462 * DeviceSettingsPage
1466 * Number of the next page.
1469 LayoutSettingsPage(PINPUT_RECORD Ir
)
1471 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1473 DrawGenericList(LayoutList
,
1479 SaveGenericListState(LayoutList
);
1481 return HandleGenericList(LayoutList
, DEVICE_SETTINGS_PAGE
, Ir
);
1486 IsDiskSizeValid(PPARTENTRY PartEntry
)
1490 size
= PartEntry
->SectorCount
.QuadPart
* PartEntry
->DiskEntry
->BytesPerSector
;
1491 size
= (size
+ 524288) / 1048576; /* in MBytes */
1493 if (size
< RequiredPartitionDiskSpace
)
1495 /* partition is too small so ask for another partition */
1496 DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size
, RequiredPartitionDiskSpace
);
1507 * Displays the SelectPartitionPage.
1510 * SelectFileSystemPage (At once if unattended)
1511 * SelectFileSystemPage (Default if free space is selected)
1512 * CreatePrimaryPartitionPage
1513 * CreateExtendedPartitionPage
1514 * CreateLogicalPartitionPage
1515 * ConfirmDeleteSystemPartitionPage (if the selected partition is the system partition, aka with the boot flag set)
1516 * DeletePartitionPage
1520 * Init DestinationDriveLetter (only if unattended or not free space is selected)
1521 * Set InstallShortcut (only if not unattended + free space is selected)
1524 * Number of the next page.
1527 SelectPartitionPage(PINPUT_RECORD Ir
)
1531 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1533 if (PartitionList
== NULL
)
1535 PartitionList
= CreatePartitionList(2,
1539 if (PartitionList
== NULL
)
1541 /* FIXME: show an error dialog */
1544 else if (IsListEmpty(&PartitionList
->DiskListHead
))
1546 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
1551 DrawPartitionList(PartitionList
);
1553 if (IsUnattendedSetup
)
1555 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1559 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1561 CreateLogicalPartition(PartitionList
,
1562 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1567 CreatePrimaryPartition(PartitionList
,
1568 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1572 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1574 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1575 RequiredPartitionDiskSpace
);
1576 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1579 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1581 return SELECT_FILE_SYSTEM_PAGE
;
1586 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1588 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1589 RequiredPartitionDiskSpace
);
1590 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1593 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1595 return SELECT_FILE_SYSTEM_PAGE
;
1601 /* Update status text */
1602 if (PartitionList
->CurrentPartition
== NULL
)
1604 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1606 else if (PartitionList
->CurrentPartition
->LogicalPartition
)
1608 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1610 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1614 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL
));
1619 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1621 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1623 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1627 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1632 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1636 CONSOLE_ConInKey(Ir
);
1638 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1639 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1641 if (ConfirmQuit(Ir
) != FALSE
)
1643 DestroyPartitionList(PartitionList
);
1644 PartitionList
= NULL
;
1650 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1651 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1653 if (ScrollDownPartitionList(PartitionList
))
1654 DrawPartitionList(PartitionList
);
1656 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1657 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1659 if (ScrollUpPartitionList(PartitionList
))
1660 DrawPartitionList(PartitionList
);
1662 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1664 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1665 continue; // return SELECT_PARTITION_PAGE;
1667 if (PartitionList
->CurrentPartition
== NULL
||
1668 PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1670 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1672 CreateLogicalPartition(PartitionList
,
1678 CreatePrimaryPartition(PartitionList
,
1684 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1686 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1687 RequiredPartitionDiskSpace
);
1688 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1691 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1693 return SELECT_FILE_SYSTEM_PAGE
;
1695 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'P') /* P */
1697 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1699 Error
= PrimaryPartitionCreationChecks(PartitionList
);
1700 if (Error
!= NOT_AN_ERROR
)
1702 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1703 return SELECT_PARTITION_PAGE
;
1706 return CREATE_PRIMARY_PARTITION_PAGE
;
1709 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'E') /* E */
1711 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1713 Error
= ExtendedPartitionCreationChecks(PartitionList
);
1714 if (Error
!= NOT_AN_ERROR
)
1716 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1717 return SELECT_PARTITION_PAGE
;
1720 return CREATE_EXTENDED_PARTITION_PAGE
;
1723 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'L') /* L */
1725 if (PartitionList
->CurrentPartition
->LogicalPartition
!= FALSE
)
1727 Error
= LogicalPartitionCreationChecks(PartitionList
);
1728 if (Error
!= NOT_AN_ERROR
)
1730 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1731 return SELECT_PARTITION_PAGE
;
1734 return CREATE_LOGICAL_PARTITION_PAGE
;
1737 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1739 if (PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1741 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1742 return SELECT_PARTITION_PAGE
;
1745 if (PartitionList
->CurrentPartition
->BootIndicator
||
1746 PartitionList
->CurrentPartition
== PartitionList
->SystemPartition
)
1748 return CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
;
1751 return DELETE_PARTITION_PAGE
;
1755 return SELECT_PARTITION_PAGE
;
1759 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 9
1760 /* Restriction for MaxSize: pow(10, (PARTITION_SIZE_INPUT_FIELD_LENGTH - 1)) - 1 */
1761 #define PARTITION_MAXSIZE (pow(10, (PARTITION_SIZE_INPUT_FIELD_LENGTH - 1)) - 1)
1764 ShowPartitionSizeInputBox(SHORT Left
,
1788 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1793 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1794 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1797 WriteConsoleOutputCharacterA(StdOutput
,
1803 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1804 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1806 WriteConsoleOutputCharacterA(StdOutput
,
1812 swprintf(InputBuffer
, L
"%lu", MaxSize
);
1813 Length
= wcslen(InputBuffer
);
1815 CONSOLE_SetInputTextXY(iLeft
,
1817 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1819 CONSOLE_SetCursorXY(iLeft
+ Length
, iTop
);
1820 CONSOLE_SetCursorType(TRUE
, TRUE
);
1824 CONSOLE_ConInKey(&Ir
);
1826 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1827 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1832 InputBuffer
[0] = UNICODE_NULL
;
1833 CONSOLE_SetCursorType(TRUE
, FALSE
);
1836 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1838 CONSOLE_SetCursorType(TRUE
, FALSE
);
1841 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1846 InputBuffer
[0] = UNICODE_NULL
;
1847 CONSOLE_SetCursorType(TRUE
, FALSE
);
1850 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1851 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_HOME
)) /* HOME */
1854 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1856 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1857 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_END
)) /* END */
1860 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1862 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1863 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_LEFT
)) /* LEFT */
1868 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1871 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1872 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RIGHT
)) /* RIGHT */
1877 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1880 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1881 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_DELETE
)) /* DEL */
1885 memmove(&InputBuffer
[Pos
],
1886 &InputBuffer
[Pos
+ 1],
1887 (Length
- Pos
- 1) * sizeof(WCHAR
));
1888 InputBuffer
[Length
- 1] = UNICODE_NULL
;
1891 CONSOLE_SetInputTextXY(iLeft
,
1893 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1895 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1898 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) /* BACKSPACE */
1903 memmove(&InputBuffer
[Pos
- 1],
1905 (Length
- Pos
) * sizeof(WCHAR
));
1906 InputBuffer
[Length
- 1] = UNICODE_NULL
;
1910 CONSOLE_SetInputTextXY(iLeft
,
1912 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1914 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1917 else if (Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00)
1919 if (Length
< PARTITION_SIZE_INPUT_FIELD_LENGTH
- 1)
1921 ch
= (WCHAR
)Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1923 if ((ch
>= L
'0') && (ch
<= L
'9'))
1926 memmove(&InputBuffer
[Pos
+ 1],
1928 (Length
- Pos
) * sizeof(WCHAR
));
1929 InputBuffer
[Length
+ 1] = UNICODE_NULL
;
1930 InputBuffer
[Pos
] = ch
;
1934 CONSOLE_SetInputTextXY(iLeft
,
1936 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1938 CONSOLE_SetCursorXY(iLeft
+ Pos
, iTop
);
1947 * Displays the CreatePrimaryPartitionPage.
1950 * SelectPartitionPage
1951 * SelectFileSystemPage (default)
1955 * Number of the next page.
1958 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1960 PDISKENTRY DiskEntry
;
1961 PPARTENTRY PartEntry
;
1964 WCHAR InputBuffer
[50];
1968 ULONGLONG SectorCount
;
1971 if (PartitionList
== NULL
||
1972 PartitionList
->CurrentDisk
== NULL
||
1973 PartitionList
->CurrentPartition
== NULL
)
1975 /* FIXME: show an error dialog */
1979 DiskEntry
= PartitionList
->CurrentDisk
;
1980 PartEntry
= PartitionList
->CurrentPartition
;
1982 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1984 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1986 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1988 if (DiskSize
>= 10737418240) /* 10 GB */
1990 DiskSize
= DiskSize
/ 1073741824;
1991 Unit
= MUIGetString(STRING_GB
);
1996 DiskSize
= DiskSize
/ 1048576;
2000 Unit
= MUIGetString(STRING_MB
);
2003 if (DiskEntry
->DriverName
.Length
> 0)
2005 CONSOLE_PrintTextXY(6, 10,
2006 MUIGetString(STRING_HDINFOPARTCREATE
),
2009 DiskEntry
->DiskNumber
,
2013 &DiskEntry
->DriverName
);
2017 CONSOLE_PrintTextXY(6, 10,
2018 MUIGetString(STRING_HDDINFOUNK1
),
2021 DiskEntry
->DiskNumber
,
2027 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2030 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2031 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2034 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2036 PartEntry
= PartitionList
->CurrentPartition
;
2039 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2041 if (MaxSize
> PARTITION_MAXSIZE
)
2042 MaxSize
= PARTITION_MAXSIZE
;
2044 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2045 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2049 if (ConfirmQuit(Ir
) != FALSE
)
2054 else if (Cancel
!= FALSE
)
2056 return SELECT_PARTITION_PAGE
;
2060 PartSize
= _wcstoui64(InputBuffer
, NULL
, 10);
2068 if (PartSize
> MaxSize
)
2074 /* Convert to bytes */
2075 if (PartSize
== MaxSize
)
2077 /* Use all of the unpartitioned disk space */
2078 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2082 /* Calculate the sector count from the size in MB */
2083 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2085 /* But never get larger than the unpartitioned disk space */
2086 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2087 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2090 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2092 CreatePrimaryPartition(PartitionList
,
2096 return SELECT_PARTITION_PAGE
;
2100 return CREATE_PRIMARY_PARTITION_PAGE
;
2105 * Displays the CreateExtendedPartitionPage.
2108 * SelectPartitionPage (default)
2112 * Number of the next page.
2115 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
2117 PDISKENTRY DiskEntry
;
2118 PPARTENTRY PartEntry
;
2121 WCHAR InputBuffer
[50];
2125 ULONGLONG SectorCount
;
2128 if (PartitionList
== NULL
||
2129 PartitionList
->CurrentDisk
== NULL
||
2130 PartitionList
->CurrentPartition
== NULL
)
2132 /* FIXME: show an error dialog */
2136 DiskEntry
= PartitionList
->CurrentDisk
;
2137 PartEntry
= PartitionList
->CurrentPartition
;
2139 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2141 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
2143 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2145 if (DiskSize
>= 10737418240) /* 10 GB */
2147 DiskSize
= DiskSize
/ 1073741824;
2148 Unit
= MUIGetString(STRING_GB
);
2153 DiskSize
= DiskSize
/ 1048576;
2157 Unit
= MUIGetString(STRING_MB
);
2160 if (DiskEntry
->DriverName
.Length
> 0)
2162 CONSOLE_PrintTextXY(6, 10,
2163 MUIGetString(STRING_HDINFOPARTCREATE
),
2166 DiskEntry
->DiskNumber
,
2170 &DiskEntry
->DriverName
);
2174 CONSOLE_PrintTextXY(6, 10,
2175 MUIGetString(STRING_HDDINFOUNK1
),
2178 DiskEntry
->DiskNumber
,
2184 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2187 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2188 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2191 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2193 PartEntry
= PartitionList
->CurrentPartition
;
2196 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2198 if (MaxSize
> PARTITION_MAXSIZE
)
2199 MaxSize
= PARTITION_MAXSIZE
;
2201 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2202 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2206 if (ConfirmQuit(Ir
) != FALSE
)
2211 else if (Cancel
!= FALSE
)
2213 return SELECT_PARTITION_PAGE
;
2217 PartSize
= _wcstoui64(InputBuffer
, NULL
, 10);
2225 if (PartSize
> MaxSize
)
2231 /* Convert to bytes */
2232 if (PartSize
== MaxSize
)
2234 /* Use all of the unpartitioned disk space */
2235 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2239 /* Calculate the sector count from the size in MB */
2240 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2242 /* But never get larger than the unpartitioned disk space */
2243 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2244 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2247 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2249 CreateExtendedPartition(PartitionList
,
2252 return SELECT_PARTITION_PAGE
;
2256 return CREATE_EXTENDED_PARTITION_PAGE
;
2261 * Displays the CreateLogicalPartitionPage.
2264 * SelectFileSystemPage (default)
2268 * Number of the next page.
2271 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2273 PDISKENTRY DiskEntry
;
2274 PPARTENTRY PartEntry
;
2277 WCHAR InputBuffer
[50];
2281 ULONGLONG SectorCount
;
2284 if (PartitionList
== NULL
||
2285 PartitionList
->CurrentDisk
== NULL
||
2286 PartitionList
->CurrentPartition
== NULL
)
2288 /* FIXME: show an error dialog */
2292 DiskEntry
= PartitionList
->CurrentDisk
;
2293 PartEntry
= PartitionList
->CurrentPartition
;
2295 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2297 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2299 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2301 if (DiskSize
>= 10737418240) /* 10 GB */
2303 DiskSize
= DiskSize
/ 1073741824;
2304 Unit
= MUIGetString(STRING_GB
);
2309 DiskSize
= DiskSize
/ 1048576;
2313 Unit
= MUIGetString(STRING_MB
);
2316 if (DiskEntry
->DriverName
.Length
> 0)
2318 CONSOLE_PrintTextXY(6, 10,
2319 MUIGetString(STRING_HDINFOPARTCREATE
),
2322 DiskEntry
->DiskNumber
,
2326 &DiskEntry
->DriverName
);
2330 CONSOLE_PrintTextXY(6, 10,
2331 MUIGetString(STRING_HDDINFOUNK1
),
2334 DiskEntry
->DiskNumber
,
2340 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2343 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2344 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2347 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2349 PartEntry
= PartitionList
->CurrentPartition
;
2352 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2354 if (MaxSize
> PARTITION_MAXSIZE
)
2355 MaxSize
= PARTITION_MAXSIZE
;
2357 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2358 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2362 if (ConfirmQuit(Ir
) != FALSE
)
2367 else if (Cancel
!= FALSE
)
2369 return SELECT_PARTITION_PAGE
;
2373 PartSize
= _wcstoui64(InputBuffer
, NULL
, 10);
2381 if (PartSize
> MaxSize
)
2387 /* Convert to bytes */
2388 if (PartSize
== MaxSize
)
2390 /* Use all of the unpartitioned disk space */
2391 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2395 /* Calculate the sector count from the size in MB */
2396 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2398 /* But never get larger than the unpartitioned disk space */
2399 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2400 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2403 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2405 CreateLogicalPartition(PartitionList
,
2409 return SELECT_PARTITION_PAGE
;
2413 return CREATE_LOGICAL_PARTITION_PAGE
;
2418 * Displays the ConfirmDeleteSystemPartitionPage.
2421 * DeletePartitionPage (default)
2422 * SelectPartitionPage
2425 * Number of the next page.
2428 ConfirmDeleteSystemPartitionPage(PINPUT_RECORD Ir
)
2430 MUIDisplayPage(CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
);
2434 CONSOLE_ConInKey(Ir
);
2436 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2437 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2439 if (ConfirmQuit(Ir
) == TRUE
)
2444 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2446 return DELETE_PARTITION_PAGE
;
2448 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2450 return SELECT_PARTITION_PAGE
;
2454 return CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
;
2459 * Displays the DeletePartitionPage.
2462 * SelectPartitionPage (default)
2466 * Number of the next page.
2469 DeletePartitionPage(PINPUT_RECORD Ir
)
2471 PDISKENTRY DiskEntry
;
2472 PPARTENTRY PartEntry
;
2476 CHAR PartTypeString
[32];
2478 if (PartitionList
== NULL
||
2479 PartitionList
->CurrentDisk
== NULL
||
2480 PartitionList
->CurrentPartition
== NULL
)
2482 /* FIXME: show an error dialog */
2486 DiskEntry
= PartitionList
->CurrentDisk
;
2487 PartEntry
= PartitionList
->CurrentPartition
;
2489 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2491 GetPartTypeStringFromPartitionType(PartEntry
->PartitionType
,
2493 ARRAYSIZE(PartTypeString
));
2495 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2497 if (PartSize
>= 10737418240) /* 10 GB */
2499 PartSize
= PartSize
/ 1073741824;
2500 Unit
= MUIGetString(STRING_GB
);
2504 if (PartSize
>= 10485760) /* 10 MB */
2506 PartSize
= PartSize
/ 1048576;
2507 Unit
= MUIGetString(STRING_MB
);
2511 PartSize
= PartSize
/ 1024;
2512 Unit
= MUIGetString(STRING_KB
);
2515 if (*PartTypeString
== '\0') // STRING_FORMATUNKNOWN ??
2517 CONSOLE_PrintTextXY(6, 10,
2518 MUIGetString(STRING_HDDINFOUNK2
),
2519 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2520 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2521 PartEntry
->PartitionType
,
2527 CONSOLE_PrintTextXY(6, 10,
2528 " %c%c %s %I64u %s",
2529 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2530 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2536 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2538 if (DiskSize
>= 10737418240) /* 10 GB */
2540 DiskSize
= DiskSize
/ 1073741824;
2541 Unit
= MUIGetString(STRING_GB
);
2546 DiskSize
= DiskSize
/ 1048576;
2550 Unit
= MUIGetString(STRING_MB
);
2553 if (DiskEntry
->DriverName
.Length
> 0)
2555 CONSOLE_PrintTextXY(6, 12,
2556 MUIGetString(STRING_HDINFOPARTDELETE
),
2559 DiskEntry
->DiskNumber
,
2563 &DiskEntry
->DriverName
);
2567 CONSOLE_PrintTextXY(6, 12,
2568 MUIGetString(STRING_HDDINFOUNK3
),
2571 DiskEntry
->DiskNumber
,
2579 CONSOLE_ConInKey(Ir
);
2581 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2582 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2584 if (ConfirmQuit(Ir
) != FALSE
)
2589 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2591 return SELECT_PARTITION_PAGE
;
2593 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2595 DeleteCurrentPartition(PartitionList
);
2597 return SELECT_PARTITION_PAGE
;
2601 return DELETE_PARTITION_PAGE
;
2606 * Displays the SelectFileSystemPage.
2609 * CheckFileSystemPage (At once if RepairUpdate is selected)
2610 * CheckFileSystemPage (At once if Unattended and not UnattendFormatPartition)
2611 * FormatPartitionPage (At once if Unattended and UnattendFormatPartition)
2612 * SelectPartitionPage (If the user aborts)
2613 * FormatPartitionPage (Default)
2617 * Sets PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType (via UpdatePartitionType)
2618 * Calls CheckActiveSystemPartition()
2621 * Number of the next page.
2624 SelectFileSystemPage(PINPUT_RECORD Ir
)
2626 PDISKENTRY DiskEntry
;
2627 PPARTENTRY PartEntry
;
2632 CHAR PartTypeString
[32];
2633 FORMATMACHINESTATE PreviousFormatState
;
2635 DPRINT("SelectFileSystemPage()\n");
2637 if (PartitionList
== NULL
||
2638 PartitionList
->CurrentDisk
== NULL
||
2639 PartitionList
->CurrentPartition
== NULL
)
2641 /* FIXME: show an error dialog */
2646 if (FileSystemList
== NULL
)
2648 FileSystemList
= CreateFileSystemList(6, 26, PartitionList
->CurrentPartition
->New
, L
"FAT");
2649 if (FileSystemList
== NULL
)
2651 /* FIXME: show an error dialog */
2655 /* FIXME: Add file systems to list */
2658 /* Find or set the active system partition */
2659 CheckActiveSystemPartition(PartitionList
, FileSystemList
);
2661 if (PartitionList
->SystemDisk
== NULL
||
2662 PartitionList
->SystemPartition
== NULL
)
2664 /* FIXME: show an error dialog */
2668 PreviousFormatState
= PartitionList
->FormatState
;
2669 switch (PartitionList
->FormatState
)
2672 if (PartitionList
->CurrentPartition
!= PartitionList
->SystemPartition
)
2674 PartitionList
->TempDisk
= PartitionList
->SystemDisk
;
2675 PartitionList
->TempPartition
= PartitionList
->SystemPartition
;
2676 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2678 PartitionList
->FormatState
= FormatSystemPartition
;
2679 DPRINT1("FormatState: Start --> FormatSystemPartition\n");
2683 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2684 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2685 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2687 PartitionList
->FormatState
= FormatInstallPartition
;
2688 DPRINT1("FormatState: Start --> FormatInstallPartition\n");
2692 case FormatSystemPartition
:
2693 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2694 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2695 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2697 PartitionList
->FormatState
= FormatInstallPartition
;
2698 DPRINT1("FormatState: FormatSystemPartition --> FormatInstallPartition\n");
2701 case FormatInstallPartition
:
2702 if (GetNextUnformattedPartition(PartitionList
,
2703 &PartitionList
->TempDisk
,
2704 &PartitionList
->TempPartition
))
2706 PartitionList
->FormatState
= FormatOtherPartition
;
2707 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2708 DPRINT1("FormatState: FormatInstallPartition --> FormatOtherPartition\n");
2712 PartitionList
->FormatState
= FormatDone
;
2713 DPRINT1("FormatState: FormatInstallPartition --> FormatDone\n");
2714 return CHECK_FILE_SYSTEM_PAGE
;
2718 case FormatOtherPartition
:
2719 if (GetNextUnformattedPartition(PartitionList
,
2720 &PartitionList
->TempDisk
,
2721 &PartitionList
->TempPartition
))
2723 PartitionList
->FormatState
= FormatOtherPartition
;
2724 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2725 DPRINT1("FormatState: FormatOtherPartition --> FormatOtherPartition\n");
2729 PartitionList
->FormatState
= FormatDone
;
2730 DPRINT1("FormatState: FormatOtherPartition --> FormatDone\n");
2731 return CHECK_FILE_SYSTEM_PAGE
;
2736 DPRINT1("FormatState: Invalid value %ld\n", PartitionList
->FormatState
);
2737 /* FIXME: show an error dialog */
2741 DiskEntry
= PartitionList
->TempDisk
;
2742 PartEntry
= PartitionList
->TempPartition
;
2744 /* Adjust disk size */
2745 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2746 if (DiskSize
>= 10737418240) /* 10 GB */
2748 DiskSize
= DiskSize
/ 1073741824;
2749 DiskUnit
= MUIGetString(STRING_GB
);
2753 DiskSize
= DiskSize
/ 1048576;
2754 DiskUnit
= MUIGetString(STRING_MB
);
2757 /* Adjust partition size */
2758 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2759 if (PartSize
>= 10737418240) /* 10 GB */
2761 PartSize
= PartSize
/ 1073741824;
2762 PartUnit
= MUIGetString(STRING_GB
);
2766 PartSize
= PartSize
/ 1048576;
2767 PartUnit
= MUIGetString(STRING_MB
);
2770 /* Adjust partition type */
2771 GetPartTypeStringFromPartitionType(PartEntry
->PartitionType
,
2773 ARRAYSIZE(PartTypeString
));
2775 if (PartEntry
->AutoCreate
!= FALSE
)
2777 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2780 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2781 PartEntry
->PartitionNumber
,
2787 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2788 DiskEntry
->DiskNumber
,
2794 &DiskEntry
->DriverName
);
2796 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2798 PartEntry
->AutoCreate
= FALSE
;
2800 else if (PartEntry
->New
!= FALSE
)
2802 switch (PartitionList
->FormatState
)
2804 case FormatSystemPartition
:
2805 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2808 case FormatInstallPartition
:
2809 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2812 case FormatOtherPartition
:
2813 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2820 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2824 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2826 if (*PartTypeString
== '\0') // STRING_FORMATUNKNOWN ??
2828 CONSOLE_PrintTextXY(8, 10,
2829 MUIGetString(STRING_HDDINFOUNK4
),
2830 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2831 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2832 PartEntry
->PartitionType
,
2838 CONSOLE_PrintTextXY(8, 10,
2840 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2841 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2847 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2848 DiskEntry
->DiskNumber
,
2854 &DiskEntry
->DriverName
);
2857 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2859 if (FileSystemList
== NULL
)
2861 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2862 if (FileSystemList
== NULL
)
2864 /* FIXME: show an error dialog */
2868 /* FIXME: Add file systems to list */
2871 DrawFileSystemList(FileSystemList
);
2873 if (RepairUpdateFlag
)
2875 return CHECK_FILE_SYSTEM_PAGE
;
2876 //return SELECT_PARTITION_PAGE;
2879 if (IsUnattendedSetup
)
2881 if (UnattendFormatPartition
)
2883 PartEntry
->FileSystem
= GetFileSystemByName(FileSystemList
, L
"FAT");
2884 return FORMAT_PARTITION_PAGE
;
2887 return CHECK_FILE_SYSTEM_PAGE
;
2892 CONSOLE_ConInKey(Ir
);
2894 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2895 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2897 if (ConfirmQuit(Ir
) != FALSE
)
2902 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2903 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2905 PartitionList
->FormatState
= Start
;
2906 return SELECT_PARTITION_PAGE
;
2908 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2909 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2911 ScrollDownFileSystemList(FileSystemList
);
2913 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2914 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2916 ScrollUpFileSystemList(FileSystemList
);
2918 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2920 if (!FileSystemList
->Selected
->FormatFunc
)
2922 return SELECT_FILE_SYSTEM_PAGE
;
2926 PartEntry
->FileSystem
= FileSystemList
->Selected
;
2927 return FORMAT_PARTITION_PAGE
;
2932 PartitionList
->FormatState
= PreviousFormatState
;
2934 return SELECT_FILE_SYSTEM_PAGE
;
2939 * Displays the FormatPartitionPage.
2942 * InstallDirectoryPage (At once if IsUnattendedSetup or InstallShortcut)
2943 * SelectPartitionPage (At once)
2947 * Sets PartitionList->CurrentPartition->FormatState
2948 * Sets DestinationRootPath
2951 * Number of the next page.
2954 FormatPartitionPage(PINPUT_RECORD Ir
)
2956 UNICODE_STRING PartitionRootPath
;
2957 WCHAR PathBuffer
[MAX_PATH
];
2958 PDISKENTRY DiskEntry
;
2959 PPARTENTRY PartEntry
;
2965 PPARTITION_INFORMATION PartitionInfo
;
2968 DPRINT("FormatPartitionPage()\n");
2970 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2972 if (PartitionList
== NULL
||
2973 PartitionList
->TempDisk
== NULL
||
2974 PartitionList
->TempPartition
== NULL
)
2976 /* FIXME: show an error dialog */
2980 DiskEntry
= PartitionList
->TempDisk
;
2981 PartEntry
= PartitionList
->TempPartition
;
2985 if (!IsUnattendedSetup
)
2987 CONSOLE_ConInKey(Ir
);
2990 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2991 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2993 if (ConfirmQuit(Ir
) != FALSE
)
2998 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
3000 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3002 if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"FAT") == 0)
3004 if (PartEntry
->SectorCount
.QuadPart
< 8192)
3006 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
3007 PartEntry
->PartitionType
= PARTITION_FAT_12
;
3009 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
3011 /* Partition starts below the 8.4GB boundary ==> CHS partition */
3013 if (PartEntry
->SectorCount
.QuadPart
< 65536)
3015 /* FAT16 CHS partition (partition size < 32MB) */
3016 PartEntry
->PartitionType
= PARTITION_FAT_16
;
3018 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
3020 /* FAT16 CHS partition (partition size < 512MB) */
3021 PartEntry
->PartitionType
= PARTITION_HUGE
;
3025 /* FAT32 CHS partition (partition size >= 512MB) */
3026 PartEntry
->PartitionType
= PARTITION_FAT32
;
3031 /* Partition starts above the 8.4GB boundary ==> LBA partition */
3033 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
3035 /* FAT16 LBA partition (partition size < 512MB) */
3036 PartEntry
->PartitionType
= PARTITION_XINT13
;
3040 /* FAT32 LBA partition (partition size >= 512MB) */
3041 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
3045 DiskEntry
->Dirty
= TRUE
;
3046 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
3047 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
3050 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"EXT2") == 0)
3052 PartEntry
->PartitionType
= PARTITION_EXT2
;
3054 DiskEntry
->Dirty
= TRUE
;
3055 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
3056 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
3058 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"NTFS") == 0)
3060 PartEntry
->PartitionType
= PARTITION_IFS
;
3062 DiskEntry
->Dirty
= TRUE
;
3063 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
3064 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
3067 else if (!PartEntry
->FileSystem
->FormatFunc
)
3069 /* FIXME: show an error dialog */
3074 CONSOLE_PrintTextXY(6, 12,
3075 "Cylinders: %I64u Tracks/Cyl: %lu Sectors/Trk: %lu Bytes/Sec: %lu %c",
3076 DiskEntry
->Cylinders
,
3077 DiskEntry
->TracksPerCylinder
,
3078 DiskEntry
->SectorsPerTrack
,
3079 DiskEntry
->BytesPerSector
,
3080 DiskEntry
->Dirty
? '*' : ' ');
3084 for (i
= 0; i
< DiskEntry
->LayoutBuffer
->PartitionCount
; i
++)
3086 PartitionInfo
= &DiskEntry
->LayoutBuffer
->PartitionEntry
[i
];
3088 CONSOLE_PrintTextXY(6, Line
,
3089 "%2u: %2lu %c %12I64u %12I64u %02x",
3091 PartitionInfo
->PartitionNumber
,
3092 PartitionInfo
->BootIndicator
? 'A' : '-',
3093 PartitionInfo
->StartingOffset
.QuadPart
/ DiskEntry
->BytesPerSector
,
3094 PartitionInfo
->PartitionLength
.QuadPart
/ DiskEntry
->BytesPerSector
,
3095 PartitionInfo
->PartitionType
);
3100 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
3102 DPRINT("WritePartitionsToDisk() failed\n");
3103 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
3107 /* Set PartitionRootPath */
3108 swprintf(PathBuffer
,
3109 L
"\\Device\\Harddisk%lu\\Partition%lu",
3110 DiskEntry
->DiskNumber
,
3111 PartEntry
->PartitionNumber
);
3112 RtlInitUnicodeString(&PartitionRootPath
,
3114 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3116 if (PartEntry
->FileSystem
->FormatFunc
)
3118 Status
= FormatPartition(&PartitionRootPath
,
3119 PartEntry
->FileSystem
);
3120 if (!NT_SUCCESS(Status
))
3122 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
3123 MUIDisplayError(ERROR_FORMATTING_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
, PathBuffer
);
3127 PartEntry
->New
= FALSE
;
3131 CONSOLE_SetStatusText(" Done. Press any key ...");
3132 CONSOLE_ConInKey(Ir
);
3135 return SELECT_FILE_SYSTEM_PAGE
;
3139 return FORMAT_PARTITION_PAGE
;
3144 * Displays the CheckFileSystemPage.
3147 * InstallDirectoryPage (At once)
3151 * Inits or reloads FileSystemList
3154 * Number of the next page.
3157 CheckFileSystemPage(PINPUT_RECORD Ir
)
3159 PFILE_SYSTEM_ITEM CurrentFileSystem
;
3160 UNICODE_STRING PartitionRootPath
;
3161 WCHAR PathBuffer
[MAX_PATH
];
3162 CHAR Buffer
[MAX_PATH
];
3163 PDISKENTRY DiskEntry
;
3164 PPARTENTRY PartEntry
;
3167 if (PartitionList
== NULL
)
3169 /* FIXME: show an error dialog */
3173 if (!GetNextUncheckedPartition(PartitionList
, &DiskEntry
, &PartEntry
))
3175 return INSTALL_DIRECTORY_PAGE
;
3178 /* Set PartitionRootPath */
3179 swprintf(PathBuffer
,
3180 L
"\\Device\\Harddisk%lu\\Partition%lu",
3181 DiskEntry
->DiskNumber
,
3182 PartEntry
->PartitionNumber
);
3183 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
3184 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3186 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
3188 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3190 CurrentFileSystem
= GetFileSystem(FileSystemList
, PartEntry
);
3191 DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystemName: %S\n",
3192 PartEntry
->PartitionType
, (CurrentFileSystem
? CurrentFileSystem
->FileSystemName
: L
"n/a"));
3194 /* HACK: Do not try to check a partition with an unknown filesystem */
3195 if (CurrentFileSystem
== NULL
)
3197 PartEntry
->NeedsCheck
= FALSE
;
3198 return CHECK_FILE_SYSTEM_PAGE
;
3201 if (CurrentFileSystem
->ChkdskFunc
== NULL
)
3204 "Setup is currently unable to check a partition formatted in %S.\n"
3206 " \x07 Press ENTER to continue Setup.\n"
3207 " \x07 Press F3 to quit Setup.",
3208 CurrentFileSystem
->FileSystemName
);
3211 MUIGetString(STRING_QUITCONTINUE
),
3212 NULL
, POPUP_WAIT_NONE
);
3216 CONSOLE_ConInKey(Ir
);
3218 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3219 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3221 if (ConfirmQuit(Ir
))
3224 return CHECK_FILE_SYSTEM_PAGE
;
3226 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3228 PartEntry
->NeedsCheck
= FALSE
;
3229 return CHECK_FILE_SYSTEM_PAGE
;
3235 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3236 if (!NT_SUCCESS(Status
))
3238 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3239 // sprintf(Buffer, "Setup failed to verify the selected partition.\n"
3240 sprintf(Buffer
, "ChkDsk detected some disk errors.\n"
3241 "(Status 0x%08lx).\n", Status
);
3243 // MUIGetString(STRING_REBOOTCOMPUTER),
3244 MUIGetString(STRING_CONTINUE
),
3245 Ir
, POPUP_WAIT_ENTER
);
3247 // return QUIT_PAGE;
3250 PartEntry
->NeedsCheck
= FALSE
;
3251 return CHECK_FILE_SYSTEM_PAGE
;
3258 BuildInstallPaths(PWCHAR InstallDir
,
3259 PDISKENTRY DiskEntry
,
3260 PPARTENTRY PartEntry
)
3262 WCHAR PathBuffer
[MAX_PATH
];
3264 /* Create 'InstallPath' string */
3265 RtlFreeUnicodeString(&InstallPath
);
3266 RtlCreateUnicodeString(&InstallPath
, InstallDir
);
3268 /* Create 'DestinationRootPath' string */
3269 RtlFreeUnicodeString(&DestinationRootPath
);
3270 swprintf(PathBuffer
,
3271 L
"\\Device\\Harddisk%lu\\Partition%lu",
3272 DiskEntry
->DiskNumber
,
3273 PartEntry
->PartitionNumber
);
3274 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
3275 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
3277 /* Create 'DestinationPath' string */
3278 RtlFreeUnicodeString(&DestinationPath
);
3279 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3281 if (InstallDir
[0] != L
'\\')
3282 wcscat(PathBuffer
, L
"\\");
3284 wcscat(PathBuffer
, InstallDir
);
3285 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
3287 /* Create 'DestinationArcPath' */
3288 RtlFreeUnicodeString(&DestinationArcPath
);
3289 swprintf(PathBuffer
,
3290 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
3291 DiskEntry
->BiosDiskNumber
,
3292 PartEntry
->PartitionNumber
);
3294 if (InstallDir
[0] != L
'\\')
3295 wcscat(PathBuffer
, L
"\\");
3297 wcscat(PathBuffer
, InstallDir
);
3298 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3303 * Displays the InstallDirectoryPage.
3306 * PrepareCopyPage (As the direct result of InstallDirectoryPage1)
3310 * Number of the next page.
3313 InstallDirectoryPage(PINPUT_RECORD Ir
)
3315 PDISKENTRY DiskEntry
;
3316 PPARTENTRY PartEntry
;
3317 WCHAR InstallDir
[51];
3321 /* We do not need the filesystem list any more */
3322 if (FileSystemList
!= NULL
)
3324 DestroyFileSystemList(FileSystemList
);
3325 FileSystemList
= NULL
;
3328 if (PartitionList
== NULL
||
3329 PartitionList
->CurrentDisk
== NULL
||
3330 PartitionList
->CurrentPartition
== NULL
)
3332 /* FIXME: show an error dialog */
3336 DiskEntry
= PartitionList
->CurrentDisk
;
3337 PartEntry
= PartitionList
->CurrentPartition
;
3339 if (IsUnattendedSetup
)
3341 if (!IsValidPath(UnattendInstallationDirectory
))
3343 /* FIXME: Log the error? */
3347 BuildInstallPaths(UnattendInstallationDirectory
,
3351 return PREPARE_COPY_PAGE
;
3354 wcscpy(InstallDir
, L
"\\ReactOS");
3356 Length
= wcslen(InstallDir
);
3358 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3359 CONSOLE_SetCursorXY(8 + Pos
, 11);
3360 CONSOLE_SetCursorType(TRUE
, TRUE
);
3361 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3365 CONSOLE_ConInKey(Ir
);
3367 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3368 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3370 CONSOLE_SetCursorType(TRUE
, FALSE
);
3372 if (ConfirmQuit(Ir
) != FALSE
)
3375 CONSOLE_SetCursorType(TRUE
, TRUE
);
3378 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3379 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DELETE
)) /* DEL */
3383 memmove(&InstallDir
[Pos
],
3384 &InstallDir
[Pos
+ 1],
3385 (Length
- Pos
- 1) * sizeof(WCHAR
));
3386 InstallDir
[Length
- 1] = UNICODE_NULL
;
3389 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3390 CONSOLE_SetCursorXY(8 + Pos
, 11);
3393 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3394 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_HOME
)) /* HOME */
3397 CONSOLE_SetCursorXY(8 + Pos
, 11);
3399 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3400 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_END
)) /* END */
3403 CONSOLE_SetCursorXY(8 + Pos
, 11);
3405 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3406 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_LEFT
)) /* LEFT */
3411 CONSOLE_SetCursorXY(8 + Pos
, 11);
3414 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3415 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RIGHT
)) /* RIGHT */
3420 CONSOLE_SetCursorXY(8 + Pos
, 11);
3423 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3425 CONSOLE_SetCursorType(TRUE
, FALSE
);
3428 * Check for the validity of the installation directory and pop up
3429 * an error if it is not the case. Then the user can fix its input.
3431 if (!IsValidPath(InstallDir
))
3433 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3434 return INSTALL_DIRECTORY_PAGE
;
3437 BuildInstallPaths(InstallDir
,
3441 return PREPARE_COPY_PAGE
;
3443 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3448 memmove(&InstallDir
[Pos
- 1],
3450 (Length
- Pos
) * sizeof(WCHAR
));
3451 InstallDir
[Length
- 1] = UNICODE_NULL
;
3455 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3456 CONSOLE_SetCursorXY(8 + Pos
, 11);
3459 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3463 c
= (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3464 if (iswalpha(c
) || iswdigit(c
) || c
== '.' || c
== '\\' || c
== '-' || c
== '_')
3467 memmove(&InstallDir
[Pos
+ 1],
3469 (Length
- Pos
) * sizeof(WCHAR
));
3470 InstallDir
[Length
+ 1] = UNICODE_NULL
;
3471 InstallDir
[Pos
] = c
;
3475 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3476 CONSOLE_SetCursorXY(8 + Pos
, 11);
3482 return INSTALL_DIRECTORY_PAGE
;
3487 AddSectionToCopyQueueCab(HINF InfFile
,
3489 PWCHAR SourceCabinet
,
3490 PCUNICODE_STRING DestinationPath
,
3493 INFCONTEXT FilesContext
;
3494 INFCONTEXT DirContext
;
3496 PWCHAR FileKeyValue
;
3498 PWCHAR TargetFileName
;
3500 /* Search for the SectionName section */
3501 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3504 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3505 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3510 * Enumerate the files in the section
3511 * and add them to the file queue.
3515 /* Get source file name and target directory id */
3516 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3518 /* FIXME: Handle error! */
3519 DPRINT1("INF_GetData() failed\n");
3523 /* Get optional target file name */
3524 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3525 TargetFileName
= NULL
;
3527 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3529 /* Lookup target directory */
3530 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3532 /* FIXME: Handle error! */
3533 DPRINT1("SetupFindFirstLine() failed\n");
3537 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3539 /* FIXME: Handle error! */
3540 DPRINT1("INF_GetData() failed\n");
3544 if (!SetupQueueCopy(SetupFileQueue
,
3546 SourceRootPath
.Buffer
,
3547 SourceRootDir
.Buffer
,
3552 /* FIXME: Handle error! */
3553 DPRINT1("SetupQueueCopy() failed\n");
3555 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3562 AddSectionToCopyQueue(HINF InfFile
,
3564 PWCHAR SourceCabinet
,
3565 PCUNICODE_STRING DestinationPath
,
3568 INFCONTEXT FilesContext
;
3569 INFCONTEXT DirContext
;
3571 PWCHAR FileKeyValue
;
3573 PWCHAR TargetFileName
;
3575 WCHAR CompleteOrigDirName
[512];
3578 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3580 /* Search for the SectionName section */
3581 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3584 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3585 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3590 * Enumerate the files in the section
3591 * and add them to the file queue.
3595 /* Get source file name and target directory id */
3596 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3598 /* FIXME: Handle error! */
3599 DPRINT1("INF_GetData() failed\n");
3603 /* Get target directory id */
3604 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3606 /* FIXME: Handle error! */
3607 DPRINT1("INF_GetData() failed\n");
3611 /* Get optional target file name */
3612 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3613 TargetFileName
= NULL
;
3614 else if (!*TargetFileName
)
3615 TargetFileName
= NULL
;
3617 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3619 /* Lookup target directory */
3620 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3622 /* FIXME: Handle error! */
3623 DPRINT1("SetupFindFirstLine() failed\n");
3627 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3629 /* FIXME: Handle error! */
3630 DPRINT1("INF_GetData() failed\n");
3634 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3636 /* Installation path */
3637 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3639 else if (DirKeyValue
[0] == L
'\\')
3642 wcscpy(CompleteOrigDirName
, DirKeyValue
);
3644 else // if (DirKeyValue[0] != L'\\')
3646 /* Path relative to the installation path */
3647 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3648 wcscat(CompleteOrigDirName
, L
"\\");
3649 wcscat(CompleteOrigDirName
, DirKeyValue
);
3652 /* Remove trailing backslash */
3653 Length
= wcslen(CompleteOrigDirName
);
3654 if ((Length
> 0) && (CompleteOrigDirName
[Length
- 1] == L
'\\'))
3656 CompleteOrigDirName
[Length
- 1] = 0;
3659 if (!SetupQueueCopy(SetupFileQueue
,
3661 SourceRootPath
.Buffer
,
3662 CompleteOrigDirName
,
3667 /* FIXME: Handle error! */
3668 DPRINT1("SetupQueueCopy() failed\n");
3670 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3677 PrepareCopyPageInfFile(HINF InfFile
,
3678 PWCHAR SourceCabinet
,
3681 WCHAR PathBuffer
[MAX_PATH
];
3682 INFCONTEXT DirContext
;
3683 PWCHAR AdditionalSectionName
= NULL
;
3688 /* Add common files */
3689 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3692 /* Add specific files depending of computer type */
3693 if (SourceCabinet
== NULL
)
3695 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3698 if (AdditionalSectionName
)
3700 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3705 /* Create directories */
3709 * - Install directories like '\reactos\test' are not handled yet.
3710 * - Copying files to DestinationRootPath should be done from within
3711 * the SystemPartitionFiles section.
3712 * At the moment we check whether we specify paths like '\foo' or '\\' for that.
3713 * For installing to DestinationPath specify just '\' .
3716 /* Get destination path */
3717 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3719 /* Remove trailing backslash */
3720 Length
= wcslen(PathBuffer
);
3721 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3723 PathBuffer
[Length
- 1] = 0;
3726 /* Create the install directory */
3727 Status
= SetupCreateDirectory(PathBuffer
);
3728 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3730 DPRINT1("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3731 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3735 /* Search for the 'Directories' section */
3736 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3740 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3744 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3750 /* Enumerate the directory values and create the subdirectories */
3753 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3759 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3761 /* Installation path */
3762 DPRINT("InstallationPath: '%S'\n", DirKeyValue
);
3764 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3766 DPRINT("FullPath: '%S'\n", PathBuffer
);
3768 else if (DirKeyValue
[0] == L
'\\')
3771 DPRINT("Absolute Path: '%S'\n", DirKeyValue
);
3773 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3774 wcscat(PathBuffer
, DirKeyValue
);
3776 /* Remove trailing backslash */
3777 Length
= wcslen(PathBuffer
);
3778 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3780 PathBuffer
[Length
- 1] = 0;
3783 DPRINT("FullPath: '%S'\n", PathBuffer
);
3785 Status
= SetupCreateDirectory(PathBuffer
);
3786 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3788 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3789 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3793 else // if (DirKeyValue[0] != L'\\')
3795 /* Path relative to the installation path */
3796 DPRINT("RelativePath: '%S'\n", DirKeyValue
);
3798 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3799 wcscat(PathBuffer
, L
"\\");
3800 wcscat(PathBuffer
, DirKeyValue
);
3802 /* Remove trailing backslash */
3803 Length
= wcslen(PathBuffer
);
3804 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3806 PathBuffer
[Length
- 1] = 0;
3809 DPRINT("FullPath: '%S'\n", PathBuffer
);
3811 Status
= SetupCreateDirectory(PathBuffer
);
3812 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3814 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3815 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3819 } while (SetupFindNextLine(&DirContext
, &DirContext
));
3826 * Displays the PrepareCopyPage.
3829 * FileCopyPage(At once)
3833 * Inits SetupFileQueue
3834 * Calls PrepareCopyPageInfFile
3837 * Number of the next page.
3840 PrepareCopyPage(PINPUT_RECORD Ir
)
3843 WCHAR PathBuffer
[MAX_PATH
];
3844 INFCONTEXT CabinetsContext
;
3850 MUIDisplayPage(PREPARE_COPY_PAGE
);
3852 /* Create the file queue */
3853 SetupFileQueue
= SetupOpenFileQueue();
3854 if (SetupFileQueue
== NULL
)
3856 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3860 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3862 /* FIXME: show an error dialog */
3866 /* Search for the 'Cabinets' section */
3867 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3869 return FILE_COPY_PAGE
;
3873 * Enumerate the directory values in the 'Cabinets'
3874 * section and parse their inf files.
3878 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3881 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3882 wcscat(PathBuffer
, L
"\\");
3883 wcscat(PathBuffer
, KeyValue
);
3885 CabinetInitialize();
3886 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3887 CabinetSetCabinetName(PathBuffer
);
3889 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3891 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3893 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3894 if (InfFileData
== NULL
)
3896 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3902 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3903 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3907 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3914 if (InfHandle
== INVALID_HANDLE_VALUE
)
3916 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3922 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3924 /* FIXME: show an error dialog */
3927 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3929 return FILE_COPY_PAGE
;
3935 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3938 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3940 /* Get the memory information from the system */
3941 NtQuerySystemInformation(SystemPerformanceInformation
,
3946 /* Check if this is initial setup */
3949 /* Set maximum limits to be total RAM pages */
3950 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3951 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3952 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3955 /* Set current values */
3956 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3957 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3958 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3964 FileCopyCallback(PVOID Context
,
3969 PCOPYCONTEXT CopyContext
;
3971 CopyContext
= (PCOPYCONTEXT
)Context
;
3973 switch (Notification
)
3975 case SPFILENOTIFY_STARTSUBQUEUE
:
3976 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3977 ProgressSetStepCount(CopyContext
->ProgressBar
,
3978 CopyContext
->TotalOperations
);
3979 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3982 case SPFILENOTIFY_STARTCOPY
:
3983 /* Display copy message */
3984 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3985 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3988 case SPFILENOTIFY_ENDCOPY
:
3989 CopyContext
->CompletedOperations
++;
3991 /* SYSREG checkpoint */
3992 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3993 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3995 ProgressNextStep(CopyContext
->ProgressBar
);
3996 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
4005 * Displays the FileCopyPage.
4008 * RegistryPage(At once)
4011 * Calls SetupCommitFileQueueW
4012 * Calls SetupCloseFileQueue
4015 * Number of the next page.
4019 FileCopyPage(PINPUT_RECORD Ir
)
4021 COPYCONTEXT CopyContext
;
4022 unsigned int mem_bar_width
;
4024 MUIDisplayPage(FILE_COPY_PAGE
);
4026 /* Create context for the copy process */
4027 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
4028 CopyContext
.InstallPath
= InstallPath
.Buffer
;
4029 CopyContext
.TotalOperations
= 0;
4030 CopyContext
.CompletedOperations
= 0;
4032 /* Create the progress bar as well */
4033 CopyContext
.ProgressBar
= CreateProgressBar(13,
4040 MUIGetString(STRING_SETUPCOPYINGFILES
));
4042 // fit memory bars to screen width, distribute them uniform
4043 mem_bar_width
= (xScreen
- 26) / 5;
4044 mem_bar_width
-= mem_bar_width
% 2; // make even
4045 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
4046 /* Create the paged pool progress bar */
4047 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
4056 /* Create the non paged pool progress bar */
4057 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
4059 (xScreen
/ 2) + (mem_bar_width
/ 2),
4061 (xScreen
/ 2)- (mem_bar_width
/ 2),
4066 /* Create the global memory progress bar */
4067 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
4071 xScreen
- 13 - mem_bar_width
,
4076 /* Do the file copying */
4077 SetupCommitFileQueueW(NULL
,
4082 /* If we get here, we're done, so cleanup the queue and progress bar */
4083 SetupCloseFileQueue(SetupFileQueue
);
4084 DestroyProgressBar(CopyContext
.ProgressBar
);
4085 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
4086 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
4087 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
4089 /* Go display the next page */
4090 return REGISTRY_PAGE
;
4095 * Displays the RegistryPage.
4098 * SuccessPage (if RepairUpdate)
4099 * BootLoaderPage (default)
4103 * Calls SetInstallPathValue
4104 * Calls NtInitializeRegistry
4105 * Calls ImportRegistryFile
4106 * Calls SetDefaultPagefile
4107 * Calls SetMountedDeviceValues
4110 * Number of the next page.
4113 RegistryPage(PINPUT_RECORD Ir
)
4115 INFCONTEXT InfContext
;
4122 MUIDisplayPage(REGISTRY_PAGE
);
4124 if (RepairUpdateFlag
)
4126 return SUCCESS_PAGE
;
4129 if (!SetInstallPathValue(&DestinationPath
))
4131 DPRINT1("SetInstallPathValue() failed\n");
4132 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
4136 /* Create the default hives */
4137 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
4138 if (!NT_SUCCESS(Status
))
4140 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
4141 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
4145 /* Update registry */
4146 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
4148 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
4150 DPRINT1("SetupFindFirstLine() failed\n");
4151 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
4157 INF_GetDataField(&InfContext
, 0, &Action
);
4158 INF_GetDataField(&InfContext
, 1, &File
);
4159 INF_GetDataField(&InfContext
, 2, &Section
);
4161 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
4166 if (!_wcsicmp(Action
, L
"AddReg"))
4170 else if (!_wcsicmp(Action
, L
"DelReg"))
4179 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
4181 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
4183 DPRINT1("Importing %S failed\n", File
);
4185 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
4188 } while (SetupFindNextLine(&InfContext
, &InfContext
));
4190 /* Update display registry settings */
4191 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
4192 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
4194 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4198 /* Set the locale */
4199 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
4200 if (!ProcessLocaleRegistry(LanguageList
))
4202 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4206 /* Add keyboard layouts */
4207 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
4208 if (!AddKeyboardLayouts())
4210 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
4216 if (!SetGeoID(MUIGetGeoID()))
4218 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
4222 if (!IsUnattendedSetup
)
4224 /* Update keyboard layout settings */
4225 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
4226 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
4228 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4233 /* Add codepage information to registry */
4234 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
4237 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
4241 /* Set the default pagefile entry */
4242 SetDefaultPagefile(DestinationDriveLetter
);
4244 /* Update the mounted devices list */
4245 SetMountedDeviceValues(PartitionList
);
4247 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
4249 return BOOT_LOADER_PAGE
;
4254 * Displays the BootLoaderPage.
4257 * SuccessPage (if RepairUpdate)
4258 * BootLoaderHarddiskMbrPage
4259 * BootLoaderHarddiskVbrPage
4260 * BootLoaderFloppyPage
4265 * Calls SetInstallPathValue
4266 * Calls NtInitializeRegistry
4267 * Calls ImportRegistryFile
4268 * Calls SetDefaultPagefile
4269 * Calls SetMountedDeviceValues
4272 * Number of the next page.
4275 BootLoaderPage(PINPUT_RECORD Ir
)
4277 UCHAR PartitionType
;
4278 BOOLEAN InstallOnFloppy
;
4280 WCHAR PathBuffer
[MAX_PATH
];
4282 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
4284 RtlFreeUnicodeString(&SystemRootPath
);
4285 swprintf(PathBuffer
,
4286 L
"\\Device\\Harddisk%lu\\Partition%lu",
4287 PartitionList
->SystemDisk
->DiskNumber
,
4288 PartitionList
->SystemPartition
->PartitionNumber
);
4289 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
4290 DPRINT1("SystemRootPath: %wZ\n", &SystemRootPath
);
4292 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4294 if (IsUnattendedSetup
)
4296 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
4298 return SUCCESS_PAGE
;
4300 else if (UnattendMBRInstallType
== 1) /* install on floppy */
4302 return BOOT_LOADER_FLOPPY_PAGE
;
4306 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
4308 DPRINT("Error: system partition invalid (unused)\n");
4309 InstallOnFloppy
= TRUE
;
4311 else if (PartitionType
== PARTITION_OS2BOOTMGR
)
4313 /* OS/2 boot manager partition */
4314 DPRINT("Found OS/2 boot manager partition\n");
4315 InstallOnFloppy
= TRUE
;
4317 else if (PartitionType
== PARTITION_EXT2
)
4319 /* Linux EXT2 partition */
4320 DPRINT("Found Linux EXT2 partition\n");
4321 InstallOnFloppy
= FALSE
;
4323 else if (PartitionType
== PARTITION_IFS
)
4325 /* NTFS partition */
4326 DPRINT("Found NTFS partition\n");
4328 // FIXME: Make it FALSE when we'll support NTFS installation!
4329 InstallOnFloppy
= TRUE
;
4331 else if ((PartitionType
== PARTITION_FAT_12
) ||
4332 (PartitionType
== PARTITION_FAT_16
) ||
4333 (PartitionType
== PARTITION_HUGE
) ||
4334 (PartitionType
== PARTITION_XINT13
) ||
4335 (PartitionType
== PARTITION_FAT32
) ||
4336 (PartitionType
== PARTITION_FAT32_XINT13
))
4338 DPRINT("Found FAT partition\n");
4339 InstallOnFloppy
= FALSE
;
4343 /* Unknown partition */
4344 DPRINT("Unknown partition found\n");
4345 InstallOnFloppy
= TRUE
;
4348 if (InstallOnFloppy
!= FALSE
)
4350 return BOOT_LOADER_FLOPPY_PAGE
;
4353 /* Unattended install on hdd? */
4354 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
4356 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4359 MUIDisplayPage(BOOT_LOADER_PAGE
);
4360 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4364 CONSOLE_ConInKey(Ir
);
4366 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4367 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
4369 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4378 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4380 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4381 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
4383 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4392 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4394 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4395 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4397 if (ConfirmQuit(Ir
) != FALSE
)
4402 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4406 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4408 else if (Line
== 13)
4410 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4412 else if (Line
== 14)
4414 return BOOT_LOADER_FLOPPY_PAGE
;
4416 else if (Line
== 15)
4418 return SUCCESS_PAGE
;
4421 return BOOT_LOADER_PAGE
;
4425 return BOOT_LOADER_PAGE
;
4430 * Displays the BootLoaderFloppyPage.
4433 * SuccessPage (At once)
4437 * Calls InstallFatBootcodeToFloppy()
4440 * Number of the next page.
4443 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4447 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4449 // SetStatusText(" Please wait...");
4453 CONSOLE_ConInKey(Ir
);
4455 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4456 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4458 if (ConfirmQuit(Ir
) != FALSE
)
4463 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4465 if (DoesFileExist(NULL
, L
"\\Device\\Floppy0", L
"\\") == FALSE
)
4467 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4468 return BOOT_LOADER_FLOPPY_PAGE
;
4471 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
4472 if (!NT_SUCCESS(Status
))
4474 /* Print error message */
4475 return BOOT_LOADER_FLOPPY_PAGE
;
4478 return SUCCESS_PAGE
;
4482 return BOOT_LOADER_FLOPPY_PAGE
;
4487 * Displays the BootLoaderHarddiskVbrPage.
4490 * SuccessPage (At once)
4494 * Calls InstallVBRToPartition()
4497 * Number of the next page.
4500 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4502 UCHAR PartitionType
;
4505 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4507 Status
= InstallVBRToPartition(&SystemRootPath
,
4509 &DestinationArcPath
,
4511 if (!NT_SUCCESS(Status
))
4513 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4517 return SUCCESS_PAGE
;
4522 * Displays the BootLoaderHarddiskMbrPage.
4525 * SuccessPage (At once)
4529 * Calls InstallVBRToPartition()
4530 * CallsInstallMbrBootCodeToDisk()
4533 * Number of the next page.
4536 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4538 UCHAR PartitionType
;
4540 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4541 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
4542 WCHAR DstPath
[MAX_PATH
];
4544 /* Step 1: Write the VBR */
4545 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4547 Status
= InstallVBRToPartition(&SystemRootPath
,
4549 &DestinationArcPath
,
4551 if (!NT_SUCCESS(Status
))
4553 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4557 /* Step 2: Write the MBR */
4558 swprintf(DestinationDevicePathBuffer
,
4559 L
"\\Device\\Harddisk%d\\Partition0",
4560 PartitionList
->SystemDisk
->DiskNumber
);
4562 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4563 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4565 if (IsThereAValidBootSector(DestinationDevicePathBuffer
))
4567 /* Save current MBR */
4568 wcscpy(DstPath
, SystemRootPath
.Buffer
);
4569 wcscat(DstPath
, L
"\\mbr.old");
4571 DPRINT1("Save MBR: %S ==> %S\n", DestinationDevicePathBuffer
, DstPath
);
4572 Status
= SaveBootSector(DestinationDevicePathBuffer
, DstPath
, sizeof(PARTITION_SECTOR
));
4573 if (!NT_SUCCESS(Status
))
4575 DPRINT1("SaveBootSector() failed (Status %lx)\n", Status
);
4576 // Don't care if we succeeded or not saving the old MBR, just go ahead.
4580 DPRINT1("Install MBR bootcode: %S ==> %S\n",
4581 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4582 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4583 DestinationDevicePathBuffer
);
4584 if (!NT_SUCCESS(Status
))
4586 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4588 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4592 return SUCCESS_PAGE
;
4597 * Displays the QuitPage.
4600 * FlushPage (At once)
4606 * Number of the next page.
4609 QuitPage(PINPUT_RECORD Ir
)
4611 MUIDisplayPage(QUIT_PAGE
);
4613 /* Destroy partition list */
4614 if (PartitionList
!= NULL
)
4616 DestroyPartitionList(PartitionList
);
4617 PartitionList
= NULL
;
4620 /* Destroy filesystem list */
4621 if (FileSystemList
!= NULL
)
4623 DestroyFileSystemList(FileSystemList
);
4624 FileSystemList
= NULL
;
4627 /* Destroy computer settings list */
4628 if (ComputerList
!= NULL
)
4630 DestroyGenericList(ComputerList
, TRUE
);
4631 ComputerList
= NULL
;
4634 /* Destroy display settings list */
4635 if (DisplayList
!= NULL
)
4637 DestroyGenericList(DisplayList
, TRUE
);
4641 /* Destroy keyboard settings list */
4642 if (KeyboardList
!= NULL
)
4644 DestroyGenericList(KeyboardList
, TRUE
);
4645 KeyboardList
= NULL
;
4648 /* Destroy keyboard layout list */
4649 if (LayoutList
!= NULL
)
4651 DestroyGenericList(LayoutList
, TRUE
);
4655 if (LanguageList
!= NULL
)
4657 DestroyGenericList(LanguageList
, FALSE
);
4658 LanguageList
= NULL
;
4661 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4665 CONSOLE_ConInKey(Ir
);
4667 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4676 * Displays the SuccessPage.
4679 * FlushPage (At once)
4685 * Number of the next page.
4688 SuccessPage(PINPUT_RECORD Ir
)
4690 MUIDisplayPage(SUCCESS_PAGE
);
4692 if (IsUnattendedSetup
)
4699 CONSOLE_ConInKey(Ir
);
4701 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4710 * Displays the FlushPage.
4713 * RebootPage (At once)
4716 * Number of the next page.
4719 FlushPage(PINPUT_RECORD Ir
)
4721 MUIDisplayPage(FLUSH_PAGE
);
4727 PnpEventThread(IN LPVOID lpParameter
);
4731 * The start routine and page management
4742 NtQuerySystemTime(&Time
);
4744 Status
= RtlCreateUserThread(NtCurrentProcess(),
4754 if (!NT_SUCCESS(Status
))
4755 hPnpThread
= INVALID_HANDLE_VALUE
;
4757 if (!CONSOLE_Init())
4759 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4760 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4761 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4763 /* Raise a hard error (crash the system/BSOD) */
4764 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4768 /* Initialize global unicode strings */
4769 RtlInitUnicodeString(&SourcePath
, NULL
);
4770 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4771 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4772 RtlInitUnicodeString(&InstallPath
, NULL
);
4773 RtlInitUnicodeString(&DestinationPath
, NULL
);
4774 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4775 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4776 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4778 /* Hide the cursor */
4779 CONSOLE_SetCursorType(TRUE
, FALSE
);
4782 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4784 CONSOLE_ClearScreen();
4787 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4794 Page
= SetupStartPage(&Ir
);
4799 Page
= LanguagePage(&Ir
);
4804 Page
= LicensePage(&Ir
);
4809 Page
= IntroPage(&Ir
);
4813 case INSTALL_INTRO_PAGE
:
4814 Page
= InstallIntroPage(&Ir
);
4818 case SCSI_CONTROLLER_PAGE
:
4819 Page
= ScsiControllerPage(&Ir
);
4824 case OEM_DRIVER_PAGE
:
4825 Page
= OemDriverPage(&Ir
);
4829 case DEVICE_SETTINGS_PAGE
:
4830 Page
= DeviceSettingsPage(&Ir
);
4833 case COMPUTER_SETTINGS_PAGE
:
4834 Page
= ComputerSettingsPage(&Ir
);
4837 case DISPLAY_SETTINGS_PAGE
:
4838 Page
= DisplaySettingsPage(&Ir
);
4841 case KEYBOARD_SETTINGS_PAGE
:
4842 Page
= KeyboardSettingsPage(&Ir
);
4845 case LAYOUT_SETTINGS_PAGE
:
4846 Page
= LayoutSettingsPage(&Ir
);
4849 case SELECT_PARTITION_PAGE
:
4850 Page
= SelectPartitionPage(&Ir
);
4853 case CREATE_PRIMARY_PARTITION_PAGE
:
4854 Page
= CreatePrimaryPartitionPage(&Ir
);
4857 case CREATE_EXTENDED_PARTITION_PAGE
:
4858 Page
= CreateExtendedPartitionPage(&Ir
);
4861 case CREATE_LOGICAL_PARTITION_PAGE
:
4862 Page
= CreateLogicalPartitionPage(&Ir
);
4865 case CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
:
4866 Page
= ConfirmDeleteSystemPartitionPage(&Ir
);
4869 case DELETE_PARTITION_PAGE
:
4870 Page
= DeletePartitionPage(&Ir
);
4873 case SELECT_FILE_SYSTEM_PAGE
:
4874 Page
= SelectFileSystemPage(&Ir
);
4877 case FORMAT_PARTITION_PAGE
:
4878 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4881 case CHECK_FILE_SYSTEM_PAGE
:
4882 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4885 case INSTALL_DIRECTORY_PAGE
:
4886 Page
= InstallDirectoryPage(&Ir
);
4889 case PREPARE_COPY_PAGE
:
4890 Page
= PrepareCopyPage(&Ir
);
4893 case FILE_COPY_PAGE
:
4894 Page
= FileCopyPage(&Ir
);
4898 Page
= RegistryPage(&Ir
);
4901 case BOOT_LOADER_PAGE
:
4902 Page
= BootLoaderPage(&Ir
);
4905 case BOOT_LOADER_FLOPPY_PAGE
:
4906 Page
= BootLoaderFloppyPage(&Ir
);
4909 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4910 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4913 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4914 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4918 case REPAIR_INTRO_PAGE
:
4919 Page
= RepairIntroPage(&Ir
);
4923 Page
= SuccessPage(&Ir
);
4927 Page
= FlushPage(&Ir
);
4931 Page
= QuitPage(&Ir
);
4940 if (Page
== RECOVERY_PAGE
)
4945 /* Avoid bugcheck */
4946 Time
.QuadPart
+= 50000000;
4947 NtDelayExecution(FALSE
, &Time
);
4950 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4951 NtShutdownSystem(ShutdownReboot
);
4952 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4953 NtTerminateProcess(NtCurrentProcess(), 0);
4958 NtProcessStartup(PPEB Peb
)
4960 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4962 ProcessHeap
= Peb
->ProcessHeap
;
4963 InfSetHeap(ProcessHeap
);