3 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/usetup.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMER: Eric Kohl
25 * Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * Hervé Poussineau (hpoussin@reactos.org)
35 /* GLOBALS ******************************************************************/
38 UNICODE_STRING SourceRootPath
;
39 UNICODE_STRING SourceRootDir
;
40 UNICODE_STRING SourcePath
;
41 BOOLEAN IsUnattendedSetup
= FALSE
;
42 LONG UnattendDestinationDiskNumber
;
43 LONG UnattendDestinationPartitionNumber
;
44 LONG UnattendMBRInstallType
= -1;
45 LONG UnattendFormatPartition
= 0;
46 LONG AutoPartition
= 0;
47 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
48 PWCHAR SelectedLanguageId
;
50 WCHAR DefaultLanguage
[20];
51 WCHAR DefaultKBLayout
[20];
52 BOOLEAN RepairUpdateFlag
= FALSE
;
53 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
54 PPARTLIST PartitionList
= NULL
;
56 /* LOCALS *******************************************************************/
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 static LANGID LanguageId
= 0;
84 static ULONG RequiredPartitionDiskSpace
= ~0;
86 /* FUNCTIONS ****************************************************************/
89 PrintString(char* fmt
,...)
93 UNICODE_STRING UnicodeString
;
94 ANSI_STRING AnsiString
;
97 vsprintf(buffer
, fmt
, ap
);
100 RtlInitAnsiString(&AnsiString
, buffer
);
101 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
102 NtDisplayString(&UnicodeString
);
103 RtlFreeUnicodeString(&UnicodeString
);
108 DrawBox(IN SHORT xLeft
,
116 /* draw upper left corner */
119 FillConsoleOutputCharacterA(StdOutput
,
125 /* draw upper edge */
128 FillConsoleOutputCharacterA(StdOutput
,
134 /* draw upper right corner */
135 coPos
.X
= xLeft
+ Width
- 1;
137 FillConsoleOutputCharacterA(StdOutput
,
143 /* Draw right edge, inner space and left edge */
144 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
147 FillConsoleOutputCharacterA(StdOutput
,
154 FillConsoleOutputCharacterA(StdOutput
,
160 coPos
.X
= xLeft
+ Width
- 1;
161 FillConsoleOutputCharacterA(StdOutput
,
168 /* draw lower left corner */
170 coPos
.Y
= yTop
+ Height
- 1;
171 FillConsoleOutputCharacterA(StdOutput
,
177 /* draw lower edge */
179 coPos
.Y
= yTop
+ Height
- 1;
180 FillConsoleOutputCharacterA(StdOutput
,
186 /* draw lower right corner */
187 coPos
.X
= xLeft
+ Width
- 1;
188 coPos
.Y
= yTop
+ Height
- 1;
189 FillConsoleOutputCharacterA(StdOutput
,
198 PopupError(PCCH Text
,
216 /* Count text lines and longest line */
223 p
= strchr(pnext
, '\n');
227 Length
= strlen(pnext
);
232 Length
= (ULONG
)(p
- pnext
);
238 if (Length
> MaxLength
)
241 if (LastLine
== TRUE
)
247 /* Check length of status line */
250 Length
= strlen(Status
);
252 if (Length
> MaxLength
)
256 Width
= MaxLength
+ 4;
262 yTop
= (yScreen
- Height
) / 2;
263 xLeft
= (xScreen
- Width
) / 2;
266 /* Set screen attributes */
268 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
270 FillConsoleOutputAttribute(StdOutput
,
271 FOREGROUND_RED
| BACKGROUND_WHITE
,
277 DrawBox(xLeft
, yTop
, Width
, Height
);
279 /* Print message text */
284 p
= strchr(pnext
, '\n');
288 Length
= strlen(pnext
);
293 Length
= (ULONG
)(p
- pnext
);
300 WriteConsoleOutputCharacterA(StdOutput
,
307 if (LastLine
== TRUE
)
314 /* Print separator line and status text */
317 coPos
.Y
= yTop
+ Height
- 3;
319 FillConsoleOutputCharacterA(StdOutput
,
326 FillConsoleOutputCharacterA(StdOutput
,
332 coPos
.X
= xLeft
+ Width
- 1;
333 FillConsoleOutputCharacterA(StdOutput
,
341 WriteConsoleOutputCharacterA(StdOutput
,
343 min(strlen(Status
), (SIZE_T
)Width
- 4),
348 if (WaitEvent
== POPUP_WAIT_NONE
)
353 CONSOLE_ConInKey(Ir
);
355 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
356 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
368 * FALSE: Don't quit setup.
371 ConfirmQuit(PINPUT_RECORD Ir
)
374 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
378 CONSOLE_ConInKey(Ir
);
380 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
381 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
386 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
398 CheckUnattendedSetup(VOID
)
400 WCHAR UnattendInfPath
[MAX_PATH
];
407 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
409 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
413 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
414 wcscat(UnattendInfPath
, L
"\\unattend.inf");
416 /* Load 'unattend.inf' from install media. */
417 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
423 if (UnattendInf
== INVALID_HANDLE_VALUE
)
425 DPRINT("SetupOpenInfFileW() failed\n");
429 /* Open 'Unattend' section */
430 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
432 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
433 SetupCloseInfFile(UnattendInf
);
437 /* Get pointer 'Signature' key */
438 if (!INF_GetData(&Context
, NULL
, &Value
))
440 DPRINT("INF_GetData() failed for key 'Signature'\n");
441 SetupCloseInfFile(UnattendInf
);
445 /* Check 'Signature' string */
446 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
448 DPRINT("Signature not $ReactOS$\n");
449 SetupCloseInfFile(UnattendInf
);
453 /* Check if Unattend setup is enabled */
454 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
456 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
457 SetupCloseInfFile(UnattendInf
);
461 if (!INF_GetData(&Context
, NULL
, &Value
))
463 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
464 SetupCloseInfFile(UnattendInf
);
468 if (_wcsicmp(Value
, L
"yes") != 0)
470 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
471 SetupCloseInfFile(UnattendInf
);
475 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
476 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
478 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
479 SetupCloseInfFile(UnattendInf
);
483 if (!SetupGetIntField(&Context
, 1, &IntValue
))
485 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
486 SetupCloseInfFile(UnattendInf
);
490 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
492 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
493 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
495 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
496 SetupCloseInfFile(UnattendInf
);
500 if (!SetupGetIntField(&Context
, 1, &IntValue
))
502 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
503 SetupCloseInfFile(UnattendInf
);
507 UnattendDestinationPartitionNumber
= IntValue
;
509 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
510 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
512 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
513 SetupCloseInfFile(UnattendInf
);
517 /* Get pointer 'InstallationDirectory' key */
518 if (!INF_GetData(&Context
, NULL
, &Value
))
520 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
521 SetupCloseInfFile(UnattendInf
);
525 wcscpy(UnattendInstallationDirectory
, Value
);
527 IsUnattendedSetup
= TRUE
;
529 /* Search for 'MBRInstallType' in the 'Unattend' section */
530 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
532 if (SetupGetIntField(&Context
, 1, &IntValue
))
534 UnattendMBRInstallType
= IntValue
;
538 /* Search for 'FormatPartition' in the 'Unattend' section */
539 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
541 if (SetupGetIntField(&Context
, 1, &IntValue
))
543 UnattendFormatPartition
= IntValue
;
547 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
549 if (SetupGetIntField(&Context
, 1, &IntValue
))
551 AutoPartition
= IntValue
;
555 /* search for LocaleID in the 'Unattend' section*/
556 if (SetupFindFirstLineW (UnattendInf
, L
"Unattend", L
"LocaleID", &Context
))
558 if (INF_GetData (&Context
, NULL
, &Value
))
560 LONG Id
= wcstol(Value
, NULL
, 16);
561 swprintf(LocaleID
,L
"%08lx", Id
);
565 SetupCloseInfFile(UnattendInf
);
567 DPRINT("Running unattended setup\n");
574 PGENERIC_LIST_ENTRY ListEntry
;
575 LPCWSTR pszNewLayout
;
577 pszNewLayout
= MUIDefaultKeyboardLayout();
579 if (LayoutList
== NULL
)
581 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
582 if (LayoutList
== NULL
)
584 /* FIXME: Handle error! */
589 ListEntry
= GetFirstListEntry(LayoutList
);
591 /* Search for default layout (if provided) */
592 if (pszNewLayout
!= NULL
)
594 while (ListEntry
!= NULL
)
596 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
598 SetCurrentListEntry(LayoutList
, ListEntry
);
602 ListEntry
= GetNextListEntry(ListEntry
);
609 LanguagePage(PINPUT_RECORD Ir
)
611 /* Initialize the computer settings list */
612 if (LanguageList
== NULL
)
614 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
616 if (LanguageList
== NULL
)
618 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
623 DrawGenericList(LanguageList
,
629 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
631 MUIDisplayPage(LANGUAGE_PAGE
);
635 CONSOLE_ConInKey(Ir
);
637 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
638 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
641 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
643 /* Redraw language selection page in native language */
644 MUIDisplayPage(LANGUAGE_PAGE
);
647 ScrollDownGenericList (LanguageList
);
649 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
650 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
653 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
655 /* Redraw language selection page in native language */
656 MUIDisplayPage(LANGUAGE_PAGE
);
659 ScrollUpGenericList(LanguageList
);
661 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
662 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
664 ScrollPageDownGenericList(LanguageList
);
666 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
667 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
669 ScrollPageUpGenericList(LanguageList
);
671 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
672 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
674 if (ConfirmQuit(Ir
) == TRUE
)
677 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
679 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
681 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
683 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
689 SetConsoleCodePage();
693 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
696 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
707 * Number of the next page.
710 SetupStartPage(PINPUT_RECORD Ir
)
712 SYSTEM_DEVICE_INFORMATION Sdi
;
714 WCHAR FileNameBuffer
[MAX_PATH
];
719 PGENERIC_LIST_ENTRY ListEntry
;
722 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
725 /* Check whether a harddisk is available */
726 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
728 sizeof(SYSTEM_DEVICE_INFORMATION
),
731 if (!NT_SUCCESS(Status
))
733 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
734 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
738 if (Sdi
.NumberOfDisks
== 0)
740 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
744 /* Get the source path and source root path */
745 Status
= GetSourcePaths(&SourcePath
,
749 if (!NT_SUCCESS(Status
))
751 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
752 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
758 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
759 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
760 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
764 /* Load txtsetup.sif from install media. */
765 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
766 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
768 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
774 if (SetupInf
== INVALID_HANDLE_VALUE
)
776 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
780 /* Open 'Version' section */
781 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
783 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
787 /* Get pointer 'Signature' key */
788 if (!INF_GetData(&Context
, NULL
, &Value
))
790 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
794 /* Check 'Signature' string */
795 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
797 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
801 /* Open 'DiskSpaceRequirements' section */
802 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
804 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
808 /* Get the 'FreeSysPartDiskSpace' value */
809 if (!SetupGetIntField(&Context
, 1, &IntValue
))
811 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
815 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
817 /* Start PnP thread */
818 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
820 NtResumeThread(hPnpThread
, NULL
);
821 hPnpThread
= INVALID_HANDLE_VALUE
;
824 CheckUnattendedSetup();
826 if (IsUnattendedSetup
)
829 //read options from inf
830 ComputerList
= CreateComputerTypeList(SetupInf
);
831 DisplayList
= CreateDisplayDriverList(SetupInf
);
832 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
833 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
834 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
837 wcscpy(SelectedLanguageId
,LocaleID
);
839 /* first we hack LanguageList */
840 ListEntry
= GetFirstListEntry(LanguageList
);
842 while (ListEntry
!= NULL
)
844 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
846 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
847 SetCurrentListEntry(LanguageList
, ListEntry
);
851 ListEntry
= GetNextListEntry(ListEntry
);
855 ListEntry
= GetFirstListEntry(LayoutList
);
857 while (ListEntry
!= NULL
)
859 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
861 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
862 SetCurrentListEntry(LayoutList
, ListEntry
);
866 ListEntry
= GetNextListEntry(ListEntry
);
869 SetConsoleCodePage();
871 return INSTALL_INTRO_PAGE
;
874 return LANGUAGE_PAGE
;
884 IntroPage(PINPUT_RECORD Ir
)
886 MUIDisplayPage(START_PAGE
);
890 CONSOLE_ConInKey(Ir
);
892 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
893 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
895 if (ConfirmQuit(Ir
) == TRUE
)
900 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
902 return INSTALL_INTRO_PAGE
;
905 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
907 return REPAIR_INTRO_PAGE
;
910 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
924 * Back to main setup page.
927 LicensePage(PINPUT_RECORD Ir
)
929 MUIDisplayPage(LICENSE_PAGE
);
933 CONSOLE_ConInKey(Ir
);
935 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
947 RepairIntroPage(PINPUT_RECORD Ir
)
949 MUIDisplayPage(REPAIR_INTRO_PAGE
);
953 CONSOLE_ConInKey(Ir
);
955 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
959 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
961 RepairUpdateFlag
= TRUE
;
962 return INSTALL_INTRO_PAGE
;
964 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
968 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
969 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
975 return REPAIR_INTRO_PAGE
;
980 InstallIntroPage(PINPUT_RECORD Ir
)
982 MUIDisplayPage(INSTALL_INTRO_PAGE
);
984 if (RepairUpdateFlag
)
986 //return SELECT_PARTITION_PAGE;
987 return DEVICE_SETTINGS_PAGE
;
990 if (IsUnattendedSetup
)
992 return SELECT_PARTITION_PAGE
;
997 CONSOLE_ConInKey(Ir
);
999 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1000 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1002 if (ConfirmQuit(Ir
) == TRUE
)
1007 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1009 return DEVICE_SETTINGS_PAGE
;
1010 // return SCSI_CONTROLLER_PAGE;
1014 return INSTALL_INTRO_PAGE
;
1020 ScsiControllerPage(PINPUT_RECORD Ir
)
1022 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1024 /* FIXME: print loaded mass storage driver descriptions */
1026 SetTextXY(8, 10, "TEST device");
1030 SetStatusText(" ENTER = Continue F3 = Quit");
1036 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1037 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1039 if (ConfirmQuit(Ir
) == TRUE
)
1044 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1046 return DEVICE_SETTINGS_PAGE
;
1050 return SCSI_CONTROLLER_PAGE
;
1056 DeviceSettingsPage(PINPUT_RECORD Ir
)
1058 static ULONG Line
= 16;
1059 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1061 /* Initialize the computer settings list */
1062 if (ComputerList
== NULL
)
1064 ComputerList
= CreateComputerTypeList(SetupInf
);
1065 if (ComputerList
== NULL
)
1067 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1072 /* Initialize the display settings list */
1073 if (DisplayList
== NULL
)
1075 DisplayList
= CreateDisplayDriverList(SetupInf
);
1076 if (DisplayList
== NULL
)
1078 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1083 /* Initialize the keyboard settings list */
1084 if (KeyboardList
== NULL
)
1086 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1087 if (KeyboardList
== NULL
)
1089 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1094 /* Initialize the keyboard layout list */
1095 if (LayoutList
== NULL
)
1097 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1098 if (LayoutList
== NULL
)
1100 /* FIXME: report error */
1101 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1106 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1109 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1110 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1111 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1112 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1114 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1116 if (RepairUpdateFlag
)
1118 return SELECT_PARTITION_PAGE
;
1123 CONSOLE_ConInKey(Ir
);
1125 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1126 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1128 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1132 else if (Line
== 16)
1137 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1139 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1140 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1142 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1146 else if (Line
== 16)
1151 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1153 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1154 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1156 if (ConfirmQuit(Ir
) == TRUE
)
1161 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1164 return COMPUTER_SETTINGS_PAGE
;
1165 else if (Line
== 12)
1166 return DISPLAY_SETTINGS_PAGE
;
1167 else if (Line
== 13)
1168 return KEYBOARD_SETTINGS_PAGE
;
1169 else if (Line
== 14)
1170 return LAYOUT_SETTINGS_PAGE
;
1171 else if (Line
== 16)
1172 return SELECT_PARTITION_PAGE
;
1176 return DEVICE_SETTINGS_PAGE
;
1181 ComputerSettingsPage(PINPUT_RECORD Ir
)
1183 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1185 DrawGenericList(ComputerList
,
1191 SaveGenericListState(ComputerList
);
1195 CONSOLE_ConInKey(Ir
);
1197 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1198 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1200 ScrollDownGenericList(ComputerList
);
1202 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1203 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1205 ScrollUpGenericList(ComputerList
);
1207 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1208 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1210 if (ConfirmQuit(Ir
) == TRUE
)
1215 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1216 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1218 RestoreGenericListState(ComputerList
);
1219 return DEVICE_SETTINGS_PAGE
;
1221 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1223 return DEVICE_SETTINGS_PAGE
;
1227 return COMPUTER_SETTINGS_PAGE
;
1232 DisplaySettingsPage(PINPUT_RECORD Ir
)
1234 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1236 DrawGenericList(DisplayList
,
1242 SaveGenericListState(DisplayList
);
1246 CONSOLE_ConInKey(Ir
);
1248 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1249 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1251 ScrollDownGenericList(DisplayList
);
1253 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1254 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1256 ScrollUpGenericList(DisplayList
);
1258 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1259 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1261 if (ConfirmQuit(Ir
) == TRUE
)
1268 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1269 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1271 RestoreGenericListState(DisplayList
);
1272 return DEVICE_SETTINGS_PAGE
;
1274 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1276 return DEVICE_SETTINGS_PAGE
;
1280 return DISPLAY_SETTINGS_PAGE
;
1285 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1287 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1289 DrawGenericList(KeyboardList
,
1295 SaveGenericListState(KeyboardList
);
1299 CONSOLE_ConInKey(Ir
);
1301 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1302 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1304 ScrollDownGenericList(KeyboardList
);
1306 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1307 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1309 ScrollUpGenericList(KeyboardList
);
1311 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1312 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1314 if (ConfirmQuit(Ir
) == TRUE
)
1319 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1320 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1322 RestoreGenericListState(KeyboardList
);
1323 return DEVICE_SETTINGS_PAGE
;
1325 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1327 return DEVICE_SETTINGS_PAGE
;
1331 return DISPLAY_SETTINGS_PAGE
;
1336 LayoutSettingsPage(PINPUT_RECORD Ir
)
1338 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1340 DrawGenericList(LayoutList
,
1346 SaveGenericListState(LayoutList
);
1350 CONSOLE_ConInKey(Ir
);
1352 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1353 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1355 ScrollDownGenericList(LayoutList
);
1357 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1358 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1360 ScrollUpGenericList(LayoutList
);
1362 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1363 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1365 ScrollPageDownGenericList(LayoutList
);
1367 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1368 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1370 ScrollPageUpGenericList(LayoutList
);
1372 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1373 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1375 if (ConfirmQuit(Ir
) == TRUE
)
1380 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1381 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1383 RestoreGenericListState(LayoutList
);
1384 return DEVICE_SETTINGS_PAGE
;
1386 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1388 return DEVICE_SETTINGS_PAGE
;
1390 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1393 GenericListKeyPress(LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1397 return DISPLAY_SETTINGS_PAGE
;
1402 IsDiskSizeValid(PPARTENTRY PartEntry
)
1406 /* check for unpartitioned space */
1407 m1
= PartEntry
->UnpartitionedLength
;
1408 m1
= (m1
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1410 if( m1
> RequiredPartitionDiskSpace
)
1415 /* check for partitioned space */
1416 m2
= PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
;
1417 m2
= (m2
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1418 if (m2
< RequiredPartitionDiskSpace
)
1420 /* partition is too small so ask for another partion */
1421 DPRINT1("Partition is too small(unpartitioned: %I64u MB, partitioned: %I64u MB), required disk space is %lu MB\n", m1
, m2
, RequiredPartitionDiskSpace
);
1432 SelectPartitionPage(PINPUT_RECORD Ir
)
1434 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1436 if (PartitionList
== NULL
)
1438 PartitionList
= CreatePartitionList(2,
1442 if (PartitionList
== NULL
)
1444 /* FIXME: show an error dialog */
1449 CheckActiveBootPartition(PartitionList
);
1451 DrawPartitionList(PartitionList
);
1453 /* Warn about partitions created by Linux Fdisk */
1454 if (WarnLinuxPartitions
== TRUE
&&
1455 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1457 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1461 CONSOLE_ConInKey(Ir
);
1463 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1464 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1468 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1470 WarnLinuxPartitions
= FALSE
;
1471 return SELECT_PARTITION_PAGE
;
1476 if (IsUnattendedSetup
)
1478 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1482 PPARTENTRY PartEntry
= PartitionList
->CurrentPartition
;
1483 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1484 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1486 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1487 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1490 CreateNewPartition(PartitionList
,
1494 return SELECT_FILE_SYSTEM_PAGE
;
1499 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1501 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1502 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1505 return SELECT_FILE_SYSTEM_PAGE
;
1511 /* Update status text */
1512 if (PartitionList
->CurrentPartition
== NULL
||
1513 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1515 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1519 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1522 CONSOLE_ConInKey(Ir
);
1524 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1525 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1527 if (ConfirmQuit(Ir
) == TRUE
)
1529 DestroyPartitionList(PartitionList
);
1530 PartitionList
= NULL
;
1536 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1537 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1539 ScrollDownPartitionList(PartitionList
);
1541 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1542 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1544 ScrollUpPartitionList(PartitionList
);
1546 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1548 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1550 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1551 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1553 if (PartitionList
->CurrentPartition
== NULL
||
1554 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1556 CreateNewPartition(PartitionList
,
1561 return SELECT_FILE_SYSTEM_PAGE
;
1563 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1565 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1567 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1568 return SELECT_PARTITION_PAGE
;
1571 return CREATE_PARTITION_PAGE
;
1573 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1575 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1577 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1578 return SELECT_PARTITION_PAGE
;
1581 return DELETE_PARTITION_PAGE
;
1585 return SELECT_PARTITION_PAGE
;
1590 DrawInputField(ULONG FieldLength
,
1601 memset(buf
, '_', sizeof(buf
));
1602 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1603 strcat(buf
, FieldContent
);
1605 WriteConsoleOutputCharacterA(StdOutput
,
1613 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1614 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1615 #define PARTITION_MAXSIZE 999999
1618 ShowPartitionSizeInputBox(SHORT Left
,
1642 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1647 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1648 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1651 WriteConsoleOutputCharacterA(StdOutput
,
1657 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1658 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1660 WriteConsoleOutputCharacterA(StdOutput
,
1666 sprintf(Buffer
, "%lu", MaxSize
);
1667 Index
= strlen(Buffer
);
1668 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1675 CONSOLE_ConInKey(&Ir
);
1677 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1678 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1686 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1690 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1698 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1704 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1709 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1710 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1712 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1714 if ((ch
>= '0') && (ch
<= '9'))
1720 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1728 strcpy(InputBuffer
, Buffer
);
1733 CreatePartitionPage(PINPUT_RECORD Ir
)
1735 PDISKENTRY DiskEntry
;
1736 PPARTENTRY PartEntry
;
1739 CHAR InputBuffer
[50];
1745 if (PartitionList
== NULL
||
1746 PartitionList
->CurrentDisk
== NULL
||
1747 PartitionList
->CurrentPartition
== NULL
)
1749 /* FIXME: show an error dialog */
1753 DiskEntry
= PartitionList
->CurrentDisk
;
1754 PartEntry
= PartitionList
->CurrentPartition
;
1756 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1758 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1761 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1763 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1764 Unit
= MUIGetString(STRING_GB
);
1769 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1774 Unit
= MUIGetString(STRING_MB
);
1777 if (DiskEntry
->DriverName
.Length
> 0)
1779 CONSOLE_PrintTextXY(6, 10,
1780 MUIGetString(STRING_HDINFOPARTCREATE
),
1783 DiskEntry
->DiskNumber
,
1787 &DiskEntry
->DriverName
);
1791 CONSOLE_PrintTextXY(6, 10,
1792 MUIGetString(STRING_HDDINFOUNK1
),
1795 DiskEntry
->DiskNumber
,
1801 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1804 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1805 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1808 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1810 PartEntry
= PartitionList
->CurrentPartition
;
1813 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1815 if (MaxSize
> PARTITION_MAXSIZE
) MaxSize
= PARTITION_MAXSIZE
;
1817 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1818 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1822 if (ConfirmQuit (Ir
) == TRUE
)
1827 else if (Cancel
== TRUE
)
1829 return SELECT_PARTITION_PAGE
;
1833 PartSize
= atoi(InputBuffer
);
1841 if (PartSize
> MaxSize
)
1847 /* Convert to bytes */
1848 if (PartSize
== MaxSize
)
1850 /* Use all of the unpartitioned disk space */
1851 PartSize
= PartEntry
->UnpartitionedLength
;
1855 /* Round-up by cylinder size */
1856 PartSize
= (PartSize
* 1024 * 1024 + DiskEntry
->CylinderSize
- 1) /
1857 DiskEntry
->CylinderSize
* DiskEntry
->CylinderSize
;
1859 /* But never get larger than the unpartitioned disk space */
1860 if (PartSize
> PartEntry
->UnpartitionedLength
)
1861 PartSize
= PartEntry
->UnpartitionedLength
;
1864 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1866 CreateNewPartition(PartitionList
,
1870 return SELECT_PARTITION_PAGE
;
1874 return CREATE_PARTITION_PAGE
;
1879 DeletePartitionPage(PINPUT_RECORD Ir
)
1881 PDISKENTRY DiskEntry
;
1882 PPARTENTRY PartEntry
;
1889 if (PartitionList
== NULL
||
1890 PartitionList
->CurrentDisk
== NULL
||
1891 PartitionList
->CurrentPartition
== NULL
)
1893 /* FIXME: show an error dialog */
1897 DiskEntry
= PartitionList
->CurrentDisk
;
1898 PartEntry
= PartitionList
->CurrentPartition
;
1899 PartNumber
= PartitionList
->CurrentPartitionNumber
;
1901 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1903 /* Determine partition type */
1905 if (PartEntry
->New
== TRUE
)
1907 PartType
= MUIGetString(STRING_UNFORMATTED
);
1909 else if (PartEntry
->Unpartitioned
== FALSE
)
1911 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
1912 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
1913 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
1914 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
1918 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
1919 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
1923 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
1927 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
1929 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1934 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1936 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1937 Unit
= MUIGetString(STRING_GB
);
1941 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1943 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1944 Unit
= MUIGetString(STRING_MB
);
1948 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1949 Unit
= MUIGetString(STRING_KB
);
1952 if (PartType
== NULL
)
1954 CONSOLE_PrintTextXY(6, 10,
1955 MUIGetString(STRING_HDDINFOUNK2
),
1956 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1957 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1958 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
1964 CONSOLE_PrintTextXY(6, 10,
1965 " %c%c %s %I64u %s",
1966 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1967 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1974 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1976 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1977 Unit
= MUIGetString(STRING_GB
);
1982 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1987 Unit
= MUIGetString(STRING_MB
);
1990 if (DiskEntry
->DriverName
.Length
> 0)
1992 CONSOLE_PrintTextXY(6, 12,
1993 MUIGetString(STRING_HDINFOPARTDELETE
),
1996 DiskEntry
->DiskNumber
,
2000 &DiskEntry
->DriverName
);
2004 CONSOLE_PrintTextXY(6, 12,
2005 MUIGetString(STRING_HDDINFOUNK3
),
2008 DiskEntry
->DiskNumber
,
2016 CONSOLE_ConInKey(Ir
);
2018 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2019 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2021 if (ConfirmQuit(Ir
) == TRUE
)
2028 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2030 return SELECT_PARTITION_PAGE
;
2032 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2034 DeleteCurrentPartition(PartitionList
);
2036 return SELECT_PARTITION_PAGE
;
2040 return DELETE_PARTITION_PAGE
;
2045 SelectFileSystemPage(PINPUT_RECORD Ir
)
2047 PDISKENTRY DiskEntry
;
2048 PPARTENTRY PartEntry
;
2056 if (PartitionList
== NULL
||
2057 PartitionList
->CurrentDisk
== NULL
||
2058 PartitionList
->CurrentPartition
== NULL
)
2060 /* FIXME: show an error dialog */
2064 DiskEntry
= PartitionList
->CurrentDisk
;
2065 PartEntry
= PartitionList
->CurrentPartition
;
2066 PartNumber
= PartitionList
->CurrentPartitionNumber
;
2068 /* adjust disk size */
2069 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
2071 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
2072 DiskUnit
= MUIGetString(STRING_GB
);
2076 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
2077 DiskUnit
= MUIGetString(STRING_MB
);
2080 /* adjust partition size */
2081 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
2083 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
2084 PartUnit
= MUIGetString(STRING_GB
);
2088 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
2089 PartUnit
= MUIGetString(STRING_MB
);
2092 /* adjust partition type */
2093 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
2094 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
2095 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
2096 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
2100 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
2101 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
2105 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
2109 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
2111 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2113 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_ENTRY_UNUSED
)
2115 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2119 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2122 if (PartEntry
->AutoCreate
== TRUE
)
2124 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2127 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2128 PartEntry
->PartInfo
[PartNumber
].PartitionNumber
,
2134 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2135 DiskEntry
->DiskNumber
,
2141 &DiskEntry
->DriverName
);
2143 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2146 PartEntry
->AutoCreate
= FALSE
;
2148 else if (PartEntry
->New
== TRUE
)
2150 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2151 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2155 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2157 if (PartType
== NULL
)
2159 CONSOLE_PrintTextXY(8, 10,
2160 MUIGetString(STRING_HDDINFOUNK4
),
2161 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2162 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2163 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
2169 CONSOLE_PrintTextXY(8, 10,
2171 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2172 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2178 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2179 DiskEntry
->DiskNumber
,
2185 &DiskEntry
->DriverName
);
2188 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2190 if (FileSystemList
== NULL
)
2192 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2193 if (FileSystemList
== NULL
)
2195 /* FIXME: show an error dialog */
2199 /* FIXME: Add file systems to list */
2201 DrawFileSystemList(FileSystemList
);
2203 if (RepairUpdateFlag
)
2205 return CHECK_FILE_SYSTEM_PAGE
;
2206 //return SELECT_PARTITION_PAGE;
2209 if (IsUnattendedSetup
)
2211 if (UnattendFormatPartition
)
2213 return FORMAT_PARTITION_PAGE
;
2216 return CHECK_FILE_SYSTEM_PAGE
;
2221 CONSOLE_ConInKey(Ir
);
2223 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2224 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2226 if (ConfirmQuit(Ir
) == TRUE
)
2233 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2234 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2236 return SELECT_PARTITION_PAGE
;
2238 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2239 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2241 ScrollDownFileSystemList(FileSystemList
);
2243 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2244 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2246 ScrollUpFileSystemList(FileSystemList
);
2248 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2250 if (!FileSystemList
->Selected
->FormatFunc
)
2252 return CHECK_FILE_SYSTEM_PAGE
;
2256 return FORMAT_PARTITION_PAGE
;
2261 return SELECT_FILE_SYSTEM_PAGE
;
2266 FormatPartitionPage(PINPUT_RECORD Ir
)
2268 WCHAR PathBuffer
[MAX_PATH
];
2269 PDISKENTRY DiskEntry
;
2270 PPARTENTRY PartEntry
;
2280 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2282 if (PartitionList
== NULL
||
2283 PartitionList
->CurrentDisk
== NULL
||
2284 PartitionList
->CurrentPartition
== NULL
)
2286 /* FIXME: show an error dialog */
2290 DiskEntry
= PartitionList
->CurrentDisk
;
2291 PartEntry
= PartitionList
->CurrentPartition
;
2292 PartNum
= PartitionList
->CurrentPartitionNumber
;
2296 if (!IsUnattendedSetup
)
2298 CONSOLE_ConInKey(Ir
);
2301 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2302 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2304 if (ConfirmQuit(Ir
) == TRUE
)
2311 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2313 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2315 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2317 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2319 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2320 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_12
;
2322 else if (PartEntry
->PartInfo
[PartNum
].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2324 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2326 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2328 /* FAT16 CHS partition (partiton size < 32MB) */
2329 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_16
;
2331 else if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2333 /* FAT16 CHS partition (partition size < 512MB) */
2334 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_HUGE
;
2338 /* FAT32 CHS partition (partition size >= 512MB) */
2339 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32
;
2344 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2346 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2348 /* FAT16 LBA partition (partition size < 512MB) */
2349 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_XINT13
;
2353 /* FAT32 LBA partition (partition size >= 512MB) */
2354 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32_XINT13
;
2358 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2359 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_EXT2
;
2360 else if (!FileSystemList
->Selected
->FormatFunc
)
2363 CheckActiveBootPartition(PartitionList
);
2366 CONSOLE_PrintTextXY(6, 12,
2367 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2368 DiskEntry
->DiskSize
,
2369 DiskEntry
->CylinderSize
,
2370 DiskEntry
->TrackSize
);
2373 DiskEntry
= PartitionList
->CurrentDisk
;
2374 Entry
= DiskEntry
->PartListHead
.Flink
;
2376 while (Entry
!= &DiskEntry
->PartListHead
)
2378 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2380 if (PartEntry
->Unpartitioned
== FALSE
)
2382 for (i
= 0; i
< 4; i
++)
2384 CONSOLE_PrintTextXY(6, Line
,
2385 "%2u: %2u %c %12I64u %12I64u %2u %c",
2387 PartEntry
->PartInfo
[i
].PartitionNumber
,
2388 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2389 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2390 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2391 PartEntry
->PartInfo
[i
].PartitionType
,
2392 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2400 Entry
= Entry
->Flink
;
2403 /* Restore the old entry */
2404 PartEntry
= PartitionList
->CurrentPartition
;
2407 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2409 DPRINT("WritePartitionsToDisk() failed\n");
2410 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2414 /* Set DestinationRootPath */
2415 RtlFreeUnicodeString(&DestinationRootPath
);
2416 swprintf(PathBuffer
,
2417 L
"\\Device\\Harddisk%lu\\Partition%lu",
2418 PartitionList
->CurrentDisk
->DiskNumber
,
2419 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2420 RtlCreateUnicodeString(&DestinationRootPath
,
2422 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2425 /* Set SystemRootPath */
2426 RtlFreeUnicodeString(&SystemRootPath
);
2427 swprintf(PathBuffer
,
2428 L
"\\Device\\Harddisk%lu\\Partition%lu",
2429 PartitionList
->ActiveBootDisk
->DiskNumber
,
2430 PartitionList
->ActiveBootPartition
->
2431 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionNumber
);
2432 RtlCreateUnicodeString(&SystemRootPath
,
2434 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2437 if (FileSystemList
->Selected
->FormatFunc
)
2439 Status
= FormatPartition(&DestinationRootPath
,
2440 FileSystemList
->Selected
);
2441 if (!NT_SUCCESS(Status
))
2443 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2444 /* FIXME: show an error dialog */
2448 PartEntry
->New
= FALSE
;
2450 CheckActiveBootPartition(PartitionList
);
2454 CONSOLE_SetStatusText(" Done. Press any key ...");
2455 CONSOLE_ConInKey(Ir
);
2458 DestroyFileSystemList(FileSystemList
);
2459 FileSystemList
= NULL
;
2460 return INSTALL_DIRECTORY_PAGE
;
2464 return FORMAT_PARTITION_PAGE
;
2469 CheckFileSystemPage(PINPUT_RECORD Ir
)
2471 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2472 WCHAR PathBuffer
[MAX_PATH
];
2473 CHAR Buffer
[MAX_PATH
];
2475 UCHAR PartNum
= PartitionList
->CurrentPartitionNumber
;
2477 /* FIXME: code duplicated in FormatPartitionPage */
2478 /* Set DestinationRootPath */
2479 RtlFreeUnicodeString(&DestinationRootPath
);
2480 swprintf(PathBuffer
,
2481 L
"\\Device\\Harddisk%lu\\Partition%lu",
2482 PartitionList
->CurrentDisk
->DiskNumber
,
2483 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2484 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2485 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2487 /* Set SystemRootPath */
2488 RtlFreeUnicodeString(&SystemRootPath
);
2489 swprintf(PathBuffer
,
2490 L
"\\Device\\Harddisk%lu\\Partition%lu",
2491 PartitionList
->ActiveBootDisk
->DiskNumber
,
2492 PartitionList
->ActiveBootPartition
->PartInfo
[PartNum
].PartitionNumber
);
2493 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2494 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2496 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2498 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2500 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2501 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2503 if (!CurrentFileSystem
->ChkdskFunc
)
2506 "Setup is currently unable to check a partition formatted in %S.\n"
2508 " \x07 Press ENTER to continue Setup.\n"
2509 " \x07 Press F3 to quit Setup.",
2510 CurrentFileSystem
->FileSystem
);
2513 MUIGetString(STRING_QUITCONTINUE
),
2514 NULL
, POPUP_WAIT_NONE
);
2518 CONSOLE_ConInKey(Ir
);
2520 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2521 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2523 if (ConfirmQuit(Ir
))
2526 return CHECK_FILE_SYSTEM_PAGE
;
2528 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2530 return INSTALL_DIRECTORY_PAGE
;
2536 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2537 if (!NT_SUCCESS(Status
))
2539 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2540 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2541 "(Status 0x%08lx).\n", Status
);
2544 MUIGetString(STRING_REBOOTCOMPUTER
),
2545 Ir
, POPUP_WAIT_ENTER
);
2550 return INSTALL_DIRECTORY_PAGE
;
2556 InstallDirectoryPage1(PWCHAR InstallDir
,
2557 PDISKENTRY DiskEntry
,
2558 PPARTENTRY PartEntry
,
2561 WCHAR PathBuffer
[MAX_PATH
];
2563 /* Create 'InstallPath' string */
2564 RtlFreeUnicodeString(&InstallPath
);
2565 RtlCreateUnicodeString(&InstallPath
,
2568 /* Create 'DestinationPath' string */
2569 RtlFreeUnicodeString(&DestinationPath
);
2570 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2572 if (InstallDir
[0] != L
'\\')
2573 wcscat(PathBuffer
, L
"\\");
2575 wcscat(PathBuffer
, InstallDir
);
2576 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2578 /* Create 'DestinationArcPath' */
2579 RtlFreeUnicodeString(&DestinationArcPath
);
2580 swprintf(PathBuffer
,
2581 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2582 DiskEntry
->BiosDiskNumber
,
2583 PartEntry
->PartInfo
[PartNum
].PartitionNumber
);
2585 if (InstallDir
[0] != L
'\\')
2586 wcscat(PathBuffer
, L
"\\");
2588 wcscat(PathBuffer
, InstallDir
);
2589 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2591 return PREPARE_COPY_PAGE
;
2596 InstallDirectoryPage(PINPUT_RECORD Ir
)
2598 PDISKENTRY DiskEntry
;
2599 PPARTENTRY PartEntry
;
2600 WCHAR InstallDir
[51];
2605 if (PartitionList
== NULL
||
2606 PartitionList
->CurrentDisk
== NULL
||
2607 PartitionList
->CurrentPartition
== NULL
)
2609 /* FIXME: show an error dialog */
2613 DiskEntry
= PartitionList
->CurrentDisk
;
2614 PartEntry
= PartitionList
->CurrentPartition
;
2616 /* Search for 'DefaultPath' in the 'SetupData' section */
2617 if (!SetupFindFirstLineW(SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2619 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2623 /* Read the 'DefaultPath' data */
2624 if (INF_GetData(&Context
, NULL
, &DefaultPath
))
2626 wcscpy(InstallDir
, DefaultPath
);
2630 wcscpy(InstallDir
, L
"\\ReactOS");
2633 Length
= wcslen(InstallDir
);
2634 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2635 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2637 if (IsUnattendedSetup
)
2639 return InstallDirectoryPage1(InstallDir
,
2642 PartitionList
->CurrentPartitionNumber
);
2647 CONSOLE_ConInKey(Ir
);
2649 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2650 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2652 if (ConfirmQuit(Ir
) == TRUE
)
2657 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2659 return InstallDirectoryPage1(InstallDir
,
2662 PartitionList
->CurrentPartitionNumber
);
2664 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2669 InstallDir
[Length
] = 0;
2670 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2673 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2677 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2679 InstallDir
[Length
] = 0;
2680 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2685 return INSTALL_DIRECTORY_PAGE
;
2690 AddSectionToCopyQueueCab(HINF InfFile
,
2692 PWCHAR SourceCabinet
,
2693 PCUNICODE_STRING DestinationPath
,
2696 INFCONTEXT FilesContext
;
2697 INFCONTEXT DirContext
;
2699 PWCHAR FileKeyValue
;
2701 PWCHAR TargetFileName
;
2703 /* Search for the SectionName section */
2704 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
2707 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2708 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2713 * Enumerate the files in the section
2714 * and add them to the file queue.
2718 /* Get source file name and target directory id */
2719 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
2721 /* FIXME: Handle error! */
2722 DPRINT1("INF_GetData() failed\n");
2726 /* Get optional target file name */
2727 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
2728 TargetFileName
= NULL
;
2730 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2732 /* Lookup target directory */
2733 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2735 /* FIXME: Handle error! */
2736 DPRINT1("SetupFindFirstLine() failed\n");
2740 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
2742 /* FIXME: Handle error! */
2743 DPRINT1("INF_GetData() failed\n");
2747 if (!SetupQueueCopy(SetupFileQueue
,
2749 SourceRootPath
.Buffer
,
2750 SourceRootDir
.Buffer
,
2755 /* FIXME: Handle error! */
2756 DPRINT1("SetupQueueCopy() failed\n");
2758 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2765 AddSectionToCopyQueue(HINF InfFile
,
2767 PWCHAR SourceCabinet
,
2768 PCUNICODE_STRING DestinationPath
,
2771 INFCONTEXT FilesContext
;
2772 INFCONTEXT DirContext
;
2774 PWCHAR FileKeyValue
;
2776 PWCHAR TargetFileName
;
2777 WCHAR CompleteOrigFileName
[512];
2780 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2782 /* Search for the SectionName section */
2783 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
2786 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2787 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2792 * Enumerate the files in the section
2793 * and add them to the file queue.
2797 /* Get source file name and target directory id */
2798 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
2800 /* FIXME: Handle error! */
2801 DPRINT1("INF_GetData() failed\n");
2805 /* Get target directory id */
2806 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
2808 /* FIXME: Handle error! */
2809 DPRINT1("INF_GetData() failed\n");
2813 /* Get optional target file name */
2814 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
2815 TargetFileName
= NULL
;
2816 else if (!*TargetFileName
)
2817 TargetFileName
= NULL
;
2819 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2821 /* Lookup target directory */
2822 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2824 /* FIXME: Handle error! */
2825 DPRINT1("SetupFindFirstLine() failed\n");
2829 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
2831 /* FIXME: Handle error! */
2832 DPRINT1("INF_GetData() failed\n");
2836 wcscpy(CompleteOrigFileName
, SourceRootDir
.Buffer
);
2837 wcscat(CompleteOrigFileName
, L
"\\");
2838 wcscat(CompleteOrigFileName
, DirKeyValue
);
2840 if (!SetupQueueCopy(SetupFileQueue
,
2842 SourceRootPath
.Buffer
,
2843 CompleteOrigFileName
,
2848 /* FIXME: Handle error! */
2849 DPRINT1("SetupQueueCopy() failed\n");
2851 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2858 PrepareCopyPageInfFile(HINF InfFile
,
2859 PWCHAR SourceCabinet
,
2862 WCHAR PathBuffer
[MAX_PATH
];
2863 INFCONTEXT DirContext
;
2864 PWCHAR AdditionalSectionName
= NULL
;
2869 /* Add common files */
2870 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2873 /* Add specific files depending of computer type */
2874 if (SourceCabinet
== NULL
)
2876 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2879 if (AdditionalSectionName
)
2881 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2886 /* Create directories */
2890 * Install directories like '\reactos\test' are not handled yet.
2893 /* Get destination path */
2894 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2896 /* Remove trailing backslash */
2897 Length
= wcslen(PathBuffer
);
2898 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2900 PathBuffer
[Length
- 1] = 0;
2903 /* Create the install directory */
2904 Status
= SetupCreateDirectory(PathBuffer
);
2905 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2907 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2908 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2912 /* Search for the 'Directories' section */
2913 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2917 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2921 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2927 /* Enumerate the directory values and create the subdirectories */
2930 if (!INF_GetData(&DirContext
, NULL
, &KeyValue
))
2936 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2938 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2940 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2941 wcscat(PathBuffer
, KeyValue
);
2943 DPRINT("FullPath: '%S'\n", PathBuffer
);
2945 else if (KeyValue
[0] != L
'\\')
2947 DPRINT("RelativePath: '%S'\n", KeyValue
);
2948 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2949 wcscat(PathBuffer
, L
"\\");
2950 wcscat(PathBuffer
, KeyValue
);
2952 DPRINT("FullPath: '%S'\n", PathBuffer
);
2954 Status
= SetupCreateDirectory(PathBuffer
);
2955 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2957 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2958 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2962 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2969 PrepareCopyPage(PINPUT_RECORD Ir
)
2972 WCHAR PathBuffer
[MAX_PATH
];
2973 INFCONTEXT CabinetsContext
;
2979 MUIDisplayPage(PREPARE_COPY_PAGE
);
2981 /* Create the file queue */
2982 SetupFileQueue
= SetupOpenFileQueue();
2983 if (SetupFileQueue
== NULL
)
2985 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2989 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2994 /* Search for the 'Cabinets' section */
2995 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2997 return FILE_COPY_PAGE
;
3001 * Enumerate the directory values in the 'Cabinets'
3002 * section and parse their inf files.
3006 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3009 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3010 wcscat(PathBuffer
, L
"\\");
3011 wcscat(PathBuffer
, KeyValue
);
3014 CabinetInitialize();
3015 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3016 CabinetSetCabinetName(PathBuffer
);
3018 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3020 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3022 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3023 if (InfFileData
== NULL
)
3025 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3031 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3032 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3036 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3043 if (InfHandle
== INVALID_HANDLE_VALUE
)
3045 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3051 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3056 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3058 return FILE_COPY_PAGE
;
3064 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3067 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3069 /* Get the memory information from the system */
3070 NtQuerySystemInformation(SystemPerformanceInformation
,
3075 /* Check if this is initial setup */
3078 /* Set maximum limits to be total RAM pages */
3079 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3080 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3081 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3084 /* Set current values */
3085 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3086 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3087 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3093 FileCopyCallback(PVOID Context
,
3098 PCOPYCONTEXT CopyContext
;
3100 CopyContext
= (PCOPYCONTEXT
)Context
;
3102 switch (Notification
)
3104 case SPFILENOTIFY_STARTSUBQUEUE
:
3105 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3106 ProgressSetStepCount(CopyContext
->ProgressBar
,
3107 CopyContext
->TotalOperations
);
3108 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3111 case SPFILENOTIFY_STARTCOPY
:
3112 /* Display copy message */
3113 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3114 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3117 case SPFILENOTIFY_ENDCOPY
:
3118 CopyContext
->CompletedOperations
++;
3119 ProgressNextStep(CopyContext
->ProgressBar
);
3120 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3130 FileCopyPage(PINPUT_RECORD Ir
)
3132 COPYCONTEXT CopyContext
;
3133 unsigned int mem_bar_width
;
3135 MUIDisplayPage(FILE_COPY_PAGE
);
3137 /* Create context for the copy process */
3138 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3139 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3140 CopyContext
.TotalOperations
= 0;
3141 CopyContext
.CompletedOperations
= 0;
3143 /* Create the progress bar as well */
3144 CopyContext
.ProgressBar
= CreateProgressBar(13,
3151 MUIGetString(STRING_SETUPCOPYINGFILES
));
3153 // fit memory bars to screen width, distribute them uniform
3154 mem_bar_width
= (xScreen
- 26) / 5;
3155 mem_bar_width
-= mem_bar_width
% 2; // make even
3156 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3157 /* Create the paged pool progress bar */
3158 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3167 /* Create the non paged pool progress bar */
3168 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3170 (xScreen
/ 2) + (mem_bar_width
/ 2),
3172 (xScreen
/ 2)- (mem_bar_width
/ 2),
3177 /* Create the global memory progress bar */
3178 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3182 xScreen
- 13 - mem_bar_width
,
3187 /* Do the file copying */
3188 SetupCommitFileQueueW(NULL
,
3193 /* If we get here, we're done, so cleanup the queue and progress bar */
3194 SetupCloseFileQueue(SetupFileQueue
);
3195 DestroyProgressBar(CopyContext
.ProgressBar
);
3196 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3197 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3198 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3200 /* Go display the next page */
3201 return REGISTRY_PAGE
;
3206 RegistryPage(PINPUT_RECORD Ir
)
3208 INFCONTEXT InfContext
;
3215 MUIDisplayPage(REGISTRY_PAGE
);
3217 if (RepairUpdateFlag
)
3219 return SUCCESS_PAGE
;
3222 if (!SetInstallPathValue(&DestinationPath
))
3224 DPRINT("SetInstallPathValue() failed\n");
3225 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3229 /* Create the default hives */
3231 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3232 if (!NT_SUCCESS(Status
))
3234 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3235 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3239 RegInitializeRegistry();
3242 /* Update registry */
3243 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3245 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3247 DPRINT1("SetupFindFirstLine() failed\n");
3248 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3254 INF_GetDataField (&InfContext
, 0, &Action
);
3255 INF_GetDataField (&InfContext
, 1, &File
);
3256 INF_GetDataField (&InfContext
, 2, &Section
);
3258 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3263 if (!_wcsicmp (Action
, L
"AddReg"))
3267 else if (!_wcsicmp (Action
, L
"DelReg"))
3276 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3278 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3280 DPRINT("Importing %S failed\n", File
);
3282 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3285 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3287 /* Update display registry settings */
3288 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3289 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3291 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3295 /* Set the locale */
3296 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3297 if (!ProcessLocaleRegistry(LanguageList
))
3299 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3303 /* Add keyboard layouts */
3304 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3305 if (!AddKeyboardLayouts())
3307 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3313 if (!SetGeoID(MUIGetGeoID()))
3315 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3319 if (!IsUnattendedSetup
)
3321 /* Update keyboard layout settings */
3322 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3323 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3325 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3330 /* Add codepage information to registry */
3331 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3334 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3338 /* Update the mounted devices list */
3339 SetMountedDeviceValues(PartitionList
);
3341 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3343 return BOOT_LOADER_PAGE
;
3348 BootLoaderPage(PINPUT_RECORD Ir
)
3350 UCHAR PartitionType
;
3351 BOOLEAN InstallOnFloppy
;
3354 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3356 PartitionType
= PartitionList
->ActiveBootPartition
->
3357 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3359 if (IsUnattendedSetup
)
3361 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3363 return SUCCESS_PAGE
;
3365 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3367 return BOOT_LOADER_FLOPPY_PAGE
;
3371 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3373 DPRINT("Error: active partition invalid (unused)\n");
3374 InstallOnFloppy
= TRUE
;
3376 else if (PartitionType
== 0x0A)
3378 /* OS/2 boot manager partition */
3379 DPRINT("Found OS/2 boot manager partition\n");
3380 InstallOnFloppy
= TRUE
;
3382 else if (PartitionType
== 0x83)
3384 /* Linux ext2 partition */
3385 DPRINT("Found Linux ext2 partition\n");
3386 InstallOnFloppy
= TRUE
;
3388 else if (PartitionType
== PARTITION_IFS
)
3390 /* NTFS partition */
3391 DPRINT("Found NTFS partition\n");
3392 InstallOnFloppy
= TRUE
;
3394 else if ((PartitionType
== PARTITION_FAT_12
) ||
3395 (PartitionType
== PARTITION_FAT_16
) ||
3396 (PartitionType
== PARTITION_HUGE
) ||
3397 (PartitionType
== PARTITION_XINT13
) ||
3398 (PartitionType
== PARTITION_FAT32
) ||
3399 (PartitionType
== PARTITION_FAT32_XINT13
))
3401 DPRINT("Found FAT partition\n");
3402 InstallOnFloppy
= FALSE
;
3406 /* Unknown partition */
3407 DPRINT("Unknown partition found\n");
3408 InstallOnFloppy
= TRUE
;
3411 if (InstallOnFloppy
== TRUE
)
3413 return BOOT_LOADER_FLOPPY_PAGE
;
3416 /* Unattended install on hdd? */
3417 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3419 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3422 MUIDisplayPage(BOOT_LOADER_PAGE
);
3423 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3427 CONSOLE_ConInKey(Ir
);
3429 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3430 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3432 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3441 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3443 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3444 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3446 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3455 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3457 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3458 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3460 if (ConfirmQuit(Ir
) == TRUE
)
3465 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3469 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3471 else if (Line
== 13)
3473 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
3475 else if (Line
== 14)
3477 return BOOT_LOADER_FLOPPY_PAGE
;
3479 else if (Line
== 15)
3481 return SUCCESS_PAGE
;
3484 return BOOT_LOADER_PAGE
;
3488 return BOOT_LOADER_PAGE
;
3493 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3497 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3499 // SetStatusText(" Please wait...");
3503 CONSOLE_ConInKey(Ir
);
3505 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3506 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3508 if (ConfirmQuit(Ir
) == TRUE
)
3513 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3515 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3517 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3518 return BOOT_LOADER_FLOPPY_PAGE
;
3521 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3522 if (!NT_SUCCESS(Status
))
3524 /* Print error message */
3525 return BOOT_LOADER_FLOPPY_PAGE
;
3528 return SUCCESS_PAGE
;
3532 return BOOT_LOADER_FLOPPY_PAGE
;
3536 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
3538 UCHAR PartitionType
;
3541 PartitionType
= PartitionList
->ActiveBootPartition
->
3542 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3544 Status
= InstallVBRToPartition(&SystemRootPath
,
3546 &DestinationArcPath
,
3548 if (!NT_SUCCESS(Status
))
3550 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3554 return SUCCESS_PAGE
;
3558 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
3560 UCHAR PartitionType
;
3562 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
3563 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
3565 /* Step 1: Write the VBR */
3566 PartitionType
= PartitionList
->ActiveBootPartition
->
3567 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3569 Status
= InstallVBRToPartition(&SystemRootPath
,
3571 &DestinationArcPath
,
3573 if (!NT_SUCCESS(Status
))
3575 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3579 /* Step 2: Write the MBR */
3580 swprintf(DestinationDevicePathBuffer
,
3581 L
"\\Device\\Harddisk%d\\Partition0",
3582 PartitionList
->ActiveBootDisk
->DiskNumber
);
3584 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
3585 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
3587 DPRINT("Install MBR bootcode: %S ==> %S\n",
3588 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
3590 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
3591 DestinationDevicePathBuffer
);
3592 if (!NT_SUCCESS (Status
))
3594 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
3596 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3600 return SUCCESS_PAGE
;
3605 QuitPage(PINPUT_RECORD Ir
)
3607 MUIDisplayPage(QUIT_PAGE
);
3609 /* Destroy partition list */
3610 if (PartitionList
!= NULL
)
3612 DestroyPartitionList (PartitionList
);
3613 PartitionList
= NULL
;
3616 /* Destroy filesystem list */
3617 if (FileSystemList
!= NULL
)
3619 DestroyFileSystemList (FileSystemList
);
3620 FileSystemList
= NULL
;
3623 /* Destroy computer settings list */
3624 if (ComputerList
!= NULL
)
3626 DestroyGenericList(ComputerList
, TRUE
);
3627 ComputerList
= NULL
;
3630 /* Destroy display settings list */
3631 if (DisplayList
!= NULL
)
3633 DestroyGenericList(DisplayList
, TRUE
);
3637 /* Destroy keyboard settings list */
3638 if (KeyboardList
!= NULL
)
3640 DestroyGenericList(KeyboardList
, TRUE
);
3641 KeyboardList
= NULL
;
3644 /* Destroy keyboard layout list */
3645 if (LayoutList
!= NULL
)
3647 DestroyGenericList(LayoutList
, TRUE
);
3651 if (LanguageList
!= NULL
)
3653 DestroyGenericList(LanguageList
, FALSE
);
3654 LanguageList
= NULL
;
3657 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3661 CONSOLE_ConInKey(Ir
);
3663 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3672 SuccessPage(PINPUT_RECORD Ir
)
3674 MUIDisplayPage(SUCCESS_PAGE
);
3676 if (IsUnattendedSetup
)
3683 CONSOLE_ConInKey(Ir
);
3685 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3694 FlushPage(PINPUT_RECORD Ir
)
3696 MUIDisplayPage(FLUSH_PAGE
);
3702 PnpEventThread(IN LPVOID lpParameter
);
3712 NtQuerySystemTime(&Time
);
3714 Status
= RtlCreateUserThread(NtCurrentProcess(),
3724 if (!NT_SUCCESS(Status
))
3725 hPnpThread
= INVALID_HANDLE_VALUE
;
3727 if (!CONSOLE_Init())
3729 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3730 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3731 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3733 /* Raise a hard error (crash the system/BSOD) */
3734 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3738 /* Initialize global unicode strings */
3739 RtlInitUnicodeString(&SourcePath
, NULL
);
3740 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3741 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3742 RtlInitUnicodeString(&InstallPath
, NULL
);
3743 RtlInitUnicodeString(&DestinationPath
, NULL
);
3744 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3745 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3746 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3748 /* Hide the cursor */
3749 CONSOLE_SetCursorType(TRUE
, FALSE
);
3752 while (Page
!= REBOOT_PAGE
)
3754 CONSOLE_ClearScreen();
3757 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3764 Page
= SetupStartPage(&Ir
);
3769 Page
= LanguagePage(&Ir
);
3774 Page
= LicensePage(&Ir
);
3779 Page
= IntroPage(&Ir
);
3783 case INSTALL_INTRO_PAGE
:
3784 Page
= InstallIntroPage(&Ir
);
3788 case SCSI_CONTROLLER_PAGE
:
3789 Page
= ScsiControllerPage(&Ir
);
3794 case OEM_DRIVER_PAGE
:
3795 Page
= OemDriverPage(&Ir
);
3799 case DEVICE_SETTINGS_PAGE
:
3800 Page
= DeviceSettingsPage(&Ir
);
3803 case COMPUTER_SETTINGS_PAGE
:
3804 Page
= ComputerSettingsPage(&Ir
);
3807 case DISPLAY_SETTINGS_PAGE
:
3808 Page
= DisplaySettingsPage(&Ir
);
3811 case KEYBOARD_SETTINGS_PAGE
:
3812 Page
= KeyboardSettingsPage(&Ir
);
3815 case LAYOUT_SETTINGS_PAGE
:
3816 Page
= LayoutSettingsPage(&Ir
);
3819 case SELECT_PARTITION_PAGE
:
3820 Page
= SelectPartitionPage(&Ir
);
3823 case CREATE_PARTITION_PAGE
:
3824 Page
= CreatePartitionPage(&Ir
);
3827 case DELETE_PARTITION_PAGE
:
3828 Page
= DeletePartitionPage(&Ir
);
3831 case SELECT_FILE_SYSTEM_PAGE
:
3832 Page
= SelectFileSystemPage(&Ir
);
3835 case FORMAT_PARTITION_PAGE
:
3836 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3839 case CHECK_FILE_SYSTEM_PAGE
:
3840 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3843 case INSTALL_DIRECTORY_PAGE
:
3844 Page
= InstallDirectoryPage(&Ir
);
3847 case PREPARE_COPY_PAGE
:
3848 Page
= PrepareCopyPage(&Ir
);
3851 case FILE_COPY_PAGE
:
3852 Page
= FileCopyPage(&Ir
);
3856 Page
= RegistryPage(&Ir
);
3859 case BOOT_LOADER_PAGE
:
3860 Page
= BootLoaderPage(&Ir
);
3863 case BOOT_LOADER_FLOPPY_PAGE
:
3864 Page
= BootLoaderFloppyPage(&Ir
);
3867 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
3868 Page
= BootLoaderHarddiskMbrPage(&Ir
);
3871 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
3872 Page
= BootLoaderHarddiskVbrPage(&Ir
);
3876 case REPAIR_INTRO_PAGE
:
3877 Page
= RepairIntroPage(&Ir
);
3881 Page
= SuccessPage(&Ir
);
3885 Page
= FlushPage(&Ir
);
3889 Page
= QuitPage(&Ir
);
3899 /* Avoid bugcheck */
3900 Time
.QuadPart
+= 50000000;
3901 NtDelayExecution(FALSE
, &Time
);
3904 NtShutdownSystem(ShutdownReboot
);
3905 NtTerminateProcess(NtCurrentProcess(), 0);
3912 NtProcessStartup(PPEB Peb
)
3914 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3916 ProcessHeap
= Peb
->ProcessHeap
;
3917 InfSetHeap(ProcessHeap
);
3920 #endif /* __REACTOS__ */