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
;
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
);
585 ListEntry
= GetFirstListEntry(LayoutList
);
587 /* Search for default layout (if provided) */
588 if (pszNewLayout
!= NULL
)
590 while (ListEntry
!= NULL
)
592 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
594 SetCurrentListEntry(LayoutList
, ListEntry
);
598 ListEntry
= GetNextListEntry(ListEntry
);
604 LanguagePage(PINPUT_RECORD Ir
)
606 /* Initialize the computer settings list */
607 if (LanguageList
== NULL
)
609 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
611 if (LanguageList
== NULL
)
613 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
618 DrawGenericList(LanguageList
,
624 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
626 MUIDisplayPage(LANGUAGE_PAGE
);
630 CONSOLE_ConInKey(Ir
);
632 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
633 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
636 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
638 /* Redraw language selection page in native language */
639 MUIDisplayPage(LANGUAGE_PAGE
);
642 ScrollDownGenericList (LanguageList
);
644 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
645 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
648 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
650 /* Redraw language selection page in native language */
651 MUIDisplayPage(LANGUAGE_PAGE
);
654 ScrollUpGenericList (LanguageList
);
656 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
657 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
659 ScrollPageDownGenericList (LanguageList
);
661 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
662 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
664 ScrollPageUpGenericList (LanguageList
);
666 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
667 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
669 if (ConfirmQuit(Ir
) == TRUE
)
672 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
674 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
676 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
682 SetConsoleCodePage();
686 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
689 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
700 * Number of the next page.
703 SetupStartPage(PINPUT_RECORD Ir
)
705 SYSTEM_DEVICE_INFORMATION Sdi
;
707 WCHAR FileNameBuffer
[MAX_PATH
];
712 PGENERIC_LIST_ENTRY ListEntry
;
714 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
717 /* Check whether a harddisk is available */
718 Status
= NtQuerySystemInformation (SystemDeviceInformation
,
720 sizeof(SYSTEM_DEVICE_INFORMATION
),
723 if (!NT_SUCCESS (Status
))
725 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
726 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
730 if (Sdi
.NumberOfDisks
== 0)
732 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
736 /* Get the source path and source root path */
737 Status
= GetSourcePaths(&SourcePath
,
741 if (!NT_SUCCESS(Status
))
743 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
744 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
750 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
751 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
752 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
756 /* Load txtsetup.sif from install media. */
757 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
758 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
760 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
765 if (SetupInf
== INVALID_HANDLE_VALUE
)
767 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
771 /* Open 'Version' section */
772 if (!SetupFindFirstLineW (SetupInf
, L
"Version", L
"Signature", &Context
))
774 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
778 /* Get pointer 'Signature' key */
779 if (!INF_GetData (&Context
, NULL
, &Value
))
781 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
785 /* Check 'Signature' string */
786 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
788 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
792 /* Start PnP thread */
793 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
795 NtResumeThread(hPnpThread
, NULL
);
796 hPnpThread
= INVALID_HANDLE_VALUE
;
799 CheckUnattendedSetup();
801 if (IsUnattendedSetup
)
804 //read options from inf
805 ComputerList
= CreateComputerTypeList(SetupInf
);
806 DisplayList
= CreateDisplayDriverList(SetupInf
);
807 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
808 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
809 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
813 wcscpy(SelectedLanguageId
,LocaleID
);
816 /* first we hack LanguageList */
817 ListEntry
= GetFirstListEntry(LanguageList
);
819 while (ListEntry
!= NULL
)
821 if (!wcscmp(LocaleID
, GetListEntryUserData(ListEntry
)))
823 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
824 SetCurrentListEntry(LanguageList
, ListEntry
);
828 ListEntry
= GetNextListEntry(ListEntry
);
831 ListEntry
= GetFirstListEntry(LayoutList
);
833 while (ListEntry
!= NULL
)
835 if (!wcscmp(LocaleID
, GetListEntryUserData(ListEntry
)))
837 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
838 SetCurrentListEntry(LayoutList
, ListEntry
);
842 ListEntry
= GetNextListEntry(ListEntry
);
844 SetConsoleCodePage();
846 return INSTALL_INTRO_PAGE
;
849 return LANGUAGE_PAGE
;
859 IntroPage(PINPUT_RECORD Ir
)
861 MUIDisplayPage(START_PAGE
);
865 CONSOLE_ConInKey(Ir
);
867 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
868 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
870 if (ConfirmQuit(Ir
) == TRUE
)
875 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
877 return INSTALL_INTRO_PAGE
;
880 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
882 return REPAIR_INTRO_PAGE
;
885 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
898 * Back to main setup page.
901 LicensePage(PINPUT_RECORD Ir
)
903 MUIDisplayPage(LICENSE_PAGE
);
907 CONSOLE_ConInKey(Ir
);
909 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
920 RepairIntroPage(PINPUT_RECORD Ir
)
922 MUIDisplayPage(REPAIR_INTRO_PAGE
);
926 CONSOLE_ConInKey(Ir
);
928 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
932 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
934 RepairUpdateFlag
= TRUE
;
935 return INSTALL_INTRO_PAGE
;
937 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
941 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
942 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
948 return REPAIR_INTRO_PAGE
;
953 InstallIntroPage(PINPUT_RECORD Ir
)
955 MUIDisplayPage(INSTALL_INTRO_PAGE
);
957 if (RepairUpdateFlag
)
959 //return SELECT_PARTITION_PAGE;
960 return DEVICE_SETTINGS_PAGE
;
963 if (IsUnattendedSetup
)
965 return SELECT_PARTITION_PAGE
;
970 CONSOLE_ConInKey(Ir
);
972 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
973 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
975 if (ConfirmQuit(Ir
) == TRUE
)
980 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
982 return DEVICE_SETTINGS_PAGE
;
983 // return SCSI_CONTROLLER_PAGE;
987 return INSTALL_INTRO_PAGE
;
993 ScsiControllerPage(PINPUT_RECORD Ir
)
995 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
997 /* FIXME: print loaded mass storage driver descriptions */
999 SetTextXY(8, 10, "TEST device");
1003 SetStatusText(" ENTER = Continue F3 = Quit");
1009 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1010 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1012 if (ConfirmQuit(Ir
) == TRUE
)
1017 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1019 return DEVICE_SETTINGS_PAGE
;
1023 return SCSI_CONTROLLER_PAGE
;
1029 DeviceSettingsPage(PINPUT_RECORD Ir
)
1031 static ULONG Line
= 16;
1032 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1034 /* Initialize the computer settings list */
1035 if (ComputerList
== NULL
)
1037 ComputerList
= CreateComputerTypeList(SetupInf
);
1038 if (ComputerList
== NULL
)
1040 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1045 /* Initialize the display settings list */
1046 if (DisplayList
== NULL
)
1048 DisplayList
= CreateDisplayDriverList(SetupInf
);
1049 if (DisplayList
== NULL
)
1051 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1056 /* Initialize the keyboard settings list */
1057 if (KeyboardList
== NULL
)
1059 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1060 if (KeyboardList
== NULL
)
1062 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1067 /* Initialize the keyboard layout list */
1068 if (LayoutList
== NULL
)
1070 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1071 if (LayoutList
== NULL
)
1073 /* FIXME: report error */
1074 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1079 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1082 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1083 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1084 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1085 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1087 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1089 if (RepairUpdateFlag
)
1091 return SELECT_PARTITION_PAGE
;
1096 CONSOLE_ConInKey(Ir
);
1098 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1099 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1101 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1105 else if (Line
== 16)
1110 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1112 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1113 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1115 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1119 else if (Line
== 16)
1124 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1126 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1127 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1129 if (ConfirmQuit(Ir
) == TRUE
)
1134 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1137 return COMPUTER_SETTINGS_PAGE
;
1138 else if (Line
== 12)
1139 return DISPLAY_SETTINGS_PAGE
;
1140 else if (Line
== 13)
1141 return KEYBOARD_SETTINGS_PAGE
;
1142 else if (Line
== 14)
1143 return LAYOUT_SETTINGS_PAGE
;
1144 else if (Line
== 16)
1145 return SELECT_PARTITION_PAGE
;
1149 return DEVICE_SETTINGS_PAGE
;
1154 ComputerSettingsPage(PINPUT_RECORD Ir
)
1156 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1158 DrawGenericList(ComputerList
,
1164 SaveGenericListState(ComputerList
);
1168 CONSOLE_ConInKey(Ir
);
1170 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1171 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1173 ScrollDownGenericList (ComputerList
);
1175 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1176 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1178 ScrollUpGenericList (ComputerList
);
1180 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1181 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1183 if (ConfirmQuit(Ir
) == TRUE
)
1188 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1189 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1191 RestoreGenericListState(ComputerList
);
1192 return DEVICE_SETTINGS_PAGE
;
1194 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1196 return DEVICE_SETTINGS_PAGE
;
1200 return COMPUTER_SETTINGS_PAGE
;
1205 DisplaySettingsPage(PINPUT_RECORD Ir
)
1207 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1209 DrawGenericList(DisplayList
,
1215 SaveGenericListState(DisplayList
);
1219 CONSOLE_ConInKey(Ir
);
1221 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1222 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1224 ScrollDownGenericList (DisplayList
);
1226 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1227 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1229 ScrollUpGenericList (DisplayList
);
1231 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1232 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1234 if (ConfirmQuit(Ir
) == TRUE
)
1241 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1242 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1244 RestoreGenericListState(DisplayList
);
1245 return DEVICE_SETTINGS_PAGE
;
1247 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1249 return DEVICE_SETTINGS_PAGE
;
1253 return DISPLAY_SETTINGS_PAGE
;
1258 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1260 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1262 DrawGenericList(KeyboardList
,
1268 SaveGenericListState(KeyboardList
);
1272 CONSOLE_ConInKey(Ir
);
1274 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1275 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1277 ScrollDownGenericList (KeyboardList
);
1279 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1280 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1282 ScrollUpGenericList (KeyboardList
);
1284 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1285 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1287 if (ConfirmQuit(Ir
) == TRUE
)
1292 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1293 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1295 RestoreGenericListState(KeyboardList
);
1296 return DEVICE_SETTINGS_PAGE
;
1298 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1300 return DEVICE_SETTINGS_PAGE
;
1304 return DISPLAY_SETTINGS_PAGE
;
1309 LayoutSettingsPage(PINPUT_RECORD Ir
)
1311 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1313 DrawGenericList(LayoutList
,
1319 SaveGenericListState(LayoutList
);
1323 CONSOLE_ConInKey(Ir
);
1325 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1326 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1328 ScrollDownGenericList (LayoutList
);
1330 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1331 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1333 ScrollUpGenericList (LayoutList
);
1335 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1336 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1338 ScrollPageDownGenericList (LayoutList
);
1340 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1341 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1343 ScrollPageUpGenericList (LayoutList
);
1345 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1346 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1348 if (ConfirmQuit(Ir
) == TRUE
)
1353 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1354 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1356 RestoreGenericListState(LayoutList
);
1357 return DEVICE_SETTINGS_PAGE
;
1359 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1361 return DEVICE_SETTINGS_PAGE
;
1363 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1366 GenericListKeyPress (LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1370 return DISPLAY_SETTINGS_PAGE
;
1375 SelectPartitionPage(PINPUT_RECORD Ir
)
1377 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1379 if (PartitionList
== NULL
)
1381 PartitionList
= CreatePartitionList (2,
1386 if (PartitionList
== NULL
)
1388 /* FIXME: show an error dialog */
1393 CheckActiveBootPartition (PartitionList
);
1395 DrawPartitionList (PartitionList
);
1397 /* Warn about partitions created by Linux Fdisk */
1398 if (WarnLinuxPartitions
== TRUE
&&
1399 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1401 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1405 CONSOLE_ConInKey(Ir
);
1407 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1408 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1412 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1414 WarnLinuxPartitions
= FALSE
;
1415 return SELECT_PARTITION_PAGE
;
1420 if (IsUnattendedSetup
)
1422 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1426 PPARTENTRY PartEntry
= PartEntry
= PartitionList
->CurrentPartition
;
1427 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1429 CreateNewPartition(PartitionList
,
1433 return (SELECT_FILE_SYSTEM_PAGE
);
1438 return(SELECT_FILE_SYSTEM_PAGE
);
1444 /* Update status text */
1445 if (PartitionList
->CurrentPartition
== NULL
||
1446 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1448 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1452 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1455 CONSOLE_ConInKey(Ir
);
1457 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1458 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1460 if (ConfirmQuit(Ir
) == TRUE
)
1462 DestroyPartitionList (PartitionList
);
1463 PartitionList
= NULL
;
1469 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1470 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1472 ScrollDownPartitionList (PartitionList
);
1474 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1475 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1477 ScrollUpPartitionList (PartitionList
);
1479 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1481 if (PartitionList
->CurrentPartition
== NULL
||
1482 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1484 CreateNewPartition (PartitionList
,
1489 return SELECT_FILE_SYSTEM_PAGE
;
1491 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1493 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1495 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1496 return SELECT_PARTITION_PAGE
;
1499 return CREATE_PARTITION_PAGE
;
1501 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1503 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1505 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1506 return SELECT_PARTITION_PAGE
;
1509 return DELETE_PARTITION_PAGE
;
1513 return SELECT_PARTITION_PAGE
;
1518 DrawInputField(ULONG FieldLength
,
1529 memset(buf
, '_', sizeof(buf
));
1530 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1531 strcat(buf
, FieldContent
);
1533 WriteConsoleOutputCharacterA (StdOutput
,
1541 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1542 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1543 #define PARTITION_MAXSIZE 999999
1546 ShowPartitionSizeInputBox(SHORT Left
,
1570 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1575 strcpy (Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1576 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
1579 WriteConsoleOutputCharacterA(StdOutput
,
1585 sprintf (Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1586 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1588 WriteConsoleOutputCharacterA(StdOutput
,
1594 sprintf(Buffer
, "%lu", MaxSize
);
1595 Index
= strlen(Buffer
);
1596 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1603 CONSOLE_ConInKey(&Ir
);
1605 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1606 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1614 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1618 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1626 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1632 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1637 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1638 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1640 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1642 if ((ch
>= '0') && (ch
<= '9'))
1648 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1656 strcpy (InputBuffer
, Buffer
);
1661 CreatePartitionPage (PINPUT_RECORD Ir
)
1663 PDISKENTRY DiskEntry
;
1664 PPARTENTRY PartEntry
;
1667 CHAR InputBuffer
[50];
1673 if (PartitionList
== NULL
||
1674 PartitionList
->CurrentDisk
== NULL
||
1675 PartitionList
->CurrentPartition
== NULL
)
1677 /* FIXME: show an error dialog */
1681 DiskEntry
= PartitionList
->CurrentDisk
;
1682 PartEntry
= PartitionList
->CurrentPartition
;
1684 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1686 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1689 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1691 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1692 Unit
= MUIGetString(STRING_GB
);
1697 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1702 Unit
= MUIGetString(STRING_MB
);
1705 if (DiskEntry
->DriverName
.Length
> 0)
1707 CONSOLE_PrintTextXY(6, 10,
1708 MUIGetString(STRING_HDINFOPARTCREATE
),
1711 DiskEntry
->DiskNumber
,
1715 &DiskEntry
->DriverName
);
1719 CONSOLE_PrintTextXY(6, 10,
1720 MUIGetString(STRING_HDDINFOUNK1
),
1723 DiskEntry
->DiskNumber
,
1729 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1732 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1733 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1736 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1738 PartEntry
= PartitionList
->CurrentPartition
;
1741 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1743 if (MaxSize
> PARTITION_MAXSIZE
) MaxSize
= PARTITION_MAXSIZE
;
1745 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1746 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1750 if (ConfirmQuit (Ir
) == TRUE
)
1755 else if (Cancel
== TRUE
)
1757 return SELECT_PARTITION_PAGE
;
1761 PartSize
= atoi(InputBuffer
);
1769 if (PartSize
> MaxSize
)
1775 /* Convert to bytes */
1776 if (PartSize
== MaxSize
)
1778 /* Use all of the unpartitioned disk space */
1779 PartSize
= PartEntry
->UnpartitionedLength
;
1783 /* Round-up by cylinder size */
1784 PartSize
= ROUND_UP (PartSize
* 1024 * 1024,
1785 DiskEntry
->CylinderSize
);
1787 /* But never get larger than the unpartitioned disk space */
1788 if (PartSize
> PartEntry
->UnpartitionedLength
)
1789 PartSize
= PartEntry
->UnpartitionedLength
;
1792 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1794 CreateNewPartition (PartitionList
,
1798 return SELECT_PARTITION_PAGE
;
1802 return CREATE_PARTITION_PAGE
;
1807 DeletePartitionPage (PINPUT_RECORD Ir
)
1809 PDISKENTRY DiskEntry
;
1810 PPARTENTRY PartEntry
;
1817 if (PartitionList
== NULL
||
1818 PartitionList
->CurrentDisk
== NULL
||
1819 PartitionList
->CurrentPartition
== NULL
)
1821 /* FIXME: show an error dialog */
1825 DiskEntry
= PartitionList
->CurrentDisk
;
1826 PartEntry
= PartitionList
->CurrentPartition
;
1827 PartNumber
= PartitionList
->CurrentPartitionNumber
;
1829 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1831 /* Determine partition type */
1833 if (PartEntry
->New
== TRUE
)
1835 PartType
= MUIGetString(STRING_UNFORMATTED
);
1837 else if (PartEntry
->Unpartitioned
== FALSE
)
1839 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
1840 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
1841 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
1842 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
1846 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
1847 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
1851 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
1855 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
1857 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1862 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1864 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1865 Unit
= MUIGetString(STRING_GB
);
1869 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1871 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1872 Unit
= MUIGetString(STRING_MB
);
1876 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1877 Unit
= MUIGetString(STRING_KB
);
1880 if (PartType
== NULL
)
1882 CONSOLE_PrintTextXY(6, 10,
1883 MUIGetString(STRING_HDDINFOUNK2
),
1884 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1885 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1886 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
1892 CONSOLE_PrintTextXY(6, 10,
1893 " %c%c %s %I64u %s",
1894 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1895 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1902 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1904 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1905 Unit
= MUIGetString(STRING_GB
);
1910 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1915 Unit
= MUIGetString(STRING_MB
);
1918 if (DiskEntry
->DriverName
.Length
> 0)
1920 CONSOLE_PrintTextXY(6, 12,
1921 MUIGetString(STRING_HDINFOPARTDELETE
),
1924 DiskEntry
->DiskNumber
,
1928 &DiskEntry
->DriverName
);
1932 CONSOLE_PrintTextXY(6, 12,
1933 MUIGetString(STRING_HDDINFOUNK3
),
1936 DiskEntry
->DiskNumber
,
1944 CONSOLE_ConInKey(Ir
);
1946 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1947 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1949 if (ConfirmQuit (Ir
) == TRUE
)
1956 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1958 return SELECT_PARTITION_PAGE
;
1960 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1962 DeleteCurrentPartition (PartitionList
);
1964 return SELECT_PARTITION_PAGE
;
1968 return DELETE_PARTITION_PAGE
;
1973 SelectFileSystemPage (PINPUT_RECORD Ir
)
1975 PDISKENTRY DiskEntry
;
1976 PPARTENTRY PartEntry
;
1984 if (PartitionList
== NULL
||
1985 PartitionList
->CurrentDisk
== NULL
||
1986 PartitionList
->CurrentPartition
== NULL
)
1988 /* FIXME: show an error dialog */
1992 DiskEntry
= PartitionList
->CurrentDisk
;
1993 PartEntry
= PartitionList
->CurrentPartition
;
1994 PartNumber
= PartitionList
->CurrentPartitionNumber
;
1996 /* adjust disk size */
1997 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1999 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
2000 DiskUnit
= MUIGetString(STRING_GB
);
2004 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
2005 DiskUnit
= MUIGetString(STRING_MB
);
2008 /* adjust partition size */
2009 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
2011 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
2012 PartUnit
= MUIGetString(STRING_GB
);
2016 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
2017 PartUnit
= MUIGetString(STRING_MB
);
2020 /* adjust partition type */
2021 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
2022 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
2023 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
2024 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
2028 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
2029 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
2033 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
2037 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
2039 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2041 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_ENTRY_UNUSED
)
2043 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2047 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2050 if (PartEntry
->AutoCreate
== TRUE
)
2052 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2055 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2056 PartEntry
->PartInfo
[PartNumber
].PartitionNumber
,
2062 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2063 DiskEntry
->DiskNumber
,
2069 &DiskEntry
->DriverName
);
2071 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2074 PartEntry
->AutoCreate
= FALSE
;
2076 else if (PartEntry
->New
== TRUE
)
2078 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2079 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2083 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2085 if (PartType
== NULL
)
2087 CONSOLE_PrintTextXY(8, 10,
2088 MUIGetString(STRING_HDDINFOUNK4
),
2089 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2090 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2091 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
2097 CONSOLE_PrintTextXY(8, 10,
2099 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2100 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2106 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2107 DiskEntry
->DiskNumber
,
2113 &DiskEntry
->DriverName
);
2116 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2118 if (FileSystemList
== NULL
)
2120 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, L
"FAT");
2121 if (FileSystemList
== NULL
)
2123 /* FIXME: show an error dialog */
2127 /* FIXME: Add file systems to list */
2129 DrawFileSystemList (FileSystemList
);
2131 if (RepairUpdateFlag
)
2133 return CHECK_FILE_SYSTEM_PAGE
;
2134 //return SELECT_PARTITION_PAGE;
2137 if (IsUnattendedSetup
)
2139 if (UnattendFormatPartition
)
2141 return FORMAT_PARTITION_PAGE
;
2144 return(CHECK_FILE_SYSTEM_PAGE
);
2149 CONSOLE_ConInKey(Ir
);
2151 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2152 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2154 if (ConfirmQuit (Ir
) == TRUE
)
2161 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2162 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2164 return SELECT_PARTITION_PAGE
;
2166 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2167 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2169 ScrollDownFileSystemList (FileSystemList
);
2171 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2172 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2174 ScrollUpFileSystemList (FileSystemList
);
2176 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2178 if (!FileSystemList
->Selected
->FormatFunc
)
2180 return CHECK_FILE_SYSTEM_PAGE
;
2184 return FORMAT_PARTITION_PAGE
;
2189 return SELECT_FILE_SYSTEM_PAGE
;
2194 FormatPartitionPage (PINPUT_RECORD Ir
)
2196 WCHAR PathBuffer
[MAX_PATH
];
2197 PDISKENTRY DiskEntry
;
2198 PPARTENTRY PartEntry
;
2208 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2210 if (PartitionList
== NULL
||
2211 PartitionList
->CurrentDisk
== NULL
||
2212 PartitionList
->CurrentPartition
== NULL
)
2214 /* FIXME: show an error dialog */
2218 DiskEntry
= PartitionList
->CurrentDisk
;
2219 PartEntry
= PartitionList
->CurrentPartition
;
2220 PartNum
= PartitionList
->CurrentPartitionNumber
;
2224 if (!IsUnattendedSetup
)
2226 CONSOLE_ConInKey(Ir
);
2229 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2230 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2232 if (ConfirmQuit (Ir
) == TRUE
)
2239 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2241 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2243 if (PartEntry
->PartInfo
[PartNum
].PartitionType
== PARTITION_ENTRY_UNUSED
)
2245 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2247 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2249 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2250 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_12
;
2252 else if (PartEntry
->PartInfo
[PartNum
].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2254 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2256 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2258 /* FAT16 CHS partition (partiton size < 32MB) */
2259 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_16
;
2261 else if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2263 /* FAT16 CHS partition (partition size < 512MB) */
2264 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_HUGE
;
2268 /* FAT32 CHS partition (partition size >= 512MB) */
2269 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32
;
2274 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2276 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2278 /* FAT16 LBA partition (partition size < 512MB) */
2279 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_XINT13
;
2283 /* FAT32 LBA partition (partition size >= 512MB) */
2284 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32_XINT13
;
2288 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2289 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_EXT2
;
2290 else if (!FileSystemList
->Selected
->FormatFunc
)
2294 CheckActiveBootPartition (PartitionList
);
2297 CONSOLE_PrintTextXY(6, 12,
2298 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2299 DiskEntry
->DiskSize
,
2300 DiskEntry
->CylinderSize
,
2301 DiskEntry
->TrackSize
);
2304 DiskEntry
= PartitionList
->CurrentDisk
;
2305 Entry
= DiskEntry
->PartListHead
.Flink
;
2307 while (Entry
!= &DiskEntry
->PartListHead
)
2309 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2311 if (PartEntry
->Unpartitioned
== FALSE
)
2313 for (i
= 0; i
< 4; i
++)
2315 CONSOLE_PrintTextXY(6, Line
,
2316 "%2u: %2u %c %12I64u %12I64u %2u %c",
2318 PartEntry
->PartInfo
[i
].PartitionNumber
,
2319 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2320 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2321 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2322 PartEntry
->PartInfo
[i
].PartitionType
,
2323 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2331 Entry
= Entry
->Flink
;
2334 /* Restore the old entry */
2335 PartEntry
= PartitionList
->CurrentPartition
;
2338 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
2340 DPRINT ("WritePartitionsToDisk() failed\n");
2341 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2345 /* Set DestinationRootPath */
2346 RtlFreeUnicodeString (&DestinationRootPath
);
2347 swprintf (PathBuffer
,
2348 L
"\\Device\\Harddisk%lu\\Partition%lu",
2349 PartitionList
->CurrentDisk
->DiskNumber
,
2350 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2351 RtlCreateUnicodeString (&DestinationRootPath
,
2353 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2356 /* Set SystemRootPath */
2357 RtlFreeUnicodeString (&SystemRootPath
);
2358 swprintf (PathBuffer
,
2359 L
"\\Device\\Harddisk%lu\\Partition%lu",
2360 PartitionList
->ActiveBootDisk
->DiskNumber
,
2361 PartitionList
->ActiveBootPartition
->
2362 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionNumber
);
2363 RtlCreateUnicodeString (&SystemRootPath
,
2365 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
2368 if (FileSystemList
->Selected
->FormatFunc
)
2370 Status
= FormatPartition(&DestinationRootPath
, FileSystemList
->Selected
);
2371 if (!NT_SUCCESS(Status
))
2373 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2374 /* FIXME: show an error dialog */
2378 PartEntry
->New
= FALSE
;
2380 CheckActiveBootPartition(PartitionList
);
2383 /* Install MBR if necessary */
2384 if (DiskEntry
->NoMbr
&&
2385 DiskEntry
->BiosDiskNumber
== 0)
2387 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2388 wcscat(PathBuffer
, L
"\\loader\\dosmbr.bin");
2390 DPRINT("Install MBR bootcode: %S ==> %S\n",
2391 PathBuffer
, DestinationRootPath
.Buffer
);
2393 /* Install MBR bootcode */
2394 Status
= InstallMbrBootCodeToDisk(PathBuffer
, DestinationRootPath
.Buffer
);
2395 if (!NT_SUCCESS (Status
))
2397 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
2402 DiskEntry
->NoMbr
= FALSE
;
2405 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2407 /* FIXME: Install boot code. This is a hack! */
2408 if ((PartEntry
->PartInfo
[PartNum
].PartitionType
== PARTITION_FAT32_XINT13
) ||
2409 (PartEntry
->PartInfo
[PartNum
].PartitionType
== PARTITION_FAT32
))
2411 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2412 wcscat(PathBuffer
, L
"\\loader\\fat32.bin");
2414 DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
2415 DestinationRootPath
.Buffer
);
2416 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2417 DestinationRootPath
.Buffer
);
2419 if (!NT_SUCCESS(Status
))
2421 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2422 /* FIXME: show an error dialog */
2423 DestroyFileSystemList(FileSystemList
);
2424 FileSystemList
= NULL
;
2430 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2431 wcscat(PathBuffer
, L
"\\loader\\fat.bin");
2433 DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer
,
2434 DestinationRootPath
.Buffer
);
2435 Status
= InstallFat16BootCodeToDisk(PathBuffer
,
2436 DestinationRootPath
.Buffer
);
2438 if (!NT_SUCCESS(Status
))
2440 DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status
);
2441 /* FIXME: show an error dialog */
2442 DestroyFileSystemList(FileSystemList
);
2443 FileSystemList
= NULL
;
2448 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2450 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2451 wcscat(PathBuffer
, L
"\\loader\\ext2.bin");
2453 DPRINT("Install EXT2 bootcode: %S ==> %S\n", PathBuffer
,
2454 DestinationRootPath
.Buffer
);
2455 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2456 DestinationRootPath
.Buffer
);
2458 if (!NT_SUCCESS(Status
))
2460 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2461 /* FIXME: show an error dialog */
2462 DestroyFileSystemList(FileSystemList
);
2463 FileSystemList
= NULL
;
2467 else if (FileSystemList
->Selected
->FormatFunc
)
2469 DestroyFileSystemList(FileSystemList
);
2470 FileSystemList
= NULL
;
2475 CONSOLE_SetStatusText(" Done. Press any key ...");
2476 CONSOLE_ConInKey(Ir
);
2479 DestroyFileSystemList(FileSystemList
);
2480 FileSystemList
= NULL
;
2481 return INSTALL_DIRECTORY_PAGE
;
2485 return FORMAT_PARTITION_PAGE
;
2490 CheckFileSystemPage(PINPUT_RECORD Ir
)
2492 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2493 WCHAR PathBuffer
[MAX_PATH
];
2494 CHAR Buffer
[MAX_PATH
];
2496 UCHAR PartNum
= PartitionList
->CurrentPartitionNumber
;
2498 /* FIXME: code duplicated in FormatPartitionPage */
2499 /* Set DestinationRootPath */
2500 RtlFreeUnicodeString(&DestinationRootPath
);
2501 swprintf(PathBuffer
,
2502 L
"\\Device\\Harddisk%lu\\Partition%lu",
2503 PartitionList
->CurrentDisk
->DiskNumber
,
2504 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2505 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2506 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2508 /* Set SystemRootPath */
2509 RtlFreeUnicodeString(&SystemRootPath
);
2510 swprintf(PathBuffer
,
2511 L
"\\Device\\Harddisk%lu\\Partition%lu",
2512 PartitionList
->ActiveBootDisk
->DiskNumber
,
2513 PartitionList
->ActiveBootPartition
->PartInfo
[PartNum
].PartitionNumber
);
2514 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2515 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2517 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2519 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2521 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2522 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2524 if (!CurrentFileSystem
->ChkdskFunc
)
2527 "Setup is currently unable to check a partition formatted in %S.\n"
2529 " \x07 Press ENTER to continue Setup.\n"
2530 " \x07 Press F3 to quit Setup.",
2531 CurrentFileSystem
->FileSystem
);
2534 MUIGetString(STRING_QUITCONTINUE
),
2535 NULL
, POPUP_WAIT_NONE
);
2539 CONSOLE_ConInKey(Ir
);
2541 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2542 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2544 if (ConfirmQuit(Ir
))
2547 return CHECK_FILE_SYSTEM_PAGE
;
2549 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2551 return INSTALL_DIRECTORY_PAGE
;
2557 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2558 if (!NT_SUCCESS(Status
))
2560 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2561 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2562 "(Status 0x%08lx).\n", Status
);
2565 MUIGetString(STRING_REBOOTCOMPUTER
),
2566 Ir
, POPUP_WAIT_ENTER
);
2571 return INSTALL_DIRECTORY_PAGE
;
2577 InstallDirectoryPage1(PWCHAR InstallDir
, PDISKENTRY DiskEntry
, PPARTENTRY PartEntry
, UCHAR PartNum
)
2579 WCHAR PathBuffer
[MAX_PATH
];
2581 /* Create 'InstallPath' string */
2582 RtlFreeUnicodeString(&InstallPath
);
2583 RtlCreateUnicodeString(&InstallPath
,
2586 /* Create 'DestinationPath' string */
2587 RtlFreeUnicodeString(&DestinationPath
);
2588 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2590 if (InstallDir
[0] != L
'\\')
2591 wcscat(PathBuffer
, L
"\\");
2593 wcscat(PathBuffer
, InstallDir
);
2594 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2596 /* Create 'DestinationArcPath' */
2597 RtlFreeUnicodeString(&DestinationArcPath
);
2598 swprintf(PathBuffer
,
2599 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2600 DiskEntry
->BiosDiskNumber
,
2601 PartEntry
->PartInfo
[PartNum
].PartitionNumber
);
2603 if (InstallDir
[0] != L
'\\')
2604 wcscat(PathBuffer
, L
"\\");
2606 wcscat(PathBuffer
, InstallDir
);
2607 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2609 return(PREPARE_COPY_PAGE
);
2614 InstallDirectoryPage(PINPUT_RECORD Ir
)
2616 PDISKENTRY DiskEntry
;
2617 PPARTENTRY PartEntry
;
2618 WCHAR InstallDir
[51];
2623 if (PartitionList
== NULL
||
2624 PartitionList
->CurrentDisk
== NULL
||
2625 PartitionList
->CurrentPartition
== NULL
)
2627 /* FIXME: show an error dialog */
2631 DiskEntry
= PartitionList
->CurrentDisk
;
2632 PartEntry
= PartitionList
->CurrentPartition
;
2634 /* Search for 'DefaultPath' in the 'SetupData' section */
2635 if (!SetupFindFirstLineW (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2637 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2641 /* Read the 'DefaultPath' data */
2642 if (INF_GetData (&Context
, NULL
, &DefaultPath
))
2644 wcscpy(InstallDir
, DefaultPath
);
2648 wcscpy(InstallDir
, L
"\\ReactOS");
2651 Length
= wcslen(InstallDir
);
2652 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2653 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2655 if (IsUnattendedSetup
)
2657 return(InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
, PartitionList
->CurrentPartitionNumber
));
2662 CONSOLE_ConInKey(Ir
);
2664 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2665 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2667 if (ConfirmQuit(Ir
) == TRUE
)
2672 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2674 return (InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
, PartitionList
->CurrentPartitionNumber
));
2676 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2681 InstallDir
[Length
] = 0;
2682 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2685 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2689 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2691 InstallDir
[Length
] = 0;
2692 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2697 return(INSTALL_DIRECTORY_PAGE
);
2701 AddSectionToCopyQueueCab(HINF InfFile
,
2703 PWCHAR SourceCabinet
,
2704 PCUNICODE_STRING DestinationPath
,
2707 INFCONTEXT FilesContext
;
2708 INFCONTEXT DirContext
;
2710 PWCHAR FileKeyValue
;
2712 PWCHAR TargetFileName
;
2714 /* Search for the SectionName section */
2715 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2718 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2719 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2724 * Enumerate the files in the section
2725 * and add them to the file queue.
2729 /* Get source file name and target directory id */
2730 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2732 /* FIXME: Handle error! */
2733 DPRINT1("INF_GetData() failed\n");
2737 /* Get optional target file name */
2738 if (!INF_GetDataField (&FilesContext
, 2, &TargetFileName
))
2739 TargetFileName
= NULL
;
2741 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2743 /* Lookup target directory */
2744 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2746 /* FIXME: Handle error! */
2747 DPRINT1("SetupFindFirstLine() failed\n");
2751 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2753 /* FIXME: Handle error! */
2754 DPRINT1("INF_GetData() failed\n");
2758 if (!SetupQueueCopy(SetupFileQueue
,
2760 SourceRootPath
.Buffer
,
2761 SourceRootDir
.Buffer
,
2766 /* FIXME: Handle error! */
2767 DPRINT1("SetupQueueCopy() failed\n");
2769 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2775 AddSectionToCopyQueue(HINF InfFile
,
2777 PWCHAR SourceCabinet
,
2778 PCUNICODE_STRING DestinationPath
,
2781 INFCONTEXT FilesContext
;
2782 INFCONTEXT DirContext
;
2784 PWCHAR FileKeyValue
;
2786 PWCHAR TargetFileName
;
2789 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2791 /* Search for the SectionName section */
2792 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2795 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2796 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2801 * Enumerate the files in the section
2802 * and add them to the file queue.
2806 /* Get source file name and target directory id */
2807 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2809 /* FIXME: Handle error! */
2810 DPRINT1("INF_GetData() failed\n");
2814 /* Get target directory id */
2815 if (!INF_GetDataField (&FilesContext
, 13, &FileKeyValue
))
2817 /* FIXME: Handle error! */
2818 DPRINT1("INF_GetData() failed\n");
2822 /* Get optional target file name */
2823 if (!INF_GetDataField (&FilesContext
, 11, &TargetFileName
))
2824 TargetFileName
= NULL
;
2825 else if (!*TargetFileName
)
2826 TargetFileName
= NULL
;
2828 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2830 /* Lookup target directory */
2831 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2833 /* FIXME: Handle error! */
2834 DPRINT1("SetupFindFirstLine() failed\n");
2838 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2840 /* FIXME: Handle error! */
2841 DPRINT1("INF_GetData() failed\n");
2845 if (!SetupQueueCopy(SetupFileQueue
,
2847 SourceRootPath
.Buffer
,
2848 SourceRootDir
.Buffer
,
2853 /* FIXME: Handle error! */
2854 DPRINT1("SetupQueueCopy() failed\n");
2856 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2862 PrepareCopyPageInfFile(HINF InfFile
,
2863 PWCHAR SourceCabinet
,
2866 WCHAR PathBuffer
[MAX_PATH
];
2867 INFCONTEXT DirContext
;
2868 PWCHAR AdditionalSectionName
= NULL
;
2873 /* Add common files */
2874 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2877 /* Add specific files depending of computer type */
2878 if (SourceCabinet
== NULL
)
2880 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2883 if (AdditionalSectionName
)
2885 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2890 /* Create directories */
2894 * Install directories like '\reactos\test' are not handled yet.
2897 /* Get destination path */
2898 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2900 /* Remove trailing backslash */
2901 Length
= wcslen(PathBuffer
);
2902 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2904 PathBuffer
[Length
- 1] = 0;
2907 /* Create the install directory */
2908 Status
= SetupCreateDirectory(PathBuffer
);
2909 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2911 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2912 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2916 /* Search for the 'Directories' section */
2917 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2921 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2925 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2931 /* Enumerate the directory values and create the subdirectories */
2934 if (!INF_GetData (&DirContext
, NULL
, &KeyValue
))
2940 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2942 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2944 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2945 wcscat(PathBuffer
, KeyValue
);
2947 DPRINT("FullPath: '%S'\n", PathBuffer
);
2949 else if (KeyValue
[0] != L
'\\')
2951 DPRINT("RelativePath: '%S'\n", KeyValue
);
2952 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2953 wcscat(PathBuffer
, L
"\\");
2954 wcscat(PathBuffer
, KeyValue
);
2956 DPRINT("FullPath: '%S'\n", PathBuffer
);
2958 Status
= SetupCreateDirectory(PathBuffer
);
2959 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2961 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2962 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2966 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2972 PrepareCopyPage(PINPUT_RECORD Ir
)
2975 WCHAR PathBuffer
[MAX_PATH
];
2976 INFCONTEXT CabinetsContext
;
2982 MUIDisplayPage(PREPARE_COPY_PAGE
);
2984 /* Create the file queue */
2985 SetupFileQueue
= SetupOpenFileQueue();
2986 if (SetupFileQueue
== NULL
)
2988 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2992 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2997 /* Search for the 'Cabinets' section */
2998 if (!SetupFindFirstLineW (SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3000 return FILE_COPY_PAGE
;
3004 * Enumerate the directory values in the 'Cabinets'
3005 * section and parse their inf files.
3009 if (!INF_GetData (&CabinetsContext
, NULL
, &KeyValue
))
3012 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3013 wcscat(PathBuffer
, L
"\\");
3014 wcscat(PathBuffer
, KeyValue
);
3017 CabinetInitialize();
3018 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3019 CabinetSetCabinetName(PathBuffer
);
3021 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3023 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3025 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3026 if (InfFileData
== NULL
)
3028 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3034 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3035 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3039 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3045 if (InfHandle
== INVALID_HANDLE_VALUE
)
3047 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3053 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3058 } while (SetupFindNextLine (&CabinetsContext
, &CabinetsContext
));
3060 return FILE_COPY_PAGE
;
3065 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3068 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3070 /* Get the memory information from the system */
3071 NtQuerySystemInformation(SystemPerformanceInformation
,
3076 /* Check if this is initial setup */
3079 /* Set maximum limits to be total RAM pages */
3080 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3081 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3082 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3085 /* Set current values */
3086 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3087 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3088 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3091 static UINT CALLBACK
3092 FileCopyCallback(PVOID Context
,
3097 PCOPYCONTEXT CopyContext
;
3099 CopyContext
= (PCOPYCONTEXT
)Context
;
3101 switch (Notification
)
3103 case SPFILENOTIFY_STARTSUBQUEUE
:
3104 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3105 ProgressSetStepCount(CopyContext
->ProgressBar
,
3106 CopyContext
->TotalOperations
);
3107 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3110 case SPFILENOTIFY_STARTCOPY
:
3111 /* Display copy message */
3112 CONSOLE_SetStatusTextAutoFitX (45 , MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3113 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3116 case SPFILENOTIFY_ENDCOPY
:
3117 CopyContext
->CompletedOperations
++;
3118 ProgressNextStep(CopyContext
->ProgressBar
);
3119 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3128 FileCopyPage(PINPUT_RECORD Ir
)
3130 COPYCONTEXT CopyContext
;
3132 MUIDisplayPage(FILE_COPY_PAGE
);
3134 /* Create context for the copy process */
3135 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3136 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3137 CopyContext
.TotalOperations
= 0;
3138 CopyContext
.CompletedOperations
= 0;
3140 /* Create the progress bar as well */
3141 CopyContext
.ProgressBar
= CreateProgressBar(13,
3148 MUIGetString(STRING_SETUPCOPYINGFILES
));
3150 // fit memory bars to screen width, distribute them uniform
3151 unsigned int mem_bar_width
= (xScreen
- 26) / 5;
3152 mem_bar_width
-= mem_bar_width
% 2; // make even
3153 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3154 /* Create the paged pool progress bar */
3155 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3164 /* Create the non paged pool progress bar */
3165 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3167 (xScreen
/ 2) + (mem_bar_width
/ 2),
3169 (xScreen
/ 2)- (mem_bar_width
/ 2),
3174 /* Create the global memory progress bar */
3175 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3179 xScreen
- 13 - mem_bar_width
,
3184 /* Do the file copying */
3185 SetupCommitFileQueueW(NULL
,
3190 /* If we get here, we're done, so cleanup the queue and progress bar */
3191 SetupCloseFileQueue(SetupFileQueue
);
3192 DestroyProgressBar(CopyContext
.ProgressBar
);
3193 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3194 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3195 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3197 /* Go display the next page */
3198 return REGISTRY_PAGE
;
3202 RegistryPage(PINPUT_RECORD Ir
)
3204 INFCONTEXT InfContext
;
3211 MUIDisplayPage(REGISTRY_PAGE
);
3213 if (RepairUpdateFlag
)
3215 return SUCCESS_PAGE
;
3218 if (!SetInstallPathValue(&DestinationPath
))
3220 DPRINT("SetInstallPathValue() failed\n");
3221 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3225 /* Create the default hives */
3227 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3228 if (!NT_SUCCESS(Status
))
3230 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3231 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3235 RegInitializeRegistry();
3238 /* Update registry */
3239 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3241 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3243 DPRINT1("SetupFindFirstLine() failed\n");
3244 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3250 INF_GetDataField (&InfContext
, 0, &Action
);
3251 INF_GetDataField (&InfContext
, 1, &File
);
3252 INF_GetDataField (&InfContext
, 2, &Section
);
3254 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3256 if (!_wcsicmp (Action
, L
"AddReg"))
3260 else if (!_wcsicmp (Action
, L
"DelReg"))
3269 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3271 if (!ImportRegistryFile(File
, Section
, Delete
))
3273 DPRINT("Importing %S failed\n", File
);
3275 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3278 } while (SetupFindNextLine (&InfContext
, &InfContext
));
3280 /* Update display registry settings */
3281 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3282 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3284 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3288 /* Set the locale */
3289 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3290 if (!ProcessLocaleRegistry(LanguageList
))
3292 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3296 /* Add keyboard layouts */
3297 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3298 if (!AddKeyboardLayouts())
3300 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3306 if (!SetGeoID(MUIGetGeoID()))
3308 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3312 if (!IsUnattendedSetup
){
3314 /* Update keyboard layout settings */
3315 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3316 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3318 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3322 /* Add codepage information to registry */
3323 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3326 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3330 /* Update the mounted devices list */
3331 SetMountedDeviceValues(PartitionList
);
3333 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3335 return BOOT_LOADER_PAGE
;
3340 BootLoaderPage(PINPUT_RECORD Ir
)
3342 UCHAR PartitionType
;
3343 BOOLEAN InstallOnFloppy
;
3346 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3348 PartitionType
= PartitionList
->ActiveBootPartition
->
3349 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3351 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3353 DPRINT("Error: active partition invalid (unused)\n");
3354 InstallOnFloppy
= TRUE
;
3356 else if (PartitionType
== 0x0A)
3358 /* OS/2 boot manager partition */
3359 DPRINT("Found OS/2 boot manager partition\n");
3360 InstallOnFloppy
= TRUE
;
3362 else if (PartitionType
== 0x83)
3364 /* Linux ext2 partition */
3365 DPRINT("Found Linux ext2 partition\n");
3366 InstallOnFloppy
= TRUE
;
3368 else if (PartitionType
== PARTITION_IFS
)
3370 /* NTFS partition */
3371 DPRINT("Found NTFS partition\n");
3372 InstallOnFloppy
= TRUE
;
3374 else if ((PartitionType
== PARTITION_FAT_12
) ||
3375 (PartitionType
== PARTITION_FAT_16
) ||
3376 (PartitionType
== PARTITION_HUGE
) ||
3377 (PartitionType
== PARTITION_XINT13
) ||
3378 (PartitionType
== PARTITION_FAT32
) ||
3379 (PartitionType
== PARTITION_FAT32_XINT13
))
3381 DPRINT("Found FAT partition\n");
3382 InstallOnFloppy
= FALSE
;
3386 /* Unknown partition */
3387 DPRINT("Unknown partition found\n");
3388 InstallOnFloppy
= TRUE
;
3391 if (InstallOnFloppy
== TRUE
)
3393 return BOOT_LOADER_FLOPPY_PAGE
;
3396 if (IsUnattendedSetup
)
3398 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3400 return SUCCESS_PAGE
;
3402 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3404 return BOOT_LOADER_FLOPPY_PAGE
;
3406 else if (UnattendMBRInstallType
== 2) /* install on hdd */
3408 return BOOT_LOADER_HARDDISK_PAGE
;
3412 MUIDisplayPage(BOOT_LOADER_PAGE
);
3413 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3417 CONSOLE_ConInKey(Ir
);
3419 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3420 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3422 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3425 if (Line
<12) Line
=14;
3426 if (Line
>14) Line
=12;
3428 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3430 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3431 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3433 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3436 if (Line
<12) Line
=14;
3437 if (Line
>14) Line
=12;
3439 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3441 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3442 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3444 if (ConfirmQuit(Ir
) == TRUE
)
3449 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3453 return BOOT_LOADER_HARDDISK_PAGE
;
3455 else if (Line
== 13)
3457 return BOOT_LOADER_FLOPPY_PAGE
;
3459 else if (Line
== 14)
3461 return SUCCESS_PAGE
;
3464 return BOOT_LOADER_PAGE
;
3468 return BOOT_LOADER_PAGE
;
3473 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3477 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3479 // SetStatusText(" Please wait...");
3483 CONSOLE_ConInKey(Ir
);
3485 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3486 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3488 if (ConfirmQuit(Ir
) == TRUE
)
3493 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3495 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3497 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3498 return BOOT_LOADER_FLOPPY_PAGE
;
3501 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3502 if (!NT_SUCCESS(Status
))
3504 /* Print error message */
3505 return BOOT_LOADER_FLOPPY_PAGE
;
3508 return SUCCESS_PAGE
;
3512 return BOOT_LOADER_FLOPPY_PAGE
;
3517 BootLoaderHarddiskPage(PINPUT_RECORD Ir
)
3519 UCHAR PartitionType
;
3522 PartitionType
= PartitionList
->ActiveBootPartition
->
3523 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3524 if ((PartitionType
== PARTITION_FAT_12
) ||
3525 (PartitionType
== PARTITION_FAT_16
) ||
3526 (PartitionType
== PARTITION_HUGE
) ||
3527 (PartitionType
== PARTITION_XINT13
) ||
3528 (PartitionType
== PARTITION_FAT32
) ||
3529 (PartitionType
== PARTITION_FAT32_XINT13
))
3531 Status
= InstallFatBootcodeToPartition(&SystemRootPath
,
3533 &DestinationArcPath
,
3535 if (!NT_SUCCESS(Status
))
3537 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3541 return SUCCESS_PAGE
;
3545 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3549 return BOOT_LOADER_HARDDISK_PAGE
;
3554 QuitPage(PINPUT_RECORD Ir
)
3556 MUIDisplayPage(QUIT_PAGE
);
3558 /* Destroy partition list */
3559 if (PartitionList
!= NULL
)
3561 DestroyPartitionList (PartitionList
);
3562 PartitionList
= NULL
;
3565 /* Destroy filesystem list */
3566 if (FileSystemList
!= NULL
)
3568 DestroyFileSystemList (FileSystemList
);
3569 FileSystemList
= NULL
;
3572 /* Destroy computer settings list */
3573 if (ComputerList
!= NULL
)
3575 DestroyGenericList(ComputerList
, TRUE
);
3576 ComputerList
= NULL
;
3579 /* Destroy display settings list */
3580 if (DisplayList
!= NULL
)
3582 DestroyGenericList(DisplayList
, TRUE
);
3586 /* Destroy keyboard settings list */
3587 if (KeyboardList
!= NULL
)
3589 DestroyGenericList(KeyboardList
, TRUE
);
3590 KeyboardList
= NULL
;
3593 /* Destroy keyboard layout list */
3594 if (LayoutList
!= NULL
)
3596 DestroyGenericList(LayoutList
, TRUE
);
3600 if (LanguageList
!= NULL
)
3602 DestroyGenericList(LanguageList
, FALSE
);
3603 LanguageList
= NULL
;
3606 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3610 CONSOLE_ConInKey(Ir
);
3612 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3621 SuccessPage(PINPUT_RECORD Ir
)
3623 MUIDisplayPage(SUCCESS_PAGE
);
3625 if (IsUnattendedSetup
)
3632 CONSOLE_ConInKey(Ir
);
3634 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3643 FlushPage(PINPUT_RECORD Ir
)
3645 MUIDisplayPage(FLUSH_PAGE
);
3651 PnpEventThread(IN LPVOID lpParameter
);
3661 NtQuerySystemTime(&Time
);
3663 Status
= RtlCreateUserThread(NtCurrentProcess(), NULL
, TRUE
, 0, 0, 0, PnpEventThread
, &SetupInf
, &hPnpThread
, NULL
);
3664 if (!NT_SUCCESS(Status
))
3665 hPnpThread
= INVALID_HANDLE_VALUE
;
3667 if (!CONSOLE_Init())
3669 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3670 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3671 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3673 /* Raise a hard error (crash the system/BSOD) */
3674 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3678 /* Initialize global unicode strings */
3679 RtlInitUnicodeString(&SourcePath
, NULL
);
3680 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3681 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3682 RtlInitUnicodeString(&InstallPath
, NULL
);
3683 RtlInitUnicodeString(&DestinationPath
, NULL
);
3684 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3685 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3686 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3688 /* Hide the cursor */
3689 CONSOLE_SetCursorType(TRUE
, FALSE
);
3692 while (Page
!= REBOOT_PAGE
)
3694 CONSOLE_ClearScreen();
3697 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3704 Page
= SetupStartPage(&Ir
);
3709 Page
= LanguagePage(&Ir
);
3714 Page
= LicensePage(&Ir
);
3719 Page
= IntroPage(&Ir
);
3723 case INSTALL_INTRO_PAGE
:
3724 Page
= InstallIntroPage(&Ir
);
3728 case SCSI_CONTROLLER_PAGE
:
3729 Page
= ScsiControllerPage(&Ir
);
3734 case OEM_DRIVER_PAGE
:
3735 Page
= OemDriverPage(&Ir
);
3739 case DEVICE_SETTINGS_PAGE
:
3740 Page
= DeviceSettingsPage(&Ir
);
3743 case COMPUTER_SETTINGS_PAGE
:
3744 Page
= ComputerSettingsPage(&Ir
);
3747 case DISPLAY_SETTINGS_PAGE
:
3748 Page
= DisplaySettingsPage(&Ir
);
3751 case KEYBOARD_SETTINGS_PAGE
:
3752 Page
= KeyboardSettingsPage(&Ir
);
3755 case LAYOUT_SETTINGS_PAGE
:
3756 Page
= LayoutSettingsPage(&Ir
);
3759 case SELECT_PARTITION_PAGE
:
3760 Page
= SelectPartitionPage(&Ir
);
3763 case CREATE_PARTITION_PAGE
:
3764 Page
= CreatePartitionPage(&Ir
);
3767 case DELETE_PARTITION_PAGE
:
3768 Page
= DeletePartitionPage(&Ir
);
3771 case SELECT_FILE_SYSTEM_PAGE
:
3772 Page
= SelectFileSystemPage(&Ir
);
3775 case FORMAT_PARTITION_PAGE
:
3776 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3779 case CHECK_FILE_SYSTEM_PAGE
:
3780 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3783 case INSTALL_DIRECTORY_PAGE
:
3784 Page
= InstallDirectoryPage(&Ir
);
3787 case PREPARE_COPY_PAGE
:
3788 Page
= PrepareCopyPage(&Ir
);
3791 case FILE_COPY_PAGE
:
3792 Page
= FileCopyPage(&Ir
);
3796 Page
= RegistryPage(&Ir
);
3799 case BOOT_LOADER_PAGE
:
3800 Page
= BootLoaderPage(&Ir
);
3803 case BOOT_LOADER_FLOPPY_PAGE
:
3804 Page
= BootLoaderFloppyPage(&Ir
);
3807 case BOOT_LOADER_HARDDISK_PAGE
:
3808 Page
= BootLoaderHarddiskPage(&Ir
);
3812 case REPAIR_INTRO_PAGE
:
3813 Page
= RepairIntroPage(&Ir
);
3817 Page
= SuccessPage(&Ir
);
3821 Page
= FlushPage(&Ir
);
3825 Page
= QuitPage(&Ir
);
3835 /* Avoid bugcheck */
3836 Time
.QuadPart
+= 50000000;
3837 NtDelayExecution(FALSE
, &Time
);
3840 NtShutdownSystem(ShutdownReboot
);
3841 NtTerminateProcess(NtCurrentProcess(), 0);
3848 NtProcessStartup(PPEB Peb
)
3850 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3852 ProcessHeap
= Peb
->ProcessHeap
;
3853 INF_SetHeap(ProcessHeap
);
3856 #endif /* __REACTOS__ */