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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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)
34 /* GLOBALS ******************************************************************/
37 UNICODE_STRING SourceRootPath
;
38 UNICODE_STRING SourceRootDir
;
39 UNICODE_STRING SourcePath
;
40 BOOLEAN IsUnattendedSetup
= FALSE
;
41 LONG UnattendDestinationDiskNumber
;
42 LONG UnattendDestinationPartitionNumber
;
43 LONG UnattendMBRInstallType
= -1;
44 LONG UnattendFormatPartition
= 0;
45 LONG AutoPartition
= 0;
46 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
47 PWCHAR SelectedLanguageId
;
48 WCHAR DefaultLanguage
[20];
49 WCHAR DefaultKBLayout
[20];
50 BOOLEAN RepairUpdateFlag
= FALSE
;
51 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
53 /* LOCALS *******************************************************************/
55 static PPARTLIST PartitionList
= NULL
;
57 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
59 static UNICODE_STRING InstallPath
;
61 /* Path to the install directory */
62 static UNICODE_STRING DestinationPath
;
63 static UNICODE_STRING DestinationArcPath
;
64 static UNICODE_STRING DestinationRootPath
;
66 /* Path to the active partition (boot manager) */
67 static UNICODE_STRING SystemRootPath
;
71 static HSPFILEQ SetupFileQueue
= NULL
;
73 static BOOLEAN WarnLinuxPartitions
= TRUE
;
75 static PGENERIC_LIST ComputerList
= NULL
;
76 static PGENERIC_LIST DisplayList
= NULL
;
77 static PGENERIC_LIST KeyboardList
= NULL
;
78 static PGENERIC_LIST LayoutList
= NULL
;
79 static PGENERIC_LIST LanguageList
= NULL
;
81 /* FUNCTIONS ****************************************************************/
84 PrintString(char* fmt
,...)
88 UNICODE_STRING UnicodeString
;
89 ANSI_STRING AnsiString
;
92 vsprintf(buffer
, fmt
, ap
);
95 RtlInitAnsiString(&AnsiString
, buffer
);
96 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
97 NtDisplayString(&UnicodeString
);
98 RtlFreeUnicodeString(&UnicodeString
);
112 /* draw upper left corner */
115 FillConsoleOutputCharacterA(
122 /* draw upper edge */
125 FillConsoleOutputCharacterA(
132 /* draw upper right corner */
133 coPos
.X
= xLeft
+ Width
- 1;
135 FillConsoleOutputCharacterA(
142 /* Draw right edge, inner space and left edge */
143 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
146 FillConsoleOutputCharacterA(
154 FillConsoleOutputCharacterA(
161 coPos
.X
= xLeft
+ Width
- 1;
162 FillConsoleOutputCharacterA(
170 /* draw lower left corner */
172 coPos
.Y
= yTop
+ Height
- 1;
173 FillConsoleOutputCharacterA(
180 /* draw lower edge */
182 coPos
.Y
= yTop
+ Height
- 1;
183 FillConsoleOutputCharacterA(
190 /* draw lower right corner */
191 coPos
.X
= xLeft
+ Width
- 1;
192 coPos
.Y
= yTop
+ Height
- 1;
193 FillConsoleOutputCharacterA(
202 PopupError(PCCH Text
,
220 /* Count text lines and longest line */
227 p
= strchr(pnext
, '\n');
231 Length
= strlen(pnext
);
236 Length
= (ULONG
)(p
- pnext
);
242 if (Length
> MaxLength
)
245 if (LastLine
== TRUE
)
251 /* Check length of status line */
254 Length
= strlen(Status
);
256 if (Length
> MaxLength
)
260 Width
= MaxLength
+ 4;
266 yTop
= (yScreen
- Height
) / 2;
267 xLeft
= (xScreen
- Width
) / 2;
270 /* Set screen attributes */
272 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
274 FillConsoleOutputAttribute(StdOutput
,
275 FOREGROUND_RED
| BACKGROUND_WHITE
,
281 DrawBox(xLeft
, yTop
, Width
, Height
);
283 /* Print message text */
288 p
= strchr(pnext
, '\n');
292 Length
= strlen(pnext
);
297 Length
= (ULONG
)(p
- pnext
);
304 WriteConsoleOutputCharacterA(StdOutput
,
311 if (LastLine
== TRUE
)
318 /* Print separator line and status text */
321 coPos
.Y
= yTop
+ Height
- 3;
323 FillConsoleOutputCharacterA(StdOutput
,
330 FillConsoleOutputCharacterA(StdOutput
,
336 coPos
.X
= xLeft
+ Width
- 1;
337 FillConsoleOutputCharacterA(StdOutput
,
345 WriteConsoleOutputCharacterA(StdOutput
,
347 min(strlen(Status
), (SIZE_T
)Width
- 4),
352 if (WaitEvent
== POPUP_WAIT_NONE
)
357 CONSOLE_ConInKey(Ir
);
359 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
360 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
372 * FALSE: Don't quit setup.
375 ConfirmQuit(PINPUT_RECORD Ir
)
378 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
382 CONSOLE_ConInKey(Ir
);
384 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
385 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
390 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
402 CheckUnattendedSetup(VOID
)
404 WCHAR UnattendInfPath
[MAX_PATH
];
411 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
413 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
417 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
418 wcscat(UnattendInfPath
, L
"\\unattend.inf");
420 /* Load 'unattend.inf' from install media. */
421 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
426 if (UnattendInf
== INVALID_HANDLE_VALUE
)
428 DPRINT("SetupOpenInfFileW() failed\n");
432 /* Open 'Unattend' section */
433 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
435 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
436 SetupCloseInfFile(UnattendInf
);
440 /* Get pointer 'Signature' key */
441 if (!INF_GetData(&Context
, NULL
, &Value
))
443 DPRINT("INF_GetData() failed for key 'Signature'\n");
444 SetupCloseInfFile(UnattendInf
);
448 /* Check 'Signature' string */
449 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
451 DPRINT("Signature not $ReactOS$\n");
452 SetupCloseInfFile(UnattendInf
);
456 /* Check if Unattend setup is enabled */
457 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
459 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
460 SetupCloseInfFile(UnattendInf
);
464 if (!INF_GetData(&Context
, NULL
, &Value
))
466 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
467 SetupCloseInfFile(UnattendInf
);
471 if (_wcsicmp(Value
, L
"yes") != 0)
473 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
474 SetupCloseInfFile(UnattendInf
);
478 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
479 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
481 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
482 SetupCloseInfFile(UnattendInf
);
486 if (!SetupGetIntField(&Context
, 1, &IntValue
))
488 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
489 SetupCloseInfFile(UnattendInf
);
493 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
495 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
496 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
498 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
499 SetupCloseInfFile(UnattendInf
);
503 if (!SetupGetIntField(&Context
, 1, &IntValue
))
505 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
506 SetupCloseInfFile(UnattendInf
);
510 UnattendDestinationPartitionNumber
= 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 /* Get pointer 'InstallationDirectory' key */
521 if (!INF_GetData(&Context
, NULL
, &Value
))
523 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
524 SetupCloseInfFile(UnattendInf
);
528 wcscpy(UnattendInstallationDirectory
, Value
);
530 IsUnattendedSetup
= TRUE
;
532 /* Search for 'MBRInstallType' in the 'Unattend' section */
533 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
535 if (SetupGetIntField(&Context
, 1, &IntValue
))
537 UnattendMBRInstallType
= IntValue
;
541 /* Search for 'FormatPartition' in the 'Unattend' section */
542 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
544 if (SetupGetIntField(&Context
, 1, &IntValue
))
546 UnattendFormatPartition
= IntValue
;
550 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
552 if (SetupGetIntField(&Context
, 1, &IntValue
))
554 AutoPartition
= IntValue
;
558 SetupCloseInfFile(UnattendInf
);
560 DPRINT("Running unattended setup\n");
566 PGENERIC_LIST_ENTRY ListEntry
;
567 LPCWSTR pszNewLayout
;
569 pszNewLayout
= MUIDefaultKeyboardLayout();
571 if (LayoutList
== NULL
)
573 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
576 ListEntry
= GetFirstListEntry(LayoutList
);
578 /* Search for default layout (if provided) */
579 if (pszNewLayout
!= NULL
)
581 while (ListEntry
!= NULL
)
583 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
585 SetCurrentListEntry(LayoutList
, ListEntry
);
589 ListEntry
= GetNextListEntry(ListEntry
);
595 LanguagePage(PINPUT_RECORD Ir
)
597 /* Initialize the computer settings list */
598 if (LanguageList
== NULL
)
600 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
602 if (LanguageList
== NULL
)
604 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
609 DrawGenericList(LanguageList
,
615 MUIDisplayPage(LANGUAGE_PAGE
);
619 CONSOLE_ConInKey(Ir
);
621 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
622 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
624 #if 0 //Dynamically update user interface
625 SelectedLanguageId
= (PWCHAR
)LanguageList
->CurrentEntry
->UserData
;
626 MUIDisplayPage(LANGUAGE_PAGE
);
628 ScrollDownGenericList (LanguageList
);
630 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
631 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
634 SelectedLanguageId
= (PWCHAR
)LanguageList
->CurrentEntry
->UserData
;
635 MUIDisplayPage(LANGUAGE_PAGE
);
637 ScrollUpGenericList (LanguageList
);
639 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
640 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
642 if (ConfirmQuit(Ir
) == TRUE
)
645 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
647 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
649 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
655 SetConsoleCodePage();
659 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
662 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
673 * Number of the next page.
676 SetupStartPage(PINPUT_RECORD Ir
)
678 SYSTEM_DEVICE_INFORMATION Sdi
;
680 WCHAR FileNameBuffer
[MAX_PATH
];
686 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
689 /* Check whether a harddisk is available */
690 Status
= NtQuerySystemInformation (SystemDeviceInformation
,
692 sizeof(SYSTEM_DEVICE_INFORMATION
),
695 if (!NT_SUCCESS (Status
))
697 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
698 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
702 if (Sdi
.NumberOfDisks
== 0)
704 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
708 /* Get the source path and source root path */
709 Status
= GetSourcePaths(&SourcePath
,
713 if (!NT_SUCCESS(Status
))
715 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
716 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
722 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
723 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
724 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
728 /* Load txtsetup.sif from install media. */
729 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
730 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
732 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
737 if (SetupInf
== INVALID_HANDLE_VALUE
)
739 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
743 /* Open 'Version' section */
744 if (!SetupFindFirstLineW (SetupInf
, L
"Version", L
"Signature", &Context
))
746 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
750 /* Get pointer 'Signature' key */
751 if (!INF_GetData (&Context
, NULL
, &Value
))
753 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
757 /* Check 'Signature' string */
758 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
760 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
764 /* Start PnP thread */
765 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
767 NtResumeThread(hPnpThread
, NULL
);
768 hPnpThread
= INVALID_HANDLE_VALUE
;
771 CheckUnattendedSetup();
773 if (IsUnattendedSetup
)
776 //read options from inf
777 ComputerList
= CreateComputerTypeList(SetupInf
);
778 DisplayList
= CreateDisplayDriverList(SetupInf
);
779 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
780 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
781 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
783 return INSTALL_INTRO_PAGE
;
786 return LANGUAGE_PAGE
;
796 IntroPage(PINPUT_RECORD Ir
)
798 MUIDisplayPage(START_PAGE
);
802 CONSOLE_ConInKey(Ir
);
804 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
805 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
807 if (ConfirmQuit(Ir
) == TRUE
)
812 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
814 return INSTALL_INTRO_PAGE
;
817 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
819 return REPAIR_INTRO_PAGE
;
822 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
835 * Back to main setup page.
838 LicensePage(PINPUT_RECORD Ir
)
840 MUIDisplayPage(LICENSE_PAGE
);
844 CONSOLE_ConInKey(Ir
);
846 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
857 RepairIntroPage(PINPUT_RECORD Ir
)
859 MUIDisplayPage(REPAIR_INTRO_PAGE
);
863 CONSOLE_ConInKey(Ir
);
865 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
869 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
871 RepairUpdateFlag
= TRUE
;
872 return INSTALL_INTRO_PAGE
;
874 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
878 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
879 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
885 return REPAIR_INTRO_PAGE
;
890 InstallIntroPage(PINPUT_RECORD Ir
)
892 MUIDisplayPage(INSTALL_INTRO_PAGE
);
894 if (RepairUpdateFlag
)
896 //return SELECT_PARTITION_PAGE;
897 return DEVICE_SETTINGS_PAGE
;
900 if (IsUnattendedSetup
)
902 return SELECT_PARTITION_PAGE
;
907 CONSOLE_ConInKey(Ir
);
909 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
910 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
912 if (ConfirmQuit(Ir
) == TRUE
)
917 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
919 return DEVICE_SETTINGS_PAGE
;
920 // return SCSI_CONTROLLER_PAGE;
924 return INSTALL_INTRO_PAGE
;
930 ScsiControllerPage(PINPUT_RECORD Ir
)
932 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
934 /* FIXME: print loaded mass storage driver descriptions */
936 SetTextXY(8, 10, "TEST device");
940 SetStatusText(" ENTER = Continue F3 = Quit");
946 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
947 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
949 if (ConfirmQuit(Ir
) == TRUE
)
954 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
956 return DEVICE_SETTINGS_PAGE
;
960 return SCSI_CONTROLLER_PAGE
;
966 DeviceSettingsPage(PINPUT_RECORD Ir
)
968 static ULONG Line
= 16;
969 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
971 /* Initialize the computer settings list */
972 if (ComputerList
== NULL
)
974 ComputerList
= CreateComputerTypeList(SetupInf
);
975 if (ComputerList
== NULL
)
977 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
982 /* Initialize the display settings list */
983 if (DisplayList
== NULL
)
985 DisplayList
= CreateDisplayDriverList(SetupInf
);
986 if (DisplayList
== NULL
)
988 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
993 /* Initialize the keyboard settings list */
994 if (KeyboardList
== NULL
)
996 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
997 if (KeyboardList
== NULL
)
999 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1004 /* Initialize the keyboard layout list */
1005 if (LayoutList
== NULL
)
1007 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1008 if (LayoutList
== NULL
)
1010 /* FIXME: report error */
1011 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1016 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1019 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1020 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1021 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1022 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1024 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1026 if (RepairUpdateFlag
)
1028 return SELECT_PARTITION_PAGE
;
1033 CONSOLE_ConInKey(Ir
);
1035 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1036 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1038 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1042 else if (Line
== 16)
1047 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1049 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1050 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1052 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1056 else if (Line
== 16)
1061 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1063 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1064 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1066 if (ConfirmQuit(Ir
) == TRUE
)
1071 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1074 return COMPUTER_SETTINGS_PAGE
;
1075 else if (Line
== 12)
1076 return DISPLAY_SETTINGS_PAGE
;
1077 else if (Line
== 13)
1078 return KEYBOARD_SETTINGS_PAGE
;
1079 else if (Line
== 14)
1080 return LAYOUT_SETTINGS_PAGE
;
1081 else if (Line
== 16)
1082 return SELECT_PARTITION_PAGE
;
1086 return DEVICE_SETTINGS_PAGE
;
1091 ComputerSettingsPage(PINPUT_RECORD Ir
)
1093 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1095 DrawGenericList(ComputerList
,
1101 SaveGenericListState(ComputerList
);
1105 CONSOLE_ConInKey(Ir
);
1107 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1108 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1110 ScrollDownGenericList (ComputerList
);
1112 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1113 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1115 ScrollUpGenericList (ComputerList
);
1117 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1118 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1120 if (ConfirmQuit(Ir
) == TRUE
)
1125 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1126 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1128 RestoreGenericListState(ComputerList
);
1129 return DEVICE_SETTINGS_PAGE
;
1131 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1133 return DEVICE_SETTINGS_PAGE
;
1137 return COMPUTER_SETTINGS_PAGE
;
1142 DisplaySettingsPage(PINPUT_RECORD Ir
)
1144 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1146 DrawGenericList(DisplayList
,
1152 SaveGenericListState(DisplayList
);
1156 CONSOLE_ConInKey(Ir
);
1158 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1159 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1161 ScrollDownGenericList (DisplayList
);
1163 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1164 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1166 ScrollUpGenericList (DisplayList
);
1168 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1169 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1171 if (ConfirmQuit(Ir
) == TRUE
)
1178 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1179 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1181 RestoreGenericListState(DisplayList
);
1182 return DEVICE_SETTINGS_PAGE
;
1184 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1186 return DEVICE_SETTINGS_PAGE
;
1190 return DISPLAY_SETTINGS_PAGE
;
1195 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1197 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1199 DrawGenericList(KeyboardList
,
1205 SaveGenericListState(KeyboardList
);
1209 CONSOLE_ConInKey(Ir
);
1211 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1212 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1214 ScrollDownGenericList (KeyboardList
);
1216 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1217 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1219 ScrollUpGenericList (KeyboardList
);
1221 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1222 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1224 if (ConfirmQuit(Ir
) == TRUE
)
1229 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1230 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1232 RestoreGenericListState(KeyboardList
);
1233 return DEVICE_SETTINGS_PAGE
;
1235 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1237 return DEVICE_SETTINGS_PAGE
;
1241 return DISPLAY_SETTINGS_PAGE
;
1246 LayoutSettingsPage(PINPUT_RECORD Ir
)
1248 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1250 DrawGenericList(LayoutList
,
1256 SaveGenericListState(LayoutList
);
1260 CONSOLE_ConInKey(Ir
);
1262 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1263 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1265 ScrollDownGenericList (LayoutList
);
1267 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1268 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1270 ScrollUpGenericList (LayoutList
);
1272 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1273 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1275 if (ConfirmQuit(Ir
) == TRUE
)
1280 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1281 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1283 RestoreGenericListState(LayoutList
);
1284 return DEVICE_SETTINGS_PAGE
;
1286 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1288 return DEVICE_SETTINGS_PAGE
;
1292 return DISPLAY_SETTINGS_PAGE
;
1297 SelectPartitionPage(PINPUT_RECORD Ir
)
1299 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1301 if (PartitionList
== NULL
)
1303 PartitionList
= CreatePartitionList (2,
1308 if (PartitionList
== NULL
)
1310 /* FIXME: show an error dialog */
1315 CheckActiveBootPartition (PartitionList
);
1317 DrawPartitionList (PartitionList
);
1319 /* Warn about partitions created by Linux Fdisk */
1320 if (WarnLinuxPartitions
== TRUE
&&
1321 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1323 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1327 CONSOLE_ConInKey(Ir
);
1329 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1330 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1334 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1336 WarnLinuxPartitions
= FALSE
;
1337 return SELECT_PARTITION_PAGE
;
1342 if (IsUnattendedSetup
)
1344 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1348 PPARTENTRY PartEntry
= PartEntry
= PartitionList
->CurrentPartition
;
1349 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1351 CreateNewPartition(PartitionList
,
1355 return (SELECT_FILE_SYSTEM_PAGE
);
1360 return(SELECT_FILE_SYSTEM_PAGE
);
1366 /* Update status text */
1367 if (PartitionList
->CurrentPartition
== NULL
||
1368 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1370 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1374 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1377 CONSOLE_ConInKey(Ir
);
1379 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1380 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1382 if (ConfirmQuit(Ir
) == TRUE
)
1384 DestroyPartitionList (PartitionList
);
1385 PartitionList
= NULL
;
1391 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1392 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1394 ScrollDownPartitionList (PartitionList
);
1396 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1397 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1399 ScrollUpPartitionList (PartitionList
);
1401 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1403 if (PartitionList
->CurrentPartition
== NULL
||
1404 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1406 CreateNewPartition (PartitionList
,
1411 return SELECT_FILE_SYSTEM_PAGE
;
1413 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1415 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1417 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1418 return SELECT_PARTITION_PAGE
;
1421 return CREATE_PARTITION_PAGE
;
1423 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1425 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1427 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1428 return SELECT_PARTITION_PAGE
;
1431 return DELETE_PARTITION_PAGE
;
1435 return SELECT_PARTITION_PAGE
;
1440 DrawInputField(ULONG FieldLength
,
1451 memset(buf
, '_', sizeof(buf
));
1452 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1453 strcat(buf
, FieldContent
);
1455 WriteConsoleOutputCharacterA (StdOutput
,
1463 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1466 ShowPartitionSizeInputBox(SHORT Left
,
1490 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1495 strcpy (Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1496 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
1499 WriteConsoleOutputCharacterA(StdOutput
,
1505 sprintf (Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1506 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1508 WriteConsoleOutputCharacterA(StdOutput
,
1514 sprintf(Buffer
, "%lu", MaxSize
);
1515 Index
= strlen(Buffer
);
1516 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1523 CONSOLE_ConInKey(&Ir
);
1525 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1526 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1534 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1538 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1546 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1552 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1557 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1558 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1560 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1562 if ((ch
>= '0') && (ch
<= '9'))
1568 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1576 strcpy (InputBuffer
, Buffer
);
1581 CreatePartitionPage (PINPUT_RECORD Ir
)
1583 PDISKENTRY DiskEntry
;
1584 PPARTENTRY PartEntry
;
1587 CHAR InputBuffer
[50];
1593 if (PartitionList
== NULL
||
1594 PartitionList
->CurrentDisk
== NULL
||
1595 PartitionList
->CurrentPartition
== NULL
)
1597 /* FIXME: show an error dialog */
1601 DiskEntry
= PartitionList
->CurrentDisk
;
1602 PartEntry
= PartitionList
->CurrentPartition
;
1604 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1606 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1609 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1611 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1612 Unit
= MUIGetString(STRING_GB
);
1617 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1622 Unit
= MUIGetString(STRING_MB
);
1625 if (DiskEntry
->DriverName
.Length
> 0)
1627 CONSOLE_PrintTextXY(6, 10,
1628 MUIGetString(STRING_HDINFOPARTCREATE
),
1631 DiskEntry
->DiskNumber
,
1635 &DiskEntry
->DriverName
);
1639 CONSOLE_PrintTextXY(6, 10,
1640 MUIGetString(STRING_HDDINFOUNK1
),
1643 DiskEntry
->DiskNumber
,
1649 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1652 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1653 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1656 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1658 PartEntry
= PartitionList
->CurrentPartition
;
1661 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1662 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1663 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1667 if (ConfirmQuit (Ir
) == TRUE
)
1672 else if (Cancel
== TRUE
)
1674 return SELECT_PARTITION_PAGE
;
1678 PartSize
= atoi(InputBuffer
);
1686 if (PartSize
> MaxSize
)
1692 /* Convert to bytes */
1693 if (PartSize
== MaxSize
)
1695 /* Use all of the unpartitioned disk space */
1696 PartSize
= PartEntry
->UnpartitionedLength
;
1700 /* Round-up by cylinder size */
1701 PartSize
= ROUND_UP (PartSize
* 1024 * 1024,
1702 DiskEntry
->CylinderSize
);
1704 /* But never get larger than the unpartitioned disk space */
1705 if (PartSize
> PartEntry
->UnpartitionedLength
)
1706 PartSize
= PartEntry
->UnpartitionedLength
;
1709 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1711 CreateNewPartition (PartitionList
,
1715 return SELECT_PARTITION_PAGE
;
1719 return CREATE_PARTITION_PAGE
;
1724 DeletePartitionPage (PINPUT_RECORD Ir
)
1726 PDISKENTRY DiskEntry
;
1727 PPARTENTRY PartEntry
;
1733 if (PartitionList
== NULL
||
1734 PartitionList
->CurrentDisk
== NULL
||
1735 PartitionList
->CurrentPartition
== NULL
)
1737 /* FIXME: show an error dialog */
1741 DiskEntry
= PartitionList
->CurrentDisk
;
1742 PartEntry
= PartitionList
->CurrentPartition
;
1744 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1746 /* Determine partition type */
1748 if (PartEntry
->New
== TRUE
)
1750 PartType
= MUIGetString(STRING_UNFORMATTED
);
1752 else if (PartEntry
->Unpartitioned
== FALSE
)
1754 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1755 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1756 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1757 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1761 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1762 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1766 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_EXT2
)
1770 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1772 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1777 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1779 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1780 Unit
= MUIGetString(STRING_GB
);
1784 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1786 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1787 Unit
= MUIGetString(STRING_MB
);
1791 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1792 Unit
= MUIGetString(STRING_KB
);
1795 if (PartType
== NULL
)
1797 CONSOLE_PrintTextXY(6, 10,
1798 MUIGetString(STRING_HDDINFOUNK2
),
1799 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1800 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1801 PartEntry
->PartInfo
[0].PartitionType
,
1807 CONSOLE_PrintTextXY(6, 10,
1808 " %c%c %s %I64u %s",
1809 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1810 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1817 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1819 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1820 Unit
= MUIGetString(STRING_GB
);
1825 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1830 Unit
= MUIGetString(STRING_MB
);
1833 if (DiskEntry
->DriverName
.Length
> 0)
1835 CONSOLE_PrintTextXY(6, 12,
1836 MUIGetString(STRING_HDINFOPARTDELETE
),
1839 DiskEntry
->DiskNumber
,
1843 &DiskEntry
->DriverName
);
1847 CONSOLE_PrintTextXY(6, 12,
1848 MUIGetString(STRING_HDDINFOUNK3
),
1851 DiskEntry
->DiskNumber
,
1859 CONSOLE_ConInKey(Ir
);
1861 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1862 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1864 if (ConfirmQuit (Ir
) == TRUE
)
1871 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1873 return SELECT_PARTITION_PAGE
;
1875 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1877 DeleteCurrentPartition (PartitionList
);
1879 return SELECT_PARTITION_PAGE
;
1883 return DELETE_PARTITION_PAGE
;
1888 SelectFileSystemPage (PINPUT_RECORD Ir
)
1890 PDISKENTRY DiskEntry
;
1891 PPARTENTRY PartEntry
;
1898 if (PartitionList
== NULL
||
1899 PartitionList
->CurrentDisk
== NULL
||
1900 PartitionList
->CurrentPartition
== NULL
)
1902 /* FIXME: show an error dialog */
1906 DiskEntry
= PartitionList
->CurrentDisk
;
1907 PartEntry
= PartitionList
->CurrentPartition
;
1909 /* adjust disk size */
1910 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1912 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1913 DiskUnit
= MUIGetString(STRING_GB
);
1917 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1918 DiskUnit
= MUIGetString(STRING_MB
);
1921 /* adjust partition size */
1922 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1924 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1925 PartUnit
= MUIGetString(STRING_GB
);
1929 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1930 PartUnit
= MUIGetString(STRING_MB
);
1933 /* adjust partition type */
1934 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1935 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1936 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1937 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1941 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1942 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1946 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_EXT2
)
1950 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1952 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1954 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
1956 PartType
= MUIGetString(STRING_FORMATUNUSED
);
1960 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
1963 if (PartEntry
->AutoCreate
== TRUE
)
1965 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
1968 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
1969 PartEntry
->PartInfo
[0].PartitionNumber
,
1975 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
1976 DiskEntry
->DiskNumber
,
1982 &DiskEntry
->DriverName
);
1984 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
1987 PartEntry
->AutoCreate
= FALSE
;
1989 else if (PartEntry
->New
== TRUE
)
1991 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
1992 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
1996 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
1998 if (PartType
== NULL
)
2000 CONSOLE_PrintTextXY(8, 10,
2001 MUIGetString(STRING_HDDINFOUNK4
),
2002 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2003 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2004 PartEntry
->PartInfo
[0].PartitionType
,
2010 CONSOLE_PrintTextXY(8, 10,
2012 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2013 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2019 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2020 DiskEntry
->DiskNumber
,
2026 &DiskEntry
->DriverName
);
2029 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2031 if (FileSystemList
== NULL
)
2033 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, L
"FAT");
2034 if (FileSystemList
== NULL
)
2036 /* FIXME: show an error dialog */
2040 /* FIXME: Add file systems to list */
2042 DrawFileSystemList (FileSystemList
);
2044 if (RepairUpdateFlag
)
2046 return CHECK_FILE_SYSTEM_PAGE
;
2047 //return SELECT_PARTITION_PAGE;
2050 if (IsUnattendedSetup
)
2052 if (UnattendFormatPartition
)
2054 return FORMAT_PARTITION_PAGE
;
2057 return(CHECK_FILE_SYSTEM_PAGE
);
2062 CONSOLE_ConInKey(Ir
);
2064 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2065 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2067 if (ConfirmQuit (Ir
) == TRUE
)
2074 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2075 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2077 return SELECT_PARTITION_PAGE
;
2079 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2080 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2082 ScrollDownFileSystemList (FileSystemList
);
2084 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2085 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2087 ScrollUpFileSystemList (FileSystemList
);
2089 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2091 if (!FileSystemList
->Selected
->FormatFunc
)
2093 return CHECK_FILE_SYSTEM_PAGE
;
2097 return FORMAT_PARTITION_PAGE
;
2102 return SELECT_FILE_SYSTEM_PAGE
;
2107 FormatPartitionPage (PINPUT_RECORD Ir
)
2109 WCHAR PathBuffer
[MAX_PATH
];
2110 PDISKENTRY DiskEntry
;
2111 PPARTENTRY PartEntry
;
2120 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2122 if (PartitionList
== NULL
||
2123 PartitionList
->CurrentDisk
== NULL
||
2124 PartitionList
->CurrentPartition
== NULL
)
2126 /* FIXME: show an error dialog */
2130 DiskEntry
= PartitionList
->CurrentDisk
;
2131 PartEntry
= PartitionList
->CurrentPartition
;
2135 if (!IsUnattendedSetup
)
2137 CONSOLE_ConInKey(Ir
);
2140 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2141 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2143 if (ConfirmQuit (Ir
) == TRUE
)
2150 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2152 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2154 if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
2156 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2158 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2160 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2161 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_12
;
2163 else if (PartEntry
->PartInfo
[0].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2165 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2167 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2169 /* FAT16 CHS partition (partiton size < 32MB) */
2170 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_16
;
2172 else if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2174 /* FAT16 CHS partition (partition size < 512MB) */
2175 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_HUGE
;
2179 /* FAT32 CHS partition (partition size >= 512MB) */
2180 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32
;
2185 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2187 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2189 /* FAT16 LBA partition (partition size < 512MB) */
2190 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_XINT13
;
2194 /* FAT32 LBA partition (partition size >= 512MB) */
2195 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32_XINT13
;
2199 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2200 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_EXT2
;
2201 else if (!FileSystemList
->Selected
->FormatFunc
)
2205 CheckActiveBootPartition (PartitionList
);
2208 CONSOLE_PrintTextXY(6, 12,
2209 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2210 DiskEntry
->DiskSize
,
2211 DiskEntry
->CylinderSize
,
2212 DiskEntry
->TrackSize
);
2215 DiskEntry
= PartitionList
->CurrentDisk
;
2216 Entry
= DiskEntry
->PartListHead
.Flink
;
2218 while (Entry
!= &DiskEntry
->PartListHead
)
2220 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2222 if (PartEntry
->Unpartitioned
== FALSE
)
2224 for (i
= 0; i
< 4; i
++)
2226 CONSOLE_PrintTextXY(6, Line
,
2227 "%2u: %2u %c %12I64u %12I64u %2u %c",
2229 PartEntry
->PartInfo
[i
].PartitionNumber
,
2230 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2231 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2232 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2233 PartEntry
->PartInfo
[i
].PartitionType
,
2234 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2242 Entry
= Entry
->Flink
;
2245 /* Restore the old entry */
2246 PartEntry
= PartitionList
->CurrentPartition
;
2249 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
2251 DPRINT ("WritePartitionsToDisk() failed\n");
2252 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2256 /* Set DestinationRootPath */
2257 RtlFreeUnicodeString (&DestinationRootPath
);
2258 swprintf (PathBuffer
,
2259 L
"\\Device\\Harddisk%lu\\Partition%lu",
2260 PartitionList
->CurrentDisk
->DiskNumber
,
2261 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2262 RtlCreateUnicodeString (&DestinationRootPath
,
2264 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2267 /* Set SystemRootPath */
2268 RtlFreeUnicodeString (&SystemRootPath
);
2269 swprintf (PathBuffer
,
2270 L
"\\Device\\Harddisk%lu\\Partition%lu",
2271 PartitionList
->ActiveBootDisk
->DiskNumber
,
2272 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2273 RtlCreateUnicodeString (&SystemRootPath
,
2275 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
2278 if (FileSystemList
->Selected
->FormatFunc
)
2280 Status
= FormatPartition(&DestinationRootPath
, FileSystemList
->Selected
);
2281 if (!NT_SUCCESS(Status
))
2283 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2284 /* FIXME: show an error dialog */
2288 PartEntry
->New
= FALSE
;
2290 CheckActiveBootPartition(PartitionList
);
2293 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2295 /* FIXME: Install boot code. This is a hack! */
2296 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
) ||
2297 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
))
2299 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2300 wcscat(PathBuffer
, L
"\\loader\\fat32.bin");
2302 DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
2303 DestinationRootPath
.Buffer
);
2304 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2305 DestinationRootPath
.Buffer
);
2307 if (!NT_SUCCESS(Status
))
2309 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2310 /* FIXME: show an error dialog */
2311 DestroyFileSystemList(FileSystemList
);
2312 FileSystemList
= NULL
;
2318 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2319 wcscat(PathBuffer
, L
"\\loader\\fat.bin");
2321 DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer
,
2322 DestinationRootPath
.Buffer
);
2323 Status
= InstallFat16BootCodeToDisk(PathBuffer
,
2324 DestinationRootPath
.Buffer
);
2326 if (!NT_SUCCESS(Status
))
2328 DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status
);
2329 /* FIXME: show an error dialog */
2330 DestroyFileSystemList(FileSystemList
);
2331 FileSystemList
= NULL
;
2336 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2338 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2339 wcscat(PathBuffer
, L
"\\loader\\ext2.bin");
2341 DPRINT("Install EXT2 bootcode: %S ==> %S\n", PathBuffer
,
2342 DestinationRootPath
.Buffer
);
2343 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2344 DestinationRootPath
.Buffer
);
2346 if (!NT_SUCCESS(Status
))
2348 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2349 /* FIXME: show an error dialog */
2350 DestroyFileSystemList(FileSystemList
);
2351 FileSystemList
= NULL
;
2355 else if (FileSystemList
->Selected
->FormatFunc
)
2357 DestroyFileSystemList(FileSystemList
);
2358 FileSystemList
= NULL
;
2363 CONSOLE_SetStatusText(" Done. Press any key ...");
2364 CONSOLE_ConInKey(Ir
);
2367 DestroyFileSystemList(FileSystemList
);
2368 FileSystemList
= NULL
;
2369 return INSTALL_DIRECTORY_PAGE
;
2373 return FORMAT_PARTITION_PAGE
;
2378 CheckFileSystemPage(PINPUT_RECORD Ir
)
2380 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2381 WCHAR PathBuffer
[MAX_PATH
];
2382 CHAR Buffer
[MAX_PATH
];
2385 /* FIXME: code duplicated in FormatPartitionPage */
2386 /* Set DestinationRootPath */
2387 RtlFreeUnicodeString(&DestinationRootPath
);
2388 swprintf(PathBuffer
,
2389 L
"\\Device\\Harddisk%lu\\Partition%lu",
2390 PartitionList
->CurrentDisk
->DiskNumber
,
2391 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2392 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2393 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2395 /* Set SystemRootPath */
2396 RtlFreeUnicodeString(&SystemRootPath
);
2397 swprintf(PathBuffer
,
2398 L
"\\Device\\Harddisk%lu\\Partition%lu",
2399 PartitionList
->ActiveBootDisk
->DiskNumber
,
2400 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2401 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2402 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2404 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2406 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2408 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2409 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2411 if (!CurrentFileSystem
->ChkdskFunc
)
2414 "Setup is currently unable to check a partition formatted in %S.\n"
2416 " \x07 Press ENTER to continue Setup.\n"
2417 " \x07 Press F3 to quit Setup.",
2418 CurrentFileSystem
->FileSystem
);
2421 MUIGetString(STRING_QUITCONTINUE
),
2422 NULL
, POPUP_WAIT_NONE
);
2426 CONSOLE_ConInKey(Ir
);
2428 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2429 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2431 if (ConfirmQuit(Ir
))
2434 return CHECK_FILE_SYSTEM_PAGE
;
2436 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2438 return INSTALL_DIRECTORY_PAGE
;
2444 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2445 if (!NT_SUCCESS(Status
))
2447 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2448 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2449 "(Status 0x%08lx).\n", Status
);
2452 MUIGetString(STRING_REBOOTCOMPUTER
),
2453 Ir
, POPUP_WAIT_ENTER
);
2458 return INSTALL_DIRECTORY_PAGE
;
2464 InstallDirectoryPage1(PWCHAR InstallDir
, PDISKENTRY DiskEntry
, PPARTENTRY PartEntry
)
2466 WCHAR PathBuffer
[MAX_PATH
];
2468 /* Create 'InstallPath' string */
2469 RtlFreeUnicodeString(&InstallPath
);
2470 RtlCreateUnicodeString(&InstallPath
,
2473 /* Create 'DestinationPath' string */
2474 RtlFreeUnicodeString(&DestinationPath
);
2475 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2477 if (InstallDir
[0] != L
'\\')
2478 wcscat(PathBuffer
, L
"\\");
2480 wcscat(PathBuffer
, InstallDir
);
2481 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2483 /* Create 'DestinationArcPath' */
2484 RtlFreeUnicodeString(&DestinationArcPath
);
2485 swprintf(PathBuffer
,
2486 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2487 DiskEntry
->BiosDiskNumber
,
2488 PartEntry
->PartInfo
[0].PartitionNumber
);
2490 if (InstallDir
[0] != L
'\\')
2491 wcscat(PathBuffer
, L
"\\");
2493 wcscat(PathBuffer
, InstallDir
);
2494 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2496 return(PREPARE_COPY_PAGE
);
2501 InstallDirectoryPage(PINPUT_RECORD Ir
)
2503 PDISKENTRY DiskEntry
;
2504 PPARTENTRY PartEntry
;
2505 WCHAR InstallDir
[51];
2510 if (PartitionList
== NULL
||
2511 PartitionList
->CurrentDisk
== NULL
||
2512 PartitionList
->CurrentPartition
== NULL
)
2514 /* FIXME: show an error dialog */
2518 DiskEntry
= PartitionList
->CurrentDisk
;
2519 PartEntry
= PartitionList
->CurrentPartition
;
2521 /* Search for 'DefaultPath' in the 'SetupData' section */
2522 if (!SetupFindFirstLineW (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2524 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2528 /* Read the 'DefaultPath' data */
2529 if (INF_GetData (&Context
, NULL
, &DefaultPath
))
2531 wcscpy(InstallDir
, DefaultPath
);
2535 wcscpy(InstallDir
, L
"\\ReactOS");
2538 Length
= wcslen(InstallDir
);
2539 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2540 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2542 if (IsUnattendedSetup
)
2544 return(InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2549 CONSOLE_ConInKey(Ir
);
2551 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2552 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2554 if (ConfirmQuit(Ir
) == TRUE
)
2559 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2561 return (InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2563 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2568 InstallDir
[Length
] = 0;
2569 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2572 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2576 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2578 InstallDir
[Length
] = 0;
2579 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2584 return(INSTALL_DIRECTORY_PAGE
);
2588 AddSectionToCopyQueueCab(HINF InfFile
,
2590 PWCHAR SourceCabinet
,
2591 PCUNICODE_STRING DestinationPath
,
2594 INFCONTEXT FilesContext
;
2595 INFCONTEXT DirContext
;
2597 PWCHAR FileKeyValue
;
2599 PWCHAR TargetFileName
;
2601 /* Search for the SectionName section */
2602 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2605 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2606 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2611 * Enumerate the files in the section
2612 * and add them to the file queue.
2616 /* Get source file name and target directory id */
2617 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2619 /* FIXME: Handle error! */
2620 DPRINT1("INF_GetData() failed\n");
2624 /* Get optional target file name */
2625 if (!INF_GetDataField (&FilesContext
, 2, &TargetFileName
))
2626 TargetFileName
= NULL
;
2628 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2630 /* Lookup target directory */
2631 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2633 /* FIXME: Handle error! */
2634 DPRINT1("SetupFindFirstLine() failed\n");
2638 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2640 /* FIXME: Handle error! */
2641 DPRINT1("INF_GetData() failed\n");
2645 if (!SetupQueueCopy(SetupFileQueue
,
2647 SourceRootPath
.Buffer
,
2648 SourceRootDir
.Buffer
,
2653 /* FIXME: Handle error! */
2654 DPRINT1("SetupQueueCopy() failed\n");
2656 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2662 AddSectionToCopyQueue(HINF InfFile
,
2664 PWCHAR SourceCabinet
,
2665 PCUNICODE_STRING DestinationPath
,
2668 INFCONTEXT FilesContext
;
2669 INFCONTEXT DirContext
;
2671 PWCHAR FileKeyValue
;
2673 PWCHAR TargetFileName
;
2676 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2678 /* Search for the SectionName section */
2679 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2682 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2683 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2688 * Enumerate the files in the section
2689 * and add them to the file queue.
2693 /* Get source file name and target directory id */
2694 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2696 /* FIXME: Handle error! */
2697 DPRINT1("INF_GetData() failed\n");
2701 /* Get target directory id */
2702 if (!INF_GetDataField (&FilesContext
, 13, &FileKeyValue
))
2704 /* FIXME: Handle error! */
2705 DPRINT1("INF_GetData() failed\n");
2709 /* Get optional target file name */
2710 if (!INF_GetDataField (&FilesContext
, 11, &TargetFileName
))
2711 TargetFileName
= NULL
;
2712 else if (!*TargetFileName
)
2713 TargetFileName
= NULL
;
2715 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2717 /* Lookup target directory */
2718 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2720 /* FIXME: Handle error! */
2721 DPRINT1("SetupFindFirstLine() failed\n");
2725 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2727 /* FIXME: Handle error! */
2728 DPRINT1("INF_GetData() failed\n");
2732 if (!SetupQueueCopy(SetupFileQueue
,
2734 SourceRootPath
.Buffer
,
2735 SourceRootDir
.Buffer
,
2740 /* FIXME: Handle error! */
2741 DPRINT1("SetupQueueCopy() failed\n");
2743 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2749 PrepareCopyPageInfFile(HINF InfFile
,
2750 PWCHAR SourceCabinet
,
2753 WCHAR PathBuffer
[MAX_PATH
];
2754 INFCONTEXT DirContext
;
2755 PWCHAR AdditionalSectionName
= NULL
;
2760 /* Add common files */
2761 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2764 /* Add specific files depending of computer type */
2765 if (SourceCabinet
== NULL
)
2767 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2770 if (AdditionalSectionName
)
2772 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2777 /* Create directories */
2781 * Install directories like '\reactos\test' are not handled yet.
2784 /* Get destination path */
2785 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2787 /* Remove trailing backslash */
2788 Length
= wcslen(PathBuffer
);
2789 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2791 PathBuffer
[Length
- 1] = 0;
2794 /* Create the install directory */
2795 Status
= SetupCreateDirectory(PathBuffer
);
2796 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2798 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2799 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2803 /* Search for the 'Directories' section */
2804 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2808 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2812 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2818 /* Enumerate the directory values and create the subdirectories */
2821 if (!INF_GetData (&DirContext
, NULL
, &KeyValue
))
2827 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2829 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2831 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2832 wcscat(PathBuffer
, KeyValue
);
2834 DPRINT("FullPath: '%S'\n", PathBuffer
);
2836 else if (KeyValue
[0] != L
'\\')
2838 DPRINT("RelativePath: '%S'\n", KeyValue
);
2839 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2840 wcscat(PathBuffer
, L
"\\");
2841 wcscat(PathBuffer
, KeyValue
);
2843 DPRINT("FullPath: '%S'\n", PathBuffer
);
2845 Status
= SetupCreateDirectory(PathBuffer
);
2846 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2848 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2849 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2853 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2859 PrepareCopyPage(PINPUT_RECORD Ir
)
2862 WCHAR PathBuffer
[MAX_PATH
];
2863 INFCONTEXT CabinetsContext
;
2869 MUIDisplayPage(PREPARE_COPY_PAGE
);
2871 /* Create the file queue */
2872 SetupFileQueue
= SetupOpenFileQueue();
2873 if (SetupFileQueue
== NULL
)
2875 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2879 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2884 /* Search for the 'Cabinets' section */
2885 if (!SetupFindFirstLineW (SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2887 return FILE_COPY_PAGE
;
2891 * Enumerate the directory values in the 'Cabinets'
2892 * section and parse their inf files.
2896 if (!INF_GetData (&CabinetsContext
, NULL
, &KeyValue
))
2899 wcscpy(PathBuffer
, SourcePath
.Buffer
);
2900 wcscat(PathBuffer
, L
"\\");
2901 wcscat(PathBuffer
, KeyValue
);
2904 CabinetInitialize();
2905 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
2906 CabinetSetCabinetName(PathBuffer
);
2908 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
2910 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
2912 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
2913 if (InfFileData
== NULL
)
2915 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
2921 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
2922 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
2926 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
2932 if (InfHandle
== INVALID_HANDLE_VALUE
)
2934 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
2940 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
2945 } while (SetupFindNextLine (&CabinetsContext
, &CabinetsContext
));
2947 return FILE_COPY_PAGE
;
2952 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
2955 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
2957 /* Get the memory information from the system */
2958 NtQuerySystemInformation(SystemPerformanceInformation
,
2963 /* Check if this is initial setup */
2966 /* Set maximum limits to be total RAM pages */
2967 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
2968 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
2969 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
2972 /* Set current values */
2973 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
);
2974 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.NonPagedPoolPages
);
2975 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
2977 /* Check if memory dropped below 40%! */
2978 if (CopyContext
->MemoryBars
[2]->Percent
<= 40)
2980 /* Wait a while until Mm does its thing */
2981 LARGE_INTEGER Interval
;
2982 Interval
.QuadPart
= -1 * 15 * 1000 * 100;
2983 NtDelayExecution(FALSE
, &Interval
);
2987 static UINT CALLBACK
2988 FileCopyCallback(PVOID Context
,
2993 PCOPYCONTEXT CopyContext
;
2995 CopyContext
= (PCOPYCONTEXT
)Context
;
2997 switch (Notification
)
2999 case SPFILENOTIFY_STARTSUBQUEUE
:
3000 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3001 ProgressSetStepCount(CopyContext
->ProgressBar
,
3002 CopyContext
->TotalOperations
);
3003 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3006 case SPFILENOTIFY_STARTCOPY
:
3007 /* Display copy message */
3008 CONSOLE_SetStatusTextAutoFitX (45 , MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3009 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3012 case SPFILENOTIFY_ENDCOPY
:
3013 CopyContext
->CompletedOperations
++;
3014 ProgressNextStep(CopyContext
->ProgressBar
);
3015 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3024 FileCopyPage(PINPUT_RECORD Ir
)
3026 COPYCONTEXT CopyContext
;
3028 MUIDisplayPage(FILE_COPY_PAGE
);
3030 /* Create context for the copy process */
3031 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3032 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3033 CopyContext
.TotalOperations
= 0;
3034 CopyContext
.CompletedOperations
= 0;
3036 /* Create the progress bar as well */
3037 CopyContext
.ProgressBar
= CreateProgressBar(13,
3044 MUIGetString(STRING_SETUPCOPYINGFILES
));
3046 /* Create the paged pool progress bar */
3047 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3054 MUIGetString(STRING_PAGEDMEM
));
3056 /* Create the non paged pool progress bar */
3057 CopyContext
.MemoryBars
[1] = CreateProgressBar(28,
3064 MUIGetString(STRING_NONPAGEDMEM
));
3066 /* Create the global memory progress bar */
3067 CopyContext
.MemoryBars
[2] = CreateProgressBar(43,
3074 MUIGetString(STRING_FREEMEM
));
3076 /* Do the file copying */
3077 SetupCommitFileQueueW(NULL
,
3082 /* If we get here, we're done, so cleanup the queue and progress bar */
3083 SetupCloseFileQueue(SetupFileQueue
);
3084 DestroyProgressBar(CopyContext
.ProgressBar
);
3085 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3086 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3087 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3089 /* Go display the next page */
3090 return REGISTRY_PAGE
;
3094 RegistryPage(PINPUT_RECORD Ir
)
3096 INFCONTEXT InfContext
;
3103 MUIDisplayPage(REGISTRY_PAGE
);
3105 if (RepairUpdateFlag
)
3107 return SUCCESS_PAGE
;
3110 if (!SetInstallPathValue(&DestinationPath
))
3112 DPRINT("SetInstallPathValue() failed\n");
3113 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3117 /* Create the default hives */
3119 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3120 if (!NT_SUCCESS(Status
))
3122 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3123 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3127 RegInitializeRegistry();
3130 /* Update registry */
3131 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3133 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3135 DPRINT1("SetupFindFirstLine() failed\n");
3136 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3142 INF_GetDataField (&InfContext
, 0, &Action
);
3143 INF_GetDataField (&InfContext
, 1, &File
);
3144 INF_GetDataField (&InfContext
, 2, &Section
);
3146 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3148 if (!_wcsicmp (Action
, L
"AddReg"))
3152 else if (!_wcsicmp (Action
, L
"DelReg"))
3161 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3163 if (!ImportRegistryFile(File
, Section
, Delete
))
3165 DPRINT("Importing %S failed\n", File
);
3167 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3170 } while (SetupFindNextLine (&InfContext
, &InfContext
));
3172 /* Update display registry settings */
3173 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3174 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3176 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3180 /* Set the locale */
3181 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3182 if (!ProcessLocaleRegistry(LanguageList
))
3184 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3188 /* Add keyboard layouts */
3189 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3190 if (!AddKeyboardLayouts())
3192 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3196 /* Update keyboard layout settings */
3197 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3198 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3200 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3204 /* Add codepage information to registry */
3205 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3208 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3212 /* Update the mounted devices list */
3213 SetMountedDeviceValues(PartitionList
);
3215 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3217 return BOOT_LOADER_PAGE
;
3222 BootLoaderPage(PINPUT_RECORD Ir
)
3224 UCHAR PartitionType
;
3225 BOOLEAN InstallOnFloppy
;
3228 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3230 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3232 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3234 DPRINT("Error: active partition invalid (unused)\n");
3235 InstallOnFloppy
= TRUE
;
3237 else if (PartitionType
== 0x0A)
3239 /* OS/2 boot manager partition */
3240 DPRINT("Found OS/2 boot manager partition\n");
3241 InstallOnFloppy
= TRUE
;
3243 else if (PartitionType
== 0x83)
3245 /* Linux ext2 partition */
3246 DPRINT("Found Linux ext2 partition\n");
3247 InstallOnFloppy
= TRUE
;
3249 else if (PartitionType
== PARTITION_IFS
)
3251 /* NTFS partition */
3252 DPRINT("Found NTFS partition\n");
3253 InstallOnFloppy
= TRUE
;
3255 else if ((PartitionType
== PARTITION_FAT_12
) ||
3256 (PartitionType
== PARTITION_FAT_16
) ||
3257 (PartitionType
== PARTITION_HUGE
) ||
3258 (PartitionType
== PARTITION_XINT13
) ||
3259 (PartitionType
== PARTITION_FAT32
) ||
3260 (PartitionType
== PARTITION_FAT32_XINT13
))
3262 DPRINT("Found FAT partition\n");
3263 InstallOnFloppy
= FALSE
;
3267 /* Unknown partition */
3268 DPRINT("Unknown partition found\n");
3269 InstallOnFloppy
= TRUE
;
3272 if (InstallOnFloppy
== TRUE
)
3274 return BOOT_LOADER_FLOPPY_PAGE
;
3277 if (IsUnattendedSetup
)
3279 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3281 return SUCCESS_PAGE
;
3283 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3285 return BOOT_LOADER_FLOPPY_PAGE
;
3287 else if (UnattendMBRInstallType
== 2) /* install on hdd */
3289 return BOOT_LOADER_HARDDISK_PAGE
;
3293 MUIDisplayPage(BOOT_LOADER_PAGE
);
3294 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3298 CONSOLE_ConInKey(Ir
);
3300 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3301 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3303 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3306 if (Line
<12) Line
=14;
3307 if (Line
>14) Line
=12;
3309 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3311 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3312 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3314 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3317 if (Line
<12) Line
=14;
3318 if (Line
>14) Line
=12;
3320 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3322 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3323 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3325 if (ConfirmQuit(Ir
) == TRUE
)
3330 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3334 return BOOT_LOADER_HARDDISK_PAGE
;
3336 else if (Line
== 13)
3338 return BOOT_LOADER_FLOPPY_PAGE
;
3340 else if (Line
== 14)
3342 return SUCCESS_PAGE
;;
3345 return BOOT_LOADER_PAGE
;
3349 return BOOT_LOADER_PAGE
;
3354 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3358 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3360 // SetStatusText(" Please wait...");
3364 CONSOLE_ConInKey(Ir
);
3366 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3367 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3369 if (ConfirmQuit(Ir
) == TRUE
)
3374 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3376 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3378 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3379 return BOOT_LOADER_FLOPPY_PAGE
;
3382 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3383 if (!NT_SUCCESS(Status
))
3385 /* Print error message */
3386 return BOOT_LOADER_FLOPPY_PAGE
;
3389 return SUCCESS_PAGE
;
3393 return BOOT_LOADER_FLOPPY_PAGE
;
3398 BootLoaderHarddiskPage(PINPUT_RECORD Ir
)
3400 UCHAR PartitionType
;
3403 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3404 if ((PartitionType
== PARTITION_FAT_12
) ||
3405 (PartitionType
== PARTITION_FAT_16
) ||
3406 (PartitionType
== PARTITION_HUGE
) ||
3407 (PartitionType
== PARTITION_XINT13
) ||
3408 (PartitionType
== PARTITION_FAT32
) ||
3409 (PartitionType
== PARTITION_FAT32_XINT13
))
3411 Status
= InstallFatBootcodeToPartition(&SystemRootPath
,
3413 &DestinationArcPath
,
3415 if (!NT_SUCCESS(Status
))
3417 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3421 return SUCCESS_PAGE
;
3425 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3429 return BOOT_LOADER_HARDDISK_PAGE
;
3434 QuitPage(PINPUT_RECORD Ir
)
3436 MUIDisplayPage(QUIT_PAGE
);
3438 /* Destroy partition list */
3439 if (PartitionList
!= NULL
)
3441 DestroyPartitionList (PartitionList
);
3442 PartitionList
= NULL
;
3445 /* Destroy filesystem list */
3446 if (FileSystemList
!= NULL
)
3448 DestroyFileSystemList (FileSystemList
);
3449 FileSystemList
= NULL
;
3452 /* Destroy computer settings list */
3453 if (ComputerList
!= NULL
)
3455 DestroyGenericList(ComputerList
, TRUE
);
3456 ComputerList
= NULL
;
3459 /* Destroy display settings list */
3460 if (DisplayList
!= NULL
)
3462 DestroyGenericList(DisplayList
, TRUE
);
3466 /* Destroy keyboard settings list */
3467 if (KeyboardList
!= NULL
)
3469 DestroyGenericList(KeyboardList
, TRUE
);
3470 KeyboardList
= NULL
;
3473 /* Destroy keyboard layout list */
3474 if (LayoutList
!= NULL
)
3476 DestroyGenericList(LayoutList
, TRUE
);
3480 if (LanguageList
!= NULL
)
3482 DestroyGenericList(LanguageList
, FALSE
);
3483 LanguageList
= NULL
;
3486 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3490 CONSOLE_ConInKey(Ir
);
3492 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3501 SuccessPage(PINPUT_RECORD Ir
)
3503 MUIDisplayPage(SUCCESS_PAGE
);
3505 if (IsUnattendedSetup
)
3512 CONSOLE_ConInKey(Ir
);
3514 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3523 FlushPage(PINPUT_RECORD Ir
)
3525 MUIDisplayPage(FLUSH_PAGE
);
3531 PnpEventThread(IN LPVOID lpParameter
);
3541 NtQuerySystemTime(&Time
);
3543 Status
= RtlCreateUserThread(NtCurrentProcess(), NULL
, TRUE
, 0, 0, 0, PnpEventThread
, &SetupInf
, &hPnpThread
, NULL
);
3544 if (!NT_SUCCESS(Status
))
3545 hPnpThread
= INVALID_HANDLE_VALUE
;
3547 if (!CONSOLE_Init())
3549 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3550 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3551 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3553 /* Raise a hard error (crash the system/BSOD) */
3554 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3558 /* Initialize global unicode strings */
3559 RtlInitUnicodeString(&SourcePath
, NULL
);
3560 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3561 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3562 RtlInitUnicodeString(&InstallPath
, NULL
);
3563 RtlInitUnicodeString(&DestinationPath
, NULL
);
3564 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3565 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3566 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3568 /* Hide the cursor */
3569 CONSOLE_SetCursorType(TRUE
, FALSE
);
3572 while (Page
!= REBOOT_PAGE
)
3574 CONSOLE_ClearScreen();
3577 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3584 Page
= SetupStartPage(&Ir
);
3589 Page
= LanguagePage(&Ir
);
3594 Page
= LicensePage(&Ir
);
3599 Page
= IntroPage(&Ir
);
3603 case INSTALL_INTRO_PAGE
:
3604 Page
= InstallIntroPage(&Ir
);
3608 case SCSI_CONTROLLER_PAGE
:
3609 Page
= ScsiControllerPage(&Ir
);
3614 case OEM_DRIVER_PAGE
:
3615 Page
= OemDriverPage(&Ir
);
3619 case DEVICE_SETTINGS_PAGE
:
3620 Page
= DeviceSettingsPage(&Ir
);
3623 case COMPUTER_SETTINGS_PAGE
:
3624 Page
= ComputerSettingsPage(&Ir
);
3627 case DISPLAY_SETTINGS_PAGE
:
3628 Page
= DisplaySettingsPage(&Ir
);
3631 case KEYBOARD_SETTINGS_PAGE
:
3632 Page
= KeyboardSettingsPage(&Ir
);
3635 case LAYOUT_SETTINGS_PAGE
:
3636 Page
= LayoutSettingsPage(&Ir
);
3639 case SELECT_PARTITION_PAGE
:
3640 Page
= SelectPartitionPage(&Ir
);
3643 case CREATE_PARTITION_PAGE
:
3644 Page
= CreatePartitionPage(&Ir
);
3647 case DELETE_PARTITION_PAGE
:
3648 Page
= DeletePartitionPage(&Ir
);
3651 case SELECT_FILE_SYSTEM_PAGE
:
3652 Page
= SelectFileSystemPage(&Ir
);
3655 case FORMAT_PARTITION_PAGE
:
3656 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3659 case CHECK_FILE_SYSTEM_PAGE
:
3660 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3663 case INSTALL_DIRECTORY_PAGE
:
3664 Page
= InstallDirectoryPage(&Ir
);
3667 case PREPARE_COPY_PAGE
:
3668 Page
= PrepareCopyPage(&Ir
);
3671 case FILE_COPY_PAGE
:
3672 Page
= FileCopyPage(&Ir
);
3676 Page
= RegistryPage(&Ir
);
3679 case BOOT_LOADER_PAGE
:
3680 Page
= BootLoaderPage(&Ir
);
3683 case BOOT_LOADER_FLOPPY_PAGE
:
3684 Page
= BootLoaderFloppyPage(&Ir
);
3687 case BOOT_LOADER_HARDDISK_PAGE
:
3688 Page
= BootLoaderHarddiskPage(&Ir
);
3692 case REPAIR_INTRO_PAGE
:
3693 Page
= RepairIntroPage(&Ir
);
3697 Page
= SuccessPage(&Ir
);
3701 Page
= FlushPage(&Ir
);
3705 Page
= QuitPage(&Ir
);
3713 /// THE FOLLOWING DPRINT IS FOR THE SYSTEM REGRESSION TOOL
3714 /// DO NOT REMOVE!!!
3715 DPRINT1("SYSREG_CHECKPOINT:USETUP_COMPLETE\n");
3719 /* Avoid bugcheck */
3720 Time
.QuadPart
+= 50000000;
3721 NtDelayExecution(FALSE
, &Time
);
3724 NtShutdownSystem(ShutdownReboot
);
3725 NtTerminateProcess(NtCurrentProcess(), 0);
3732 NtProcessStartup(PPEB Peb
)
3734 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3736 ProcessHeap
= Peb
->ProcessHeap
;
3737 INF_SetHeap(ProcessHeap
);
3740 #endif /* __REACTOS__ */