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(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
));
2799 PartEntry
->AutoCreate
= FALSE
;
2801 else if (PartEntry
->New
!= FALSE
)
2803 switch (PartitionList
->FormatState
)
2805 case FormatSystemPartition
:
2806 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2809 case FormatInstallPartition
:
2810 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2813 case FormatOtherPartition
:
2814 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2821 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2825 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2827 if (*PartTypeString
== '\0') // STRING_FORMATUNKNOWN ??
2829 CONSOLE_PrintTextXY(8, 10,
2830 MUIGetString(STRING_HDDINFOUNK4
),
2831 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2832 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2833 PartEntry
->PartitionType
,
2839 CONSOLE_PrintTextXY(8, 10,
2841 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2842 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2848 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2849 DiskEntry
->DiskNumber
,
2855 &DiskEntry
->DriverName
);
2858 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2860 if (FileSystemList
== NULL
)
2862 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2863 if (FileSystemList
== NULL
)
2865 /* FIXME: show an error dialog */
2869 /* FIXME: Add file systems to list */
2872 DrawFileSystemList(FileSystemList
);
2874 if (RepairUpdateFlag
)
2876 return CHECK_FILE_SYSTEM_PAGE
;
2877 //return SELECT_PARTITION_PAGE;
2880 if (IsUnattendedSetup
)
2882 if (UnattendFormatPartition
)
2884 PartEntry
->FileSystem
= GetFileSystemByName(FileSystemList
, L
"FAT");
2885 return FORMAT_PARTITION_PAGE
;
2888 return CHECK_FILE_SYSTEM_PAGE
;
2893 CONSOLE_ConInKey(Ir
);
2895 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2896 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2898 if (ConfirmQuit(Ir
) != FALSE
)
2903 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2904 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2906 PartitionList
->FormatState
= Start
;
2907 return SELECT_PARTITION_PAGE
;
2909 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2910 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2912 ScrollDownFileSystemList(FileSystemList
);
2914 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2915 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2917 ScrollUpFileSystemList(FileSystemList
);
2919 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2921 if (!FileSystemList
->Selected
->FormatFunc
)
2923 return SELECT_FILE_SYSTEM_PAGE
;
2927 PartEntry
->FileSystem
= FileSystemList
->Selected
;
2928 return FORMAT_PARTITION_PAGE
;
2933 PartitionList
->FormatState
= PreviousFormatState
;
2935 return SELECT_FILE_SYSTEM_PAGE
;
2940 * Displays the FormatPartitionPage.
2943 * InstallDirectoryPage (At once if IsUnattendedSetup or InstallShortcut)
2944 * SelectPartitionPage (At once)
2948 * Sets PartitionList->CurrentPartition->FormatState
2949 * Sets DestinationRootPath
2952 * Number of the next page.
2955 FormatPartitionPage(PINPUT_RECORD Ir
)
2957 UNICODE_STRING PartitionRootPath
;
2958 WCHAR PathBuffer
[MAX_PATH
];
2959 PDISKENTRY DiskEntry
;
2960 PPARTENTRY PartEntry
;
2966 PPARTITION_INFORMATION PartitionInfo
;
2969 DPRINT("FormatPartitionPage()\n");
2971 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2973 if (PartitionList
== NULL
||
2974 PartitionList
->TempDisk
== NULL
||
2975 PartitionList
->TempPartition
== NULL
)
2977 /* FIXME: show an error dialog */
2981 DiskEntry
= PartitionList
->TempDisk
;
2982 PartEntry
= PartitionList
->TempPartition
;
2986 if (!IsUnattendedSetup
)
2988 CONSOLE_ConInKey(Ir
);
2991 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2992 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2994 if (ConfirmQuit(Ir
) != FALSE
)
2999 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
3001 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3003 if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"FAT") == 0)
3005 if (PartEntry
->SectorCount
.QuadPart
< 8192)
3007 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
3008 PartEntry
->PartitionType
= PARTITION_FAT_12
;
3010 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
3012 /* Partition starts below the 8.4GB boundary ==> CHS partition */
3014 if (PartEntry
->SectorCount
.QuadPart
< 65536)
3016 /* FAT16 CHS partition (partition size < 32MB) */
3017 PartEntry
->PartitionType
= PARTITION_FAT_16
;
3019 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
3021 /* FAT16 CHS partition (partition size < 512MB) */
3022 PartEntry
->PartitionType
= PARTITION_HUGE
;
3026 /* FAT32 CHS partition (partition size >= 512MB) */
3027 PartEntry
->PartitionType
= PARTITION_FAT32
;
3032 /* Partition starts above the 8.4GB boundary ==> LBA partition */
3034 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
3036 /* FAT16 LBA partition (partition size < 512MB) */
3037 PartEntry
->PartitionType
= PARTITION_XINT13
;
3041 /* FAT32 LBA partition (partition size >= 512MB) */
3042 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
3046 DiskEntry
->Dirty
= TRUE
;
3047 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
3048 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
3051 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"EXT2") == 0)
3053 PartEntry
->PartitionType
= PARTITION_EXT2
;
3055 DiskEntry
->Dirty
= TRUE
;
3056 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
3057 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
3059 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"NTFS") == 0)
3061 PartEntry
->PartitionType
= PARTITION_IFS
;
3063 DiskEntry
->Dirty
= TRUE
;
3064 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
3065 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
3068 else if (!PartEntry
->FileSystem
->FormatFunc
)
3070 /* FIXME: show an error dialog */
3075 CONSOLE_PrintTextXY(6, 12,
3076 "Cylinders: %I64u Tracks/Cyl: %lu Sectors/Trk: %lu Bytes/Sec: %lu %c",
3077 DiskEntry
->Cylinders
,
3078 DiskEntry
->TracksPerCylinder
,
3079 DiskEntry
->SectorsPerTrack
,
3080 DiskEntry
->BytesPerSector
,
3081 DiskEntry
->Dirty
? '*' : ' ');
3085 for (i
= 0; i
< DiskEntry
->LayoutBuffer
->PartitionCount
; i
++)
3087 PartitionInfo
= &DiskEntry
->LayoutBuffer
->PartitionEntry
[i
];
3089 CONSOLE_PrintTextXY(6, Line
,
3090 "%2u: %2lu %c %12I64u %12I64u %02x",
3092 PartitionInfo
->PartitionNumber
,
3093 PartitionInfo
->BootIndicator
? 'A' : '-',
3094 PartitionInfo
->StartingOffset
.QuadPart
/ DiskEntry
->BytesPerSector
,
3095 PartitionInfo
->PartitionLength
.QuadPart
/ DiskEntry
->BytesPerSector
,
3096 PartitionInfo
->PartitionType
);
3101 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
3103 DPRINT("WritePartitionsToDisk() failed\n");
3104 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
3108 /* Set PartitionRootPath */
3109 swprintf(PathBuffer
,
3110 L
"\\Device\\Harddisk%lu\\Partition%lu",
3111 DiskEntry
->DiskNumber
,
3112 PartEntry
->PartitionNumber
);
3113 RtlInitUnicodeString(&PartitionRootPath
,
3115 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3117 if (PartEntry
->FileSystem
->FormatFunc
)
3119 Status
= FormatPartition(&PartitionRootPath
,
3120 PartEntry
->FileSystem
);
3121 if (!NT_SUCCESS(Status
))
3123 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
3124 MUIDisplayError(ERROR_FORMATTING_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
, PathBuffer
);
3128 PartEntry
->New
= FALSE
;
3132 CONSOLE_SetStatusText(" Done. Press any key ...");
3133 CONSOLE_ConInKey(Ir
);
3136 return SELECT_FILE_SYSTEM_PAGE
;
3140 return FORMAT_PARTITION_PAGE
;
3145 * Displays the CheckFileSystemPage.
3148 * InstallDirectoryPage (At once)
3152 * Inits or reloads FileSystemList
3155 * Number of the next page.
3158 CheckFileSystemPage(PINPUT_RECORD Ir
)
3160 PFILE_SYSTEM_ITEM CurrentFileSystem
;
3161 UNICODE_STRING PartitionRootPath
;
3162 WCHAR PathBuffer
[MAX_PATH
];
3163 CHAR Buffer
[MAX_PATH
];
3164 PDISKENTRY DiskEntry
;
3165 PPARTENTRY PartEntry
;
3168 if (PartitionList
== NULL
)
3170 /* FIXME: show an error dialog */
3174 if (!GetNextUncheckedPartition(PartitionList
, &DiskEntry
, &PartEntry
))
3176 return INSTALL_DIRECTORY_PAGE
;
3179 /* Set PartitionRootPath */
3180 swprintf(PathBuffer
,
3181 L
"\\Device\\Harddisk%lu\\Partition%lu",
3182 DiskEntry
->DiskNumber
,
3183 PartEntry
->PartitionNumber
);
3184 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
3185 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3187 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
3189 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3191 CurrentFileSystem
= GetFileSystem(FileSystemList
, PartEntry
);
3192 DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystemName: %S\n",
3193 PartEntry
->PartitionType
, (CurrentFileSystem
? CurrentFileSystem
->FileSystemName
: L
"n/a"));
3195 /* HACK: Do not try to check a partition with an unknown filesystem */
3196 if (CurrentFileSystem
== NULL
)
3198 PartEntry
->NeedsCheck
= FALSE
;
3199 return CHECK_FILE_SYSTEM_PAGE
;
3202 if (CurrentFileSystem
->ChkdskFunc
== NULL
)
3205 "Setup is currently unable to check a partition formatted in %S.\n"
3207 " \x07 Press ENTER to continue Setup.\n"
3208 " \x07 Press F3 to quit Setup.",
3209 CurrentFileSystem
->FileSystemName
);
3212 MUIGetString(STRING_QUITCONTINUE
),
3213 NULL
, POPUP_WAIT_NONE
);
3217 CONSOLE_ConInKey(Ir
);
3219 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3220 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3222 if (ConfirmQuit(Ir
))
3225 return CHECK_FILE_SYSTEM_PAGE
;
3227 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3229 PartEntry
->NeedsCheck
= FALSE
;
3230 return CHECK_FILE_SYSTEM_PAGE
;
3236 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3237 if (!NT_SUCCESS(Status
))
3239 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3240 // sprintf(Buffer, "Setup failed to verify the selected partition.\n"
3241 sprintf(Buffer
, "ChkDsk detected some disk errors.\n"
3242 "(Status 0x%08lx).\n", Status
);
3244 // MUIGetString(STRING_REBOOTCOMPUTER),
3245 MUIGetString(STRING_CONTINUE
),
3246 Ir
, POPUP_WAIT_ENTER
);
3248 // return QUIT_PAGE;
3251 PartEntry
->NeedsCheck
= FALSE
;
3252 return CHECK_FILE_SYSTEM_PAGE
;
3259 BuildInstallPaths(PWCHAR InstallDir
,
3260 PDISKENTRY DiskEntry
,
3261 PPARTENTRY PartEntry
)
3263 WCHAR PathBuffer
[MAX_PATH
];
3265 /* Create 'InstallPath' string */
3266 RtlFreeUnicodeString(&InstallPath
);
3267 RtlCreateUnicodeString(&InstallPath
, InstallDir
);
3269 /* Create 'DestinationRootPath' string */
3270 RtlFreeUnicodeString(&DestinationRootPath
);
3271 swprintf(PathBuffer
,
3272 L
"\\Device\\Harddisk%lu\\Partition%lu",
3273 DiskEntry
->DiskNumber
,
3274 PartEntry
->PartitionNumber
);
3275 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
3276 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
3278 /* Create 'DestinationPath' string */
3279 RtlFreeUnicodeString(&DestinationPath
);
3280 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3282 if (InstallDir
[0] != L
'\\')
3283 wcscat(PathBuffer
, L
"\\");
3285 wcscat(PathBuffer
, InstallDir
);
3286 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
3288 /* Create 'DestinationArcPath' */
3289 RtlFreeUnicodeString(&DestinationArcPath
);
3290 swprintf(PathBuffer
,
3291 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
3292 DiskEntry
->BiosDiskNumber
,
3293 PartEntry
->PartitionNumber
);
3295 if (InstallDir
[0] != L
'\\')
3296 wcscat(PathBuffer
, L
"\\");
3298 wcscat(PathBuffer
, InstallDir
);
3299 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3304 * Displays the InstallDirectoryPage.
3307 * PrepareCopyPage (As the direct result of InstallDirectoryPage1)
3311 * Number of the next page.
3314 InstallDirectoryPage(PINPUT_RECORD Ir
)
3316 PDISKENTRY DiskEntry
;
3317 PPARTENTRY PartEntry
;
3318 WCHAR InstallDir
[51];
3322 /* We do not need the filesystem list any more */
3323 if (FileSystemList
!= NULL
)
3325 DestroyFileSystemList(FileSystemList
);
3326 FileSystemList
= NULL
;
3329 if (PartitionList
== NULL
||
3330 PartitionList
->CurrentDisk
== NULL
||
3331 PartitionList
->CurrentPartition
== NULL
)
3333 /* FIXME: show an error dialog */
3337 DiskEntry
= PartitionList
->CurrentDisk
;
3338 PartEntry
= PartitionList
->CurrentPartition
;
3340 if (IsUnattendedSetup
)
3342 if (!IsValidPath(UnattendInstallationDirectory
))
3344 /* FIXME: Log the error? */
3348 BuildInstallPaths(UnattendInstallationDirectory
,
3352 return PREPARE_COPY_PAGE
;
3355 wcscpy(InstallDir
, L
"\\ReactOS");
3357 Length
= wcslen(InstallDir
);
3359 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3360 CONSOLE_SetCursorXY(8 + Pos
, 11);
3361 CONSOLE_SetCursorType(TRUE
, TRUE
);
3362 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3366 CONSOLE_ConInKey(Ir
);
3368 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3369 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3371 CONSOLE_SetCursorType(TRUE
, FALSE
);
3373 if (ConfirmQuit(Ir
) != FALSE
)
3376 CONSOLE_SetCursorType(TRUE
, TRUE
);
3379 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3380 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DELETE
)) /* DEL */
3384 memmove(&InstallDir
[Pos
],
3385 &InstallDir
[Pos
+ 1],
3386 (Length
- Pos
- 1) * sizeof(WCHAR
));
3387 InstallDir
[Length
- 1] = UNICODE_NULL
;
3390 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3391 CONSOLE_SetCursorXY(8 + Pos
, 11);
3394 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3395 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_HOME
)) /* HOME */
3398 CONSOLE_SetCursorXY(8 + Pos
, 11);
3400 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3401 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_END
)) /* END */
3404 CONSOLE_SetCursorXY(8 + Pos
, 11);
3406 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3407 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_LEFT
)) /* LEFT */
3412 CONSOLE_SetCursorXY(8 + Pos
, 11);
3415 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3416 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RIGHT
)) /* RIGHT */
3421 CONSOLE_SetCursorXY(8 + Pos
, 11);
3424 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3426 CONSOLE_SetCursorType(TRUE
, FALSE
);
3429 * Check for the validity of the installation directory and pop up
3430 * an error if it is not the case. Then the user can fix its input.
3432 if (!IsValidPath(InstallDir
))
3434 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3435 return INSTALL_DIRECTORY_PAGE
;
3438 BuildInstallPaths(InstallDir
,
3442 return PREPARE_COPY_PAGE
;
3444 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3449 memmove(&InstallDir
[Pos
- 1],
3451 (Length
- Pos
) * sizeof(WCHAR
));
3452 InstallDir
[Length
- 1] = UNICODE_NULL
;
3456 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3457 CONSOLE_SetCursorXY(8 + Pos
, 11);
3460 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3464 c
= (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3465 if (iswalpha(c
) || iswdigit(c
) || c
== '.' || c
== '\\' || c
== '-' || c
== '_')
3468 memmove(&InstallDir
[Pos
+ 1],
3470 (Length
- Pos
) * sizeof(WCHAR
));
3471 InstallDir
[Length
+ 1] = UNICODE_NULL
;
3472 InstallDir
[Pos
] = c
;
3476 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3477 CONSOLE_SetCursorXY(8 + Pos
, 11);
3483 return INSTALL_DIRECTORY_PAGE
;
3488 AddSectionToCopyQueueCab(HINF InfFile
,
3490 PWCHAR SourceCabinet
,
3491 PCUNICODE_STRING DestinationPath
,
3494 INFCONTEXT FilesContext
;
3495 INFCONTEXT DirContext
;
3497 PWCHAR FileKeyValue
;
3499 PWCHAR TargetFileName
;
3501 /* Search for the SectionName section */
3502 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3505 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3506 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3511 * Enumerate the files in the section
3512 * and add them to the file queue.
3516 /* Get source file name and target directory id */
3517 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3519 /* FIXME: Handle error! */
3520 DPRINT1("INF_GetData() failed\n");
3524 /* Get optional target file name */
3525 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3526 TargetFileName
= NULL
;
3528 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3530 /* Lookup target directory */
3531 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3533 /* FIXME: Handle error! */
3534 DPRINT1("SetupFindFirstLine() failed\n");
3538 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3540 /* FIXME: Handle error! */
3541 DPRINT1("INF_GetData() failed\n");
3545 if (!SetupQueueCopy(SetupFileQueue
,
3547 SourceRootPath
.Buffer
,
3548 SourceRootDir
.Buffer
,
3553 /* FIXME: Handle error! */
3554 DPRINT1("SetupQueueCopy() failed\n");
3556 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3563 AddSectionToCopyQueue(HINF InfFile
,
3565 PWCHAR SourceCabinet
,
3566 PCUNICODE_STRING DestinationPath
,
3569 INFCONTEXT FilesContext
;
3570 INFCONTEXT DirContext
;
3572 PWCHAR FileKeyValue
;
3574 PWCHAR TargetFileName
;
3576 WCHAR CompleteOrigDirName
[512];
3579 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3581 /* Search for the SectionName section */
3582 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3585 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3586 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3591 * Enumerate the files in the section
3592 * and add them to the file queue.
3596 /* Get source file name and target directory id */
3597 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3599 /* FIXME: Handle error! */
3600 DPRINT1("INF_GetData() failed\n");
3604 /* Get target directory id */
3605 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3607 /* FIXME: Handle error! */
3608 DPRINT1("INF_GetData() failed\n");
3612 /* Get optional target file name */
3613 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3614 TargetFileName
= NULL
;
3615 else if (!*TargetFileName
)
3616 TargetFileName
= NULL
;
3618 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3620 /* Lookup target directory */
3621 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3623 /* FIXME: Handle error! */
3624 DPRINT1("SetupFindFirstLine() failed\n");
3628 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3630 /* FIXME: Handle error! */
3631 DPRINT1("INF_GetData() failed\n");
3635 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3637 /* Installation path */
3638 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3640 else if (DirKeyValue
[0] == L
'\\')
3643 wcscpy(CompleteOrigDirName
, DirKeyValue
);
3645 else // if (DirKeyValue[0] != L'\\')
3647 /* Path relative to the installation path */
3648 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3649 wcscat(CompleteOrigDirName
, L
"\\");
3650 wcscat(CompleteOrigDirName
, DirKeyValue
);
3653 /* Remove trailing backslash */
3654 Length
= wcslen(CompleteOrigDirName
);
3655 if ((Length
> 0) && (CompleteOrigDirName
[Length
- 1] == L
'\\'))
3657 CompleteOrigDirName
[Length
- 1] = 0;
3660 if (!SetupQueueCopy(SetupFileQueue
,
3662 SourceRootPath
.Buffer
,
3663 CompleteOrigDirName
,
3668 /* FIXME: Handle error! */
3669 DPRINT1("SetupQueueCopy() failed\n");
3671 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3678 PrepareCopyPageInfFile(HINF InfFile
,
3679 PWCHAR SourceCabinet
,
3682 WCHAR PathBuffer
[MAX_PATH
];
3683 INFCONTEXT DirContext
;
3684 PWCHAR AdditionalSectionName
= NULL
;
3689 /* Add common files */
3690 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3693 /* Add specific files depending of computer type */
3694 if (SourceCabinet
== NULL
)
3696 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3699 if (AdditionalSectionName
)
3701 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3706 /* Create directories */
3710 * - Install directories like '\reactos\test' are not handled yet.
3711 * - Copying files to DestinationRootPath should be done from within
3712 * the SystemPartitionFiles section.
3713 * At the moment we check whether we specify paths like '\foo' or '\\' for that.
3714 * For installing to DestinationPath specify just '\' .
3717 /* Get destination path */
3718 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3720 /* Remove trailing backslash */
3721 Length
= wcslen(PathBuffer
);
3722 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3724 PathBuffer
[Length
- 1] = 0;
3727 /* Create the install directory */
3728 Status
= SetupCreateDirectory(PathBuffer
);
3729 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3731 DPRINT1("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3732 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3736 /* Search for the 'Directories' section */
3737 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3741 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3745 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3751 /* Enumerate the directory values and create the subdirectories */
3754 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3760 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3762 /* Installation path */
3763 DPRINT("InstallationPath: '%S'\n", DirKeyValue
);
3765 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3767 DPRINT("FullPath: '%S'\n", PathBuffer
);
3769 else if (DirKeyValue
[0] == L
'\\')
3772 DPRINT("Absolute Path: '%S'\n", DirKeyValue
);
3774 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3775 wcscat(PathBuffer
, DirKeyValue
);
3777 /* Remove trailing backslash */
3778 Length
= wcslen(PathBuffer
);
3779 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3781 PathBuffer
[Length
- 1] = 0;
3784 DPRINT("FullPath: '%S'\n", PathBuffer
);
3786 Status
= SetupCreateDirectory(PathBuffer
);
3787 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3789 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3790 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3794 else // if (DirKeyValue[0] != L'\\')
3796 /* Path relative to the installation path */
3797 DPRINT("RelativePath: '%S'\n", DirKeyValue
);
3799 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3800 wcscat(PathBuffer
, L
"\\");
3801 wcscat(PathBuffer
, DirKeyValue
);
3803 /* Remove trailing backslash */
3804 Length
= wcslen(PathBuffer
);
3805 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3807 PathBuffer
[Length
- 1] = 0;
3810 DPRINT("FullPath: '%S'\n", PathBuffer
);
3812 Status
= SetupCreateDirectory(PathBuffer
);
3813 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3815 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3816 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3820 } while (SetupFindNextLine(&DirContext
, &DirContext
));
3827 * Displays the PrepareCopyPage.
3830 * FileCopyPage(At once)
3834 * Inits SetupFileQueue
3835 * Calls PrepareCopyPageInfFile
3838 * Number of the next page.
3841 PrepareCopyPage(PINPUT_RECORD Ir
)
3844 WCHAR PathBuffer
[MAX_PATH
];
3845 INFCONTEXT CabinetsContext
;
3851 MUIDisplayPage(PREPARE_COPY_PAGE
);
3853 /* Create the file queue */
3854 SetupFileQueue
= SetupOpenFileQueue();
3855 if (SetupFileQueue
== NULL
)
3857 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3861 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3863 /* FIXME: show an error dialog */
3867 /* Search for the 'Cabinets' section */
3868 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3870 return FILE_COPY_PAGE
;
3874 * Enumerate the directory values in the 'Cabinets'
3875 * section and parse their inf files.
3879 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3882 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3883 wcscat(PathBuffer
, L
"\\");
3884 wcscat(PathBuffer
, KeyValue
);
3886 CabinetInitialize();
3887 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3888 CabinetSetCabinetName(PathBuffer
);
3890 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3892 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3894 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3895 if (InfFileData
== NULL
)
3897 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3903 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3904 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3908 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3915 if (InfHandle
== INVALID_HANDLE_VALUE
)
3917 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3923 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3925 /* FIXME: show an error dialog */
3928 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3930 return FILE_COPY_PAGE
;
3936 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3939 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3941 /* Get the memory information from the system */
3942 NtQuerySystemInformation(SystemPerformanceInformation
,
3947 /* Check if this is initial setup */
3950 /* Set maximum limits to be total RAM pages */
3951 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3952 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3953 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3956 /* Set current values */
3957 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3958 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3959 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3965 FileCopyCallback(PVOID Context
,
3970 PCOPYCONTEXT CopyContext
;
3972 CopyContext
= (PCOPYCONTEXT
)Context
;
3974 switch (Notification
)
3976 case SPFILENOTIFY_STARTSUBQUEUE
:
3977 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3978 ProgressSetStepCount(CopyContext
->ProgressBar
,
3979 CopyContext
->TotalOperations
);
3980 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3983 case SPFILENOTIFY_STARTCOPY
:
3984 /* Display copy message */
3985 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3986 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3989 case SPFILENOTIFY_ENDCOPY
:
3990 CopyContext
->CompletedOperations
++;
3992 /* SYSREG checkpoint */
3993 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3994 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3996 ProgressNextStep(CopyContext
->ProgressBar
);
3997 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
4006 * Displays the FileCopyPage.
4009 * RegistryPage(At once)
4012 * Calls SetupCommitFileQueueW
4013 * Calls SetupCloseFileQueue
4016 * Number of the next page.
4020 FileCopyPage(PINPUT_RECORD Ir
)
4022 COPYCONTEXT CopyContext
;
4023 unsigned int mem_bar_width
;
4025 MUIDisplayPage(FILE_COPY_PAGE
);
4027 /* Create context for the copy process */
4028 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
4029 CopyContext
.InstallPath
= InstallPath
.Buffer
;
4030 CopyContext
.TotalOperations
= 0;
4031 CopyContext
.CompletedOperations
= 0;
4033 /* Create the progress bar as well */
4034 CopyContext
.ProgressBar
= CreateProgressBar(13,
4041 MUIGetString(STRING_SETUPCOPYINGFILES
));
4043 // fit memory bars to screen width, distribute them uniform
4044 mem_bar_width
= (xScreen
- 26) / 5;
4045 mem_bar_width
-= mem_bar_width
% 2; // make even
4046 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
4047 /* Create the paged pool progress bar */
4048 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
4057 /* Create the non paged pool progress bar */
4058 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
4060 (xScreen
/ 2) + (mem_bar_width
/ 2),
4062 (xScreen
/ 2)- (mem_bar_width
/ 2),
4067 /* Create the global memory progress bar */
4068 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
4072 xScreen
- 13 - mem_bar_width
,
4077 /* Do the file copying */
4078 SetupCommitFileQueueW(NULL
,
4083 /* If we get here, we're done, so cleanup the queue and progress bar */
4084 SetupCloseFileQueue(SetupFileQueue
);
4085 DestroyProgressBar(CopyContext
.ProgressBar
);
4086 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
4087 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
4088 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
4090 /* Go display the next page */
4091 return REGISTRY_PAGE
;
4096 * Displays the RegistryPage.
4099 * SuccessPage (if RepairUpdate)
4100 * BootLoaderPage (default)
4104 * Calls SetInstallPathValue
4105 * Calls NtInitializeRegistry
4106 * Calls ImportRegistryFile
4107 * Calls SetDefaultPagefile
4108 * Calls SetMountedDeviceValues
4111 * Number of the next page.
4114 RegistryPage(PINPUT_RECORD Ir
)
4116 INFCONTEXT InfContext
;
4123 MUIDisplayPage(REGISTRY_PAGE
);
4125 if (RepairUpdateFlag
)
4127 return SUCCESS_PAGE
;
4130 if (!SetInstallPathValue(&DestinationPath
))
4132 DPRINT1("SetInstallPathValue() failed\n");
4133 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
4137 /* Create the default hives */
4138 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
4139 if (!NT_SUCCESS(Status
))
4141 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
4142 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
4146 /* Update registry */
4147 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
4149 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
4151 DPRINT1("SetupFindFirstLine() failed\n");
4152 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
4158 INF_GetDataField(&InfContext
, 0, &Action
);
4159 INF_GetDataField(&InfContext
, 1, &File
);
4160 INF_GetDataField(&InfContext
, 2, &Section
);
4162 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
4167 if (!_wcsicmp(Action
, L
"AddReg"))
4171 else if (!_wcsicmp(Action
, L
"DelReg"))
4180 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
4182 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
4184 DPRINT1("Importing %S failed\n", File
);
4186 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
4189 } while (SetupFindNextLine(&InfContext
, &InfContext
));
4191 /* Update display registry settings */
4192 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
4193 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
4195 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4199 /* Set the locale */
4200 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
4201 if (!ProcessLocaleRegistry(LanguageList
))
4203 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4207 /* Add keyboard layouts */
4208 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
4209 if (!AddKeyboardLayouts())
4211 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
4217 if (!SetGeoID(MUIGetGeoID()))
4219 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
4223 if (!IsUnattendedSetup
)
4225 /* Update keyboard layout settings */
4226 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
4227 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
4229 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4234 /* Add codepage information to registry */
4235 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
4238 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
4242 /* Set the default pagefile entry */
4243 SetDefaultPagefile(DestinationDriveLetter
);
4245 /* Update the mounted devices list */
4246 SetMountedDeviceValues(PartitionList
);
4248 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
4250 return BOOT_LOADER_PAGE
;
4255 * Displays the BootLoaderPage.
4258 * SuccessPage (if RepairUpdate)
4259 * BootLoaderHarddiskMbrPage
4260 * BootLoaderHarddiskVbrPage
4261 * BootLoaderFloppyPage
4266 * Calls SetInstallPathValue
4267 * Calls NtInitializeRegistry
4268 * Calls ImportRegistryFile
4269 * Calls SetDefaultPagefile
4270 * Calls SetMountedDeviceValues
4273 * Number of the next page.
4276 BootLoaderPage(PINPUT_RECORD Ir
)
4278 UCHAR PartitionType
;
4279 BOOLEAN InstallOnFloppy
;
4281 WCHAR PathBuffer
[MAX_PATH
];
4283 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
4285 RtlFreeUnicodeString(&SystemRootPath
);
4286 swprintf(PathBuffer
,
4287 L
"\\Device\\Harddisk%lu\\Partition%lu",
4288 PartitionList
->SystemDisk
->DiskNumber
,
4289 PartitionList
->SystemPartition
->PartitionNumber
);
4290 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
4291 DPRINT1("SystemRootPath: %wZ\n", &SystemRootPath
);
4293 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4295 if (IsUnattendedSetup
)
4297 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
4299 return SUCCESS_PAGE
;
4301 else if (UnattendMBRInstallType
== 1) /* install on floppy */
4303 return BOOT_LOADER_FLOPPY_PAGE
;
4307 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
4309 DPRINT("Error: system partition invalid (unused)\n");
4310 InstallOnFloppy
= TRUE
;
4312 else if (PartitionType
== PARTITION_OS2BOOTMGR
)
4314 /* OS/2 boot manager partition */
4315 DPRINT("Found OS/2 boot manager partition\n");
4316 InstallOnFloppy
= TRUE
;
4318 else if (PartitionType
== PARTITION_EXT2
)
4320 /* Linux EXT2 partition */
4321 DPRINT("Found Linux EXT2 partition\n");
4322 InstallOnFloppy
= FALSE
;
4324 else if (PartitionType
== PARTITION_IFS
)
4326 /* NTFS partition */
4327 DPRINT("Found NTFS partition\n");
4329 // FIXME: Make it FALSE when we'll support NTFS installation!
4330 InstallOnFloppy
= TRUE
;
4332 else if ((PartitionType
== PARTITION_FAT_12
) ||
4333 (PartitionType
== PARTITION_FAT_16
) ||
4334 (PartitionType
== PARTITION_HUGE
) ||
4335 (PartitionType
== PARTITION_XINT13
) ||
4336 (PartitionType
== PARTITION_FAT32
) ||
4337 (PartitionType
== PARTITION_FAT32_XINT13
))
4339 DPRINT("Found FAT partition\n");
4340 InstallOnFloppy
= FALSE
;
4344 /* Unknown partition */
4345 DPRINT("Unknown partition found\n");
4346 InstallOnFloppy
= TRUE
;
4349 if (InstallOnFloppy
!= FALSE
)
4351 return BOOT_LOADER_FLOPPY_PAGE
;
4354 /* Unattended install on hdd? */
4355 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
4357 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4360 MUIDisplayPage(BOOT_LOADER_PAGE
);
4361 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4365 CONSOLE_ConInKey(Ir
);
4367 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4368 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
4370 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4379 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4381 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4382 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
4384 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4393 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4395 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4396 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4398 if (ConfirmQuit(Ir
) != FALSE
)
4403 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4407 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4409 else if (Line
== 13)
4411 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4413 else if (Line
== 14)
4415 return BOOT_LOADER_FLOPPY_PAGE
;
4417 else if (Line
== 15)
4419 return SUCCESS_PAGE
;
4422 return BOOT_LOADER_PAGE
;
4426 return BOOT_LOADER_PAGE
;
4431 * Displays the BootLoaderFloppyPage.
4434 * SuccessPage (At once)
4438 * Calls InstallFatBootcodeToFloppy()
4441 * Number of the next page.
4444 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4448 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4450 // SetStatusText(" Please wait...");
4454 CONSOLE_ConInKey(Ir
);
4456 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4457 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4459 if (ConfirmQuit(Ir
) != FALSE
)
4464 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4466 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
4468 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4469 return BOOT_LOADER_FLOPPY_PAGE
;
4472 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
4473 if (!NT_SUCCESS(Status
))
4475 /* Print error message */
4476 return BOOT_LOADER_FLOPPY_PAGE
;
4479 return SUCCESS_PAGE
;
4483 return BOOT_LOADER_FLOPPY_PAGE
;
4488 * Displays the BootLoaderHarddiskVbrPage.
4491 * SuccessPage (At once)
4495 * Calls InstallVBRToPartition()
4498 * Number of the next page.
4501 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4503 UCHAR PartitionType
;
4506 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4508 Status
= InstallVBRToPartition(&SystemRootPath
,
4510 &DestinationArcPath
,
4512 if (!NT_SUCCESS(Status
))
4514 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4518 return SUCCESS_PAGE
;
4523 * Displays the BootLoaderHarddiskMbrPage.
4526 * SuccessPage (At once)
4530 * Calls InstallVBRToPartition()
4531 * CallsInstallMbrBootCodeToDisk()
4534 * Number of the next page.
4537 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4539 UCHAR PartitionType
;
4541 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4542 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
4543 WCHAR DstPath
[MAX_PATH
];
4545 /* Step 1: Write the VBR */
4546 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4548 Status
= InstallVBRToPartition(&SystemRootPath
,
4550 &DestinationArcPath
,
4552 if (!NT_SUCCESS(Status
))
4554 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4558 /* Step 2: Write the MBR */
4559 swprintf(DestinationDevicePathBuffer
,
4560 L
"\\Device\\Harddisk%d\\Partition0",
4561 PartitionList
->SystemDisk
->DiskNumber
);
4563 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4564 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4566 if (IsThereAValidBootSector(DestinationDevicePathBuffer
))
4568 /* Save current MBR */
4569 wcscpy(DstPath
, SystemRootPath
.Buffer
);
4570 wcscat(DstPath
, L
"\\mbr.old");
4572 DPRINT1("Save MBR: %S ==> %S\n", DestinationDevicePathBuffer
, DstPath
);
4573 Status
= SaveBootSector(DestinationDevicePathBuffer
, DstPath
, sizeof(PARTITION_SECTOR
));
4574 if (!NT_SUCCESS(Status
))
4576 DPRINT1("SaveBootSector() failed (Status %lx)\n", Status
);
4577 // Don't care if we succeeded or not saving the old MBR, just go ahead.
4581 DPRINT1("Install MBR bootcode: %S ==> %S\n",
4582 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4583 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4584 DestinationDevicePathBuffer
);
4585 if (!NT_SUCCESS(Status
))
4587 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4589 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4593 return SUCCESS_PAGE
;
4598 * Displays the QuitPage.
4601 * FlushPage (At once)
4607 * Number of the next page.
4610 QuitPage(PINPUT_RECORD Ir
)
4612 MUIDisplayPage(QUIT_PAGE
);
4614 /* Destroy partition list */
4615 if (PartitionList
!= NULL
)
4617 DestroyPartitionList(PartitionList
);
4618 PartitionList
= NULL
;
4621 /* Destroy filesystem list */
4622 if (FileSystemList
!= NULL
)
4624 DestroyFileSystemList(FileSystemList
);
4625 FileSystemList
= NULL
;
4628 /* Destroy computer settings list */
4629 if (ComputerList
!= NULL
)
4631 DestroyGenericList(ComputerList
, TRUE
);
4632 ComputerList
= NULL
;
4635 /* Destroy display settings list */
4636 if (DisplayList
!= NULL
)
4638 DestroyGenericList(DisplayList
, TRUE
);
4642 /* Destroy keyboard settings list */
4643 if (KeyboardList
!= NULL
)
4645 DestroyGenericList(KeyboardList
, TRUE
);
4646 KeyboardList
= NULL
;
4649 /* Destroy keyboard layout list */
4650 if (LayoutList
!= NULL
)
4652 DestroyGenericList(LayoutList
, TRUE
);
4656 if (LanguageList
!= NULL
)
4658 DestroyGenericList(LanguageList
, FALSE
);
4659 LanguageList
= NULL
;
4662 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4666 CONSOLE_ConInKey(Ir
);
4668 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4677 * Displays the SuccessPage.
4680 * FlushPage (At once)
4686 * Number of the next page.
4689 SuccessPage(PINPUT_RECORD Ir
)
4691 MUIDisplayPage(SUCCESS_PAGE
);
4693 if (IsUnattendedSetup
)
4700 CONSOLE_ConInKey(Ir
);
4702 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4711 * Displays the FlushPage.
4714 * RebootPage (At once)
4717 * Number of the next page.
4720 FlushPage(PINPUT_RECORD Ir
)
4722 MUIDisplayPage(FLUSH_PAGE
);
4728 PnpEventThread(IN LPVOID lpParameter
);
4732 * The start routine and page management
4743 NtQuerySystemTime(&Time
);
4745 Status
= RtlCreateUserThread(NtCurrentProcess(),
4755 if (!NT_SUCCESS(Status
))
4756 hPnpThread
= INVALID_HANDLE_VALUE
;
4758 if (!CONSOLE_Init())
4760 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4761 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4762 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4764 /* Raise a hard error (crash the system/BSOD) */
4765 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4769 /* Initialize global unicode strings */
4770 RtlInitUnicodeString(&SourcePath
, NULL
);
4771 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4772 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4773 RtlInitUnicodeString(&InstallPath
, NULL
);
4774 RtlInitUnicodeString(&DestinationPath
, NULL
);
4775 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4776 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4777 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4779 /* Hide the cursor */
4780 CONSOLE_SetCursorType(TRUE
, FALSE
);
4783 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4785 CONSOLE_ClearScreen();
4788 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4795 Page
= SetupStartPage(&Ir
);
4800 Page
= LanguagePage(&Ir
);
4805 Page
= LicensePage(&Ir
);
4810 Page
= IntroPage(&Ir
);
4814 case INSTALL_INTRO_PAGE
:
4815 Page
= InstallIntroPage(&Ir
);
4819 case SCSI_CONTROLLER_PAGE
:
4820 Page
= ScsiControllerPage(&Ir
);
4825 case OEM_DRIVER_PAGE
:
4826 Page
= OemDriverPage(&Ir
);
4830 case DEVICE_SETTINGS_PAGE
:
4831 Page
= DeviceSettingsPage(&Ir
);
4834 case COMPUTER_SETTINGS_PAGE
:
4835 Page
= ComputerSettingsPage(&Ir
);
4838 case DISPLAY_SETTINGS_PAGE
:
4839 Page
= DisplaySettingsPage(&Ir
);
4842 case KEYBOARD_SETTINGS_PAGE
:
4843 Page
= KeyboardSettingsPage(&Ir
);
4846 case LAYOUT_SETTINGS_PAGE
:
4847 Page
= LayoutSettingsPage(&Ir
);
4850 case SELECT_PARTITION_PAGE
:
4851 Page
= SelectPartitionPage(&Ir
);
4854 case CREATE_PRIMARY_PARTITION_PAGE
:
4855 Page
= CreatePrimaryPartitionPage(&Ir
);
4858 case CREATE_EXTENDED_PARTITION_PAGE
:
4859 Page
= CreateExtendedPartitionPage(&Ir
);
4862 case CREATE_LOGICAL_PARTITION_PAGE
:
4863 Page
= CreateLogicalPartitionPage(&Ir
);
4866 case CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
:
4867 Page
= ConfirmDeleteSystemPartitionPage(&Ir
);
4870 case DELETE_PARTITION_PAGE
:
4871 Page
= DeletePartitionPage(&Ir
);
4874 case SELECT_FILE_SYSTEM_PAGE
:
4875 Page
= SelectFileSystemPage(&Ir
);
4878 case FORMAT_PARTITION_PAGE
:
4879 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4882 case CHECK_FILE_SYSTEM_PAGE
:
4883 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4886 case INSTALL_DIRECTORY_PAGE
:
4887 Page
= InstallDirectoryPage(&Ir
);
4890 case PREPARE_COPY_PAGE
:
4891 Page
= PrepareCopyPage(&Ir
);
4894 case FILE_COPY_PAGE
:
4895 Page
= FileCopyPage(&Ir
);
4899 Page
= RegistryPage(&Ir
);
4902 case BOOT_LOADER_PAGE
:
4903 Page
= BootLoaderPage(&Ir
);
4906 case BOOT_LOADER_FLOPPY_PAGE
:
4907 Page
= BootLoaderFloppyPage(&Ir
);
4910 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4911 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4914 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4915 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4919 case REPAIR_INTRO_PAGE
:
4920 Page
= RepairIntroPage(&Ir
);
4924 Page
= SuccessPage(&Ir
);
4928 Page
= FlushPage(&Ir
);
4932 Page
= QuitPage(&Ir
);
4941 if (Page
== RECOVERY_PAGE
)
4946 /* Avoid bugcheck */
4947 Time
.QuadPart
+= 50000000;
4948 NtDelayExecution(FALSE
, &Time
);
4951 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4952 NtShutdownSystem(ShutdownReboot
);
4953 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4954 NtTerminateProcess(NtCurrentProcess(), 0);
4959 NtProcessStartup(PPEB Peb
)
4961 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4963 ProcessHeap
= Peb
->ProcessHeap
;
4964 InfSetHeap(ProcessHeap
);