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: subsys/system/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)
35 /* GLOBALS ******************************************************************/
38 UNICODE_STRING SourceRootPath
;
39 UNICODE_STRING SourceRootDir
;
40 UNICODE_STRING SourcePath
;
41 BOOLEAN IsUnattendedSetup
= FALSE
;
42 LONG UnattendDestinationDiskNumber
;
43 LONG UnattendDestinationPartitionNumber
;
44 LONG UnattendMBRInstallType
= -1;
45 LONG UnattendFormatPartition
= 0;
46 LONG AutoPartition
= 0;
47 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
48 PWCHAR SelectedLanguageId
;
50 WCHAR DefaultLanguage
[20];
51 WCHAR DefaultKBLayout
[20];
52 BOOLEAN RepairUpdateFlag
= FALSE
;
53 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
54 PPARTLIST PartitionList
= NULL
;
56 /* LOCALS *******************************************************************/
58 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
60 static UNICODE_STRING InstallPath
;
62 /* Path to the install directory */
63 static UNICODE_STRING DestinationPath
;
64 static UNICODE_STRING DestinationArcPath
;
65 static UNICODE_STRING DestinationRootPath
;
67 /* Path to the active partition (boot manager) */
68 static UNICODE_STRING SystemRootPath
;
72 static HSPFILEQ SetupFileQueue
= NULL
;
74 static BOOLEAN WarnLinuxPartitions
= TRUE
;
76 static PGENERIC_LIST ComputerList
= NULL
;
77 static PGENERIC_LIST DisplayList
= NULL
;
78 static PGENERIC_LIST KeyboardList
= NULL
;
79 static PGENERIC_LIST LayoutList
= NULL
;
80 static PGENERIC_LIST LanguageList
= NULL
;
82 static LANGID LanguageId
= 0;
84 static ULONG RequiredPartitionDiskSpace
= ~0;
86 /* FUNCTIONS ****************************************************************/
89 PrintString(char* fmt
,...)
93 UNICODE_STRING UnicodeString
;
94 ANSI_STRING AnsiString
;
97 vsprintf(buffer
, fmt
, ap
);
100 RtlInitAnsiString(&AnsiString
, buffer
);
101 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
102 NtDisplayString(&UnicodeString
);
103 RtlFreeUnicodeString(&UnicodeString
);
108 DrawBox(IN SHORT xLeft
,
116 /* draw upper left corner */
119 FillConsoleOutputCharacterA(StdOutput
,
125 /* draw upper edge */
128 FillConsoleOutputCharacterA(StdOutput
,
134 /* draw upper right corner */
135 coPos
.X
= xLeft
+ Width
- 1;
137 FillConsoleOutputCharacterA(StdOutput
,
143 /* Draw right edge, inner space and left edge */
144 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
147 FillConsoleOutputCharacterA(StdOutput
,
154 FillConsoleOutputCharacterA(StdOutput
,
160 coPos
.X
= xLeft
+ Width
- 1;
161 FillConsoleOutputCharacterA(StdOutput
,
168 /* draw lower left corner */
170 coPos
.Y
= yTop
+ Height
- 1;
171 FillConsoleOutputCharacterA(StdOutput
,
177 /* draw lower edge */
179 coPos
.Y
= yTop
+ Height
- 1;
180 FillConsoleOutputCharacterA(StdOutput
,
186 /* draw lower right corner */
187 coPos
.X
= xLeft
+ Width
- 1;
188 coPos
.Y
= yTop
+ Height
- 1;
189 FillConsoleOutputCharacterA(StdOutput
,
198 PopupError(PCCH Text
,
216 /* Count text lines and longest line */
223 p
= strchr(pnext
, '\n');
227 Length
= strlen(pnext
);
232 Length
= (ULONG
)(p
- pnext
);
238 if (Length
> MaxLength
)
241 if (LastLine
== TRUE
)
247 /* Check length of status line */
250 Length
= strlen(Status
);
252 if (Length
> MaxLength
)
256 Width
= MaxLength
+ 4;
262 yTop
= (yScreen
- Height
) / 2;
263 xLeft
= (xScreen
- Width
) / 2;
266 /* Set screen attributes */
268 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
270 FillConsoleOutputAttribute(StdOutput
,
271 FOREGROUND_RED
| BACKGROUND_WHITE
,
277 DrawBox(xLeft
, yTop
, Width
, Height
);
279 /* Print message text */
284 p
= strchr(pnext
, '\n');
288 Length
= strlen(pnext
);
293 Length
= (ULONG
)(p
- pnext
);
300 WriteConsoleOutputCharacterA(StdOutput
,
307 if (LastLine
== TRUE
)
314 /* Print separator line and status text */
317 coPos
.Y
= yTop
+ Height
- 3;
319 FillConsoleOutputCharacterA(StdOutput
,
326 FillConsoleOutputCharacterA(StdOutput
,
332 coPos
.X
= xLeft
+ Width
- 1;
333 FillConsoleOutputCharacterA(StdOutput
,
341 WriteConsoleOutputCharacterA(StdOutput
,
343 min(strlen(Status
), (SIZE_T
)Width
- 4),
348 if (WaitEvent
== POPUP_WAIT_NONE
)
353 CONSOLE_ConInKey(Ir
);
355 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
356 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
368 * FALSE: Don't quit setup.
371 ConfirmQuit(PINPUT_RECORD Ir
)
374 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
378 CONSOLE_ConInKey(Ir
);
380 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
381 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
386 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
398 CheckUnattendedSetup(VOID
)
400 WCHAR UnattendInfPath
[MAX_PATH
];
407 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
409 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
413 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
414 wcscat(UnattendInfPath
, L
"\\unattend.inf");
416 /* Load 'unattend.inf' from install media. */
417 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
423 if (UnattendInf
== INVALID_HANDLE_VALUE
)
425 DPRINT("SetupOpenInfFileW() failed\n");
429 /* Open 'Unattend' section */
430 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
432 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
433 SetupCloseInfFile(UnattendInf
);
437 /* Get pointer 'Signature' key */
438 if (!INF_GetData(&Context
, NULL
, &Value
))
440 DPRINT("INF_GetData() failed for key 'Signature'\n");
441 SetupCloseInfFile(UnattendInf
);
445 /* Check 'Signature' string */
446 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
448 DPRINT("Signature not $ReactOS$\n");
449 SetupCloseInfFile(UnattendInf
);
453 /* Check if Unattend setup is enabled */
454 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
456 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
457 SetupCloseInfFile(UnattendInf
);
461 if (!INF_GetData(&Context
, NULL
, &Value
))
463 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
464 SetupCloseInfFile(UnattendInf
);
468 if (_wcsicmp(Value
, L
"yes") != 0)
470 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
471 SetupCloseInfFile(UnattendInf
);
475 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
476 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
478 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
479 SetupCloseInfFile(UnattendInf
);
483 if (!SetupGetIntField(&Context
, 1, &IntValue
))
485 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
486 SetupCloseInfFile(UnattendInf
);
490 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
492 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
493 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
495 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
496 SetupCloseInfFile(UnattendInf
);
500 if (!SetupGetIntField(&Context
, 1, &IntValue
))
502 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
503 SetupCloseInfFile(UnattendInf
);
507 UnattendDestinationPartitionNumber
= IntValue
;
509 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
510 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
512 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
513 SetupCloseInfFile(UnattendInf
);
517 /* Get pointer 'InstallationDirectory' key */
518 if (!INF_GetData(&Context
, NULL
, &Value
))
520 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
521 SetupCloseInfFile(UnattendInf
);
525 wcscpy(UnattendInstallationDirectory
, Value
);
527 IsUnattendedSetup
= TRUE
;
529 /* Search for 'MBRInstallType' in the 'Unattend' section */
530 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
532 if (SetupGetIntField(&Context
, 1, &IntValue
))
534 UnattendMBRInstallType
= IntValue
;
538 /* Search for 'FormatPartition' in the 'Unattend' section */
539 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
541 if (SetupGetIntField(&Context
, 1, &IntValue
))
543 UnattendFormatPartition
= IntValue
;
547 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
549 if (SetupGetIntField(&Context
, 1, &IntValue
))
551 AutoPartition
= IntValue
;
555 /* search for LocaleID in the 'Unattend' section*/
556 if (SetupFindFirstLineW (UnattendInf
, L
"Unattend", L
"LocaleID", &Context
))
558 if (INF_GetData (&Context
, NULL
, &Value
))
560 LONG Id
= wcstol(Value
, NULL
, 16);
561 swprintf(LocaleID
,L
"%08lx", Id
);
565 SetupCloseInfFile(UnattendInf
);
567 DPRINT("Running unattended setup\n");
574 PGENERIC_LIST_ENTRY ListEntry
;
575 LPCWSTR pszNewLayout
;
577 pszNewLayout
= MUIDefaultKeyboardLayout();
579 if (LayoutList
== NULL
)
581 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
582 if (LayoutList
== NULL
)
584 /* FIXME: Handle error! */
589 ListEntry
= GetFirstListEntry(LayoutList
);
591 /* Search for default layout (if provided) */
592 if (pszNewLayout
!= NULL
)
594 while (ListEntry
!= NULL
)
596 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
598 SetCurrentListEntry(LayoutList
, ListEntry
);
602 ListEntry
= GetNextListEntry(ListEntry
);
609 LanguagePage(PINPUT_RECORD Ir
)
611 /* Initialize the computer settings list */
612 if (LanguageList
== NULL
)
614 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
616 if (LanguageList
== NULL
)
618 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
623 DrawGenericList(LanguageList
,
629 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
631 MUIDisplayPage(LANGUAGE_PAGE
);
635 CONSOLE_ConInKey(Ir
);
637 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
638 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
641 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
643 /* Redraw language selection page in native language */
644 MUIDisplayPage(LANGUAGE_PAGE
);
647 ScrollDownGenericList (LanguageList
);
649 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
650 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
653 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
655 /* Redraw language selection page in native language */
656 MUIDisplayPage(LANGUAGE_PAGE
);
659 ScrollUpGenericList(LanguageList
);
661 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
662 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
664 ScrollPageDownGenericList(LanguageList
);
666 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
667 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
669 ScrollPageUpGenericList(LanguageList
);
671 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
672 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
674 if (ConfirmQuit(Ir
) == TRUE
)
677 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
679 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
681 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
683 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
689 SetConsoleCodePage();
693 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
696 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
707 * Number of the next page.
710 SetupStartPage(PINPUT_RECORD Ir
)
712 SYSTEM_DEVICE_INFORMATION Sdi
;
714 WCHAR FileNameBuffer
[MAX_PATH
];
719 PGENERIC_LIST_ENTRY ListEntry
;
722 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
725 /* Check whether a harddisk is available */
726 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
728 sizeof(SYSTEM_DEVICE_INFORMATION
),
731 if (!NT_SUCCESS(Status
))
733 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
734 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
738 if (Sdi
.NumberOfDisks
== 0)
740 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
744 /* Get the source path and source root path */
745 Status
= GetSourcePaths(&SourcePath
,
749 if (!NT_SUCCESS(Status
))
751 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
752 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
758 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
759 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
760 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
764 /* Load txtsetup.sif from install media. */
765 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
766 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
768 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
774 if (SetupInf
== INVALID_HANDLE_VALUE
)
776 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
780 /* Open 'Version' section */
781 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
783 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
787 /* Get pointer 'Signature' key */
788 if (!INF_GetData(&Context
, NULL
, &Value
))
790 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
794 /* Check 'Signature' string */
795 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
797 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
801 /* Open 'DiskSpaceRequirements' section */
802 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
804 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
808 /* Get the 'FreeSysPartDiskSpace' value */
809 if (!SetupGetIntField(&Context
, 1, &IntValue
))
811 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
815 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
817 /* Start PnP thread */
818 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
820 NtResumeThread(hPnpThread
, NULL
);
821 hPnpThread
= INVALID_HANDLE_VALUE
;
824 CheckUnattendedSetup();
826 if (IsUnattendedSetup
)
829 //read options from inf
830 ComputerList
= CreateComputerTypeList(SetupInf
);
831 DisplayList
= CreateDisplayDriverList(SetupInf
);
832 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
833 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
834 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
837 wcscpy(SelectedLanguageId
,LocaleID
);
839 /* first we hack LanguageList */
840 ListEntry
= GetFirstListEntry(LanguageList
);
842 while (ListEntry
!= NULL
)
844 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
846 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
847 SetCurrentListEntry(LanguageList
, ListEntry
);
851 ListEntry
= GetNextListEntry(ListEntry
);
855 ListEntry
= GetFirstListEntry(LayoutList
);
857 while (ListEntry
!= NULL
)
859 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
861 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
862 SetCurrentListEntry(LayoutList
, ListEntry
);
866 ListEntry
= GetNextListEntry(ListEntry
);
869 SetConsoleCodePage();
871 return INSTALL_INTRO_PAGE
;
874 return LANGUAGE_PAGE
;
884 IntroPage(PINPUT_RECORD Ir
)
886 MUIDisplayPage(START_PAGE
);
890 CONSOLE_ConInKey(Ir
);
892 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
893 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
895 if (ConfirmQuit(Ir
) == TRUE
)
900 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
902 return INSTALL_INTRO_PAGE
;
905 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
907 return REPAIR_INTRO_PAGE
;
910 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
924 * Back to main setup page.
927 LicensePage(PINPUT_RECORD Ir
)
929 MUIDisplayPage(LICENSE_PAGE
);
933 CONSOLE_ConInKey(Ir
);
935 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
947 RepairIntroPage(PINPUT_RECORD Ir
)
949 MUIDisplayPage(REPAIR_INTRO_PAGE
);
953 CONSOLE_ConInKey(Ir
);
955 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
959 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
961 RepairUpdateFlag
= TRUE
;
962 return INSTALL_INTRO_PAGE
;
964 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
968 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
969 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
975 return REPAIR_INTRO_PAGE
;
980 InstallIntroPage(PINPUT_RECORD Ir
)
982 MUIDisplayPage(INSTALL_INTRO_PAGE
);
984 if (RepairUpdateFlag
)
986 //return SELECT_PARTITION_PAGE;
987 return DEVICE_SETTINGS_PAGE
;
990 if (IsUnattendedSetup
)
992 return SELECT_PARTITION_PAGE
;
997 CONSOLE_ConInKey(Ir
);
999 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1000 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1002 if (ConfirmQuit(Ir
) == TRUE
)
1007 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1009 return DEVICE_SETTINGS_PAGE
;
1010 // return SCSI_CONTROLLER_PAGE;
1014 return INSTALL_INTRO_PAGE
;
1020 ScsiControllerPage(PINPUT_RECORD Ir
)
1022 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1024 /* FIXME: print loaded mass storage driver descriptions */
1026 SetTextXY(8, 10, "TEST device");
1030 SetStatusText(" ENTER = Continue F3 = Quit");
1036 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1037 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1039 if (ConfirmQuit(Ir
) == TRUE
)
1044 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1046 return DEVICE_SETTINGS_PAGE
;
1050 return SCSI_CONTROLLER_PAGE
;
1056 DeviceSettingsPage(PINPUT_RECORD Ir
)
1058 static ULONG Line
= 16;
1059 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1061 /* Initialize the computer settings list */
1062 if (ComputerList
== NULL
)
1064 ComputerList
= CreateComputerTypeList(SetupInf
);
1065 if (ComputerList
== NULL
)
1067 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1072 /* Initialize the display settings list */
1073 if (DisplayList
== NULL
)
1075 DisplayList
= CreateDisplayDriverList(SetupInf
);
1076 if (DisplayList
== NULL
)
1078 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1083 /* Initialize the keyboard settings list */
1084 if (KeyboardList
== NULL
)
1086 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1087 if (KeyboardList
== NULL
)
1089 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1094 /* Initialize the keyboard layout list */
1095 if (LayoutList
== NULL
)
1097 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1098 if (LayoutList
== NULL
)
1100 /* FIXME: report error */
1101 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1106 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1109 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1110 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1111 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1112 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1114 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1116 if (RepairUpdateFlag
)
1118 return SELECT_PARTITION_PAGE
;
1123 CONSOLE_ConInKey(Ir
);
1125 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1126 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1128 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1132 else if (Line
== 16)
1137 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1139 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1140 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1142 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1146 else if (Line
== 16)
1151 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1153 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1154 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1156 if (ConfirmQuit(Ir
) == TRUE
)
1161 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1164 return COMPUTER_SETTINGS_PAGE
;
1165 else if (Line
== 12)
1166 return DISPLAY_SETTINGS_PAGE
;
1167 else if (Line
== 13)
1168 return KEYBOARD_SETTINGS_PAGE
;
1169 else if (Line
== 14)
1170 return LAYOUT_SETTINGS_PAGE
;
1171 else if (Line
== 16)
1172 return SELECT_PARTITION_PAGE
;
1176 return DEVICE_SETTINGS_PAGE
;
1181 ComputerSettingsPage(PINPUT_RECORD Ir
)
1183 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1185 DrawGenericList(ComputerList
,
1191 SaveGenericListState(ComputerList
);
1195 CONSOLE_ConInKey(Ir
);
1197 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1198 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1200 ScrollDownGenericList(ComputerList
);
1202 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1203 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1205 ScrollUpGenericList(ComputerList
);
1207 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1208 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1210 if (ConfirmQuit(Ir
) == TRUE
)
1215 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1216 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1218 RestoreGenericListState(ComputerList
);
1219 return DEVICE_SETTINGS_PAGE
;
1221 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1223 return DEVICE_SETTINGS_PAGE
;
1227 return COMPUTER_SETTINGS_PAGE
;
1232 DisplaySettingsPage(PINPUT_RECORD Ir
)
1234 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1236 DrawGenericList(DisplayList
,
1242 SaveGenericListState(DisplayList
);
1246 CONSOLE_ConInKey(Ir
);
1248 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1249 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1251 ScrollDownGenericList(DisplayList
);
1253 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1254 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1256 ScrollUpGenericList(DisplayList
);
1258 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1259 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1261 if (ConfirmQuit(Ir
) == TRUE
)
1268 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1269 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1271 RestoreGenericListState(DisplayList
);
1272 return DEVICE_SETTINGS_PAGE
;
1274 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1276 return DEVICE_SETTINGS_PAGE
;
1280 return DISPLAY_SETTINGS_PAGE
;
1285 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1287 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1289 DrawGenericList(KeyboardList
,
1295 SaveGenericListState(KeyboardList
);
1299 CONSOLE_ConInKey(Ir
);
1301 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1302 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1304 ScrollDownGenericList(KeyboardList
);
1306 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1307 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1309 ScrollUpGenericList(KeyboardList
);
1311 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1312 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1314 if (ConfirmQuit(Ir
) == TRUE
)
1319 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1320 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1322 RestoreGenericListState(KeyboardList
);
1323 return DEVICE_SETTINGS_PAGE
;
1325 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1327 return DEVICE_SETTINGS_PAGE
;
1331 return DISPLAY_SETTINGS_PAGE
;
1336 LayoutSettingsPage(PINPUT_RECORD Ir
)
1338 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1340 DrawGenericList(LayoutList
,
1346 SaveGenericListState(LayoutList
);
1350 CONSOLE_ConInKey(Ir
);
1352 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1353 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1355 ScrollDownGenericList(LayoutList
);
1357 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1358 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1360 ScrollUpGenericList(LayoutList
);
1362 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1363 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1365 ScrollPageDownGenericList(LayoutList
);
1367 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1368 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1370 ScrollPageUpGenericList(LayoutList
);
1372 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1373 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1375 if (ConfirmQuit(Ir
) == TRUE
)
1380 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1381 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1383 RestoreGenericListState(LayoutList
);
1384 return DEVICE_SETTINGS_PAGE
;
1386 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1388 return DEVICE_SETTINGS_PAGE
;
1390 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1393 GenericListKeyPress(LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1397 return DISPLAY_SETTINGS_PAGE
;
1402 IsDiskSizeValid(PPARTENTRY PartEntry
)
1406 /* check for unpartitioned space */
1407 m1
= PartEntry
->UnpartitionedLength
;
1408 m1
= (m1
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1410 if( m1
> RequiredPartitionDiskSpace
)
1415 /* check for partitioned space */
1416 m2
= PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
;
1417 m2
= (m2
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1418 if (m2
< RequiredPartitionDiskSpace
)
1420 /* partition is too small so ask for another partion */
1421 DPRINT1("Partition is too small(unpartitioned: %I64u MB, partitioned: %I64u MB), required disk space is %lu MB\n", m1
, m2
, RequiredPartitionDiskSpace
);
1432 SelectPartitionPage(PINPUT_RECORD Ir
)
1434 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1436 if (PartitionList
== NULL
)
1438 PartitionList
= CreatePartitionList(2,
1442 if (PartitionList
== NULL
)
1444 /* FIXME: show an error dialog */
1449 CheckActiveBootPartition(PartitionList
);
1451 DrawPartitionList(PartitionList
);
1453 /* Warn about partitions created by Linux Fdisk */
1454 if (WarnLinuxPartitions
== TRUE
&&
1455 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1457 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1461 CONSOLE_ConInKey(Ir
);
1463 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1464 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1468 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1470 WarnLinuxPartitions
= FALSE
;
1471 return SELECT_PARTITION_PAGE
;
1476 if (IsUnattendedSetup
)
1478 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1482 PPARTENTRY PartEntry
= PartitionList
->CurrentPartition
;
1483 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1484 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1486 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1487 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1490 CreateNewPartition(PartitionList
,
1494 return SELECT_FILE_SYSTEM_PAGE
;
1499 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1501 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1502 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1505 return SELECT_FILE_SYSTEM_PAGE
;
1511 /* Update status text */
1512 if (PartitionList
->CurrentPartition
== NULL
||
1513 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1515 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1519 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1522 CONSOLE_ConInKey(Ir
);
1524 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1525 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1527 if (ConfirmQuit(Ir
) == TRUE
)
1529 DestroyPartitionList(PartitionList
);
1530 PartitionList
= NULL
;
1536 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1537 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1539 ScrollDownPartitionList(PartitionList
);
1541 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1542 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1544 ScrollUpPartitionList(PartitionList
);
1546 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1548 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1550 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1551 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1553 if (PartitionList
->CurrentPartition
== NULL
||
1554 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1556 CreateNewPartition(PartitionList
,
1561 return SELECT_FILE_SYSTEM_PAGE
;
1563 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1565 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1567 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1568 return SELECT_PARTITION_PAGE
;
1571 return CREATE_PARTITION_PAGE
;
1573 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1575 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1577 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1578 return SELECT_PARTITION_PAGE
;
1581 return DELETE_PARTITION_PAGE
;
1585 return SELECT_PARTITION_PAGE
;
1590 DrawInputField(ULONG FieldLength
,
1601 memset(buf
, '_', sizeof(buf
));
1602 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1603 strcat(buf
, FieldContent
);
1605 WriteConsoleOutputCharacterA(StdOutput
,
1613 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1614 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1615 #define PARTITION_MAXSIZE 999999
1618 ShowPartitionSizeInputBox(SHORT Left
,
1642 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1647 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1648 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1651 WriteConsoleOutputCharacterA(StdOutput
,
1657 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1658 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1660 WriteConsoleOutputCharacterA(StdOutput
,
1666 sprintf(Buffer
, "%lu", MaxSize
);
1667 Index
= strlen(Buffer
);
1668 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1675 CONSOLE_ConInKey(&Ir
);
1677 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1678 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1686 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1690 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1698 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1704 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1709 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1710 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1712 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1714 if ((ch
>= '0') && (ch
<= '9'))
1720 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1728 strcpy(InputBuffer
, Buffer
);
1733 CreatePartitionPage(PINPUT_RECORD Ir
)
1735 PDISKENTRY DiskEntry
;
1736 PPARTENTRY PartEntry
;
1739 CHAR InputBuffer
[50];
1745 if (PartitionList
== NULL
||
1746 PartitionList
->CurrentDisk
== NULL
||
1747 PartitionList
->CurrentPartition
== NULL
)
1749 /* FIXME: show an error dialog */
1753 DiskEntry
= PartitionList
->CurrentDisk
;
1754 PartEntry
= PartitionList
->CurrentPartition
;
1756 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1758 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1761 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1763 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1764 Unit
= MUIGetString(STRING_GB
);
1769 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1774 Unit
= MUIGetString(STRING_MB
);
1777 if (DiskEntry
->DriverName
.Length
> 0)
1779 CONSOLE_PrintTextXY(6, 10,
1780 MUIGetString(STRING_HDINFOPARTCREATE
),
1783 DiskEntry
->DiskNumber
,
1787 &DiskEntry
->DriverName
);
1791 CONSOLE_PrintTextXY(6, 10,
1792 MUIGetString(STRING_HDDINFOUNK1
),
1795 DiskEntry
->DiskNumber
,
1801 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1804 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1805 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1808 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1810 PartEntry
= PartitionList
->CurrentPartition
;
1813 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1815 if (MaxSize
> PARTITION_MAXSIZE
) MaxSize
= PARTITION_MAXSIZE
;
1817 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1818 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1822 if (ConfirmQuit (Ir
) == TRUE
)
1827 else if (Cancel
== TRUE
)
1829 return SELECT_PARTITION_PAGE
;
1833 PartSize
= atoi(InputBuffer
);
1841 if (PartSize
> MaxSize
)
1847 /* Convert to bytes */
1848 if (PartSize
== MaxSize
)
1850 /* Use all of the unpartitioned disk space */
1851 PartSize
= PartEntry
->UnpartitionedLength
;
1855 /* Round-up by cylinder size */
1856 PartSize
= (PartSize
* 1024 * 1024 + DiskEntry
->CylinderSize
- 1) /
1857 DiskEntry
->CylinderSize
* DiskEntry
->CylinderSize
;
1859 /* But never get larger than the unpartitioned disk space */
1860 if (PartSize
> PartEntry
->UnpartitionedLength
)
1861 PartSize
= PartEntry
->UnpartitionedLength
;
1864 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1866 CreateNewPartition(PartitionList
,
1870 return SELECT_PARTITION_PAGE
;
1874 return CREATE_PARTITION_PAGE
;
1879 DeletePartitionPage(PINPUT_RECORD Ir
)
1881 PDISKENTRY DiskEntry
;
1882 PPARTENTRY PartEntry
;
1889 if (PartitionList
== NULL
||
1890 PartitionList
->CurrentDisk
== NULL
||
1891 PartitionList
->CurrentPartition
== NULL
)
1893 /* FIXME: show an error dialog */
1897 DiskEntry
= PartitionList
->CurrentDisk
;
1898 PartEntry
= PartitionList
->CurrentPartition
;
1899 PartNumber
= PartitionList
->CurrentPartitionNumber
;
1901 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1903 /* Determine partition type */
1905 if (PartEntry
->New
== TRUE
)
1907 PartType
= MUIGetString(STRING_UNFORMATTED
);
1909 else if (PartEntry
->Unpartitioned
== FALSE
)
1911 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
1912 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
1913 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
1914 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
1918 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
1919 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
1923 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
1927 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
1929 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1934 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1936 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1937 Unit
= MUIGetString(STRING_GB
);
1941 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1943 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1944 Unit
= MUIGetString(STRING_MB
);
1948 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1949 Unit
= MUIGetString(STRING_KB
);
1952 if (PartType
== NULL
)
1954 CONSOLE_PrintTextXY(6, 10,
1955 MUIGetString(STRING_HDDINFOUNK2
),
1956 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1957 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1958 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
1964 CONSOLE_PrintTextXY(6, 10,
1965 " %c%c %s %I64u %s",
1966 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1967 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1974 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1976 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1977 Unit
= MUIGetString(STRING_GB
);
1982 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1987 Unit
= MUIGetString(STRING_MB
);
1990 if (DiskEntry
->DriverName
.Length
> 0)
1992 CONSOLE_PrintTextXY(6, 12,
1993 MUIGetString(STRING_HDINFOPARTDELETE
),
1996 DiskEntry
->DiskNumber
,
2000 &DiskEntry
->DriverName
);
2004 CONSOLE_PrintTextXY(6, 12,
2005 MUIGetString(STRING_HDDINFOUNK3
),
2008 DiskEntry
->DiskNumber
,
2016 CONSOLE_ConInKey(Ir
);
2018 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2019 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2021 if (ConfirmQuit(Ir
) == TRUE
)
2028 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2030 return SELECT_PARTITION_PAGE
;
2032 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2034 DeleteCurrentPartition(PartitionList
);
2036 return SELECT_PARTITION_PAGE
;
2040 return DELETE_PARTITION_PAGE
;
2045 SelectFileSystemPage(PINPUT_RECORD Ir
)
2047 PDISKENTRY DiskEntry
;
2048 PPARTENTRY PartEntry
;
2056 if (PartitionList
== NULL
||
2057 PartitionList
->CurrentDisk
== NULL
||
2058 PartitionList
->CurrentPartition
== NULL
)
2060 /* FIXME: show an error dialog */
2064 DiskEntry
= PartitionList
->CurrentDisk
;
2065 PartEntry
= PartitionList
->CurrentPartition
;
2066 PartNumber
= PartitionList
->CurrentPartitionNumber
;
2068 /* adjust disk size */
2069 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
2071 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
2072 DiskUnit
= MUIGetString(STRING_GB
);
2076 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
2077 DiskUnit
= MUIGetString(STRING_MB
);
2080 /* adjust partition size */
2081 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
2083 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
2084 PartUnit
= MUIGetString(STRING_GB
);
2088 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
2089 PartUnit
= MUIGetString(STRING_MB
);
2092 /* adjust partition type */
2093 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
2094 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
2095 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
2096 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
2100 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
2101 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
2105 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
2109 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
2111 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2113 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_ENTRY_UNUSED
)
2115 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2119 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2122 if (PartEntry
->AutoCreate
== TRUE
)
2124 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2127 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2128 PartEntry
->PartInfo
[PartNumber
].PartitionNumber
,
2134 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2135 DiskEntry
->DiskNumber
,
2141 &DiskEntry
->DriverName
);
2143 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2146 PartEntry
->AutoCreate
= FALSE
;
2148 else if (PartEntry
->New
== TRUE
)
2150 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2151 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2155 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2157 if (PartType
== NULL
)
2159 CONSOLE_PrintTextXY(8, 10,
2160 MUIGetString(STRING_HDDINFOUNK4
),
2161 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2162 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2163 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
2169 CONSOLE_PrintTextXY(8, 10,
2171 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2172 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2178 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2179 DiskEntry
->DiskNumber
,
2185 &DiskEntry
->DriverName
);
2188 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2190 if (FileSystemList
== NULL
)
2192 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2193 if (FileSystemList
== NULL
)
2195 /* FIXME: show an error dialog */
2199 /* FIXME: Add file systems to list */
2201 DrawFileSystemList(FileSystemList
);
2203 if (RepairUpdateFlag
)
2205 return CHECK_FILE_SYSTEM_PAGE
;
2206 //return SELECT_PARTITION_PAGE;
2209 if (IsUnattendedSetup
)
2211 if (UnattendFormatPartition
)
2213 return FORMAT_PARTITION_PAGE
;
2216 return CHECK_FILE_SYSTEM_PAGE
;
2221 CONSOLE_ConInKey(Ir
);
2223 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2224 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2226 if (ConfirmQuit(Ir
) == TRUE
)
2233 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2234 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2236 return SELECT_PARTITION_PAGE
;
2238 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2239 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2241 ScrollDownFileSystemList(FileSystemList
);
2243 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2244 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2246 ScrollUpFileSystemList(FileSystemList
);
2248 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2250 if (!FileSystemList
->Selected
->FormatFunc
)
2252 return CHECK_FILE_SYSTEM_PAGE
;
2256 return FORMAT_PARTITION_PAGE
;
2261 return SELECT_FILE_SYSTEM_PAGE
;
2266 FormatPartitionPage(PINPUT_RECORD Ir
)
2268 WCHAR PathBuffer
[MAX_PATH
];
2269 PPARTENTRY PartEntry
;
2274 PDISKENTRY DiskEntry
;
2280 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2282 if (PartitionList
== NULL
||
2283 PartitionList
->CurrentDisk
== NULL
||
2284 PartitionList
->CurrentPartition
== NULL
)
2286 /* FIXME: show an error dialog */
2291 DiskEntry
= PartitionList
->CurrentDisk
;
2293 PartEntry
= PartitionList
->CurrentPartition
;
2294 PartNum
= PartitionList
->CurrentPartitionNumber
;
2298 if (!IsUnattendedSetup
)
2300 CONSOLE_ConInKey(Ir
);
2303 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2304 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2306 if (ConfirmQuit(Ir
) == TRUE
)
2313 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2315 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2317 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2319 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2321 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2322 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_12
;
2324 else if (PartEntry
->PartInfo
[PartNum
].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2326 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2328 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2330 /* FAT16 CHS partition (partiton size < 32MB) */
2331 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_16
;
2333 else if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2335 /* FAT16 CHS partition (partition size < 512MB) */
2336 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_HUGE
;
2340 /* FAT32 CHS partition (partition size >= 512MB) */
2341 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32
;
2346 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2348 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2350 /* FAT16 LBA partition (partition size < 512MB) */
2351 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_XINT13
;
2355 /* FAT32 LBA partition (partition size >= 512MB) */
2356 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32_XINT13
;
2360 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2361 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_EXT2
;
2362 else if (!FileSystemList
->Selected
->FormatFunc
)
2365 CheckActiveBootPartition(PartitionList
);
2368 CONSOLE_PrintTextXY(6, 12,
2369 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2370 DiskEntry
->DiskSize
,
2371 DiskEntry
->CylinderSize
,
2372 DiskEntry
->TrackSize
);
2375 DiskEntry
= PartitionList
->CurrentDisk
;
2376 Entry
= DiskEntry
->PartListHead
.Flink
;
2378 while (Entry
!= &DiskEntry
->PartListHead
)
2380 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2382 if (PartEntry
->Unpartitioned
== FALSE
)
2384 for (i
= 0; i
< 4; i
++)
2386 CONSOLE_PrintTextXY(6, Line
,
2387 "%2u: %2u %c %12I64u %12I64u %2u %c",
2389 PartEntry
->PartInfo
[i
].PartitionNumber
,
2390 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2391 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2392 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2393 PartEntry
->PartInfo
[i
].PartitionType
,
2394 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2402 Entry
= Entry
->Flink
;
2405 /* Restore the old entry */
2406 PartEntry
= PartitionList
->CurrentPartition
;
2409 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2411 DPRINT("WritePartitionsToDisk() failed\n");
2412 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2416 /* Set DestinationRootPath */
2417 RtlFreeUnicodeString(&DestinationRootPath
);
2418 swprintf(PathBuffer
,
2419 L
"\\Device\\Harddisk%lu\\Partition%lu",
2420 PartitionList
->CurrentDisk
->DiskNumber
,
2421 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2422 RtlCreateUnicodeString(&DestinationRootPath
,
2424 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2427 /* Set SystemRootPath */
2428 RtlFreeUnicodeString(&SystemRootPath
);
2429 swprintf(PathBuffer
,
2430 L
"\\Device\\Harddisk%lu\\Partition%lu",
2431 PartitionList
->ActiveBootDisk
->DiskNumber
,
2432 PartitionList
->ActiveBootPartition
->
2433 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionNumber
);
2434 RtlCreateUnicodeString(&SystemRootPath
,
2436 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2439 if (FileSystemList
->Selected
->FormatFunc
)
2441 Status
= FormatPartition(&DestinationRootPath
,
2442 FileSystemList
->Selected
);
2443 if (!NT_SUCCESS(Status
))
2445 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2446 /* FIXME: show an error dialog */
2450 PartEntry
->New
= FALSE
;
2452 CheckActiveBootPartition(PartitionList
);
2456 CONSOLE_SetStatusText(" Done. Press any key ...");
2457 CONSOLE_ConInKey(Ir
);
2460 DestroyFileSystemList(FileSystemList
);
2461 FileSystemList
= NULL
;
2462 return INSTALL_DIRECTORY_PAGE
;
2466 return FORMAT_PARTITION_PAGE
;
2471 CheckFileSystemPage(PINPUT_RECORD Ir
)
2473 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2474 WCHAR PathBuffer
[MAX_PATH
];
2475 CHAR Buffer
[MAX_PATH
];
2477 UCHAR PartNum
= PartitionList
->CurrentPartitionNumber
;
2479 /* FIXME: code duplicated in FormatPartitionPage */
2480 /* Set DestinationRootPath */
2481 RtlFreeUnicodeString(&DestinationRootPath
);
2482 swprintf(PathBuffer
,
2483 L
"\\Device\\Harddisk%lu\\Partition%lu",
2484 PartitionList
->CurrentDisk
->DiskNumber
,
2485 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2486 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2487 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2489 /* Set SystemRootPath */
2490 RtlFreeUnicodeString(&SystemRootPath
);
2491 swprintf(PathBuffer
,
2492 L
"\\Device\\Harddisk%lu\\Partition%lu",
2493 PartitionList
->ActiveBootDisk
->DiskNumber
,
2494 PartitionList
->ActiveBootPartition
->PartInfo
[PartNum
].PartitionNumber
);
2495 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2496 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2498 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2500 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2502 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2503 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2505 if (!CurrentFileSystem
->ChkdskFunc
)
2508 "Setup is currently unable to check a partition formatted in %S.\n"
2510 " \x07 Press ENTER to continue Setup.\n"
2511 " \x07 Press F3 to quit Setup.",
2512 CurrentFileSystem
->FileSystem
);
2515 MUIGetString(STRING_QUITCONTINUE
),
2516 NULL
, POPUP_WAIT_NONE
);
2520 CONSOLE_ConInKey(Ir
);
2522 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2523 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2525 if (ConfirmQuit(Ir
))
2528 return CHECK_FILE_SYSTEM_PAGE
;
2530 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2532 return INSTALL_DIRECTORY_PAGE
;
2538 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2539 if (!NT_SUCCESS(Status
))
2541 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2542 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2543 "(Status 0x%08lx).\n", Status
);
2546 MUIGetString(STRING_REBOOTCOMPUTER
),
2547 Ir
, POPUP_WAIT_ENTER
);
2552 return INSTALL_DIRECTORY_PAGE
;
2558 InstallDirectoryPage1(PWCHAR InstallDir
,
2559 PDISKENTRY DiskEntry
,
2560 PPARTENTRY PartEntry
,
2563 WCHAR PathBuffer
[MAX_PATH
];
2565 /* Create 'InstallPath' string */
2566 RtlFreeUnicodeString(&InstallPath
);
2567 RtlCreateUnicodeString(&InstallPath
,
2570 /* Create 'DestinationPath' string */
2571 RtlFreeUnicodeString(&DestinationPath
);
2572 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2574 if (InstallDir
[0] != L
'\\')
2575 wcscat(PathBuffer
, L
"\\");
2577 wcscat(PathBuffer
, InstallDir
);
2578 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2580 /* Create 'DestinationArcPath' */
2581 RtlFreeUnicodeString(&DestinationArcPath
);
2582 swprintf(PathBuffer
,
2583 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2584 DiskEntry
->BiosDiskNumber
,
2585 PartEntry
->PartInfo
[PartNum
].PartitionNumber
);
2587 if (InstallDir
[0] != L
'\\')
2588 wcscat(PathBuffer
, L
"\\");
2590 wcscat(PathBuffer
, InstallDir
);
2591 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2593 return PREPARE_COPY_PAGE
;
2598 InstallDirectoryPage(PINPUT_RECORD Ir
)
2600 PDISKENTRY DiskEntry
;
2601 PPARTENTRY PartEntry
;
2602 WCHAR InstallDir
[51];
2607 if (PartitionList
== NULL
||
2608 PartitionList
->CurrentDisk
== NULL
||
2609 PartitionList
->CurrentPartition
== NULL
)
2611 /* FIXME: show an error dialog */
2615 DiskEntry
= PartitionList
->CurrentDisk
;
2616 PartEntry
= PartitionList
->CurrentPartition
;
2618 /* Search for 'DefaultPath' in the 'SetupData' section */
2619 if (!SetupFindFirstLineW(SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2621 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2625 /* Read the 'DefaultPath' data */
2626 if (INF_GetData(&Context
, NULL
, &DefaultPath
))
2628 wcscpy(InstallDir
, DefaultPath
);
2632 wcscpy(InstallDir
, L
"\\ReactOS");
2635 Length
= wcslen(InstallDir
);
2636 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2637 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2639 if (IsUnattendedSetup
)
2641 return InstallDirectoryPage1(InstallDir
,
2644 PartitionList
->CurrentPartitionNumber
);
2649 CONSOLE_ConInKey(Ir
);
2651 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2652 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2654 if (ConfirmQuit(Ir
) == TRUE
)
2659 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2661 return InstallDirectoryPage1(InstallDir
,
2664 PartitionList
->CurrentPartitionNumber
);
2666 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2671 InstallDir
[Length
] = 0;
2672 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2675 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2679 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2681 InstallDir
[Length
] = 0;
2682 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2687 return INSTALL_DIRECTORY_PAGE
;
2692 AddSectionToCopyQueueCab(HINF InfFile
,
2694 PWCHAR SourceCabinet
,
2695 PCUNICODE_STRING DestinationPath
,
2698 INFCONTEXT FilesContext
;
2699 INFCONTEXT DirContext
;
2701 PWCHAR FileKeyValue
;
2703 PWCHAR TargetFileName
;
2705 /* Search for the SectionName section */
2706 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
2709 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2710 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2715 * Enumerate the files in the section
2716 * and add them to the file queue.
2720 /* Get source file name and target directory id */
2721 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
2723 /* FIXME: Handle error! */
2724 DPRINT1("INF_GetData() failed\n");
2728 /* Get optional target file name */
2729 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
2730 TargetFileName
= NULL
;
2732 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2734 /* Lookup target directory */
2735 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2737 /* FIXME: Handle error! */
2738 DPRINT1("SetupFindFirstLine() failed\n");
2742 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
2744 /* FIXME: Handle error! */
2745 DPRINT1("INF_GetData() failed\n");
2749 if (!SetupQueueCopy(SetupFileQueue
,
2751 SourceRootPath
.Buffer
,
2752 SourceRootDir
.Buffer
,
2757 /* FIXME: Handle error! */
2758 DPRINT1("SetupQueueCopy() failed\n");
2760 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2767 AddSectionToCopyQueue(HINF InfFile
,
2769 PWCHAR SourceCabinet
,
2770 PCUNICODE_STRING DestinationPath
,
2773 INFCONTEXT FilesContext
;
2774 INFCONTEXT DirContext
;
2776 PWCHAR FileKeyValue
;
2778 PWCHAR TargetFileName
;
2779 WCHAR CompleteOrigFileName
[512];
2782 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2784 /* Search for the SectionName section */
2785 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
2788 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2789 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2794 * Enumerate the files in the section
2795 * and add them to the file queue.
2799 /* Get source file name and target directory id */
2800 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
2802 /* FIXME: Handle error! */
2803 DPRINT1("INF_GetData() failed\n");
2807 /* Get target directory id */
2808 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
2810 /* FIXME: Handle error! */
2811 DPRINT1("INF_GetData() failed\n");
2815 /* Get optional target file name */
2816 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
2817 TargetFileName
= NULL
;
2818 else if (!*TargetFileName
)
2819 TargetFileName
= NULL
;
2821 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2823 /* Lookup target directory */
2824 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2826 /* FIXME: Handle error! */
2827 DPRINT1("SetupFindFirstLine() failed\n");
2831 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
2833 /* FIXME: Handle error! */
2834 DPRINT1("INF_GetData() failed\n");
2838 wcscpy(CompleteOrigFileName
, SourceRootDir
.Buffer
);
2839 wcscat(CompleteOrigFileName
, L
"\\");
2840 wcscat(CompleteOrigFileName
, DirKeyValue
);
2842 if (!SetupQueueCopy(SetupFileQueue
,
2844 SourceRootPath
.Buffer
,
2845 CompleteOrigFileName
,
2850 /* FIXME: Handle error! */
2851 DPRINT1("SetupQueueCopy() failed\n");
2853 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2860 PrepareCopyPageInfFile(HINF InfFile
,
2861 PWCHAR SourceCabinet
,
2864 WCHAR PathBuffer
[MAX_PATH
];
2865 INFCONTEXT DirContext
;
2866 PWCHAR AdditionalSectionName
= NULL
;
2871 /* Add common files */
2872 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2875 /* Add specific files depending of computer type */
2876 if (SourceCabinet
== NULL
)
2878 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2881 if (AdditionalSectionName
)
2883 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2888 /* Create directories */
2892 * Install directories like '\reactos\test' are not handled yet.
2895 /* Get destination path */
2896 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2898 /* Remove trailing backslash */
2899 Length
= wcslen(PathBuffer
);
2900 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2902 PathBuffer
[Length
- 1] = 0;
2905 /* Create the install directory */
2906 Status
= SetupCreateDirectory(PathBuffer
);
2907 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2909 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2910 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2914 /* Search for the 'Directories' section */
2915 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2919 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2923 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2929 /* Enumerate the directory values and create the subdirectories */
2932 if (!INF_GetData(&DirContext
, NULL
, &KeyValue
))
2938 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2940 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2942 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2943 wcscat(PathBuffer
, KeyValue
);
2945 DPRINT("FullPath: '%S'\n", PathBuffer
);
2947 else if (KeyValue
[0] != L
'\\')
2949 DPRINT("RelativePath: '%S'\n", KeyValue
);
2950 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2951 wcscat(PathBuffer
, L
"\\");
2952 wcscat(PathBuffer
, KeyValue
);
2954 DPRINT("FullPath: '%S'\n", PathBuffer
);
2956 Status
= SetupCreateDirectory(PathBuffer
);
2957 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2959 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2960 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2964 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2971 PrepareCopyPage(PINPUT_RECORD Ir
)
2974 WCHAR PathBuffer
[MAX_PATH
];
2975 INFCONTEXT CabinetsContext
;
2981 MUIDisplayPage(PREPARE_COPY_PAGE
);
2983 /* Create the file queue */
2984 SetupFileQueue
= SetupOpenFileQueue();
2985 if (SetupFileQueue
== NULL
)
2987 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2991 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2996 /* Search for the 'Cabinets' section */
2997 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2999 return FILE_COPY_PAGE
;
3003 * Enumerate the directory values in the 'Cabinets'
3004 * section and parse their inf files.
3008 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3011 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3012 wcscat(PathBuffer
, L
"\\");
3013 wcscat(PathBuffer
, KeyValue
);
3016 CabinetInitialize();
3017 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3018 CabinetSetCabinetName(PathBuffer
);
3020 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3022 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3024 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3025 if (InfFileData
== NULL
)
3027 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3033 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3034 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3038 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3045 if (InfHandle
== INVALID_HANDLE_VALUE
)
3047 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3053 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3058 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3060 return FILE_COPY_PAGE
;
3066 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3069 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3071 /* Get the memory information from the system */
3072 NtQuerySystemInformation(SystemPerformanceInformation
,
3077 /* Check if this is initial setup */
3080 /* Set maximum limits to be total RAM pages */
3081 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3082 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3083 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3086 /* Set current values */
3087 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3088 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3089 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3095 FileCopyCallback(PVOID Context
,
3100 PCOPYCONTEXT CopyContext
;
3102 CopyContext
= (PCOPYCONTEXT
)Context
;
3104 switch (Notification
)
3106 case SPFILENOTIFY_STARTSUBQUEUE
:
3107 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3108 ProgressSetStepCount(CopyContext
->ProgressBar
,
3109 CopyContext
->TotalOperations
);
3110 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3113 case SPFILENOTIFY_STARTCOPY
:
3114 /* Display copy message */
3115 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3116 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3119 case SPFILENOTIFY_ENDCOPY
:
3120 CopyContext
->CompletedOperations
++;
3121 ProgressNextStep(CopyContext
->ProgressBar
);
3122 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3132 FileCopyPage(PINPUT_RECORD Ir
)
3134 COPYCONTEXT CopyContext
;
3135 unsigned int mem_bar_width
;
3137 MUIDisplayPage(FILE_COPY_PAGE
);
3139 /* Create context for the copy process */
3140 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3141 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3142 CopyContext
.TotalOperations
= 0;
3143 CopyContext
.CompletedOperations
= 0;
3145 /* Create the progress bar as well */
3146 CopyContext
.ProgressBar
= CreateProgressBar(13,
3153 MUIGetString(STRING_SETUPCOPYINGFILES
));
3155 // fit memory bars to screen width, distribute them uniform
3156 mem_bar_width
= (xScreen
- 26) / 5;
3157 mem_bar_width
-= mem_bar_width
% 2; // make even
3158 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3159 /* Create the paged pool progress bar */
3160 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3169 /* Create the non paged pool progress bar */
3170 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3172 (xScreen
/ 2) + (mem_bar_width
/ 2),
3174 (xScreen
/ 2)- (mem_bar_width
/ 2),
3179 /* Create the global memory progress bar */
3180 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3184 xScreen
- 13 - mem_bar_width
,
3189 /* Do the file copying */
3190 SetupCommitFileQueueW(NULL
,
3195 /* If we get here, we're done, so cleanup the queue and progress bar */
3196 SetupCloseFileQueue(SetupFileQueue
);
3197 DestroyProgressBar(CopyContext
.ProgressBar
);
3198 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3199 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3200 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3202 /* Go display the next page */
3203 return REGISTRY_PAGE
;
3208 RegistryPage(PINPUT_RECORD Ir
)
3210 INFCONTEXT InfContext
;
3217 MUIDisplayPage(REGISTRY_PAGE
);
3219 if (RepairUpdateFlag
)
3221 return SUCCESS_PAGE
;
3224 if (!SetInstallPathValue(&DestinationPath
))
3226 DPRINT("SetInstallPathValue() failed\n");
3227 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3231 /* Create the default hives */
3233 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3234 if (!NT_SUCCESS(Status
))
3236 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3237 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3241 RegInitializeRegistry();
3244 /* Update registry */
3245 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3247 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3249 DPRINT1("SetupFindFirstLine() failed\n");
3250 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3256 INF_GetDataField (&InfContext
, 0, &Action
);
3257 INF_GetDataField (&InfContext
, 1, &File
);
3258 INF_GetDataField (&InfContext
, 2, &Section
);
3260 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3265 if (!_wcsicmp (Action
, L
"AddReg"))
3269 else if (!_wcsicmp (Action
, L
"DelReg"))
3278 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3280 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3282 DPRINT("Importing %S failed\n", File
);
3284 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3287 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3289 /* Update display registry settings */
3290 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3291 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3293 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3297 /* Set the locale */
3298 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3299 if (!ProcessLocaleRegistry(LanguageList
))
3301 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3305 /* Add keyboard layouts */
3306 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3307 if (!AddKeyboardLayouts())
3309 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3315 if (!SetGeoID(MUIGetGeoID()))
3317 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3321 if (!IsUnattendedSetup
)
3323 /* Update keyboard layout settings */
3324 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3325 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3327 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3332 /* Add codepage information to registry */
3333 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3336 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3340 /* Update the mounted devices list */
3341 SetMountedDeviceValues(PartitionList
);
3343 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3345 return BOOT_LOADER_PAGE
;
3350 BootLoaderPage(PINPUT_RECORD Ir
)
3352 UCHAR PartitionType
;
3353 BOOLEAN InstallOnFloppy
;
3356 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3358 PartitionType
= PartitionList
->ActiveBootPartition
->
3359 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3361 if (IsUnattendedSetup
)
3363 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3365 return SUCCESS_PAGE
;
3367 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3369 return BOOT_LOADER_FLOPPY_PAGE
;
3373 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3375 DPRINT("Error: active partition invalid (unused)\n");
3376 InstallOnFloppy
= TRUE
;
3378 else if (PartitionType
== 0x0A)
3380 /* OS/2 boot manager partition */
3381 DPRINT("Found OS/2 boot manager partition\n");
3382 InstallOnFloppy
= TRUE
;
3384 else if (PartitionType
== 0x83)
3386 /* Linux ext2 partition */
3387 DPRINT("Found Linux ext2 partition\n");
3388 InstallOnFloppy
= TRUE
;
3390 else if (PartitionType
== PARTITION_IFS
)
3392 /* NTFS partition */
3393 DPRINT("Found NTFS partition\n");
3394 InstallOnFloppy
= TRUE
;
3396 else if ((PartitionType
== PARTITION_FAT_12
) ||
3397 (PartitionType
== PARTITION_FAT_16
) ||
3398 (PartitionType
== PARTITION_HUGE
) ||
3399 (PartitionType
== PARTITION_XINT13
) ||
3400 (PartitionType
== PARTITION_FAT32
) ||
3401 (PartitionType
== PARTITION_FAT32_XINT13
))
3403 DPRINT("Found FAT partition\n");
3404 InstallOnFloppy
= FALSE
;
3408 /* Unknown partition */
3409 DPRINT("Unknown partition found\n");
3410 InstallOnFloppy
= TRUE
;
3413 if (InstallOnFloppy
== TRUE
)
3415 return BOOT_LOADER_FLOPPY_PAGE
;
3418 /* Unattended install on hdd? */
3419 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3421 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3424 MUIDisplayPage(BOOT_LOADER_PAGE
);
3425 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3429 CONSOLE_ConInKey(Ir
);
3431 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3432 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3434 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3443 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3445 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3446 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3448 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3457 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3459 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3460 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3462 if (ConfirmQuit(Ir
) == TRUE
)
3467 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3471 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3473 else if (Line
== 13)
3475 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
3477 else if (Line
== 14)
3479 return BOOT_LOADER_FLOPPY_PAGE
;
3481 else if (Line
== 15)
3483 return SUCCESS_PAGE
;
3486 return BOOT_LOADER_PAGE
;
3490 return BOOT_LOADER_PAGE
;
3495 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3499 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3501 // SetStatusText(" Please wait...");
3505 CONSOLE_ConInKey(Ir
);
3507 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3508 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3510 if (ConfirmQuit(Ir
) == TRUE
)
3515 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3517 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3519 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3520 return BOOT_LOADER_FLOPPY_PAGE
;
3523 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3524 if (!NT_SUCCESS(Status
))
3526 /* Print error message */
3527 return BOOT_LOADER_FLOPPY_PAGE
;
3530 return SUCCESS_PAGE
;
3534 return BOOT_LOADER_FLOPPY_PAGE
;
3538 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
3540 UCHAR PartitionType
;
3543 PartitionType
= PartitionList
->ActiveBootPartition
->
3544 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3546 Status
= InstallVBRToPartition(&SystemRootPath
,
3548 &DestinationArcPath
,
3550 if (!NT_SUCCESS(Status
))
3552 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3556 return SUCCESS_PAGE
;
3560 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
3562 UCHAR PartitionType
;
3564 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
3565 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
3567 /* Step 1: Write the VBR */
3568 PartitionType
= PartitionList
->ActiveBootPartition
->
3569 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3571 Status
= InstallVBRToPartition(&SystemRootPath
,
3573 &DestinationArcPath
,
3575 if (!NT_SUCCESS(Status
))
3577 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3581 /* Step 2: Write the MBR */
3582 swprintf(DestinationDevicePathBuffer
,
3583 L
"\\Device\\Harddisk%d\\Partition0",
3584 PartitionList
->ActiveBootDisk
->DiskNumber
);
3586 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
3587 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
3589 DPRINT("Install MBR bootcode: %S ==> %S\n",
3590 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
3592 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
3593 DestinationDevicePathBuffer
);
3594 if (!NT_SUCCESS (Status
))
3596 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
3598 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3602 return SUCCESS_PAGE
;
3607 QuitPage(PINPUT_RECORD Ir
)
3609 MUIDisplayPage(QUIT_PAGE
);
3611 /* Destroy partition list */
3612 if (PartitionList
!= NULL
)
3614 DestroyPartitionList (PartitionList
);
3615 PartitionList
= NULL
;
3618 /* Destroy filesystem list */
3619 if (FileSystemList
!= NULL
)
3621 DestroyFileSystemList (FileSystemList
);
3622 FileSystemList
= NULL
;
3625 /* Destroy computer settings list */
3626 if (ComputerList
!= NULL
)
3628 DestroyGenericList(ComputerList
, TRUE
);
3629 ComputerList
= NULL
;
3632 /* Destroy display settings list */
3633 if (DisplayList
!= NULL
)
3635 DestroyGenericList(DisplayList
, TRUE
);
3639 /* Destroy keyboard settings list */
3640 if (KeyboardList
!= NULL
)
3642 DestroyGenericList(KeyboardList
, TRUE
);
3643 KeyboardList
= NULL
;
3646 /* Destroy keyboard layout list */
3647 if (LayoutList
!= NULL
)
3649 DestroyGenericList(LayoutList
, TRUE
);
3653 if (LanguageList
!= NULL
)
3655 DestroyGenericList(LanguageList
, FALSE
);
3656 LanguageList
= NULL
;
3659 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3663 CONSOLE_ConInKey(Ir
);
3665 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3674 SuccessPage(PINPUT_RECORD Ir
)
3676 MUIDisplayPage(SUCCESS_PAGE
);
3678 if (IsUnattendedSetup
)
3685 CONSOLE_ConInKey(Ir
);
3687 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3696 FlushPage(PINPUT_RECORD Ir
)
3698 MUIDisplayPage(FLUSH_PAGE
);
3704 PnpEventThread(IN LPVOID lpParameter
);
3714 NtQuerySystemTime(&Time
);
3716 Status
= RtlCreateUserThread(NtCurrentProcess(),
3726 if (!NT_SUCCESS(Status
))
3727 hPnpThread
= INVALID_HANDLE_VALUE
;
3729 if (!CONSOLE_Init())
3731 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3732 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3733 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3735 /* Raise a hard error (crash the system/BSOD) */
3736 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3740 /* Initialize global unicode strings */
3741 RtlInitUnicodeString(&SourcePath
, NULL
);
3742 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3743 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3744 RtlInitUnicodeString(&InstallPath
, NULL
);
3745 RtlInitUnicodeString(&DestinationPath
, NULL
);
3746 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3747 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3748 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3750 /* Hide the cursor */
3751 CONSOLE_SetCursorType(TRUE
, FALSE
);
3754 while (Page
!= REBOOT_PAGE
)
3756 CONSOLE_ClearScreen();
3759 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3766 Page
= SetupStartPage(&Ir
);
3771 Page
= LanguagePage(&Ir
);
3776 Page
= LicensePage(&Ir
);
3781 Page
= IntroPage(&Ir
);
3785 case INSTALL_INTRO_PAGE
:
3786 Page
= InstallIntroPage(&Ir
);
3790 case SCSI_CONTROLLER_PAGE
:
3791 Page
= ScsiControllerPage(&Ir
);
3796 case OEM_DRIVER_PAGE
:
3797 Page
= OemDriverPage(&Ir
);
3801 case DEVICE_SETTINGS_PAGE
:
3802 Page
= DeviceSettingsPage(&Ir
);
3805 case COMPUTER_SETTINGS_PAGE
:
3806 Page
= ComputerSettingsPage(&Ir
);
3809 case DISPLAY_SETTINGS_PAGE
:
3810 Page
= DisplaySettingsPage(&Ir
);
3813 case KEYBOARD_SETTINGS_PAGE
:
3814 Page
= KeyboardSettingsPage(&Ir
);
3817 case LAYOUT_SETTINGS_PAGE
:
3818 Page
= LayoutSettingsPage(&Ir
);
3821 case SELECT_PARTITION_PAGE
:
3822 Page
= SelectPartitionPage(&Ir
);
3825 case CREATE_PARTITION_PAGE
:
3826 Page
= CreatePartitionPage(&Ir
);
3829 case DELETE_PARTITION_PAGE
:
3830 Page
= DeletePartitionPage(&Ir
);
3833 case SELECT_FILE_SYSTEM_PAGE
:
3834 Page
= SelectFileSystemPage(&Ir
);
3837 case FORMAT_PARTITION_PAGE
:
3838 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3841 case CHECK_FILE_SYSTEM_PAGE
:
3842 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3845 case INSTALL_DIRECTORY_PAGE
:
3846 Page
= InstallDirectoryPage(&Ir
);
3849 case PREPARE_COPY_PAGE
:
3850 Page
= PrepareCopyPage(&Ir
);
3853 case FILE_COPY_PAGE
:
3854 Page
= FileCopyPage(&Ir
);
3858 Page
= RegistryPage(&Ir
);
3861 case BOOT_LOADER_PAGE
:
3862 Page
= BootLoaderPage(&Ir
);
3865 case BOOT_LOADER_FLOPPY_PAGE
:
3866 Page
= BootLoaderFloppyPage(&Ir
);
3869 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
3870 Page
= BootLoaderHarddiskMbrPage(&Ir
);
3873 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
3874 Page
= BootLoaderHarddiskVbrPage(&Ir
);
3878 case REPAIR_INTRO_PAGE
:
3879 Page
= RepairIntroPage(&Ir
);
3883 Page
= SuccessPage(&Ir
);
3887 Page
= FlushPage(&Ir
);
3891 Page
= QuitPage(&Ir
);
3901 /* Avoid bugcheck */
3902 Time
.QuadPart
+= 50000000;
3903 NtDelayExecution(FALSE
, &Time
);
3906 NtShutdownSystem(ShutdownReboot
);
3907 NtTerminateProcess(NtCurrentProcess(), 0);
3914 NtProcessStartup(PPEB Peb
)
3916 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3918 ProcessHeap
= Peb
->ProcessHeap
;
3919 InfSetHeap(ProcessHeap
);
3922 #endif /* __REACTOS__ */