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 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2385 /* FIXME: Install boot code. This is a hack! */
2386 if ((PartEntry
->PartInfo
[PartNum
].PartitionType
== PARTITION_FAT32_XINT13
) ||
2387 (PartEntry
->PartInfo
[PartNum
].PartitionType
== PARTITION_FAT32
))
2389 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2390 wcscat(PathBuffer
, L
"\\loader\\fat32.bin");
2392 DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
2393 DestinationRootPath
.Buffer
);
2394 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2395 DestinationRootPath
.Buffer
);
2397 if (!NT_SUCCESS(Status
))
2399 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2400 /* FIXME: show an error dialog */
2401 DestroyFileSystemList(FileSystemList
);
2402 FileSystemList
= NULL
;
2408 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2409 wcscat(PathBuffer
, L
"\\loader\\fat.bin");
2411 DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer
,
2412 DestinationRootPath
.Buffer
);
2413 Status
= InstallFat16BootCodeToDisk(PathBuffer
,
2414 DestinationRootPath
.Buffer
);
2416 if (!NT_SUCCESS(Status
))
2418 DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status
);
2419 /* FIXME: show an error dialog */
2420 DestroyFileSystemList(FileSystemList
);
2421 FileSystemList
= NULL
;
2426 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2428 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2429 wcscat(PathBuffer
, L
"\\loader\\ext2.bin");
2431 DPRINT("Install EXT2 bootcode: %S ==> %S\n", PathBuffer
,
2432 DestinationRootPath
.Buffer
);
2433 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2434 DestinationRootPath
.Buffer
);
2436 if (!NT_SUCCESS(Status
))
2438 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2439 /* FIXME: show an error dialog */
2440 DestroyFileSystemList(FileSystemList
);
2441 FileSystemList
= NULL
;
2445 else if (FileSystemList
->Selected
->FormatFunc
)
2447 DestroyFileSystemList(FileSystemList
);
2448 FileSystemList
= NULL
;
2453 CONSOLE_SetStatusText(" Done. Press any key ...");
2454 CONSOLE_ConInKey(Ir
);
2457 DestroyFileSystemList(FileSystemList
);
2458 FileSystemList
= NULL
;
2459 return INSTALL_DIRECTORY_PAGE
;
2463 return FORMAT_PARTITION_PAGE
;
2468 CheckFileSystemPage(PINPUT_RECORD Ir
)
2470 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2471 WCHAR PathBuffer
[MAX_PATH
];
2472 CHAR Buffer
[MAX_PATH
];
2474 UCHAR PartNum
= PartitionList
->CurrentPartitionNumber
;
2476 /* FIXME: code duplicated in FormatPartitionPage */
2477 /* Set DestinationRootPath */
2478 RtlFreeUnicodeString(&DestinationRootPath
);
2479 swprintf(PathBuffer
,
2480 L
"\\Device\\Harddisk%lu\\Partition%lu",
2481 PartitionList
->CurrentDisk
->DiskNumber
,
2482 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2483 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2484 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2486 /* Set SystemRootPath */
2487 RtlFreeUnicodeString(&SystemRootPath
);
2488 swprintf(PathBuffer
,
2489 L
"\\Device\\Harddisk%lu\\Partition%lu",
2490 PartitionList
->ActiveBootDisk
->DiskNumber
,
2491 PartitionList
->ActiveBootPartition
->PartInfo
[PartNum
].PartitionNumber
);
2492 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2493 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2495 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2497 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2499 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2500 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2502 if (!CurrentFileSystem
->ChkdskFunc
)
2505 "Setup is currently unable to check a partition formatted in %S.\n"
2507 " \x07 Press ENTER to continue Setup.\n"
2508 " \x07 Press F3 to quit Setup.",
2509 CurrentFileSystem
->FileSystem
);
2512 MUIGetString(STRING_QUITCONTINUE
),
2513 NULL
, POPUP_WAIT_NONE
);
2517 CONSOLE_ConInKey(Ir
);
2519 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2520 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2522 if (ConfirmQuit(Ir
))
2525 return CHECK_FILE_SYSTEM_PAGE
;
2527 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2529 return INSTALL_DIRECTORY_PAGE
;
2535 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2536 if (!NT_SUCCESS(Status
))
2538 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2539 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2540 "(Status 0x%08lx).\n", Status
);
2543 MUIGetString(STRING_REBOOTCOMPUTER
),
2544 Ir
, POPUP_WAIT_ENTER
);
2549 return INSTALL_DIRECTORY_PAGE
;
2555 InstallDirectoryPage1(PWCHAR InstallDir
, PDISKENTRY DiskEntry
, PPARTENTRY PartEntry
, UCHAR PartNum
)
2557 WCHAR PathBuffer
[MAX_PATH
];
2559 /* Create 'InstallPath' string */
2560 RtlFreeUnicodeString(&InstallPath
);
2561 RtlCreateUnicodeString(&InstallPath
,
2564 /* Create 'DestinationPath' string */
2565 RtlFreeUnicodeString(&DestinationPath
);
2566 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2568 if (InstallDir
[0] != L
'\\')
2569 wcscat(PathBuffer
, L
"\\");
2571 wcscat(PathBuffer
, InstallDir
);
2572 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2574 /* Create 'DestinationArcPath' */
2575 RtlFreeUnicodeString(&DestinationArcPath
);
2576 swprintf(PathBuffer
,
2577 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2578 DiskEntry
->BiosDiskNumber
,
2579 PartEntry
->PartInfo
[PartNum
].PartitionNumber
);
2581 if (InstallDir
[0] != L
'\\')
2582 wcscat(PathBuffer
, L
"\\");
2584 wcscat(PathBuffer
, InstallDir
);
2585 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2587 return(PREPARE_COPY_PAGE
);
2592 InstallDirectoryPage(PINPUT_RECORD Ir
)
2594 PDISKENTRY DiskEntry
;
2595 PPARTENTRY PartEntry
;
2596 WCHAR InstallDir
[51];
2601 if (PartitionList
== NULL
||
2602 PartitionList
->CurrentDisk
== NULL
||
2603 PartitionList
->CurrentPartition
== NULL
)
2605 /* FIXME: show an error dialog */
2609 DiskEntry
= PartitionList
->CurrentDisk
;
2610 PartEntry
= PartitionList
->CurrentPartition
;
2612 /* Search for 'DefaultPath' in the 'SetupData' section */
2613 if (!SetupFindFirstLineW (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2615 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2619 /* Read the 'DefaultPath' data */
2620 if (INF_GetData (&Context
, NULL
, &DefaultPath
))
2622 wcscpy(InstallDir
, DefaultPath
);
2626 wcscpy(InstallDir
, L
"\\ReactOS");
2629 Length
= wcslen(InstallDir
);
2630 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2631 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2633 if (IsUnattendedSetup
)
2635 return(InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
, PartitionList
->CurrentPartitionNumber
));
2640 CONSOLE_ConInKey(Ir
);
2642 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2643 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2645 if (ConfirmQuit(Ir
) == TRUE
)
2650 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2652 return (InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
, PartitionList
->CurrentPartitionNumber
));
2654 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2659 InstallDir
[Length
] = 0;
2660 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2663 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2667 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2669 InstallDir
[Length
] = 0;
2670 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2675 return(INSTALL_DIRECTORY_PAGE
);
2679 AddSectionToCopyQueueCab(HINF InfFile
,
2681 PWCHAR SourceCabinet
,
2682 PCUNICODE_STRING DestinationPath
,
2685 INFCONTEXT FilesContext
;
2686 INFCONTEXT DirContext
;
2688 PWCHAR FileKeyValue
;
2690 PWCHAR TargetFileName
;
2692 /* Search for the SectionName section */
2693 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2696 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2697 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2702 * Enumerate the files in the section
2703 * and add them to the file queue.
2707 /* Get source file name and target directory id */
2708 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2710 /* FIXME: Handle error! */
2711 DPRINT1("INF_GetData() failed\n");
2715 /* Get optional target file name */
2716 if (!INF_GetDataField (&FilesContext
, 2, &TargetFileName
))
2717 TargetFileName
= NULL
;
2719 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2721 /* Lookup target directory */
2722 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2724 /* FIXME: Handle error! */
2725 DPRINT1("SetupFindFirstLine() failed\n");
2729 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2731 /* FIXME: Handle error! */
2732 DPRINT1("INF_GetData() failed\n");
2736 if (!SetupQueueCopy(SetupFileQueue
,
2738 SourceRootPath
.Buffer
,
2739 SourceRootDir
.Buffer
,
2744 /* FIXME: Handle error! */
2745 DPRINT1("SetupQueueCopy() failed\n");
2747 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2753 AddSectionToCopyQueue(HINF InfFile
,
2755 PWCHAR SourceCabinet
,
2756 PCUNICODE_STRING DestinationPath
,
2759 INFCONTEXT FilesContext
;
2760 INFCONTEXT DirContext
;
2762 PWCHAR FileKeyValue
;
2764 PWCHAR TargetFileName
;
2767 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2769 /* Search for the SectionName section */
2770 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2773 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2774 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2779 * Enumerate the files in the section
2780 * and add them to the file queue.
2784 /* Get source file name and target directory id */
2785 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2787 /* FIXME: Handle error! */
2788 DPRINT1("INF_GetData() failed\n");
2792 /* Get target directory id */
2793 if (!INF_GetDataField (&FilesContext
, 13, &FileKeyValue
))
2795 /* FIXME: Handle error! */
2796 DPRINT1("INF_GetData() failed\n");
2800 /* Get optional target file name */
2801 if (!INF_GetDataField (&FilesContext
, 11, &TargetFileName
))
2802 TargetFileName
= NULL
;
2803 else if (!*TargetFileName
)
2804 TargetFileName
= NULL
;
2806 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2808 /* Lookup target directory */
2809 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2811 /* FIXME: Handle error! */
2812 DPRINT1("SetupFindFirstLine() failed\n");
2816 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2818 /* FIXME: Handle error! */
2819 DPRINT1("INF_GetData() failed\n");
2823 if (!SetupQueueCopy(SetupFileQueue
,
2825 SourceRootPath
.Buffer
,
2826 SourceRootDir
.Buffer
,
2831 /* FIXME: Handle error! */
2832 DPRINT1("SetupQueueCopy() failed\n");
2834 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2840 PrepareCopyPageInfFile(HINF InfFile
,
2841 PWCHAR SourceCabinet
,
2844 WCHAR PathBuffer
[MAX_PATH
];
2845 INFCONTEXT DirContext
;
2846 PWCHAR AdditionalSectionName
= NULL
;
2851 /* Add common files */
2852 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2855 /* Add specific files depending of computer type */
2856 if (SourceCabinet
== NULL
)
2858 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2861 if (AdditionalSectionName
)
2863 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2868 /* Create directories */
2872 * Install directories like '\reactos\test' are not handled yet.
2875 /* Get destination path */
2876 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2878 /* Remove trailing backslash */
2879 Length
= wcslen(PathBuffer
);
2880 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2882 PathBuffer
[Length
- 1] = 0;
2885 /* Create the install directory */
2886 Status
= SetupCreateDirectory(PathBuffer
);
2887 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2889 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2890 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2894 /* Search for the 'Directories' section */
2895 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2899 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2903 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2909 /* Enumerate the directory values and create the subdirectories */
2912 if (!INF_GetData (&DirContext
, NULL
, &KeyValue
))
2918 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2920 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2922 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2923 wcscat(PathBuffer
, KeyValue
);
2925 DPRINT("FullPath: '%S'\n", PathBuffer
);
2927 else if (KeyValue
[0] != L
'\\')
2929 DPRINT("RelativePath: '%S'\n", KeyValue
);
2930 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2931 wcscat(PathBuffer
, L
"\\");
2932 wcscat(PathBuffer
, KeyValue
);
2934 DPRINT("FullPath: '%S'\n", PathBuffer
);
2936 Status
= SetupCreateDirectory(PathBuffer
);
2937 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2939 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2940 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2944 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2950 PrepareCopyPage(PINPUT_RECORD Ir
)
2953 WCHAR PathBuffer
[MAX_PATH
];
2954 INFCONTEXT CabinetsContext
;
2960 MUIDisplayPage(PREPARE_COPY_PAGE
);
2962 /* Create the file queue */
2963 SetupFileQueue
= SetupOpenFileQueue();
2964 if (SetupFileQueue
== NULL
)
2966 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2970 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2975 /* Search for the 'Cabinets' section */
2976 if (!SetupFindFirstLineW (SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2978 return FILE_COPY_PAGE
;
2982 * Enumerate the directory values in the 'Cabinets'
2983 * section and parse their inf files.
2987 if (!INF_GetData (&CabinetsContext
, NULL
, &KeyValue
))
2990 wcscpy(PathBuffer
, SourcePath
.Buffer
);
2991 wcscat(PathBuffer
, L
"\\");
2992 wcscat(PathBuffer
, KeyValue
);
2995 CabinetInitialize();
2996 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
2997 CabinetSetCabinetName(PathBuffer
);
2999 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3001 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3003 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3004 if (InfFileData
== NULL
)
3006 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3012 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3013 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3017 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3023 if (InfHandle
== INVALID_HANDLE_VALUE
)
3025 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3031 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3036 } while (SetupFindNextLine (&CabinetsContext
, &CabinetsContext
));
3038 return FILE_COPY_PAGE
;
3043 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3046 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3048 /* Get the memory information from the system */
3049 NtQuerySystemInformation(SystemPerformanceInformation
,
3054 /* Check if this is initial setup */
3057 /* Set maximum limits to be total RAM pages */
3058 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3059 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3060 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3063 /* Set current values */
3064 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3065 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3066 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3069 static UINT CALLBACK
3070 FileCopyCallback(PVOID Context
,
3075 PCOPYCONTEXT CopyContext
;
3077 CopyContext
= (PCOPYCONTEXT
)Context
;
3079 switch (Notification
)
3081 case SPFILENOTIFY_STARTSUBQUEUE
:
3082 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3083 ProgressSetStepCount(CopyContext
->ProgressBar
,
3084 CopyContext
->TotalOperations
);
3085 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3088 case SPFILENOTIFY_STARTCOPY
:
3089 /* Display copy message */
3090 CONSOLE_SetStatusTextAutoFitX (45 , MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3091 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3094 case SPFILENOTIFY_ENDCOPY
:
3095 CopyContext
->CompletedOperations
++;
3096 ProgressNextStep(CopyContext
->ProgressBar
);
3097 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3106 FileCopyPage(PINPUT_RECORD Ir
)
3108 COPYCONTEXT CopyContext
;
3110 MUIDisplayPage(FILE_COPY_PAGE
);
3112 /* Create context for the copy process */
3113 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3114 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3115 CopyContext
.TotalOperations
= 0;
3116 CopyContext
.CompletedOperations
= 0;
3118 /* Create the progress bar as well */
3119 CopyContext
.ProgressBar
= CreateProgressBar(13,
3126 MUIGetString(STRING_SETUPCOPYINGFILES
));
3128 // fit memory bars to screen width, distribute them uniform
3129 unsigned int mem_bar_width
= (xScreen
- 26) / 5;
3130 mem_bar_width
-= mem_bar_width
% 2; // make even
3131 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3132 /* Create the paged pool progress bar */
3133 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3142 /* Create the non paged pool progress bar */
3143 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3145 (xScreen
/ 2) + (mem_bar_width
/ 2),
3147 (xScreen
/ 2)- (mem_bar_width
/ 2),
3152 /* Create the global memory progress bar */
3153 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3157 xScreen
- 13 - mem_bar_width
,
3162 /* Do the file copying */
3163 SetupCommitFileQueueW(NULL
,
3168 /* If we get here, we're done, so cleanup the queue and progress bar */
3169 SetupCloseFileQueue(SetupFileQueue
);
3170 DestroyProgressBar(CopyContext
.ProgressBar
);
3171 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3172 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3173 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3175 /* Go display the next page */
3176 return REGISTRY_PAGE
;
3180 RegistryPage(PINPUT_RECORD Ir
)
3182 INFCONTEXT InfContext
;
3189 MUIDisplayPage(REGISTRY_PAGE
);
3191 if (RepairUpdateFlag
)
3193 return SUCCESS_PAGE
;
3196 if (!SetInstallPathValue(&DestinationPath
))
3198 DPRINT("SetInstallPathValue() failed\n");
3199 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3203 /* Create the default hives */
3205 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3206 if (!NT_SUCCESS(Status
))
3208 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3209 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3213 RegInitializeRegistry();
3216 /* Update registry */
3217 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3219 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3221 DPRINT1("SetupFindFirstLine() failed\n");
3222 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3228 INF_GetDataField (&InfContext
, 0, &Action
);
3229 INF_GetDataField (&InfContext
, 1, &File
);
3230 INF_GetDataField (&InfContext
, 2, &Section
);
3232 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3234 if (!_wcsicmp (Action
, L
"AddReg"))
3238 else if (!_wcsicmp (Action
, L
"DelReg"))
3247 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3249 if (!ImportRegistryFile(File
, Section
, Delete
))
3251 DPRINT("Importing %S failed\n", File
);
3253 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3256 } while (SetupFindNextLine (&InfContext
, &InfContext
));
3258 /* Update display registry settings */
3259 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3260 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3262 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3266 /* Set the locale */
3267 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3268 if (!ProcessLocaleRegistry(LanguageList
))
3270 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3274 /* Add keyboard layouts */
3275 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3276 if (!AddKeyboardLayouts())
3278 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3284 if (!SetGeoID(MUIGetGeoID()))
3286 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3290 if (!IsUnattendedSetup
){
3292 /* Update keyboard layout settings */
3293 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3294 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3296 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3300 /* Add codepage information to registry */
3301 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3304 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3308 /* Update the mounted devices list */
3309 SetMountedDeviceValues(PartitionList
);
3311 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3313 return BOOT_LOADER_PAGE
;
3318 BootLoaderPage(PINPUT_RECORD Ir
)
3320 UCHAR PartitionType
;
3321 BOOLEAN InstallOnFloppy
;
3324 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3326 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3328 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3330 DPRINT("Error: active partition invalid (unused)\n");
3331 InstallOnFloppy
= TRUE
;
3333 else if (PartitionType
== 0x0A)
3335 /* OS/2 boot manager partition */
3336 DPRINT("Found OS/2 boot manager partition\n");
3337 InstallOnFloppy
= TRUE
;
3339 else if (PartitionType
== 0x83)
3341 /* Linux ext2 partition */
3342 DPRINT("Found Linux ext2 partition\n");
3343 InstallOnFloppy
= TRUE
;
3345 else if (PartitionType
== PARTITION_IFS
)
3347 /* NTFS partition */
3348 DPRINT("Found NTFS partition\n");
3349 InstallOnFloppy
= TRUE
;
3351 else if ((PartitionType
== PARTITION_FAT_12
) ||
3352 (PartitionType
== PARTITION_FAT_16
) ||
3353 (PartitionType
== PARTITION_HUGE
) ||
3354 (PartitionType
== PARTITION_XINT13
) ||
3355 (PartitionType
== PARTITION_FAT32
) ||
3356 (PartitionType
== PARTITION_FAT32_XINT13
))
3358 DPRINT("Found FAT partition\n");
3359 InstallOnFloppy
= FALSE
;
3363 /* Unknown partition */
3364 DPRINT("Unknown partition found\n");
3365 InstallOnFloppy
= TRUE
;
3368 if (InstallOnFloppy
== TRUE
)
3370 return BOOT_LOADER_FLOPPY_PAGE
;
3373 if (IsUnattendedSetup
)
3375 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3377 return SUCCESS_PAGE
;
3379 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3381 return BOOT_LOADER_FLOPPY_PAGE
;
3383 else if (UnattendMBRInstallType
== 2) /* install on hdd */
3385 return BOOT_LOADER_HARDDISK_PAGE
;
3389 MUIDisplayPage(BOOT_LOADER_PAGE
);
3390 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3394 CONSOLE_ConInKey(Ir
);
3396 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3397 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3399 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3402 if (Line
<12) Line
=14;
3403 if (Line
>14) Line
=12;
3405 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3407 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3408 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3410 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3413 if (Line
<12) Line
=14;
3414 if (Line
>14) Line
=12;
3416 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3418 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3419 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3421 if (ConfirmQuit(Ir
) == TRUE
)
3426 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3430 return BOOT_LOADER_HARDDISK_PAGE
;
3432 else if (Line
== 13)
3434 return BOOT_LOADER_FLOPPY_PAGE
;
3436 else if (Line
== 14)
3438 return SUCCESS_PAGE
;
3441 return BOOT_LOADER_PAGE
;
3445 return BOOT_LOADER_PAGE
;
3450 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3454 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3456 // SetStatusText(" Please wait...");
3460 CONSOLE_ConInKey(Ir
);
3462 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3463 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3465 if (ConfirmQuit(Ir
) == TRUE
)
3470 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3472 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3474 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3475 return BOOT_LOADER_FLOPPY_PAGE
;
3478 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3479 if (!NT_SUCCESS(Status
))
3481 /* Print error message */
3482 return BOOT_LOADER_FLOPPY_PAGE
;
3485 return SUCCESS_PAGE
;
3489 return BOOT_LOADER_FLOPPY_PAGE
;
3494 BootLoaderHarddiskPage(PINPUT_RECORD Ir
)
3496 UCHAR PartitionType
;
3499 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3500 if ((PartitionType
== PARTITION_FAT_12
) ||
3501 (PartitionType
== PARTITION_FAT_16
) ||
3502 (PartitionType
== PARTITION_HUGE
) ||
3503 (PartitionType
== PARTITION_XINT13
) ||
3504 (PartitionType
== PARTITION_FAT32
) ||
3505 (PartitionType
== PARTITION_FAT32_XINT13
))
3507 Status
= InstallFatBootcodeToPartition(&SystemRootPath
,
3509 &DestinationArcPath
,
3511 if (!NT_SUCCESS(Status
))
3513 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3517 return SUCCESS_PAGE
;
3521 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3525 return BOOT_LOADER_HARDDISK_PAGE
;
3530 QuitPage(PINPUT_RECORD Ir
)
3532 MUIDisplayPage(QUIT_PAGE
);
3534 /* Destroy partition list */
3535 if (PartitionList
!= NULL
)
3537 DestroyPartitionList (PartitionList
);
3538 PartitionList
= NULL
;
3541 /* Destroy filesystem list */
3542 if (FileSystemList
!= NULL
)
3544 DestroyFileSystemList (FileSystemList
);
3545 FileSystemList
= NULL
;
3548 /* Destroy computer settings list */
3549 if (ComputerList
!= NULL
)
3551 DestroyGenericList(ComputerList
, TRUE
);
3552 ComputerList
= NULL
;
3555 /* Destroy display settings list */
3556 if (DisplayList
!= NULL
)
3558 DestroyGenericList(DisplayList
, TRUE
);
3562 /* Destroy keyboard settings list */
3563 if (KeyboardList
!= NULL
)
3565 DestroyGenericList(KeyboardList
, TRUE
);
3566 KeyboardList
= NULL
;
3569 /* Destroy keyboard layout list */
3570 if (LayoutList
!= NULL
)
3572 DestroyGenericList(LayoutList
, TRUE
);
3576 if (LanguageList
!= NULL
)
3578 DestroyGenericList(LanguageList
, FALSE
);
3579 LanguageList
= NULL
;
3582 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3586 CONSOLE_ConInKey(Ir
);
3588 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3597 SuccessPage(PINPUT_RECORD Ir
)
3599 MUIDisplayPage(SUCCESS_PAGE
);
3601 if (IsUnattendedSetup
)
3608 CONSOLE_ConInKey(Ir
);
3610 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3619 FlushPage(PINPUT_RECORD Ir
)
3621 MUIDisplayPage(FLUSH_PAGE
);
3627 PnpEventThread(IN LPVOID lpParameter
);
3637 NtQuerySystemTime(&Time
);
3639 Status
= RtlCreateUserThread(NtCurrentProcess(), NULL
, TRUE
, 0, 0, 0, PnpEventThread
, &SetupInf
, &hPnpThread
, NULL
);
3640 if (!NT_SUCCESS(Status
))
3641 hPnpThread
= INVALID_HANDLE_VALUE
;
3643 if (!CONSOLE_Init())
3645 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3646 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3647 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3649 /* Raise a hard error (crash the system/BSOD) */
3650 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3654 /* Initialize global unicode strings */
3655 RtlInitUnicodeString(&SourcePath
, NULL
);
3656 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3657 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3658 RtlInitUnicodeString(&InstallPath
, NULL
);
3659 RtlInitUnicodeString(&DestinationPath
, NULL
);
3660 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3661 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3662 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3664 /* Hide the cursor */
3665 CONSOLE_SetCursorType(TRUE
, FALSE
);
3668 while (Page
!= REBOOT_PAGE
)
3670 CONSOLE_ClearScreen();
3673 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3680 Page
= SetupStartPage(&Ir
);
3685 Page
= LanguagePage(&Ir
);
3690 Page
= LicensePage(&Ir
);
3695 Page
= IntroPage(&Ir
);
3699 case INSTALL_INTRO_PAGE
:
3700 Page
= InstallIntroPage(&Ir
);
3704 case SCSI_CONTROLLER_PAGE
:
3705 Page
= ScsiControllerPage(&Ir
);
3710 case OEM_DRIVER_PAGE
:
3711 Page
= OemDriverPage(&Ir
);
3715 case DEVICE_SETTINGS_PAGE
:
3716 Page
= DeviceSettingsPage(&Ir
);
3719 case COMPUTER_SETTINGS_PAGE
:
3720 Page
= ComputerSettingsPage(&Ir
);
3723 case DISPLAY_SETTINGS_PAGE
:
3724 Page
= DisplaySettingsPage(&Ir
);
3727 case KEYBOARD_SETTINGS_PAGE
:
3728 Page
= KeyboardSettingsPage(&Ir
);
3731 case LAYOUT_SETTINGS_PAGE
:
3732 Page
= LayoutSettingsPage(&Ir
);
3735 case SELECT_PARTITION_PAGE
:
3736 Page
= SelectPartitionPage(&Ir
);
3739 case CREATE_PARTITION_PAGE
:
3740 Page
= CreatePartitionPage(&Ir
);
3743 case DELETE_PARTITION_PAGE
:
3744 Page
= DeletePartitionPage(&Ir
);
3747 case SELECT_FILE_SYSTEM_PAGE
:
3748 Page
= SelectFileSystemPage(&Ir
);
3751 case FORMAT_PARTITION_PAGE
:
3752 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3755 case CHECK_FILE_SYSTEM_PAGE
:
3756 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3759 case INSTALL_DIRECTORY_PAGE
:
3760 Page
= InstallDirectoryPage(&Ir
);
3763 case PREPARE_COPY_PAGE
:
3764 Page
= PrepareCopyPage(&Ir
);
3767 case FILE_COPY_PAGE
:
3768 Page
= FileCopyPage(&Ir
);
3772 Page
= RegistryPage(&Ir
);
3775 case BOOT_LOADER_PAGE
:
3776 Page
= BootLoaderPage(&Ir
);
3779 case BOOT_LOADER_FLOPPY_PAGE
:
3780 Page
= BootLoaderFloppyPage(&Ir
);
3783 case BOOT_LOADER_HARDDISK_PAGE
:
3784 Page
= BootLoaderHarddiskPage(&Ir
);
3788 case REPAIR_INTRO_PAGE
:
3789 Page
= RepairIntroPage(&Ir
);
3793 Page
= SuccessPage(&Ir
);
3797 Page
= FlushPage(&Ir
);
3801 Page
= QuitPage(&Ir
);
3811 /* Avoid bugcheck */
3812 Time
.QuadPart
+= 50000000;
3813 NtDelayExecution(FALSE
, &Time
);
3816 NtShutdownSystem(ShutdownReboot
);
3817 NtTerminateProcess(NtCurrentProcess(), 0);
3824 NtProcessStartup(PPEB Peb
)
3826 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3828 ProcessHeap
= Peb
->ProcessHeap
;
3829 INF_SetHeap(ProcessHeap
);
3832 #endif /* __REACTOS__ */