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 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
617 MUIDisplayPage(LANGUAGE_PAGE
);
621 CONSOLE_ConInKey(Ir
);
623 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
624 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
627 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
629 /* Redraw language selection page in native language */
630 MUIDisplayPage(LANGUAGE_PAGE
);
633 ScrollDownGenericList (LanguageList
);
635 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
636 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
639 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
641 /* Redraw language selection page in native language */
642 MUIDisplayPage(LANGUAGE_PAGE
);
645 ScrollUpGenericList (LanguageList
);
647 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
648 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
650 ScrollPageDownGenericList (LanguageList
);
652 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
653 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
655 ScrollPageUpGenericList (LanguageList
);
657 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
658 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
660 if (ConfirmQuit(Ir
) == TRUE
)
663 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
665 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
667 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
673 SetConsoleCodePage();
677 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
680 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
691 * Number of the next page.
694 SetupStartPage(PINPUT_RECORD Ir
)
696 SYSTEM_DEVICE_INFORMATION Sdi
;
698 WCHAR FileNameBuffer
[MAX_PATH
];
704 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
707 /* Check whether a harddisk is available */
708 Status
= NtQuerySystemInformation (SystemDeviceInformation
,
710 sizeof(SYSTEM_DEVICE_INFORMATION
),
713 if (!NT_SUCCESS (Status
))
715 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
716 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
720 if (Sdi
.NumberOfDisks
== 0)
722 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
726 /* Get the source path and source root path */
727 Status
= GetSourcePaths(&SourcePath
,
731 if (!NT_SUCCESS(Status
))
733 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
734 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
740 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
741 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
742 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
746 /* Load txtsetup.sif from install media. */
747 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
748 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
750 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
755 if (SetupInf
== INVALID_HANDLE_VALUE
)
757 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
761 /* Open 'Version' section */
762 if (!SetupFindFirstLineW (SetupInf
, L
"Version", L
"Signature", &Context
))
764 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
768 /* Get pointer 'Signature' key */
769 if (!INF_GetData (&Context
, NULL
, &Value
))
771 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
775 /* Check 'Signature' string */
776 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
778 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
782 /* Start PnP thread */
783 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
785 NtResumeThread(hPnpThread
, NULL
);
786 hPnpThread
= INVALID_HANDLE_VALUE
;
789 CheckUnattendedSetup();
791 if (IsUnattendedSetup
)
794 //read options from inf
795 ComputerList
= CreateComputerTypeList(SetupInf
);
796 DisplayList
= CreateDisplayDriverList(SetupInf
);
797 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
798 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
799 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
801 return INSTALL_INTRO_PAGE
;
804 return LANGUAGE_PAGE
;
814 IntroPage(PINPUT_RECORD Ir
)
816 MUIDisplayPage(START_PAGE
);
820 CONSOLE_ConInKey(Ir
);
822 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
823 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
825 if (ConfirmQuit(Ir
) == TRUE
)
830 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
832 return INSTALL_INTRO_PAGE
;
835 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
837 return REPAIR_INTRO_PAGE
;
840 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
853 * Back to main setup page.
856 LicensePage(PINPUT_RECORD Ir
)
858 MUIDisplayPage(LICENSE_PAGE
);
862 CONSOLE_ConInKey(Ir
);
864 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
875 RepairIntroPage(PINPUT_RECORD Ir
)
877 MUIDisplayPage(REPAIR_INTRO_PAGE
);
881 CONSOLE_ConInKey(Ir
);
883 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
887 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
889 RepairUpdateFlag
= TRUE
;
890 return INSTALL_INTRO_PAGE
;
892 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
896 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
897 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
903 return REPAIR_INTRO_PAGE
;
908 InstallIntroPage(PINPUT_RECORD Ir
)
910 MUIDisplayPage(INSTALL_INTRO_PAGE
);
912 if (RepairUpdateFlag
)
914 //return SELECT_PARTITION_PAGE;
915 return DEVICE_SETTINGS_PAGE
;
918 if (IsUnattendedSetup
)
920 return SELECT_PARTITION_PAGE
;
925 CONSOLE_ConInKey(Ir
);
927 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
928 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
930 if (ConfirmQuit(Ir
) == TRUE
)
935 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
937 return DEVICE_SETTINGS_PAGE
;
938 // return SCSI_CONTROLLER_PAGE;
942 return INSTALL_INTRO_PAGE
;
948 ScsiControllerPage(PINPUT_RECORD Ir
)
950 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
952 /* FIXME: print loaded mass storage driver descriptions */
954 SetTextXY(8, 10, "TEST device");
958 SetStatusText(" ENTER = Continue F3 = Quit");
964 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
965 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
967 if (ConfirmQuit(Ir
) == TRUE
)
972 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
974 return DEVICE_SETTINGS_PAGE
;
978 return SCSI_CONTROLLER_PAGE
;
984 DeviceSettingsPage(PINPUT_RECORD Ir
)
986 static ULONG Line
= 16;
987 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
989 /* Initialize the computer settings list */
990 if (ComputerList
== NULL
)
992 ComputerList
= CreateComputerTypeList(SetupInf
);
993 if (ComputerList
== NULL
)
995 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1000 /* Initialize the display settings list */
1001 if (DisplayList
== NULL
)
1003 DisplayList
= CreateDisplayDriverList(SetupInf
);
1004 if (DisplayList
== NULL
)
1006 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1011 /* Initialize the keyboard settings list */
1012 if (KeyboardList
== NULL
)
1014 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1015 if (KeyboardList
== NULL
)
1017 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1022 /* Initialize the keyboard layout list */
1023 if (LayoutList
== NULL
)
1025 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1026 if (LayoutList
== NULL
)
1028 /* FIXME: report error */
1029 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1034 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1037 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1038 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1039 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1040 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1042 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1044 if (RepairUpdateFlag
)
1046 return SELECT_PARTITION_PAGE
;
1051 CONSOLE_ConInKey(Ir
);
1053 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1054 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1056 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1060 else if (Line
== 16)
1065 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1067 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1068 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1070 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1074 else if (Line
== 16)
1079 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1081 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1082 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1084 if (ConfirmQuit(Ir
) == TRUE
)
1089 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1092 return COMPUTER_SETTINGS_PAGE
;
1093 else if (Line
== 12)
1094 return DISPLAY_SETTINGS_PAGE
;
1095 else if (Line
== 13)
1096 return KEYBOARD_SETTINGS_PAGE
;
1097 else if (Line
== 14)
1098 return LAYOUT_SETTINGS_PAGE
;
1099 else if (Line
== 16)
1100 return SELECT_PARTITION_PAGE
;
1104 return DEVICE_SETTINGS_PAGE
;
1109 ComputerSettingsPage(PINPUT_RECORD Ir
)
1111 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1113 DrawGenericList(ComputerList
,
1119 SaveGenericListState(ComputerList
);
1123 CONSOLE_ConInKey(Ir
);
1125 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1126 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1128 ScrollDownGenericList (ComputerList
);
1130 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1131 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1133 ScrollUpGenericList (ComputerList
);
1135 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1136 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1138 if (ConfirmQuit(Ir
) == TRUE
)
1143 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1144 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1146 RestoreGenericListState(ComputerList
);
1147 return DEVICE_SETTINGS_PAGE
;
1149 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1151 return DEVICE_SETTINGS_PAGE
;
1155 return COMPUTER_SETTINGS_PAGE
;
1160 DisplaySettingsPage(PINPUT_RECORD Ir
)
1162 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1164 DrawGenericList(DisplayList
,
1170 SaveGenericListState(DisplayList
);
1174 CONSOLE_ConInKey(Ir
);
1176 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1177 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1179 ScrollDownGenericList (DisplayList
);
1181 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1182 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1184 ScrollUpGenericList (DisplayList
);
1186 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1187 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1189 if (ConfirmQuit(Ir
) == TRUE
)
1196 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1197 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1199 RestoreGenericListState(DisplayList
);
1200 return DEVICE_SETTINGS_PAGE
;
1202 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1204 return DEVICE_SETTINGS_PAGE
;
1208 return DISPLAY_SETTINGS_PAGE
;
1213 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1215 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1217 DrawGenericList(KeyboardList
,
1223 SaveGenericListState(KeyboardList
);
1227 CONSOLE_ConInKey(Ir
);
1229 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1230 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1232 ScrollDownGenericList (KeyboardList
);
1234 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1235 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1237 ScrollUpGenericList (KeyboardList
);
1239 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1240 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1242 if (ConfirmQuit(Ir
) == TRUE
)
1247 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1248 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1250 RestoreGenericListState(KeyboardList
);
1251 return DEVICE_SETTINGS_PAGE
;
1253 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1255 return DEVICE_SETTINGS_PAGE
;
1259 return DISPLAY_SETTINGS_PAGE
;
1264 LayoutSettingsPage(PINPUT_RECORD Ir
)
1266 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1268 DrawGenericList(LayoutList
,
1274 SaveGenericListState(LayoutList
);
1278 CONSOLE_ConInKey(Ir
);
1280 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1281 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1283 ScrollDownGenericList (LayoutList
);
1285 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1286 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1288 ScrollUpGenericList (LayoutList
);
1290 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1291 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1293 ScrollPageDownGenericList (LayoutList
);
1295 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1296 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1298 ScrollPageUpGenericList (LayoutList
);
1300 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1301 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1303 if (ConfirmQuit(Ir
) == TRUE
)
1308 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1309 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1311 RestoreGenericListState(LayoutList
);
1312 return DEVICE_SETTINGS_PAGE
;
1314 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1316 return DEVICE_SETTINGS_PAGE
;
1318 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1321 GenericListKeyPress (LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1325 return DISPLAY_SETTINGS_PAGE
;
1330 SelectPartitionPage(PINPUT_RECORD Ir
)
1332 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1334 if (PartitionList
== NULL
)
1336 PartitionList
= CreatePartitionList (2,
1341 if (PartitionList
== NULL
)
1343 /* FIXME: show an error dialog */
1348 CheckActiveBootPartition (PartitionList
);
1350 DrawPartitionList (PartitionList
);
1352 /* Warn about partitions created by Linux Fdisk */
1353 if (WarnLinuxPartitions
== TRUE
&&
1354 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1356 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1360 CONSOLE_ConInKey(Ir
);
1362 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1363 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1367 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1369 WarnLinuxPartitions
= FALSE
;
1370 return SELECT_PARTITION_PAGE
;
1375 if (IsUnattendedSetup
)
1377 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1381 PPARTENTRY PartEntry
= PartEntry
= PartitionList
->CurrentPartition
;
1382 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1384 CreateNewPartition(PartitionList
,
1388 return (SELECT_FILE_SYSTEM_PAGE
);
1393 return(SELECT_FILE_SYSTEM_PAGE
);
1399 /* Update status text */
1400 if (PartitionList
->CurrentPartition
== NULL
||
1401 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1403 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1407 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1410 CONSOLE_ConInKey(Ir
);
1412 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1413 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1415 if (ConfirmQuit(Ir
) == TRUE
)
1417 DestroyPartitionList (PartitionList
);
1418 PartitionList
= NULL
;
1424 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1425 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1427 ScrollDownPartitionList (PartitionList
);
1429 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1430 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1432 ScrollUpPartitionList (PartitionList
);
1434 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1436 if (PartitionList
->CurrentPartition
== NULL
||
1437 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1439 CreateNewPartition (PartitionList
,
1444 return SELECT_FILE_SYSTEM_PAGE
;
1446 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1448 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1450 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1451 return SELECT_PARTITION_PAGE
;
1454 return CREATE_PARTITION_PAGE
;
1456 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1458 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1460 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1461 return SELECT_PARTITION_PAGE
;
1464 return DELETE_PARTITION_PAGE
;
1468 return SELECT_PARTITION_PAGE
;
1473 DrawInputField(ULONG FieldLength
,
1484 memset(buf
, '_', sizeof(buf
));
1485 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1486 strcat(buf
, FieldContent
);
1488 WriteConsoleOutputCharacterA (StdOutput
,
1496 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1497 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1498 #define PARTITION_MAXSIZE 999999
1501 ShowPartitionSizeInputBox(SHORT Left
,
1525 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1530 strcpy (Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1531 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
1534 WriteConsoleOutputCharacterA(StdOutput
,
1540 sprintf (Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1541 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1543 WriteConsoleOutputCharacterA(StdOutput
,
1549 sprintf(Buffer
, "%lu", MaxSize
);
1550 Index
= strlen(Buffer
);
1551 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1558 CONSOLE_ConInKey(&Ir
);
1560 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1561 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1569 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1573 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1581 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1587 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1592 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1593 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1595 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1597 if ((ch
>= '0') && (ch
<= '9'))
1603 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1611 strcpy (InputBuffer
, Buffer
);
1616 CreatePartitionPage (PINPUT_RECORD Ir
)
1618 PDISKENTRY DiskEntry
;
1619 PPARTENTRY PartEntry
;
1622 CHAR InputBuffer
[50];
1628 if (PartitionList
== NULL
||
1629 PartitionList
->CurrentDisk
== NULL
||
1630 PartitionList
->CurrentPartition
== NULL
)
1632 /* FIXME: show an error dialog */
1636 DiskEntry
= PartitionList
->CurrentDisk
;
1637 PartEntry
= PartitionList
->CurrentPartition
;
1639 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1641 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1644 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1646 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1647 Unit
= MUIGetString(STRING_GB
);
1652 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1657 Unit
= MUIGetString(STRING_MB
);
1660 if (DiskEntry
->DriverName
.Length
> 0)
1662 CONSOLE_PrintTextXY(6, 10,
1663 MUIGetString(STRING_HDINFOPARTCREATE
),
1666 DiskEntry
->DiskNumber
,
1670 &DiskEntry
->DriverName
);
1674 CONSOLE_PrintTextXY(6, 10,
1675 MUIGetString(STRING_HDDINFOUNK1
),
1678 DiskEntry
->DiskNumber
,
1684 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1687 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1688 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1691 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1693 PartEntry
= PartitionList
->CurrentPartition
;
1696 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1698 if (MaxSize
> PARTITION_MAXSIZE
) MaxSize
= PARTITION_MAXSIZE
;
1700 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1701 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1705 if (ConfirmQuit (Ir
) == TRUE
)
1710 else if (Cancel
== TRUE
)
1712 return SELECT_PARTITION_PAGE
;
1716 PartSize
= atoi(InputBuffer
);
1724 if (PartSize
> MaxSize
)
1730 /* Convert to bytes */
1731 if (PartSize
== MaxSize
)
1733 /* Use all of the unpartitioned disk space */
1734 PartSize
= PartEntry
->UnpartitionedLength
;
1738 /* Round-up by cylinder size */
1739 PartSize
= ROUND_UP (PartSize
* 1024 * 1024,
1740 DiskEntry
->CylinderSize
);
1742 /* But never get larger than the unpartitioned disk space */
1743 if (PartSize
> PartEntry
->UnpartitionedLength
)
1744 PartSize
= PartEntry
->UnpartitionedLength
;
1747 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1749 CreateNewPartition (PartitionList
,
1753 return SELECT_PARTITION_PAGE
;
1757 return CREATE_PARTITION_PAGE
;
1762 DeletePartitionPage (PINPUT_RECORD Ir
)
1764 PDISKENTRY DiskEntry
;
1765 PPARTENTRY PartEntry
;
1771 if (PartitionList
== NULL
||
1772 PartitionList
->CurrentDisk
== NULL
||
1773 PartitionList
->CurrentPartition
== NULL
)
1775 /* FIXME: show an error dialog */
1779 DiskEntry
= PartitionList
->CurrentDisk
;
1780 PartEntry
= PartitionList
->CurrentPartition
;
1782 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1784 /* Determine partition type */
1786 if (PartEntry
->New
== TRUE
)
1788 PartType
= MUIGetString(STRING_UNFORMATTED
);
1790 else if (PartEntry
->Unpartitioned
== FALSE
)
1792 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1793 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1794 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1795 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1799 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1800 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1804 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_EXT2
)
1808 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1810 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1815 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1817 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1818 Unit
= MUIGetString(STRING_GB
);
1822 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1824 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1825 Unit
= MUIGetString(STRING_MB
);
1829 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1830 Unit
= MUIGetString(STRING_KB
);
1833 if (PartType
== NULL
)
1835 CONSOLE_PrintTextXY(6, 10,
1836 MUIGetString(STRING_HDDINFOUNK2
),
1837 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1838 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1839 PartEntry
->PartInfo
[0].PartitionType
,
1845 CONSOLE_PrintTextXY(6, 10,
1846 " %c%c %s %I64u %s",
1847 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1848 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1855 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1857 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1858 Unit
= MUIGetString(STRING_GB
);
1863 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1868 Unit
= MUIGetString(STRING_MB
);
1871 if (DiskEntry
->DriverName
.Length
> 0)
1873 CONSOLE_PrintTextXY(6, 12,
1874 MUIGetString(STRING_HDINFOPARTDELETE
),
1877 DiskEntry
->DiskNumber
,
1881 &DiskEntry
->DriverName
);
1885 CONSOLE_PrintTextXY(6, 12,
1886 MUIGetString(STRING_HDDINFOUNK3
),
1889 DiskEntry
->DiskNumber
,
1897 CONSOLE_ConInKey(Ir
);
1899 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1900 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1902 if (ConfirmQuit (Ir
) == TRUE
)
1909 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1911 return SELECT_PARTITION_PAGE
;
1913 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1915 DeleteCurrentPartition (PartitionList
);
1917 return SELECT_PARTITION_PAGE
;
1921 return DELETE_PARTITION_PAGE
;
1926 SelectFileSystemPage (PINPUT_RECORD Ir
)
1928 PDISKENTRY DiskEntry
;
1929 PPARTENTRY PartEntry
;
1936 if (PartitionList
== NULL
||
1937 PartitionList
->CurrentDisk
== NULL
||
1938 PartitionList
->CurrentPartition
== NULL
)
1940 /* FIXME: show an error dialog */
1944 DiskEntry
= PartitionList
->CurrentDisk
;
1945 PartEntry
= PartitionList
->CurrentPartition
;
1947 /* adjust disk size */
1948 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1950 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1951 DiskUnit
= MUIGetString(STRING_GB
);
1955 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1956 DiskUnit
= MUIGetString(STRING_MB
);
1959 /* adjust partition size */
1960 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1962 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1963 PartUnit
= MUIGetString(STRING_GB
);
1967 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1968 PartUnit
= MUIGetString(STRING_MB
);
1971 /* adjust partition type */
1972 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1973 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1974 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1975 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1979 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1980 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1984 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_EXT2
)
1988 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1990 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1992 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
1994 PartType
= MUIGetString(STRING_FORMATUNUSED
);
1998 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2001 if (PartEntry
->AutoCreate
== TRUE
)
2003 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2006 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2007 PartEntry
->PartInfo
[0].PartitionNumber
,
2013 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2014 DiskEntry
->DiskNumber
,
2020 &DiskEntry
->DriverName
);
2022 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2025 PartEntry
->AutoCreate
= FALSE
;
2027 else if (PartEntry
->New
== TRUE
)
2029 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2030 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2034 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2036 if (PartType
== NULL
)
2038 CONSOLE_PrintTextXY(8, 10,
2039 MUIGetString(STRING_HDDINFOUNK4
),
2040 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2041 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2042 PartEntry
->PartInfo
[0].PartitionType
,
2048 CONSOLE_PrintTextXY(8, 10,
2050 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2051 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2057 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2058 DiskEntry
->DiskNumber
,
2064 &DiskEntry
->DriverName
);
2067 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2069 if (FileSystemList
== NULL
)
2071 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, L
"FAT");
2072 if (FileSystemList
== NULL
)
2074 /* FIXME: show an error dialog */
2078 /* FIXME: Add file systems to list */
2080 DrawFileSystemList (FileSystemList
);
2082 if (RepairUpdateFlag
)
2084 return CHECK_FILE_SYSTEM_PAGE
;
2085 //return SELECT_PARTITION_PAGE;
2088 if (IsUnattendedSetup
)
2090 if (UnattendFormatPartition
)
2092 return FORMAT_PARTITION_PAGE
;
2095 return(CHECK_FILE_SYSTEM_PAGE
);
2100 CONSOLE_ConInKey(Ir
);
2102 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2103 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2105 if (ConfirmQuit (Ir
) == TRUE
)
2112 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2113 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2115 return SELECT_PARTITION_PAGE
;
2117 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2118 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2120 ScrollDownFileSystemList (FileSystemList
);
2122 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2123 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2125 ScrollUpFileSystemList (FileSystemList
);
2127 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2129 if (!FileSystemList
->Selected
->FormatFunc
)
2131 return CHECK_FILE_SYSTEM_PAGE
;
2135 return FORMAT_PARTITION_PAGE
;
2140 return SELECT_FILE_SYSTEM_PAGE
;
2145 FormatPartitionPage (PINPUT_RECORD Ir
)
2147 WCHAR PathBuffer
[MAX_PATH
];
2148 PDISKENTRY DiskEntry
;
2149 PPARTENTRY PartEntry
;
2158 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2160 if (PartitionList
== NULL
||
2161 PartitionList
->CurrentDisk
== NULL
||
2162 PartitionList
->CurrentPartition
== NULL
)
2164 /* FIXME: show an error dialog */
2168 DiskEntry
= PartitionList
->CurrentDisk
;
2169 PartEntry
= PartitionList
->CurrentPartition
;
2173 if (!IsUnattendedSetup
)
2175 CONSOLE_ConInKey(Ir
);
2178 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2179 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2181 if (ConfirmQuit (Ir
) == TRUE
)
2188 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2190 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2192 if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
2194 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2196 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2198 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2199 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_12
;
2201 else if (PartEntry
->PartInfo
[0].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2203 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2205 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2207 /* FAT16 CHS partition (partiton size < 32MB) */
2208 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_16
;
2210 else if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2212 /* FAT16 CHS partition (partition size < 512MB) */
2213 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_HUGE
;
2217 /* FAT32 CHS partition (partition size >= 512MB) */
2218 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32
;
2223 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2225 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2227 /* FAT16 LBA partition (partition size < 512MB) */
2228 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_XINT13
;
2232 /* FAT32 LBA partition (partition size >= 512MB) */
2233 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32_XINT13
;
2237 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2238 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_EXT2
;
2239 else if (!FileSystemList
->Selected
->FormatFunc
)
2243 CheckActiveBootPartition (PartitionList
);
2246 CONSOLE_PrintTextXY(6, 12,
2247 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2248 DiskEntry
->DiskSize
,
2249 DiskEntry
->CylinderSize
,
2250 DiskEntry
->TrackSize
);
2253 DiskEntry
= PartitionList
->CurrentDisk
;
2254 Entry
= DiskEntry
->PartListHead
.Flink
;
2256 while (Entry
!= &DiskEntry
->PartListHead
)
2258 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2260 if (PartEntry
->Unpartitioned
== FALSE
)
2262 for (i
= 0; i
< 4; i
++)
2264 CONSOLE_PrintTextXY(6, Line
,
2265 "%2u: %2u %c %12I64u %12I64u %2u %c",
2267 PartEntry
->PartInfo
[i
].PartitionNumber
,
2268 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2269 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2270 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2271 PartEntry
->PartInfo
[i
].PartitionType
,
2272 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2280 Entry
= Entry
->Flink
;
2283 /* Restore the old entry */
2284 PartEntry
= PartitionList
->CurrentPartition
;
2287 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
2289 DPRINT ("WritePartitionsToDisk() failed\n");
2290 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2294 /* Set DestinationRootPath */
2295 RtlFreeUnicodeString (&DestinationRootPath
);
2296 swprintf (PathBuffer
,
2297 L
"\\Device\\Harddisk%lu\\Partition%lu",
2298 PartitionList
->CurrentDisk
->DiskNumber
,
2299 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2300 RtlCreateUnicodeString (&DestinationRootPath
,
2302 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2305 /* Set SystemRootPath */
2306 RtlFreeUnicodeString (&SystemRootPath
);
2307 swprintf (PathBuffer
,
2308 L
"\\Device\\Harddisk%lu\\Partition%lu",
2309 PartitionList
->ActiveBootDisk
->DiskNumber
,
2310 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2311 RtlCreateUnicodeString (&SystemRootPath
,
2313 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
2316 if (FileSystemList
->Selected
->FormatFunc
)
2318 Status
= FormatPartition(&DestinationRootPath
, FileSystemList
->Selected
);
2319 if (!NT_SUCCESS(Status
))
2321 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2322 /* FIXME: show an error dialog */
2326 PartEntry
->New
= FALSE
;
2328 CheckActiveBootPartition(PartitionList
);
2331 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2333 /* FIXME: Install boot code. This is a hack! */
2334 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
) ||
2335 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
))
2337 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2338 wcscat(PathBuffer
, L
"\\loader\\fat32.bin");
2340 DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
2341 DestinationRootPath
.Buffer
);
2342 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2343 DestinationRootPath
.Buffer
);
2345 if (!NT_SUCCESS(Status
))
2347 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2348 /* FIXME: show an error dialog */
2349 DestroyFileSystemList(FileSystemList
);
2350 FileSystemList
= NULL
;
2356 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2357 wcscat(PathBuffer
, L
"\\loader\\fat.bin");
2359 DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer
,
2360 DestinationRootPath
.Buffer
);
2361 Status
= InstallFat16BootCodeToDisk(PathBuffer
,
2362 DestinationRootPath
.Buffer
);
2364 if (!NT_SUCCESS(Status
))
2366 DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status
);
2367 /* FIXME: show an error dialog */
2368 DestroyFileSystemList(FileSystemList
);
2369 FileSystemList
= NULL
;
2374 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2376 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2377 wcscat(PathBuffer
, L
"\\loader\\ext2.bin");
2379 DPRINT("Install EXT2 bootcode: %S ==> %S\n", PathBuffer
,
2380 DestinationRootPath
.Buffer
);
2381 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2382 DestinationRootPath
.Buffer
);
2384 if (!NT_SUCCESS(Status
))
2386 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2387 /* FIXME: show an error dialog */
2388 DestroyFileSystemList(FileSystemList
);
2389 FileSystemList
= NULL
;
2393 else if (FileSystemList
->Selected
->FormatFunc
)
2395 DestroyFileSystemList(FileSystemList
);
2396 FileSystemList
= NULL
;
2401 CONSOLE_SetStatusText(" Done. Press any key ...");
2402 CONSOLE_ConInKey(Ir
);
2405 DestroyFileSystemList(FileSystemList
);
2406 FileSystemList
= NULL
;
2407 return INSTALL_DIRECTORY_PAGE
;
2411 return FORMAT_PARTITION_PAGE
;
2416 CheckFileSystemPage(PINPUT_RECORD Ir
)
2418 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2419 WCHAR PathBuffer
[MAX_PATH
];
2420 CHAR Buffer
[MAX_PATH
];
2423 /* FIXME: code duplicated in FormatPartitionPage */
2424 /* Set DestinationRootPath */
2425 RtlFreeUnicodeString(&DestinationRootPath
);
2426 swprintf(PathBuffer
,
2427 L
"\\Device\\Harddisk%lu\\Partition%lu",
2428 PartitionList
->CurrentDisk
->DiskNumber
,
2429 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2430 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2431 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2433 /* Set SystemRootPath */
2434 RtlFreeUnicodeString(&SystemRootPath
);
2435 swprintf(PathBuffer
,
2436 L
"\\Device\\Harddisk%lu\\Partition%lu",
2437 PartitionList
->ActiveBootDisk
->DiskNumber
,
2438 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2439 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2440 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2442 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2444 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2446 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2447 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2449 if (!CurrentFileSystem
->ChkdskFunc
)
2452 "Setup is currently unable to check a partition formatted in %S.\n"
2454 " \x07 Press ENTER to continue Setup.\n"
2455 " \x07 Press F3 to quit Setup.",
2456 CurrentFileSystem
->FileSystem
);
2459 MUIGetString(STRING_QUITCONTINUE
),
2460 NULL
, POPUP_WAIT_NONE
);
2464 CONSOLE_ConInKey(Ir
);
2466 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2467 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2469 if (ConfirmQuit(Ir
))
2472 return CHECK_FILE_SYSTEM_PAGE
;
2474 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2476 return INSTALL_DIRECTORY_PAGE
;
2482 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2483 if (!NT_SUCCESS(Status
))
2485 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2486 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2487 "(Status 0x%08lx).\n", Status
);
2490 MUIGetString(STRING_REBOOTCOMPUTER
),
2491 Ir
, POPUP_WAIT_ENTER
);
2496 return INSTALL_DIRECTORY_PAGE
;
2502 InstallDirectoryPage1(PWCHAR InstallDir
, PDISKENTRY DiskEntry
, PPARTENTRY PartEntry
)
2504 WCHAR PathBuffer
[MAX_PATH
];
2506 /* Create 'InstallPath' string */
2507 RtlFreeUnicodeString(&InstallPath
);
2508 RtlCreateUnicodeString(&InstallPath
,
2511 /* Create 'DestinationPath' string */
2512 RtlFreeUnicodeString(&DestinationPath
);
2513 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2515 if (InstallDir
[0] != L
'\\')
2516 wcscat(PathBuffer
, L
"\\");
2518 wcscat(PathBuffer
, InstallDir
);
2519 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2521 /* Create 'DestinationArcPath' */
2522 RtlFreeUnicodeString(&DestinationArcPath
);
2523 swprintf(PathBuffer
,
2524 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2525 DiskEntry
->BiosDiskNumber
,
2526 PartEntry
->PartInfo
[0].PartitionNumber
);
2528 if (InstallDir
[0] != L
'\\')
2529 wcscat(PathBuffer
, L
"\\");
2531 wcscat(PathBuffer
, InstallDir
);
2532 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2534 return(PREPARE_COPY_PAGE
);
2539 InstallDirectoryPage(PINPUT_RECORD Ir
)
2541 PDISKENTRY DiskEntry
;
2542 PPARTENTRY PartEntry
;
2543 WCHAR InstallDir
[51];
2548 if (PartitionList
== NULL
||
2549 PartitionList
->CurrentDisk
== NULL
||
2550 PartitionList
->CurrentPartition
== NULL
)
2552 /* FIXME: show an error dialog */
2556 DiskEntry
= PartitionList
->CurrentDisk
;
2557 PartEntry
= PartitionList
->CurrentPartition
;
2559 /* Search for 'DefaultPath' in the 'SetupData' section */
2560 if (!SetupFindFirstLineW (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2562 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2566 /* Read the 'DefaultPath' data */
2567 if (INF_GetData (&Context
, NULL
, &DefaultPath
))
2569 wcscpy(InstallDir
, DefaultPath
);
2573 wcscpy(InstallDir
, L
"\\ReactOS");
2576 Length
= wcslen(InstallDir
);
2577 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2578 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2580 if (IsUnattendedSetup
)
2582 return(InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2587 CONSOLE_ConInKey(Ir
);
2589 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2590 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2592 if (ConfirmQuit(Ir
) == TRUE
)
2597 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2599 return (InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2601 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2606 InstallDir
[Length
] = 0;
2607 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2610 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2614 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2616 InstallDir
[Length
] = 0;
2617 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2622 return(INSTALL_DIRECTORY_PAGE
);
2626 AddSectionToCopyQueueCab(HINF InfFile
,
2628 PWCHAR SourceCabinet
,
2629 PCUNICODE_STRING DestinationPath
,
2632 INFCONTEXT FilesContext
;
2633 INFCONTEXT DirContext
;
2635 PWCHAR FileKeyValue
;
2637 PWCHAR TargetFileName
;
2639 /* Search for the SectionName section */
2640 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2643 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2644 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2649 * Enumerate the files in the section
2650 * and add them to the file queue.
2654 /* Get source file name and target directory id */
2655 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2657 /* FIXME: Handle error! */
2658 DPRINT1("INF_GetData() failed\n");
2662 /* Get optional target file name */
2663 if (!INF_GetDataField (&FilesContext
, 2, &TargetFileName
))
2664 TargetFileName
= NULL
;
2666 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2668 /* Lookup target directory */
2669 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2671 /* FIXME: Handle error! */
2672 DPRINT1("SetupFindFirstLine() failed\n");
2676 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2678 /* FIXME: Handle error! */
2679 DPRINT1("INF_GetData() failed\n");
2683 if (!SetupQueueCopy(SetupFileQueue
,
2685 SourceRootPath
.Buffer
,
2686 SourceRootDir
.Buffer
,
2691 /* FIXME: Handle error! */
2692 DPRINT1("SetupQueueCopy() failed\n");
2694 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2700 AddSectionToCopyQueue(HINF InfFile
,
2702 PWCHAR SourceCabinet
,
2703 PCUNICODE_STRING DestinationPath
,
2706 INFCONTEXT FilesContext
;
2707 INFCONTEXT DirContext
;
2709 PWCHAR FileKeyValue
;
2711 PWCHAR TargetFileName
;
2714 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2716 /* Search for the SectionName section */
2717 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2720 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2721 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2726 * Enumerate the files in the section
2727 * and add them to the file queue.
2731 /* Get source file name and target directory id */
2732 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2734 /* FIXME: Handle error! */
2735 DPRINT1("INF_GetData() failed\n");
2739 /* Get target directory id */
2740 if (!INF_GetDataField (&FilesContext
, 13, &FileKeyValue
))
2742 /* FIXME: Handle error! */
2743 DPRINT1("INF_GetData() failed\n");
2747 /* Get optional target file name */
2748 if (!INF_GetDataField (&FilesContext
, 11, &TargetFileName
))
2749 TargetFileName
= NULL
;
2750 else if (!*TargetFileName
)
2751 TargetFileName
= NULL
;
2753 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2755 /* Lookup target directory */
2756 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2758 /* FIXME: Handle error! */
2759 DPRINT1("SetupFindFirstLine() failed\n");
2763 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2765 /* FIXME: Handle error! */
2766 DPRINT1("INF_GetData() failed\n");
2770 if (!SetupQueueCopy(SetupFileQueue
,
2772 SourceRootPath
.Buffer
,
2773 SourceRootDir
.Buffer
,
2778 /* FIXME: Handle error! */
2779 DPRINT1("SetupQueueCopy() failed\n");
2781 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2787 PrepareCopyPageInfFile(HINF InfFile
,
2788 PWCHAR SourceCabinet
,
2791 WCHAR PathBuffer
[MAX_PATH
];
2792 INFCONTEXT DirContext
;
2793 PWCHAR AdditionalSectionName
= NULL
;
2798 /* Add common files */
2799 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2802 /* Add specific files depending of computer type */
2803 if (SourceCabinet
== NULL
)
2805 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2808 if (AdditionalSectionName
)
2810 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2815 /* Create directories */
2819 * Install directories like '\reactos\test' are not handled yet.
2822 /* Get destination path */
2823 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2825 /* Remove trailing backslash */
2826 Length
= wcslen(PathBuffer
);
2827 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2829 PathBuffer
[Length
- 1] = 0;
2832 /* Create the install directory */
2833 Status
= SetupCreateDirectory(PathBuffer
);
2834 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2836 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2837 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2841 /* Search for the 'Directories' section */
2842 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2846 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2850 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2856 /* Enumerate the directory values and create the subdirectories */
2859 if (!INF_GetData (&DirContext
, NULL
, &KeyValue
))
2865 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2867 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2869 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2870 wcscat(PathBuffer
, KeyValue
);
2872 DPRINT("FullPath: '%S'\n", PathBuffer
);
2874 else if (KeyValue
[0] != L
'\\')
2876 DPRINT("RelativePath: '%S'\n", KeyValue
);
2877 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2878 wcscat(PathBuffer
, L
"\\");
2879 wcscat(PathBuffer
, KeyValue
);
2881 DPRINT("FullPath: '%S'\n", PathBuffer
);
2883 Status
= SetupCreateDirectory(PathBuffer
);
2884 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2886 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2887 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2891 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2897 PrepareCopyPage(PINPUT_RECORD Ir
)
2900 WCHAR PathBuffer
[MAX_PATH
];
2901 INFCONTEXT CabinetsContext
;
2907 MUIDisplayPage(PREPARE_COPY_PAGE
);
2909 /* Create the file queue */
2910 SetupFileQueue
= SetupOpenFileQueue();
2911 if (SetupFileQueue
== NULL
)
2913 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2917 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2922 /* Search for the 'Cabinets' section */
2923 if (!SetupFindFirstLineW (SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2925 return FILE_COPY_PAGE
;
2929 * Enumerate the directory values in the 'Cabinets'
2930 * section and parse their inf files.
2934 if (!INF_GetData (&CabinetsContext
, NULL
, &KeyValue
))
2937 wcscpy(PathBuffer
, SourcePath
.Buffer
);
2938 wcscat(PathBuffer
, L
"\\");
2939 wcscat(PathBuffer
, KeyValue
);
2942 CabinetInitialize();
2943 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
2944 CabinetSetCabinetName(PathBuffer
);
2946 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
2948 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
2950 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
2951 if (InfFileData
== NULL
)
2953 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
2959 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
2960 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
2964 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
2970 if (InfHandle
== INVALID_HANDLE_VALUE
)
2972 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
2978 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
2983 } while (SetupFindNextLine (&CabinetsContext
, &CabinetsContext
));
2985 return FILE_COPY_PAGE
;
2990 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
2993 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
2995 /* Get the memory information from the system */
2996 NtQuerySystemInformation(SystemPerformanceInformation
,
3001 /* Check if this is initial setup */
3004 /* Set maximum limits to be total RAM pages */
3005 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3006 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3007 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3010 /* Set current values */
3011 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
);
3012 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.NonPagedPoolPages
);
3013 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3015 /* Check if memory dropped below 40%! */
3016 if (CopyContext
->MemoryBars
[2]->Percent
<= 40)
3018 /* Wait a while until Mm does its thing */
3019 LARGE_INTEGER Interval
;
3020 Interval
.QuadPart
= -1 * 15 * 1000 * 100;
3021 NtDelayExecution(FALSE
, &Interval
);
3025 static UINT CALLBACK
3026 FileCopyCallback(PVOID Context
,
3031 PCOPYCONTEXT CopyContext
;
3033 CopyContext
= (PCOPYCONTEXT
)Context
;
3035 switch (Notification
)
3037 case SPFILENOTIFY_STARTSUBQUEUE
:
3038 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3039 ProgressSetStepCount(CopyContext
->ProgressBar
,
3040 CopyContext
->TotalOperations
);
3041 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3044 case SPFILENOTIFY_STARTCOPY
:
3045 /* Display copy message */
3046 CONSOLE_SetStatusTextAutoFitX (45 , MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3047 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3050 case SPFILENOTIFY_ENDCOPY
:
3051 CopyContext
->CompletedOperations
++;
3052 ProgressNextStep(CopyContext
->ProgressBar
);
3053 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3062 FileCopyPage(PINPUT_RECORD Ir
)
3064 COPYCONTEXT CopyContext
;
3066 MUIDisplayPage(FILE_COPY_PAGE
);
3068 /* Create context for the copy process */
3069 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3070 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3071 CopyContext
.TotalOperations
= 0;
3072 CopyContext
.CompletedOperations
= 0;
3074 /* Create the progress bar as well */
3075 CopyContext
.ProgressBar
= CreateProgressBar(13,
3082 MUIGetString(STRING_SETUPCOPYINGFILES
));
3084 // fit memory bars to screen width, distribute them uniform
3085 unsigned int mem_bar_width
= (xScreen
- 26) / 5;
3086 mem_bar_width
-= mem_bar_width
% 2; // make even
3087 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3088 /* Create the paged pool progress bar */
3089 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3098 /* Create the non paged pool progress bar */
3099 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3101 (xScreen
/ 2) + (mem_bar_width
/ 2),
3103 (xScreen
/ 2)- (mem_bar_width
/ 2),
3108 /* Create the global memory progress bar */
3109 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3113 xScreen
- 13 - mem_bar_width
,
3118 /* Do the file copying */
3119 SetupCommitFileQueueW(NULL
,
3124 /* If we get here, we're done, so cleanup the queue and progress bar */
3125 SetupCloseFileQueue(SetupFileQueue
);
3126 DestroyProgressBar(CopyContext
.ProgressBar
);
3127 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3128 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3129 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3131 /* Go display the next page */
3132 return REGISTRY_PAGE
;
3136 RegistryPage(PINPUT_RECORD Ir
)
3138 INFCONTEXT InfContext
;
3145 MUIDisplayPage(REGISTRY_PAGE
);
3147 if (RepairUpdateFlag
)
3149 return SUCCESS_PAGE
;
3152 if (!SetInstallPathValue(&DestinationPath
))
3154 DPRINT("SetInstallPathValue() failed\n");
3155 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3159 /* Create the default hives */
3161 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3162 if (!NT_SUCCESS(Status
))
3164 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3165 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3169 RegInitializeRegistry();
3172 /* Update registry */
3173 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3175 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3177 DPRINT1("SetupFindFirstLine() failed\n");
3178 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3184 INF_GetDataField (&InfContext
, 0, &Action
);
3185 INF_GetDataField (&InfContext
, 1, &File
);
3186 INF_GetDataField (&InfContext
, 2, &Section
);
3188 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3190 if (!_wcsicmp (Action
, L
"AddReg"))
3194 else if (!_wcsicmp (Action
, L
"DelReg"))
3203 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3205 if (!ImportRegistryFile(File
, Section
, Delete
))
3207 DPRINT("Importing %S failed\n", File
);
3209 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3212 } while (SetupFindNextLine (&InfContext
, &InfContext
));
3214 /* Update display registry settings */
3215 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3216 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3218 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3222 /* Set the locale */
3223 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3224 if (!ProcessLocaleRegistry(LanguageList
))
3226 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3230 /* Add keyboard layouts */
3231 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3232 if (!AddKeyboardLayouts())
3234 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3238 /* Update keyboard layout settings */
3239 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3240 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3242 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3246 /* Add codepage information to registry */
3247 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3250 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3254 /* Update the mounted devices list */
3255 SetMountedDeviceValues(PartitionList
);
3257 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3259 return BOOT_LOADER_PAGE
;
3264 BootLoaderPage(PINPUT_RECORD Ir
)
3266 UCHAR PartitionType
;
3267 BOOLEAN InstallOnFloppy
;
3270 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3272 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3274 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3276 DPRINT("Error: active partition invalid (unused)\n");
3277 InstallOnFloppy
= TRUE
;
3279 else if (PartitionType
== 0x0A)
3281 /* OS/2 boot manager partition */
3282 DPRINT("Found OS/2 boot manager partition\n");
3283 InstallOnFloppy
= TRUE
;
3285 else if (PartitionType
== 0x83)
3287 /* Linux ext2 partition */
3288 DPRINT("Found Linux ext2 partition\n");
3289 InstallOnFloppy
= TRUE
;
3291 else if (PartitionType
== PARTITION_IFS
)
3293 /* NTFS partition */
3294 DPRINT("Found NTFS partition\n");
3295 InstallOnFloppy
= TRUE
;
3297 else if ((PartitionType
== PARTITION_FAT_12
) ||
3298 (PartitionType
== PARTITION_FAT_16
) ||
3299 (PartitionType
== PARTITION_HUGE
) ||
3300 (PartitionType
== PARTITION_XINT13
) ||
3301 (PartitionType
== PARTITION_FAT32
) ||
3302 (PartitionType
== PARTITION_FAT32_XINT13
))
3304 DPRINT("Found FAT partition\n");
3305 InstallOnFloppy
= FALSE
;
3309 /* Unknown partition */
3310 DPRINT("Unknown partition found\n");
3311 InstallOnFloppy
= TRUE
;
3314 if (InstallOnFloppy
== TRUE
)
3316 return BOOT_LOADER_FLOPPY_PAGE
;
3319 if (IsUnattendedSetup
)
3321 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3323 return SUCCESS_PAGE
;
3325 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3327 return BOOT_LOADER_FLOPPY_PAGE
;
3329 else if (UnattendMBRInstallType
== 2) /* install on hdd */
3331 return BOOT_LOADER_HARDDISK_PAGE
;
3335 MUIDisplayPage(BOOT_LOADER_PAGE
);
3336 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3340 CONSOLE_ConInKey(Ir
);
3342 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3343 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3345 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3348 if (Line
<12) Line
=14;
3349 if (Line
>14) Line
=12;
3351 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3353 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3354 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3356 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3359 if (Line
<12) Line
=14;
3360 if (Line
>14) Line
=12;
3362 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3364 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3365 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3367 if (ConfirmQuit(Ir
) == TRUE
)
3372 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3376 return BOOT_LOADER_HARDDISK_PAGE
;
3378 else if (Line
== 13)
3380 return BOOT_LOADER_FLOPPY_PAGE
;
3382 else if (Line
== 14)
3384 return SUCCESS_PAGE
;;
3387 return BOOT_LOADER_PAGE
;
3391 return BOOT_LOADER_PAGE
;
3396 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3400 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3402 // SetStatusText(" Please wait...");
3406 CONSOLE_ConInKey(Ir
);
3408 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3409 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3411 if (ConfirmQuit(Ir
) == TRUE
)
3416 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3418 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3420 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3421 return BOOT_LOADER_FLOPPY_PAGE
;
3424 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3425 if (!NT_SUCCESS(Status
))
3427 /* Print error message */
3428 return BOOT_LOADER_FLOPPY_PAGE
;
3431 return SUCCESS_PAGE
;
3435 return BOOT_LOADER_FLOPPY_PAGE
;
3440 BootLoaderHarddiskPage(PINPUT_RECORD Ir
)
3442 UCHAR PartitionType
;
3445 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3446 if ((PartitionType
== PARTITION_FAT_12
) ||
3447 (PartitionType
== PARTITION_FAT_16
) ||
3448 (PartitionType
== PARTITION_HUGE
) ||
3449 (PartitionType
== PARTITION_XINT13
) ||
3450 (PartitionType
== PARTITION_FAT32
) ||
3451 (PartitionType
== PARTITION_FAT32_XINT13
))
3453 Status
= InstallFatBootcodeToPartition(&SystemRootPath
,
3455 &DestinationArcPath
,
3457 if (!NT_SUCCESS(Status
))
3459 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3463 return SUCCESS_PAGE
;
3467 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3471 return BOOT_LOADER_HARDDISK_PAGE
;
3476 QuitPage(PINPUT_RECORD Ir
)
3478 MUIDisplayPage(QUIT_PAGE
);
3480 /* Destroy partition list */
3481 if (PartitionList
!= NULL
)
3483 DestroyPartitionList (PartitionList
);
3484 PartitionList
= NULL
;
3487 /* Destroy filesystem list */
3488 if (FileSystemList
!= NULL
)
3490 DestroyFileSystemList (FileSystemList
);
3491 FileSystemList
= NULL
;
3494 /* Destroy computer settings list */
3495 if (ComputerList
!= NULL
)
3497 DestroyGenericList(ComputerList
, TRUE
);
3498 ComputerList
= NULL
;
3501 /* Destroy display settings list */
3502 if (DisplayList
!= NULL
)
3504 DestroyGenericList(DisplayList
, TRUE
);
3508 /* Destroy keyboard settings list */
3509 if (KeyboardList
!= NULL
)
3511 DestroyGenericList(KeyboardList
, TRUE
);
3512 KeyboardList
= NULL
;
3515 /* Destroy keyboard layout list */
3516 if (LayoutList
!= NULL
)
3518 DestroyGenericList(LayoutList
, TRUE
);
3522 if (LanguageList
!= NULL
)
3524 DestroyGenericList(LanguageList
, FALSE
);
3525 LanguageList
= NULL
;
3528 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3532 CONSOLE_ConInKey(Ir
);
3534 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3543 SuccessPage(PINPUT_RECORD Ir
)
3545 MUIDisplayPage(SUCCESS_PAGE
);
3547 if (IsUnattendedSetup
)
3554 CONSOLE_ConInKey(Ir
);
3556 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3565 FlushPage(PINPUT_RECORD Ir
)
3567 MUIDisplayPage(FLUSH_PAGE
);
3573 PnpEventThread(IN LPVOID lpParameter
);
3583 NtQuerySystemTime(&Time
);
3585 Status
= RtlCreateUserThread(NtCurrentProcess(), NULL
, TRUE
, 0, 0, 0, PnpEventThread
, &SetupInf
, &hPnpThread
, NULL
);
3586 if (!NT_SUCCESS(Status
))
3587 hPnpThread
= INVALID_HANDLE_VALUE
;
3589 if (!CONSOLE_Init())
3591 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3592 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3593 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3595 /* Raise a hard error (crash the system/BSOD) */
3596 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3600 /* Initialize global unicode strings */
3601 RtlInitUnicodeString(&SourcePath
, NULL
);
3602 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3603 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3604 RtlInitUnicodeString(&InstallPath
, NULL
);
3605 RtlInitUnicodeString(&DestinationPath
, NULL
);
3606 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3607 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3608 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3610 /* Hide the cursor */
3611 CONSOLE_SetCursorType(TRUE
, FALSE
);
3614 while (Page
!= REBOOT_PAGE
)
3616 CONSOLE_ClearScreen();
3619 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3626 Page
= SetupStartPage(&Ir
);
3631 Page
= LanguagePage(&Ir
);
3636 Page
= LicensePage(&Ir
);
3641 Page
= IntroPage(&Ir
);
3645 case INSTALL_INTRO_PAGE
:
3646 Page
= InstallIntroPage(&Ir
);
3650 case SCSI_CONTROLLER_PAGE
:
3651 Page
= ScsiControllerPage(&Ir
);
3656 case OEM_DRIVER_PAGE
:
3657 Page
= OemDriverPage(&Ir
);
3661 case DEVICE_SETTINGS_PAGE
:
3662 Page
= DeviceSettingsPage(&Ir
);
3665 case COMPUTER_SETTINGS_PAGE
:
3666 Page
= ComputerSettingsPage(&Ir
);
3669 case DISPLAY_SETTINGS_PAGE
:
3670 Page
= DisplaySettingsPage(&Ir
);
3673 case KEYBOARD_SETTINGS_PAGE
:
3674 Page
= KeyboardSettingsPage(&Ir
);
3677 case LAYOUT_SETTINGS_PAGE
:
3678 Page
= LayoutSettingsPage(&Ir
);
3681 case SELECT_PARTITION_PAGE
:
3682 Page
= SelectPartitionPage(&Ir
);
3685 case CREATE_PARTITION_PAGE
:
3686 Page
= CreatePartitionPage(&Ir
);
3689 case DELETE_PARTITION_PAGE
:
3690 Page
= DeletePartitionPage(&Ir
);
3693 case SELECT_FILE_SYSTEM_PAGE
:
3694 Page
= SelectFileSystemPage(&Ir
);
3697 case FORMAT_PARTITION_PAGE
:
3698 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3701 case CHECK_FILE_SYSTEM_PAGE
:
3702 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3705 case INSTALL_DIRECTORY_PAGE
:
3706 Page
= InstallDirectoryPage(&Ir
);
3709 case PREPARE_COPY_PAGE
:
3710 Page
= PrepareCopyPage(&Ir
);
3713 case FILE_COPY_PAGE
:
3714 Page
= FileCopyPage(&Ir
);
3718 Page
= RegistryPage(&Ir
);
3721 case BOOT_LOADER_PAGE
:
3722 Page
= BootLoaderPage(&Ir
);
3725 case BOOT_LOADER_FLOPPY_PAGE
:
3726 Page
= BootLoaderFloppyPage(&Ir
);
3729 case BOOT_LOADER_HARDDISK_PAGE
:
3730 Page
= BootLoaderHarddiskPage(&Ir
);
3734 case REPAIR_INTRO_PAGE
:
3735 Page
= RepairIntroPage(&Ir
);
3739 Page
= SuccessPage(&Ir
);
3743 Page
= FlushPage(&Ir
);
3747 Page
= QuitPage(&Ir
);
3757 /* Avoid bugcheck */
3758 Time
.QuadPart
+= 50000000;
3759 NtDelayExecution(FALSE
, &Time
);
3762 NtShutdownSystem(ShutdownReboot
);
3763 NtTerminateProcess(NtCurrentProcess(), 0);
3770 NtProcessStartup(PPEB Peb
)
3772 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3774 ProcessHeap
= Peb
->ProcessHeap
;
3775 INF_SetHeap(ProcessHeap
);
3778 #endif /* __REACTOS__ */