3 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/usetup.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMER: Eric Kohl
25 * Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * Hervé Poussineau (hpoussin@reactos.org)
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
;
49 WCHAR DefaultLanguage
[20];
50 WCHAR DefaultKBLayout
[20];
51 BOOLEAN RepairUpdateFlag
= FALSE
;
52 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
54 /* LOCALS *******************************************************************/
56 static PPARTLIST PartitionList
= NULL
;
58 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
60 static UNICODE_STRING InstallPath
;
62 /* Path to the install directory */
63 static UNICODE_STRING DestinationPath
;
64 static UNICODE_STRING DestinationArcPath
;
65 static UNICODE_STRING DestinationRootPath
;
67 /* Path to the active partition (boot manager) */
68 static UNICODE_STRING SystemRootPath
;
72 static HSPFILEQ SetupFileQueue
= NULL
;
74 static BOOLEAN WarnLinuxPartitions
= TRUE
;
76 static PGENERIC_LIST ComputerList
= NULL
;
77 static PGENERIC_LIST DisplayList
= NULL
;
78 static PGENERIC_LIST KeyboardList
= NULL
;
79 static PGENERIC_LIST LayoutList
= NULL
;
80 static PGENERIC_LIST LanguageList
= NULL
;
82 /* FUNCTIONS ****************************************************************/
85 PrintString(char* fmt
,...)
89 UNICODE_STRING UnicodeString
;
90 ANSI_STRING AnsiString
;
93 vsprintf(buffer
, fmt
, ap
);
96 RtlInitAnsiString(&AnsiString
, buffer
);
97 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
98 NtDisplayString(&UnicodeString
);
99 RtlFreeUnicodeString(&UnicodeString
);
113 /* draw upper left corner */
116 FillConsoleOutputCharacterA(
123 /* draw upper edge */
126 FillConsoleOutputCharacterA(
133 /* draw upper right corner */
134 coPos
.X
= xLeft
+ Width
- 1;
136 FillConsoleOutputCharacterA(
143 /* Draw right edge, inner space and left edge */
144 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
147 FillConsoleOutputCharacterA(
155 FillConsoleOutputCharacterA(
162 coPos
.X
= xLeft
+ Width
- 1;
163 FillConsoleOutputCharacterA(
171 /* draw lower left corner */
173 coPos
.Y
= yTop
+ Height
- 1;
174 FillConsoleOutputCharacterA(
181 /* draw lower edge */
183 coPos
.Y
= yTop
+ Height
- 1;
184 FillConsoleOutputCharacterA(
191 /* draw lower right corner */
192 coPos
.X
= xLeft
+ Width
- 1;
193 coPos
.Y
= yTop
+ Height
- 1;
194 FillConsoleOutputCharacterA(
203 PopupError(PCCH Text
,
221 /* Count text lines and longest line */
228 p
= strchr(pnext
, '\n');
232 Length
= strlen(pnext
);
237 Length
= (ULONG
)(p
- pnext
);
243 if (Length
> MaxLength
)
246 if (LastLine
== TRUE
)
252 /* Check length of status line */
255 Length
= strlen(Status
);
257 if (Length
> MaxLength
)
261 Width
= MaxLength
+ 4;
267 yTop
= (yScreen
- Height
) / 2;
268 xLeft
= (xScreen
- Width
) / 2;
271 /* Set screen attributes */
273 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
275 FillConsoleOutputAttribute(StdOutput
,
276 FOREGROUND_RED
| BACKGROUND_WHITE
,
282 DrawBox(xLeft
, yTop
, Width
, Height
);
284 /* Print message text */
289 p
= strchr(pnext
, '\n');
293 Length
= strlen(pnext
);
298 Length
= (ULONG
)(p
- pnext
);
305 WriteConsoleOutputCharacterA(StdOutput
,
312 if (LastLine
== TRUE
)
319 /* Print separator line and status text */
322 coPos
.Y
= yTop
+ Height
- 3;
324 FillConsoleOutputCharacterA(StdOutput
,
331 FillConsoleOutputCharacterA(StdOutput
,
337 coPos
.X
= xLeft
+ Width
- 1;
338 FillConsoleOutputCharacterA(StdOutput
,
346 WriteConsoleOutputCharacterA(StdOutput
,
348 min(strlen(Status
), (SIZE_T
)Width
- 4),
353 if (WaitEvent
== POPUP_WAIT_NONE
)
358 CONSOLE_ConInKey(Ir
);
360 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
361 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
373 * FALSE: Don't quit setup.
376 ConfirmQuit(PINPUT_RECORD Ir
)
379 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
383 CONSOLE_ConInKey(Ir
);
385 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
386 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
391 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
403 CheckUnattendedSetup(VOID
)
405 WCHAR UnattendInfPath
[MAX_PATH
];
412 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
414 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
418 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
419 wcscat(UnattendInfPath
, L
"\\unattend.inf");
421 /* Load 'unattend.inf' from install media. */
422 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
427 if (UnattendInf
== INVALID_HANDLE_VALUE
)
429 DPRINT("SetupOpenInfFileW() failed\n");
433 /* Open 'Unattend' section */
434 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
436 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
437 SetupCloseInfFile(UnattendInf
);
441 /* Get pointer 'Signature' key */
442 if (!INF_GetData(&Context
, NULL
, &Value
))
444 DPRINT("INF_GetData() failed for key 'Signature'\n");
445 SetupCloseInfFile(UnattendInf
);
449 /* Check 'Signature' string */
450 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
452 DPRINT("Signature not $ReactOS$\n");
453 SetupCloseInfFile(UnattendInf
);
457 /* Check if Unattend setup is enabled */
458 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
460 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
461 SetupCloseInfFile(UnattendInf
);
465 if (!INF_GetData(&Context
, NULL
, &Value
))
467 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
468 SetupCloseInfFile(UnattendInf
);
472 if (_wcsicmp(Value
, L
"yes") != 0)
474 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
475 SetupCloseInfFile(UnattendInf
);
479 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
480 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
482 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
483 SetupCloseInfFile(UnattendInf
);
487 if (!SetupGetIntField(&Context
, 1, &IntValue
))
489 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
490 SetupCloseInfFile(UnattendInf
);
494 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
496 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
497 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
499 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
500 SetupCloseInfFile(UnattendInf
);
504 if (!SetupGetIntField(&Context
, 1, &IntValue
))
506 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
507 SetupCloseInfFile(UnattendInf
);
511 UnattendDestinationPartitionNumber
= IntValue
;
513 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
514 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
516 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
517 SetupCloseInfFile(UnattendInf
);
521 /* Get pointer 'InstallationDirectory' key */
522 if (!INF_GetData(&Context
, NULL
, &Value
))
524 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
525 SetupCloseInfFile(UnattendInf
);
529 wcscpy(UnattendInstallationDirectory
, Value
);
531 IsUnattendedSetup
= TRUE
;
533 /* Search for 'MBRInstallType' in the 'Unattend' section */
534 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
536 if (SetupGetIntField(&Context
, 1, &IntValue
))
538 UnattendMBRInstallType
= IntValue
;
542 /* Search for 'FormatPartition' in the 'Unattend' section */
543 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
545 if (SetupGetIntField(&Context
, 1, &IntValue
))
547 UnattendFormatPartition
= IntValue
;
551 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
553 if (SetupGetIntField(&Context
, 1, &IntValue
))
555 AutoPartition
= IntValue
;
559 /* search for LocaleID in the 'Unattend' section*/
560 if (SetupFindFirstLineW (UnattendInf
, L
"Unattend", L
"LocaleID", &Context
)){
561 if (INF_GetData (&Context
, NULL
, &Value
)){
562 LONG Id
= wcstol(Value
, NULL
, 16);
563 swprintf(LocaleID
,L
"%08lx", Id
);
567 SetupCloseInfFile(UnattendInf
);
569 DPRINT("Running unattended setup\n");
575 PGENERIC_LIST_ENTRY ListEntry
;
576 LPCWSTR pszNewLayout
;
578 pszNewLayout
= MUIDefaultKeyboardLayout();
580 if (LayoutList
== NULL
)
582 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
583 if (LayoutList
== NULL
)
585 /* FIXME: Handle error! */
590 ListEntry
= GetFirstListEntry(LayoutList
);
592 /* Search for default layout (if provided) */
593 if (pszNewLayout
!= NULL
)
595 while (ListEntry
!= NULL
)
597 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
599 SetCurrentListEntry(LayoutList
, ListEntry
);
603 ListEntry
= GetNextListEntry(ListEntry
);
609 LanguagePage(PINPUT_RECORD Ir
)
611 /* Initialize the computer settings list */
612 if (LanguageList
== NULL
)
614 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
616 if (LanguageList
== NULL
)
618 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
623 DrawGenericList(LanguageList
,
629 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
631 MUIDisplayPage(LANGUAGE_PAGE
);
635 CONSOLE_ConInKey(Ir
);
637 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
638 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
641 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
643 /* Redraw language selection page in native language */
644 MUIDisplayPage(LANGUAGE_PAGE
);
647 ScrollDownGenericList (LanguageList
);
649 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
650 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
653 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
655 /* Redraw language selection page in native language */
656 MUIDisplayPage(LANGUAGE_PAGE
);
659 ScrollUpGenericList (LanguageList
);
661 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
662 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
664 ScrollPageDownGenericList (LanguageList
);
666 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
667 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
669 ScrollPageUpGenericList (LanguageList
);
671 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
672 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
674 if (ConfirmQuit(Ir
) == TRUE
)
677 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
679 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
681 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
687 SetConsoleCodePage();
691 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
694 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
705 * Number of the next page.
708 SetupStartPage(PINPUT_RECORD Ir
)
710 SYSTEM_DEVICE_INFORMATION Sdi
;
712 WCHAR FileNameBuffer
[MAX_PATH
];
717 PGENERIC_LIST_ENTRY ListEntry
;
719 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
722 /* Check whether a harddisk is available */
723 Status
= NtQuerySystemInformation (SystemDeviceInformation
,
725 sizeof(SYSTEM_DEVICE_INFORMATION
),
728 if (!NT_SUCCESS (Status
))
730 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
731 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
735 if (Sdi
.NumberOfDisks
== 0)
737 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
741 /* Get the source path and source root path */
742 Status
= GetSourcePaths(&SourcePath
,
746 if (!NT_SUCCESS(Status
))
748 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
749 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
755 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
756 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
757 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
761 /* Load txtsetup.sif from install media. */
762 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
763 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
765 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
770 if (SetupInf
== INVALID_HANDLE_VALUE
)
772 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
776 /* Open 'Version' section */
777 if (!SetupFindFirstLineW (SetupInf
, L
"Version", L
"Signature", &Context
))
779 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
783 /* Get pointer 'Signature' key */
784 if (!INF_GetData (&Context
, NULL
, &Value
))
786 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
790 /* Check 'Signature' string */
791 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
793 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
797 /* Start PnP thread */
798 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
800 NtResumeThread(hPnpThread
, NULL
);
801 hPnpThread
= INVALID_HANDLE_VALUE
;
804 CheckUnattendedSetup();
806 if (IsUnattendedSetup
)
809 //read options from inf
810 ComputerList
= CreateComputerTypeList(SetupInf
);
811 DisplayList
= CreateDisplayDriverList(SetupInf
);
812 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
813 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
814 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
818 wcscpy(SelectedLanguageId
,LocaleID
);
821 /* first we hack LanguageList */
822 ListEntry
= GetFirstListEntry(LanguageList
);
824 while (ListEntry
!= NULL
)
826 if (!wcscmp(LocaleID
, GetListEntryUserData(ListEntry
)))
828 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
829 SetCurrentListEntry(LanguageList
, ListEntry
);
833 ListEntry
= GetNextListEntry(ListEntry
);
836 ListEntry
= GetFirstListEntry(LayoutList
);
838 while (ListEntry
!= NULL
)
840 if (!wcscmp(LocaleID
, GetListEntryUserData(ListEntry
)))
842 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
843 SetCurrentListEntry(LayoutList
, ListEntry
);
847 ListEntry
= GetNextListEntry(ListEntry
);
849 SetConsoleCodePage();
851 return INSTALL_INTRO_PAGE
;
854 return LANGUAGE_PAGE
;
864 IntroPage(PINPUT_RECORD Ir
)
866 MUIDisplayPage(START_PAGE
);
870 CONSOLE_ConInKey(Ir
);
872 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
873 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
875 if (ConfirmQuit(Ir
) == TRUE
)
880 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
882 return INSTALL_INTRO_PAGE
;
885 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
887 return REPAIR_INTRO_PAGE
;
890 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
903 * Back to main setup page.
906 LicensePage(PINPUT_RECORD Ir
)
908 MUIDisplayPage(LICENSE_PAGE
);
912 CONSOLE_ConInKey(Ir
);
914 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
925 RepairIntroPage(PINPUT_RECORD Ir
)
927 MUIDisplayPage(REPAIR_INTRO_PAGE
);
931 CONSOLE_ConInKey(Ir
);
933 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
937 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
939 RepairUpdateFlag
= TRUE
;
940 return INSTALL_INTRO_PAGE
;
942 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
946 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
947 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
953 return REPAIR_INTRO_PAGE
;
958 InstallIntroPage(PINPUT_RECORD Ir
)
960 MUIDisplayPage(INSTALL_INTRO_PAGE
);
962 if (RepairUpdateFlag
)
964 //return SELECT_PARTITION_PAGE;
965 return DEVICE_SETTINGS_PAGE
;
968 if (IsUnattendedSetup
)
970 return SELECT_PARTITION_PAGE
;
975 CONSOLE_ConInKey(Ir
);
977 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
978 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
980 if (ConfirmQuit(Ir
) == TRUE
)
985 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
987 return DEVICE_SETTINGS_PAGE
;
988 // return SCSI_CONTROLLER_PAGE;
992 return INSTALL_INTRO_PAGE
;
998 ScsiControllerPage(PINPUT_RECORD Ir
)
1000 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1002 /* FIXME: print loaded mass storage driver descriptions */
1004 SetTextXY(8, 10, "TEST device");
1008 SetStatusText(" ENTER = Continue F3 = Quit");
1014 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1015 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1017 if (ConfirmQuit(Ir
) == TRUE
)
1022 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1024 return DEVICE_SETTINGS_PAGE
;
1028 return SCSI_CONTROLLER_PAGE
;
1034 DeviceSettingsPage(PINPUT_RECORD Ir
)
1036 static ULONG Line
= 16;
1037 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1039 /* Initialize the computer settings list */
1040 if (ComputerList
== NULL
)
1042 ComputerList
= CreateComputerTypeList(SetupInf
);
1043 if (ComputerList
== NULL
)
1045 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1050 /* Initialize the display settings list */
1051 if (DisplayList
== NULL
)
1053 DisplayList
= CreateDisplayDriverList(SetupInf
);
1054 if (DisplayList
== NULL
)
1056 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1061 /* Initialize the keyboard settings list */
1062 if (KeyboardList
== NULL
)
1064 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1065 if (KeyboardList
== NULL
)
1067 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1072 /* Initialize the keyboard layout list */
1073 if (LayoutList
== NULL
)
1075 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1076 if (LayoutList
== NULL
)
1078 /* FIXME: report error */
1079 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1084 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1087 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1088 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1089 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1090 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1092 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1094 if (RepairUpdateFlag
)
1096 return SELECT_PARTITION_PAGE
;
1101 CONSOLE_ConInKey(Ir
);
1103 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1104 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1106 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1110 else if (Line
== 16)
1115 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1117 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1118 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1120 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1124 else if (Line
== 16)
1129 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1131 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1132 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1134 if (ConfirmQuit(Ir
) == TRUE
)
1139 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1142 return COMPUTER_SETTINGS_PAGE
;
1143 else if (Line
== 12)
1144 return DISPLAY_SETTINGS_PAGE
;
1145 else if (Line
== 13)
1146 return KEYBOARD_SETTINGS_PAGE
;
1147 else if (Line
== 14)
1148 return LAYOUT_SETTINGS_PAGE
;
1149 else if (Line
== 16)
1150 return SELECT_PARTITION_PAGE
;
1154 return DEVICE_SETTINGS_PAGE
;
1159 ComputerSettingsPage(PINPUT_RECORD Ir
)
1161 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1163 DrawGenericList(ComputerList
,
1169 SaveGenericListState(ComputerList
);
1173 CONSOLE_ConInKey(Ir
);
1175 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1176 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1178 ScrollDownGenericList (ComputerList
);
1180 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1181 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1183 ScrollUpGenericList (ComputerList
);
1185 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1186 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1188 if (ConfirmQuit(Ir
) == TRUE
)
1193 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1194 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1196 RestoreGenericListState(ComputerList
);
1197 return DEVICE_SETTINGS_PAGE
;
1199 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1201 return DEVICE_SETTINGS_PAGE
;
1205 return COMPUTER_SETTINGS_PAGE
;
1210 DisplaySettingsPage(PINPUT_RECORD Ir
)
1212 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1214 DrawGenericList(DisplayList
,
1220 SaveGenericListState(DisplayList
);
1224 CONSOLE_ConInKey(Ir
);
1226 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1227 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1229 ScrollDownGenericList (DisplayList
);
1231 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1232 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1234 ScrollUpGenericList (DisplayList
);
1236 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1237 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1239 if (ConfirmQuit(Ir
) == TRUE
)
1246 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1247 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1249 RestoreGenericListState(DisplayList
);
1250 return DEVICE_SETTINGS_PAGE
;
1252 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1254 return DEVICE_SETTINGS_PAGE
;
1258 return DISPLAY_SETTINGS_PAGE
;
1263 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1265 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1267 DrawGenericList(KeyboardList
,
1273 SaveGenericListState(KeyboardList
);
1277 CONSOLE_ConInKey(Ir
);
1279 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1280 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1282 ScrollDownGenericList (KeyboardList
);
1284 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1285 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1287 ScrollUpGenericList (KeyboardList
);
1289 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1290 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1292 if (ConfirmQuit(Ir
) == TRUE
)
1297 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1298 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1300 RestoreGenericListState(KeyboardList
);
1301 return DEVICE_SETTINGS_PAGE
;
1303 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1305 return DEVICE_SETTINGS_PAGE
;
1309 return DISPLAY_SETTINGS_PAGE
;
1314 LayoutSettingsPage(PINPUT_RECORD Ir
)
1316 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1318 DrawGenericList(LayoutList
,
1324 SaveGenericListState(LayoutList
);
1328 CONSOLE_ConInKey(Ir
);
1330 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1331 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1333 ScrollDownGenericList (LayoutList
);
1335 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1336 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1338 ScrollUpGenericList (LayoutList
);
1340 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1341 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1343 ScrollPageDownGenericList (LayoutList
);
1345 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1346 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1348 ScrollPageUpGenericList (LayoutList
);
1350 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1351 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1353 if (ConfirmQuit(Ir
) == TRUE
)
1358 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1359 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1361 RestoreGenericListState(LayoutList
);
1362 return DEVICE_SETTINGS_PAGE
;
1364 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1366 return DEVICE_SETTINGS_PAGE
;
1368 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1371 GenericListKeyPress (LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1375 return DISPLAY_SETTINGS_PAGE
;
1380 SelectPartitionPage(PINPUT_RECORD Ir
)
1382 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1384 if (PartitionList
== NULL
)
1386 PartitionList
= CreatePartitionList (2,
1391 if (PartitionList
== NULL
)
1393 /* FIXME: show an error dialog */
1398 CheckActiveBootPartition (PartitionList
);
1400 DrawPartitionList (PartitionList
);
1402 /* Warn about partitions created by Linux Fdisk */
1403 if (WarnLinuxPartitions
== TRUE
&&
1404 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1406 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1410 CONSOLE_ConInKey(Ir
);
1412 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1413 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1417 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1419 WarnLinuxPartitions
= FALSE
;
1420 return SELECT_PARTITION_PAGE
;
1425 if (IsUnattendedSetup
)
1427 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1431 PPARTENTRY PartEntry
= PartEntry
= PartitionList
->CurrentPartition
;
1432 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1434 CreateNewPartition(PartitionList
,
1438 return (SELECT_FILE_SYSTEM_PAGE
);
1443 return(SELECT_FILE_SYSTEM_PAGE
);
1449 /* Update status text */
1450 if (PartitionList
->CurrentPartition
== NULL
||
1451 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1453 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1457 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1460 CONSOLE_ConInKey(Ir
);
1462 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1463 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1465 if (ConfirmQuit(Ir
) == TRUE
)
1467 DestroyPartitionList (PartitionList
);
1468 PartitionList
= NULL
;
1474 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1475 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1477 ScrollDownPartitionList (PartitionList
);
1479 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1480 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1482 ScrollUpPartitionList (PartitionList
);
1484 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1486 if (PartitionList
->CurrentPartition
== NULL
||
1487 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1489 CreateNewPartition (PartitionList
,
1494 return SELECT_FILE_SYSTEM_PAGE
;
1496 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1498 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1500 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1501 return SELECT_PARTITION_PAGE
;
1504 return CREATE_PARTITION_PAGE
;
1506 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1508 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1510 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1511 return SELECT_PARTITION_PAGE
;
1514 return DELETE_PARTITION_PAGE
;
1518 return SELECT_PARTITION_PAGE
;
1523 DrawInputField(ULONG FieldLength
,
1534 memset(buf
, '_', sizeof(buf
));
1535 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1536 strcat(buf
, FieldContent
);
1538 WriteConsoleOutputCharacterA (StdOutput
,
1546 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1547 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1548 #define PARTITION_MAXSIZE 999999
1551 ShowPartitionSizeInputBox(SHORT Left
,
1575 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1580 strcpy (Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1581 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
1584 WriteConsoleOutputCharacterA(StdOutput
,
1590 sprintf (Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1591 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1593 WriteConsoleOutputCharacterA(StdOutput
,
1599 sprintf(Buffer
, "%lu", MaxSize
);
1600 Index
= strlen(Buffer
);
1601 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1608 CONSOLE_ConInKey(&Ir
);
1610 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1611 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1619 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1623 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1631 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1637 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1642 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1643 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1645 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1647 if ((ch
>= '0') && (ch
<= '9'))
1653 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1661 strcpy (InputBuffer
, Buffer
);
1666 CreatePartitionPage (PINPUT_RECORD Ir
)
1668 PDISKENTRY DiskEntry
;
1669 PPARTENTRY PartEntry
;
1672 CHAR InputBuffer
[50];
1678 if (PartitionList
== NULL
||
1679 PartitionList
->CurrentDisk
== NULL
||
1680 PartitionList
->CurrentPartition
== NULL
)
1682 /* FIXME: show an error dialog */
1686 DiskEntry
= PartitionList
->CurrentDisk
;
1687 PartEntry
= PartitionList
->CurrentPartition
;
1689 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1691 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1694 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1696 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1697 Unit
= MUIGetString(STRING_GB
);
1702 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1707 Unit
= MUIGetString(STRING_MB
);
1710 if (DiskEntry
->DriverName
.Length
> 0)
1712 CONSOLE_PrintTextXY(6, 10,
1713 MUIGetString(STRING_HDINFOPARTCREATE
),
1716 DiskEntry
->DiskNumber
,
1720 &DiskEntry
->DriverName
);
1724 CONSOLE_PrintTextXY(6, 10,
1725 MUIGetString(STRING_HDDINFOUNK1
),
1728 DiskEntry
->DiskNumber
,
1734 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1737 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1738 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1741 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1743 PartEntry
= PartitionList
->CurrentPartition
;
1746 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1748 if (MaxSize
> PARTITION_MAXSIZE
) MaxSize
= PARTITION_MAXSIZE
;
1750 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1751 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1755 if (ConfirmQuit (Ir
) == TRUE
)
1760 else if (Cancel
== TRUE
)
1762 return SELECT_PARTITION_PAGE
;
1766 PartSize
= atoi(InputBuffer
);
1774 if (PartSize
> MaxSize
)
1780 /* Convert to bytes */
1781 if (PartSize
== MaxSize
)
1783 /* Use all of the unpartitioned disk space */
1784 PartSize
= PartEntry
->UnpartitionedLength
;
1788 /* Round-up by cylinder size */
1789 PartSize
= (PartSize
* 1024 * 1024 + DiskEntry
->CylinderSize
- 1) /
1790 DiskEntry
->CylinderSize
* DiskEntry
->CylinderSize
;
1792 /* But never get larger than the unpartitioned disk space */
1793 if (PartSize
> PartEntry
->UnpartitionedLength
)
1794 PartSize
= PartEntry
->UnpartitionedLength
;
1797 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1799 CreateNewPartition (PartitionList
,
1803 return SELECT_PARTITION_PAGE
;
1807 return CREATE_PARTITION_PAGE
;
1812 DeletePartitionPage (PINPUT_RECORD Ir
)
1814 PDISKENTRY DiskEntry
;
1815 PPARTENTRY PartEntry
;
1822 if (PartitionList
== NULL
||
1823 PartitionList
->CurrentDisk
== NULL
||
1824 PartitionList
->CurrentPartition
== NULL
)
1826 /* FIXME: show an error dialog */
1830 DiskEntry
= PartitionList
->CurrentDisk
;
1831 PartEntry
= PartitionList
->CurrentPartition
;
1832 PartNumber
= PartitionList
->CurrentPartitionNumber
;
1834 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1836 /* Determine partition type */
1838 if (PartEntry
->New
== TRUE
)
1840 PartType
= MUIGetString(STRING_UNFORMATTED
);
1842 else if (PartEntry
->Unpartitioned
== FALSE
)
1844 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
1845 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
1846 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
1847 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
1851 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
1852 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
1856 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
1860 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
1862 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1867 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1869 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1870 Unit
= MUIGetString(STRING_GB
);
1874 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1876 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1877 Unit
= MUIGetString(STRING_MB
);
1881 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1882 Unit
= MUIGetString(STRING_KB
);
1885 if (PartType
== NULL
)
1887 CONSOLE_PrintTextXY(6, 10,
1888 MUIGetString(STRING_HDDINFOUNK2
),
1889 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1890 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1891 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
1897 CONSOLE_PrintTextXY(6, 10,
1898 " %c%c %s %I64u %s",
1899 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1900 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1907 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1909 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1910 Unit
= MUIGetString(STRING_GB
);
1915 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1920 Unit
= MUIGetString(STRING_MB
);
1923 if (DiskEntry
->DriverName
.Length
> 0)
1925 CONSOLE_PrintTextXY(6, 12,
1926 MUIGetString(STRING_HDINFOPARTDELETE
),
1929 DiskEntry
->DiskNumber
,
1933 &DiskEntry
->DriverName
);
1937 CONSOLE_PrintTextXY(6, 12,
1938 MUIGetString(STRING_HDDINFOUNK3
),
1941 DiskEntry
->DiskNumber
,
1949 CONSOLE_ConInKey(Ir
);
1951 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1952 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1954 if (ConfirmQuit (Ir
) == TRUE
)
1961 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1963 return SELECT_PARTITION_PAGE
;
1965 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1967 DeleteCurrentPartition (PartitionList
);
1969 return SELECT_PARTITION_PAGE
;
1973 return DELETE_PARTITION_PAGE
;
1978 SelectFileSystemPage (PINPUT_RECORD Ir
)
1980 PDISKENTRY DiskEntry
;
1981 PPARTENTRY PartEntry
;
1989 if (PartitionList
== NULL
||
1990 PartitionList
->CurrentDisk
== NULL
||
1991 PartitionList
->CurrentPartition
== NULL
)
1993 /* FIXME: show an error dialog */
1997 DiskEntry
= PartitionList
->CurrentDisk
;
1998 PartEntry
= PartitionList
->CurrentPartition
;
1999 PartNumber
= PartitionList
->CurrentPartitionNumber
;
2001 /* adjust disk size */
2002 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
2004 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
2005 DiskUnit
= MUIGetString(STRING_GB
);
2009 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
2010 DiskUnit
= MUIGetString(STRING_MB
);
2013 /* adjust partition size */
2014 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
2016 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
2017 PartUnit
= MUIGetString(STRING_GB
);
2021 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
2022 PartUnit
= MUIGetString(STRING_MB
);
2025 /* adjust partition type */
2026 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
2027 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
2028 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
2029 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
2033 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
2034 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
2038 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
2042 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
2044 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2046 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_ENTRY_UNUSED
)
2048 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2052 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2055 if (PartEntry
->AutoCreate
== TRUE
)
2057 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2060 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2061 PartEntry
->PartInfo
[PartNumber
].PartitionNumber
,
2067 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2068 DiskEntry
->DiskNumber
,
2074 &DiskEntry
->DriverName
);
2076 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2079 PartEntry
->AutoCreate
= FALSE
;
2081 else if (PartEntry
->New
== TRUE
)
2083 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2084 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2088 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2090 if (PartType
== NULL
)
2092 CONSOLE_PrintTextXY(8, 10,
2093 MUIGetString(STRING_HDDINFOUNK4
),
2094 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2095 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2096 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
2102 CONSOLE_PrintTextXY(8, 10,
2104 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2105 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2111 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2112 DiskEntry
->DiskNumber
,
2118 &DiskEntry
->DriverName
);
2121 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2123 if (FileSystemList
== NULL
)
2125 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, L
"FAT");
2126 if (FileSystemList
== NULL
)
2128 /* FIXME: show an error dialog */
2132 /* FIXME: Add file systems to list */
2134 DrawFileSystemList (FileSystemList
);
2136 if (RepairUpdateFlag
)
2138 return CHECK_FILE_SYSTEM_PAGE
;
2139 //return SELECT_PARTITION_PAGE;
2142 if (IsUnattendedSetup
)
2144 if (UnattendFormatPartition
)
2146 return FORMAT_PARTITION_PAGE
;
2149 return(CHECK_FILE_SYSTEM_PAGE
);
2154 CONSOLE_ConInKey(Ir
);
2156 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2157 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2159 if (ConfirmQuit (Ir
) == TRUE
)
2166 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2167 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2169 return SELECT_PARTITION_PAGE
;
2171 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2172 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2174 ScrollDownFileSystemList (FileSystemList
);
2176 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2177 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2179 ScrollUpFileSystemList (FileSystemList
);
2181 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2183 if (!FileSystemList
->Selected
->FormatFunc
)
2185 return CHECK_FILE_SYSTEM_PAGE
;
2189 return FORMAT_PARTITION_PAGE
;
2194 return SELECT_FILE_SYSTEM_PAGE
;
2199 FormatPartitionPage (PINPUT_RECORD Ir
)
2201 WCHAR PathBuffer
[MAX_PATH
];
2202 PDISKENTRY DiskEntry
;
2203 PPARTENTRY PartEntry
;
2213 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2215 if (PartitionList
== NULL
||
2216 PartitionList
->CurrentDisk
== NULL
||
2217 PartitionList
->CurrentPartition
== NULL
)
2219 /* FIXME: show an error dialog */
2223 DiskEntry
= PartitionList
->CurrentDisk
;
2224 PartEntry
= PartitionList
->CurrentPartition
;
2225 PartNum
= PartitionList
->CurrentPartitionNumber
;
2229 if (!IsUnattendedSetup
)
2231 CONSOLE_ConInKey(Ir
);
2234 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2235 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2237 if (ConfirmQuit (Ir
) == TRUE
)
2244 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2246 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2248 if (PartEntry
->PartInfo
[PartNum
].PartitionType
== PARTITION_ENTRY_UNUSED
)
2250 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2252 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2254 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2255 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_12
;
2257 else if (PartEntry
->PartInfo
[PartNum
].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2259 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2261 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2263 /* FAT16 CHS partition (partiton size < 32MB) */
2264 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_16
;
2266 else if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2268 /* FAT16 CHS partition (partition size < 512MB) */
2269 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_HUGE
;
2273 /* FAT32 CHS partition (partition size >= 512MB) */
2274 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32
;
2279 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2281 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2283 /* FAT16 LBA partition (partition size < 512MB) */
2284 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_XINT13
;
2288 /* FAT32 LBA partition (partition size >= 512MB) */
2289 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32_XINT13
;
2293 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2294 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_EXT2
;
2295 else if (!FileSystemList
->Selected
->FormatFunc
)
2299 CheckActiveBootPartition (PartitionList
);
2302 CONSOLE_PrintTextXY(6, 12,
2303 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2304 DiskEntry
->DiskSize
,
2305 DiskEntry
->CylinderSize
,
2306 DiskEntry
->TrackSize
);
2309 DiskEntry
= PartitionList
->CurrentDisk
;
2310 Entry
= DiskEntry
->PartListHead
.Flink
;
2312 while (Entry
!= &DiskEntry
->PartListHead
)
2314 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2316 if (PartEntry
->Unpartitioned
== FALSE
)
2318 for (i
= 0; i
< 4; i
++)
2320 CONSOLE_PrintTextXY(6, Line
,
2321 "%2u: %2u %c %12I64u %12I64u %2u %c",
2323 PartEntry
->PartInfo
[i
].PartitionNumber
,
2324 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2325 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2326 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2327 PartEntry
->PartInfo
[i
].PartitionType
,
2328 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2336 Entry
= Entry
->Flink
;
2339 /* Restore the old entry */
2340 PartEntry
= PartitionList
->CurrentPartition
;
2343 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
2345 DPRINT ("WritePartitionsToDisk() failed\n");
2346 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2350 /* Set DestinationRootPath */
2351 RtlFreeUnicodeString (&DestinationRootPath
);
2352 swprintf (PathBuffer
,
2353 L
"\\Device\\Harddisk%lu\\Partition%lu",
2354 PartitionList
->CurrentDisk
->DiskNumber
,
2355 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2356 RtlCreateUnicodeString (&DestinationRootPath
,
2358 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2361 /* Set SystemRootPath */
2362 RtlFreeUnicodeString (&SystemRootPath
);
2363 swprintf (PathBuffer
,
2364 L
"\\Device\\Harddisk%lu\\Partition%lu",
2365 PartitionList
->ActiveBootDisk
->DiskNumber
,
2366 PartitionList
->ActiveBootPartition
->
2367 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionNumber
);
2368 RtlCreateUnicodeString (&SystemRootPath
,
2370 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
2373 if (FileSystemList
->Selected
->FormatFunc
)
2375 Status
= FormatPartition(&DestinationRootPath
, FileSystemList
->Selected
);
2376 if (!NT_SUCCESS(Status
))
2378 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2379 /* FIXME: show an error dialog */
2383 PartEntry
->New
= FALSE
;
2385 CheckActiveBootPartition(PartitionList
);
2388 /* Install MBR if necessary */
2389 if (DiskEntry
->NoMbr
&&
2390 DiskEntry
->BiosDiskNumber
== 0)
2392 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2393 wcscat(PathBuffer
, L
"\\loader\\dosmbr.bin");
2395 DPRINT("Install MBR bootcode: %S ==> %S\n",
2396 PathBuffer
, DestinationRootPath
.Buffer
);
2398 /* Install MBR bootcode */
2399 Status
= InstallMbrBootCodeToDisk(PathBuffer
, DestinationRootPath
.Buffer
);
2400 if (!NT_SUCCESS (Status
))
2402 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
2407 DiskEntry
->NoMbr
= FALSE
;
2410 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2412 /* FIXME: Install boot code. This is a hack! */
2413 if ((PartEntry
->PartInfo
[PartNum
].PartitionType
== PARTITION_FAT32_XINT13
) ||
2414 (PartEntry
->PartInfo
[PartNum
].PartitionType
== PARTITION_FAT32
))
2416 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2417 wcscat(PathBuffer
, L
"\\loader\\fat32.bin");
2419 DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
2420 DestinationRootPath
.Buffer
);
2421 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2422 DestinationRootPath
.Buffer
);
2424 if (!NT_SUCCESS(Status
))
2426 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2427 /* FIXME: show an error dialog */
2428 DestroyFileSystemList(FileSystemList
);
2429 FileSystemList
= NULL
;
2435 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2436 wcscat(PathBuffer
, L
"\\loader\\fat.bin");
2438 DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer
,
2439 DestinationRootPath
.Buffer
);
2440 Status
= InstallFat16BootCodeToDisk(PathBuffer
,
2441 DestinationRootPath
.Buffer
);
2443 if (!NT_SUCCESS(Status
))
2445 DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status
);
2446 /* FIXME: show an error dialog */
2447 DestroyFileSystemList(FileSystemList
);
2448 FileSystemList
= NULL
;
2453 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2455 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2456 wcscat(PathBuffer
, L
"\\loader\\ext2.bin");
2458 DPRINT("Install EXT2 bootcode: %S ==> %S\n", PathBuffer
,
2459 DestinationRootPath
.Buffer
);
2460 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2461 DestinationRootPath
.Buffer
);
2463 if (!NT_SUCCESS(Status
))
2465 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2466 /* FIXME: show an error dialog */
2467 DestroyFileSystemList(FileSystemList
);
2468 FileSystemList
= NULL
;
2472 else if (FileSystemList
->Selected
->FormatFunc
)
2474 DestroyFileSystemList(FileSystemList
);
2475 FileSystemList
= NULL
;
2480 CONSOLE_SetStatusText(" Done. Press any key ...");
2481 CONSOLE_ConInKey(Ir
);
2484 DestroyFileSystemList(FileSystemList
);
2485 FileSystemList
= NULL
;
2486 return INSTALL_DIRECTORY_PAGE
;
2490 return FORMAT_PARTITION_PAGE
;
2495 CheckFileSystemPage(PINPUT_RECORD Ir
)
2497 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2498 WCHAR PathBuffer
[MAX_PATH
];
2499 CHAR Buffer
[MAX_PATH
];
2501 UCHAR PartNum
= PartitionList
->CurrentPartitionNumber
;
2503 /* FIXME: code duplicated in FormatPartitionPage */
2504 /* Set DestinationRootPath */
2505 RtlFreeUnicodeString(&DestinationRootPath
);
2506 swprintf(PathBuffer
,
2507 L
"\\Device\\Harddisk%lu\\Partition%lu",
2508 PartitionList
->CurrentDisk
->DiskNumber
,
2509 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2510 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2511 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2513 /* Set SystemRootPath */
2514 RtlFreeUnicodeString(&SystemRootPath
);
2515 swprintf(PathBuffer
,
2516 L
"\\Device\\Harddisk%lu\\Partition%lu",
2517 PartitionList
->ActiveBootDisk
->DiskNumber
,
2518 PartitionList
->ActiveBootPartition
->PartInfo
[PartNum
].PartitionNumber
);
2519 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2520 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2522 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2524 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2526 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2527 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2529 if (!CurrentFileSystem
->ChkdskFunc
)
2532 "Setup is currently unable to check a partition formatted in %S.\n"
2534 " \x07 Press ENTER to continue Setup.\n"
2535 " \x07 Press F3 to quit Setup.",
2536 CurrentFileSystem
->FileSystem
);
2539 MUIGetString(STRING_QUITCONTINUE
),
2540 NULL
, POPUP_WAIT_NONE
);
2544 CONSOLE_ConInKey(Ir
);
2546 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2547 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2549 if (ConfirmQuit(Ir
))
2552 return CHECK_FILE_SYSTEM_PAGE
;
2554 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2556 return INSTALL_DIRECTORY_PAGE
;
2562 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2563 if (!NT_SUCCESS(Status
))
2565 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2566 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2567 "(Status 0x%08lx).\n", Status
);
2570 MUIGetString(STRING_REBOOTCOMPUTER
),
2571 Ir
, POPUP_WAIT_ENTER
);
2576 return INSTALL_DIRECTORY_PAGE
;
2582 InstallDirectoryPage1(PWCHAR InstallDir
, PDISKENTRY DiskEntry
, PPARTENTRY PartEntry
, UCHAR PartNum
)
2584 WCHAR PathBuffer
[MAX_PATH
];
2586 /* Create 'InstallPath' string */
2587 RtlFreeUnicodeString(&InstallPath
);
2588 RtlCreateUnicodeString(&InstallPath
,
2591 /* Create 'DestinationPath' string */
2592 RtlFreeUnicodeString(&DestinationPath
);
2593 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2595 if (InstallDir
[0] != L
'\\')
2596 wcscat(PathBuffer
, L
"\\");
2598 wcscat(PathBuffer
, InstallDir
);
2599 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2601 /* Create 'DestinationArcPath' */
2602 RtlFreeUnicodeString(&DestinationArcPath
);
2603 swprintf(PathBuffer
,
2604 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2605 DiskEntry
->BiosDiskNumber
,
2606 PartEntry
->PartInfo
[PartNum
].PartitionNumber
);
2608 if (InstallDir
[0] != L
'\\')
2609 wcscat(PathBuffer
, L
"\\");
2611 wcscat(PathBuffer
, InstallDir
);
2612 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2614 return(PREPARE_COPY_PAGE
);
2619 InstallDirectoryPage(PINPUT_RECORD Ir
)
2621 PDISKENTRY DiskEntry
;
2622 PPARTENTRY PartEntry
;
2623 WCHAR InstallDir
[51];
2628 if (PartitionList
== NULL
||
2629 PartitionList
->CurrentDisk
== NULL
||
2630 PartitionList
->CurrentPartition
== NULL
)
2632 /* FIXME: show an error dialog */
2636 DiskEntry
= PartitionList
->CurrentDisk
;
2637 PartEntry
= PartitionList
->CurrentPartition
;
2639 /* Search for 'DefaultPath' in the 'SetupData' section */
2640 if (!SetupFindFirstLineW (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2642 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2646 /* Read the 'DefaultPath' data */
2647 if (INF_GetData (&Context
, NULL
, &DefaultPath
))
2649 wcscpy(InstallDir
, DefaultPath
);
2653 wcscpy(InstallDir
, L
"\\ReactOS");
2656 Length
= wcslen(InstallDir
);
2657 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2658 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2660 if (IsUnattendedSetup
)
2662 return(InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
, PartitionList
->CurrentPartitionNumber
));
2667 CONSOLE_ConInKey(Ir
);
2669 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2670 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2672 if (ConfirmQuit(Ir
) == TRUE
)
2677 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2679 return (InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
, PartitionList
->CurrentPartitionNumber
));
2681 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2686 InstallDir
[Length
] = 0;
2687 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2690 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2694 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2696 InstallDir
[Length
] = 0;
2697 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2702 return(INSTALL_DIRECTORY_PAGE
);
2706 AddSectionToCopyQueueCab(HINF InfFile
,
2708 PWCHAR SourceCabinet
,
2709 PCUNICODE_STRING DestinationPath
,
2712 INFCONTEXT FilesContext
;
2713 INFCONTEXT DirContext
;
2715 PWCHAR FileKeyValue
;
2717 PWCHAR TargetFileName
;
2719 /* Search for the SectionName section */
2720 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2723 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2724 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2729 * Enumerate the files in the section
2730 * and add them to the file queue.
2734 /* Get source file name and target directory id */
2735 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2737 /* FIXME: Handle error! */
2738 DPRINT1("INF_GetData() failed\n");
2742 /* Get optional target file name */
2743 if (!INF_GetDataField (&FilesContext
, 2, &TargetFileName
))
2744 TargetFileName
= NULL
;
2746 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2748 /* Lookup target directory */
2749 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2751 /* FIXME: Handle error! */
2752 DPRINT1("SetupFindFirstLine() failed\n");
2756 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2758 /* FIXME: Handle error! */
2759 DPRINT1("INF_GetData() failed\n");
2763 if (!SetupQueueCopy(SetupFileQueue
,
2765 SourceRootPath
.Buffer
,
2766 SourceRootDir
.Buffer
,
2771 /* FIXME: Handle error! */
2772 DPRINT1("SetupQueueCopy() failed\n");
2774 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2780 AddSectionToCopyQueue(HINF InfFile
,
2782 PWCHAR SourceCabinet
,
2783 PCUNICODE_STRING DestinationPath
,
2786 INFCONTEXT FilesContext
;
2787 INFCONTEXT DirContext
;
2789 PWCHAR FileKeyValue
;
2791 PWCHAR TargetFileName
;
2794 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2796 /* Search for the SectionName section */
2797 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2800 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2801 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2806 * Enumerate the files in the section
2807 * and add them to the file queue.
2811 /* Get source file name and target directory id */
2812 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2814 /* FIXME: Handle error! */
2815 DPRINT1("INF_GetData() failed\n");
2819 /* Get target directory id */
2820 if (!INF_GetDataField (&FilesContext
, 13, &FileKeyValue
))
2822 /* FIXME: Handle error! */
2823 DPRINT1("INF_GetData() failed\n");
2827 /* Get optional target file name */
2828 if (!INF_GetDataField (&FilesContext
, 11, &TargetFileName
))
2829 TargetFileName
= NULL
;
2830 else if (!*TargetFileName
)
2831 TargetFileName
= NULL
;
2833 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2835 /* Lookup target directory */
2836 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2838 /* FIXME: Handle error! */
2839 DPRINT1("SetupFindFirstLine() failed\n");
2843 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2845 /* FIXME: Handle error! */
2846 DPRINT1("INF_GetData() failed\n");
2850 if (!SetupQueueCopy(SetupFileQueue
,
2852 SourceRootPath
.Buffer
,
2853 SourceRootDir
.Buffer
,
2858 /* FIXME: Handle error! */
2859 DPRINT1("SetupQueueCopy() failed\n");
2861 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2867 PrepareCopyPageInfFile(HINF InfFile
,
2868 PWCHAR SourceCabinet
,
2871 WCHAR PathBuffer
[MAX_PATH
];
2872 INFCONTEXT DirContext
;
2873 PWCHAR AdditionalSectionName
= NULL
;
2878 /* Add common files */
2879 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2882 /* Add specific files depending of computer type */
2883 if (SourceCabinet
== NULL
)
2885 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2888 if (AdditionalSectionName
)
2890 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2895 /* Create directories */
2899 * Install directories like '\reactos\test' are not handled yet.
2902 /* Get destination path */
2903 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2905 /* Remove trailing backslash */
2906 Length
= wcslen(PathBuffer
);
2907 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2909 PathBuffer
[Length
- 1] = 0;
2912 /* Create the install directory */
2913 Status
= SetupCreateDirectory(PathBuffer
);
2914 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2916 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2917 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2921 /* Search for the 'Directories' section */
2922 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2926 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2930 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2936 /* Enumerate the directory values and create the subdirectories */
2939 if (!INF_GetData (&DirContext
, NULL
, &KeyValue
))
2945 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2947 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2949 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2950 wcscat(PathBuffer
, KeyValue
);
2952 DPRINT("FullPath: '%S'\n", PathBuffer
);
2954 else if (KeyValue
[0] != L
'\\')
2956 DPRINT("RelativePath: '%S'\n", KeyValue
);
2957 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2958 wcscat(PathBuffer
, L
"\\");
2959 wcscat(PathBuffer
, KeyValue
);
2961 DPRINT("FullPath: '%S'\n", PathBuffer
);
2963 Status
= SetupCreateDirectory(PathBuffer
);
2964 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2966 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2967 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2971 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2977 PrepareCopyPage(PINPUT_RECORD Ir
)
2980 WCHAR PathBuffer
[MAX_PATH
];
2981 INFCONTEXT CabinetsContext
;
2987 MUIDisplayPage(PREPARE_COPY_PAGE
);
2989 /* Create the file queue */
2990 SetupFileQueue
= SetupOpenFileQueue();
2991 if (SetupFileQueue
== NULL
)
2993 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2997 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3002 /* Search for the 'Cabinets' section */
3003 if (!SetupFindFirstLineW (SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3005 return FILE_COPY_PAGE
;
3009 * Enumerate the directory values in the 'Cabinets'
3010 * section and parse their inf files.
3014 if (!INF_GetData (&CabinetsContext
, NULL
, &KeyValue
))
3017 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3018 wcscat(PathBuffer
, L
"\\");
3019 wcscat(PathBuffer
, KeyValue
);
3022 CabinetInitialize();
3023 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3024 CabinetSetCabinetName(PathBuffer
);
3026 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3028 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3030 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3031 if (InfFileData
== NULL
)
3033 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3039 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3040 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3044 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3050 if (InfHandle
== INVALID_HANDLE_VALUE
)
3052 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3058 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3063 } while (SetupFindNextLine (&CabinetsContext
, &CabinetsContext
));
3065 return FILE_COPY_PAGE
;
3070 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3073 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3075 /* Get the memory information from the system */
3076 NtQuerySystemInformation(SystemPerformanceInformation
,
3081 /* Check if this is initial setup */
3084 /* Set maximum limits to be total RAM pages */
3085 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3086 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3087 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3090 /* Set current values */
3091 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3092 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3093 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3096 static UINT CALLBACK
3097 FileCopyCallback(PVOID Context
,
3102 PCOPYCONTEXT CopyContext
;
3104 CopyContext
= (PCOPYCONTEXT
)Context
;
3106 switch (Notification
)
3108 case SPFILENOTIFY_STARTSUBQUEUE
:
3109 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3110 ProgressSetStepCount(CopyContext
->ProgressBar
,
3111 CopyContext
->TotalOperations
);
3112 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3115 case SPFILENOTIFY_STARTCOPY
:
3116 /* Display copy message */
3117 CONSOLE_SetStatusTextAutoFitX (45 , MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3118 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3121 case SPFILENOTIFY_ENDCOPY
:
3122 CopyContext
->CompletedOperations
++;
3123 ProgressNextStep(CopyContext
->ProgressBar
);
3124 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3133 FileCopyPage(PINPUT_RECORD Ir
)
3135 COPYCONTEXT CopyContext
;
3136 unsigned int mem_bar_width
;
3138 MUIDisplayPage(FILE_COPY_PAGE
);
3140 /* Create context for the copy process */
3141 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3142 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3143 CopyContext
.TotalOperations
= 0;
3144 CopyContext
.CompletedOperations
= 0;
3146 /* Create the progress bar as well */
3147 CopyContext
.ProgressBar
= CreateProgressBar(13,
3154 MUIGetString(STRING_SETUPCOPYINGFILES
));
3156 // fit memory bars to screen width, distribute them uniform
3157 mem_bar_width
= (xScreen
- 26) / 5;
3158 mem_bar_width
-= mem_bar_width
% 2; // make even
3159 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3160 /* Create the paged pool progress bar */
3161 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3170 /* Create the non paged pool progress bar */
3171 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3173 (xScreen
/ 2) + (mem_bar_width
/ 2),
3175 (xScreen
/ 2)- (mem_bar_width
/ 2),
3180 /* Create the global memory progress bar */
3181 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3185 xScreen
- 13 - mem_bar_width
,
3190 /* Do the file copying */
3191 SetupCommitFileQueueW(NULL
,
3196 /* If we get here, we're done, so cleanup the queue and progress bar */
3197 SetupCloseFileQueue(SetupFileQueue
);
3198 DestroyProgressBar(CopyContext
.ProgressBar
);
3199 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3200 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3201 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3203 /* Go display the next page */
3204 return REGISTRY_PAGE
;
3208 RegistryPage(PINPUT_RECORD Ir
)
3210 INFCONTEXT InfContext
;
3217 MUIDisplayPage(REGISTRY_PAGE
);
3219 if (RepairUpdateFlag
)
3221 return SUCCESS_PAGE
;
3224 if (!SetInstallPathValue(&DestinationPath
))
3226 DPRINT("SetInstallPathValue() failed\n");
3227 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3231 /* Create the default hives */
3233 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3234 if (!NT_SUCCESS(Status
))
3236 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3237 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3241 RegInitializeRegistry();
3244 /* Update registry */
3245 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3247 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3249 DPRINT1("SetupFindFirstLine() failed\n");
3250 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3256 INF_GetDataField (&InfContext
, 0, &Action
);
3257 INF_GetDataField (&InfContext
, 1, &File
);
3258 INF_GetDataField (&InfContext
, 2, &Section
);
3260 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3262 if (!_wcsicmp (Action
, L
"AddReg"))
3266 else if (!_wcsicmp (Action
, L
"DelReg"))
3275 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3277 if (!ImportRegistryFile(File
, Section
, Delete
))
3279 DPRINT("Importing %S failed\n", File
);
3281 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3284 } while (SetupFindNextLine (&InfContext
, &InfContext
));
3286 /* Update display registry settings */
3287 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3288 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3290 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3294 /* Set the locale */
3295 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3296 if (!ProcessLocaleRegistry(LanguageList
))
3298 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3302 /* Add keyboard layouts */
3303 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3304 if (!AddKeyboardLayouts())
3306 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3312 if (!SetGeoID(MUIGetGeoID()))
3314 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3318 if (!IsUnattendedSetup
){
3320 /* Update keyboard layout settings */
3321 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3322 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3324 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3328 /* Add codepage information to registry */
3329 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3332 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3336 /* Update the mounted devices list */
3337 SetMountedDeviceValues(PartitionList
);
3339 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3341 return BOOT_LOADER_PAGE
;
3346 BootLoaderPage(PINPUT_RECORD Ir
)
3348 UCHAR PartitionType
;
3349 BOOLEAN InstallOnFloppy
;
3352 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3354 PartitionType
= PartitionList
->ActiveBootPartition
->
3355 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3357 if (IsUnattendedSetup
)
3359 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3361 return SUCCESS_PAGE
;
3363 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3365 return BOOT_LOADER_FLOPPY_PAGE
;
3369 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3371 DPRINT("Error: active partition invalid (unused)\n");
3372 InstallOnFloppy
= TRUE
;
3374 else if (PartitionType
== 0x0A)
3376 /* OS/2 boot manager partition */
3377 DPRINT("Found OS/2 boot manager partition\n");
3378 InstallOnFloppy
= TRUE
;
3380 else if (PartitionType
== 0x83)
3382 /* Linux ext2 partition */
3383 DPRINT("Found Linux ext2 partition\n");
3384 InstallOnFloppy
= TRUE
;
3386 else if (PartitionType
== PARTITION_IFS
)
3388 /* NTFS partition */
3389 DPRINT("Found NTFS partition\n");
3390 InstallOnFloppy
= TRUE
;
3392 else if ((PartitionType
== PARTITION_FAT_12
) ||
3393 (PartitionType
== PARTITION_FAT_16
) ||
3394 (PartitionType
== PARTITION_HUGE
) ||
3395 (PartitionType
== PARTITION_XINT13
) ||
3396 (PartitionType
== PARTITION_FAT32
) ||
3397 (PartitionType
== PARTITION_FAT32_XINT13
))
3399 DPRINT("Found FAT partition\n");
3400 InstallOnFloppy
= FALSE
;
3404 /* Unknown partition */
3405 DPRINT("Unknown partition found\n");
3406 InstallOnFloppy
= TRUE
;
3409 if (InstallOnFloppy
== TRUE
)
3411 return BOOT_LOADER_FLOPPY_PAGE
;
3414 /* Unattended install on hdd? */
3415 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3417 return BOOT_LOADER_HARDDISK_PAGE
;
3420 MUIDisplayPage(BOOT_LOADER_PAGE
);
3421 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3425 CONSOLE_ConInKey(Ir
);
3427 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3428 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3430 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3433 if (Line
<12) Line
=14;
3434 if (Line
>14) Line
=12;
3436 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3438 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3439 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3441 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3444 if (Line
<12) Line
=14;
3445 if (Line
>14) Line
=12;
3447 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3449 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3450 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3452 if (ConfirmQuit(Ir
) == TRUE
)
3457 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3461 return BOOT_LOADER_HARDDISK_PAGE
;
3463 else if (Line
== 13)
3465 return BOOT_LOADER_FLOPPY_PAGE
;
3467 else if (Line
== 14)
3469 return SUCCESS_PAGE
;
3472 return BOOT_LOADER_PAGE
;
3476 return BOOT_LOADER_PAGE
;
3481 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3485 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3487 // SetStatusText(" Please wait...");
3491 CONSOLE_ConInKey(Ir
);
3493 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3494 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3496 if (ConfirmQuit(Ir
) == TRUE
)
3501 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3503 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3505 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3506 return BOOT_LOADER_FLOPPY_PAGE
;
3509 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3510 if (!NT_SUCCESS(Status
))
3512 /* Print error message */
3513 return BOOT_LOADER_FLOPPY_PAGE
;
3516 return SUCCESS_PAGE
;
3520 return BOOT_LOADER_FLOPPY_PAGE
;
3525 BootLoaderHarddiskPage(PINPUT_RECORD Ir
)
3527 UCHAR PartitionType
;
3530 PartitionType
= PartitionList
->ActiveBootPartition
->
3531 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3532 if ((PartitionType
== PARTITION_FAT_12
) ||
3533 (PartitionType
== PARTITION_FAT_16
) ||
3534 (PartitionType
== PARTITION_HUGE
) ||
3535 (PartitionType
== PARTITION_XINT13
) ||
3536 (PartitionType
== PARTITION_FAT32
) ||
3537 (PartitionType
== PARTITION_FAT32_XINT13
))
3539 Status
= InstallFatBootcodeToPartition(&SystemRootPath
,
3541 &DestinationArcPath
,
3543 if (!NT_SUCCESS(Status
))
3545 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3549 return SUCCESS_PAGE
;
3553 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3557 return BOOT_LOADER_HARDDISK_PAGE
;
3562 QuitPage(PINPUT_RECORD Ir
)
3564 MUIDisplayPage(QUIT_PAGE
);
3566 /* Destroy partition list */
3567 if (PartitionList
!= NULL
)
3569 DestroyPartitionList (PartitionList
);
3570 PartitionList
= NULL
;
3573 /* Destroy filesystem list */
3574 if (FileSystemList
!= NULL
)
3576 DestroyFileSystemList (FileSystemList
);
3577 FileSystemList
= NULL
;
3580 /* Destroy computer settings list */
3581 if (ComputerList
!= NULL
)
3583 DestroyGenericList(ComputerList
, TRUE
);
3584 ComputerList
= NULL
;
3587 /* Destroy display settings list */
3588 if (DisplayList
!= NULL
)
3590 DestroyGenericList(DisplayList
, TRUE
);
3594 /* Destroy keyboard settings list */
3595 if (KeyboardList
!= NULL
)
3597 DestroyGenericList(KeyboardList
, TRUE
);
3598 KeyboardList
= NULL
;
3601 /* Destroy keyboard layout list */
3602 if (LayoutList
!= NULL
)
3604 DestroyGenericList(LayoutList
, TRUE
);
3608 if (LanguageList
!= NULL
)
3610 DestroyGenericList(LanguageList
, FALSE
);
3611 LanguageList
= NULL
;
3614 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3618 CONSOLE_ConInKey(Ir
);
3620 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3629 SuccessPage(PINPUT_RECORD Ir
)
3631 MUIDisplayPage(SUCCESS_PAGE
);
3633 if (IsUnattendedSetup
)
3640 CONSOLE_ConInKey(Ir
);
3642 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3651 FlushPage(PINPUT_RECORD Ir
)
3653 MUIDisplayPage(FLUSH_PAGE
);
3659 PnpEventThread(IN LPVOID lpParameter
);
3669 NtQuerySystemTime(&Time
);
3671 Status
= RtlCreateUserThread(NtCurrentProcess(), NULL
, TRUE
, 0, 0, 0, PnpEventThread
, &SetupInf
, &hPnpThread
, NULL
);
3672 if (!NT_SUCCESS(Status
))
3673 hPnpThread
= INVALID_HANDLE_VALUE
;
3675 if (!CONSOLE_Init())
3677 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3678 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3679 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3681 /* Raise a hard error (crash the system/BSOD) */
3682 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3686 /* Initialize global unicode strings */
3687 RtlInitUnicodeString(&SourcePath
, NULL
);
3688 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3689 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3690 RtlInitUnicodeString(&InstallPath
, NULL
);
3691 RtlInitUnicodeString(&DestinationPath
, NULL
);
3692 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3693 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3694 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3696 /* Hide the cursor */
3697 CONSOLE_SetCursorType(TRUE
, FALSE
);
3700 while (Page
!= REBOOT_PAGE
)
3702 CONSOLE_ClearScreen();
3705 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3712 Page
= SetupStartPage(&Ir
);
3717 Page
= LanguagePage(&Ir
);
3722 Page
= LicensePage(&Ir
);
3727 Page
= IntroPage(&Ir
);
3731 case INSTALL_INTRO_PAGE
:
3732 Page
= InstallIntroPage(&Ir
);
3736 case SCSI_CONTROLLER_PAGE
:
3737 Page
= ScsiControllerPage(&Ir
);
3742 case OEM_DRIVER_PAGE
:
3743 Page
= OemDriverPage(&Ir
);
3747 case DEVICE_SETTINGS_PAGE
:
3748 Page
= DeviceSettingsPage(&Ir
);
3751 case COMPUTER_SETTINGS_PAGE
:
3752 Page
= ComputerSettingsPage(&Ir
);
3755 case DISPLAY_SETTINGS_PAGE
:
3756 Page
= DisplaySettingsPage(&Ir
);
3759 case KEYBOARD_SETTINGS_PAGE
:
3760 Page
= KeyboardSettingsPage(&Ir
);
3763 case LAYOUT_SETTINGS_PAGE
:
3764 Page
= LayoutSettingsPage(&Ir
);
3767 case SELECT_PARTITION_PAGE
:
3768 Page
= SelectPartitionPage(&Ir
);
3771 case CREATE_PARTITION_PAGE
:
3772 Page
= CreatePartitionPage(&Ir
);
3775 case DELETE_PARTITION_PAGE
:
3776 Page
= DeletePartitionPage(&Ir
);
3779 case SELECT_FILE_SYSTEM_PAGE
:
3780 Page
= SelectFileSystemPage(&Ir
);
3783 case FORMAT_PARTITION_PAGE
:
3784 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3787 case CHECK_FILE_SYSTEM_PAGE
:
3788 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3791 case INSTALL_DIRECTORY_PAGE
:
3792 Page
= InstallDirectoryPage(&Ir
);
3795 case PREPARE_COPY_PAGE
:
3796 Page
= PrepareCopyPage(&Ir
);
3799 case FILE_COPY_PAGE
:
3800 Page
= FileCopyPage(&Ir
);
3804 Page
= RegistryPage(&Ir
);
3807 case BOOT_LOADER_PAGE
:
3808 Page
= BootLoaderPage(&Ir
);
3811 case BOOT_LOADER_FLOPPY_PAGE
:
3812 Page
= BootLoaderFloppyPage(&Ir
);
3815 case BOOT_LOADER_HARDDISK_PAGE
:
3816 Page
= BootLoaderHarddiskPage(&Ir
);
3820 case REPAIR_INTRO_PAGE
:
3821 Page
= RepairIntroPage(&Ir
);
3825 Page
= SuccessPage(&Ir
);
3829 Page
= FlushPage(&Ir
);
3833 Page
= QuitPage(&Ir
);
3843 /* Avoid bugcheck */
3844 Time
.QuadPart
+= 50000000;
3845 NtDelayExecution(FALSE
, &Time
);
3848 NtShutdownSystem(ShutdownReboot
);
3849 NtTerminateProcess(NtCurrentProcess(), 0);
3856 NtProcessStartup(PPEB Peb
)
3858 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3860 ProcessHeap
= Peb
->ProcessHeap
;
3861 INF_SetHeap(ProcessHeap
);
3864 #endif /* __REACTOS__ */