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 PWCHAR NewLanguageId
;
612 BOOL RefreshPage
= FALSE
;
614 /* Initialize the computer settings list */
615 if (LanguageList
== NULL
)
617 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
619 if (LanguageList
== NULL
)
621 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
627 SelectedLanguageId
= DefaultLanguage
;
628 SetConsoleCodePage();
630 DrawGenericList(LanguageList
,
636 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
638 MUIDisplayPage(LANGUAGE_PAGE
);
642 CONSOLE_ConInKey(Ir
);
644 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
645 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
647 ScrollDownGenericList (LanguageList
);
650 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
651 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
653 ScrollUpGenericList(LanguageList
);
656 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
657 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
659 ScrollPageDownGenericList(LanguageList
);
662 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
663 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
665 ScrollPageUpGenericList(LanguageList
);
668 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
669 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
671 if (ConfirmQuit(Ir
) == TRUE
)
674 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
676 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
678 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
680 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
686 SetConsoleCodePage();
690 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
693 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
699 NewLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
701 if (SelectedLanguageId
!= NewLanguageId
)
703 /* Clear the language page */
704 MUIClearPage(LANGUAGE_PAGE
);
706 SelectedLanguageId
= NewLanguageId
;
709 SetConsoleCodePage();
711 /* Redraw language selection page in native language */
712 MUIDisplayPage(LANGUAGE_PAGE
);
726 * Number of the next page.
729 SetupStartPage(PINPUT_RECORD Ir
)
731 //SYSTEM_DEVICE_INFORMATION Sdi;
733 WCHAR FileNameBuffer
[MAX_PATH
];
738 PGENERIC_LIST_ENTRY ListEntry
;
741 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
744 /* Check whether a harddisk is available */
745 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
747 sizeof(SYSTEM_DEVICE_INFORMATION
),
750 if (!NT_SUCCESS(Status
))
752 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
753 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
757 if (Sdi
.NumberOfDisks
== 0)
759 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
764 /* Get the source path and source root path */
765 Status
= GetSourcePaths(&SourcePath
,
769 if (!NT_SUCCESS(Status
))
771 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
772 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
778 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
779 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
780 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
784 /* Load txtsetup.sif from install media. */
785 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
786 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
788 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
794 if (SetupInf
== INVALID_HANDLE_VALUE
)
796 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
800 /* Open 'Version' section */
801 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
803 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
807 /* Get pointer 'Signature' key */
808 if (!INF_GetData(&Context
, NULL
, &Value
))
810 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
814 /* Check 'Signature' string */
815 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
817 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
821 /* Open 'DiskSpaceRequirements' section */
822 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
824 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
828 /* Get the 'FreeSysPartDiskSpace' value */
829 if (!SetupGetIntField(&Context
, 1, &IntValue
))
831 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
835 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
837 /* Start PnP thread */
838 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
840 NtResumeThread(hPnpThread
, NULL
);
841 hPnpThread
= INVALID_HANDLE_VALUE
;
844 CheckUnattendedSetup();
846 if (IsUnattendedSetup
)
849 //read options from inf
850 ComputerList
= CreateComputerTypeList(SetupInf
);
851 DisplayList
= CreateDisplayDriverList(SetupInf
);
852 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
853 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
854 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
857 wcscpy(SelectedLanguageId
,LocaleID
);
859 /* first we hack LanguageList */
860 ListEntry
= GetFirstListEntry(LanguageList
);
862 while (ListEntry
!= NULL
)
864 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
866 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
867 SetCurrentListEntry(LanguageList
, ListEntry
);
871 ListEntry
= GetNextListEntry(ListEntry
);
875 ListEntry
= GetFirstListEntry(LayoutList
);
877 while (ListEntry
!= NULL
)
879 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
881 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
882 SetCurrentListEntry(LayoutList
, ListEntry
);
886 ListEntry
= GetNextListEntry(ListEntry
);
889 SetConsoleCodePage();
891 return INSTALL_INTRO_PAGE
;
894 return LANGUAGE_PAGE
;
904 IntroPage(PINPUT_RECORD Ir
)
906 MUIDisplayPage(START_PAGE
);
910 CONSOLE_ConInKey(Ir
);
912 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
913 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
915 if (ConfirmQuit(Ir
) == TRUE
)
920 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
922 return INSTALL_INTRO_PAGE
;
925 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
927 return REPAIR_INTRO_PAGE
;
930 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
944 * Back to main setup page.
947 LicensePage(PINPUT_RECORD Ir
)
949 MUIDisplayPage(LICENSE_PAGE
);
953 CONSOLE_ConInKey(Ir
);
955 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
967 RepairIntroPage(PINPUT_RECORD Ir
)
969 MUIDisplayPage(REPAIR_INTRO_PAGE
);
973 CONSOLE_ConInKey(Ir
);
975 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
979 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
981 RepairUpdateFlag
= TRUE
;
982 return INSTALL_INTRO_PAGE
;
984 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
988 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
989 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
995 return REPAIR_INTRO_PAGE
;
1000 InstallIntroPage(PINPUT_RECORD Ir
)
1002 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1004 if (RepairUpdateFlag
)
1006 //return SELECT_PARTITION_PAGE;
1007 return DEVICE_SETTINGS_PAGE
;
1010 if (IsUnattendedSetup
)
1012 return SELECT_PARTITION_PAGE
;
1017 CONSOLE_ConInKey(Ir
);
1019 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1020 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1022 if (ConfirmQuit(Ir
) == TRUE
)
1027 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1029 return DEVICE_SETTINGS_PAGE
;
1030 // return SCSI_CONTROLLER_PAGE;
1034 return INSTALL_INTRO_PAGE
;
1040 ScsiControllerPage(PINPUT_RECORD Ir
)
1042 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1044 /* FIXME: print loaded mass storage driver descriptions */
1046 SetTextXY(8, 10, "TEST device");
1050 SetStatusText(" ENTER = Continue F3 = Quit");
1056 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1057 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1059 if (ConfirmQuit(Ir
) == TRUE
)
1064 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1066 return DEVICE_SETTINGS_PAGE
;
1070 return SCSI_CONTROLLER_PAGE
;
1076 DeviceSettingsPage(PINPUT_RECORD Ir
)
1078 static ULONG Line
= 16;
1079 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1081 /* Initialize the computer settings list */
1082 if (ComputerList
== NULL
)
1084 ComputerList
= CreateComputerTypeList(SetupInf
);
1085 if (ComputerList
== NULL
)
1087 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1092 /* Initialize the display settings list */
1093 if (DisplayList
== NULL
)
1095 DisplayList
= CreateDisplayDriverList(SetupInf
);
1096 if (DisplayList
== NULL
)
1098 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1103 /* Initialize the keyboard settings list */
1104 if (KeyboardList
== NULL
)
1106 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1107 if (KeyboardList
== NULL
)
1109 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1114 /* Initialize the keyboard layout list */
1115 if (LayoutList
== NULL
)
1117 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1118 if (LayoutList
== NULL
)
1120 /* FIXME: report error */
1121 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1126 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1129 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1130 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1131 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1132 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1134 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1136 if (RepairUpdateFlag
)
1138 return SELECT_PARTITION_PAGE
;
1143 CONSOLE_ConInKey(Ir
);
1145 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1146 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1148 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1152 else if (Line
== 16)
1157 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1159 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1160 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1162 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1166 else if (Line
== 16)
1171 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1173 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1174 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1176 if (ConfirmQuit(Ir
) == TRUE
)
1181 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1184 return COMPUTER_SETTINGS_PAGE
;
1185 else if (Line
== 12)
1186 return DISPLAY_SETTINGS_PAGE
;
1187 else if (Line
== 13)
1188 return KEYBOARD_SETTINGS_PAGE
;
1189 else if (Line
== 14)
1190 return LAYOUT_SETTINGS_PAGE
;
1191 else if (Line
== 16)
1192 return SELECT_PARTITION_PAGE
;
1196 return DEVICE_SETTINGS_PAGE
;
1201 ComputerSettingsPage(PINPUT_RECORD Ir
)
1203 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1205 DrawGenericList(ComputerList
,
1211 SaveGenericListState(ComputerList
);
1215 CONSOLE_ConInKey(Ir
);
1217 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1218 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1220 ScrollDownGenericList(ComputerList
);
1222 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1223 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1225 ScrollUpGenericList(ComputerList
);
1227 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1228 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1230 if (ConfirmQuit(Ir
) == TRUE
)
1235 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1236 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1238 RestoreGenericListState(ComputerList
);
1239 return DEVICE_SETTINGS_PAGE
;
1241 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1243 return DEVICE_SETTINGS_PAGE
;
1247 return COMPUTER_SETTINGS_PAGE
;
1252 DisplaySettingsPage(PINPUT_RECORD Ir
)
1254 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1256 DrawGenericList(DisplayList
,
1262 SaveGenericListState(DisplayList
);
1266 CONSOLE_ConInKey(Ir
);
1268 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1269 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1271 ScrollDownGenericList(DisplayList
);
1273 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1274 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1276 ScrollUpGenericList(DisplayList
);
1278 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1279 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1281 if (ConfirmQuit(Ir
) == TRUE
)
1288 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1289 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1291 RestoreGenericListState(DisplayList
);
1292 return DEVICE_SETTINGS_PAGE
;
1294 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1296 return DEVICE_SETTINGS_PAGE
;
1300 return DISPLAY_SETTINGS_PAGE
;
1305 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1307 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1309 DrawGenericList(KeyboardList
,
1315 SaveGenericListState(KeyboardList
);
1319 CONSOLE_ConInKey(Ir
);
1321 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1322 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1324 ScrollDownGenericList(KeyboardList
);
1326 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1327 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1329 ScrollUpGenericList(KeyboardList
);
1331 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1332 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1334 if (ConfirmQuit(Ir
) == TRUE
)
1339 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1340 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1342 RestoreGenericListState(KeyboardList
);
1343 return DEVICE_SETTINGS_PAGE
;
1345 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1347 return DEVICE_SETTINGS_PAGE
;
1351 return DISPLAY_SETTINGS_PAGE
;
1356 LayoutSettingsPage(PINPUT_RECORD Ir
)
1358 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1360 DrawGenericList(LayoutList
,
1366 SaveGenericListState(LayoutList
);
1370 CONSOLE_ConInKey(Ir
);
1372 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1373 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1375 ScrollDownGenericList(LayoutList
);
1377 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1378 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1380 ScrollUpGenericList(LayoutList
);
1382 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1383 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1385 ScrollPageDownGenericList(LayoutList
);
1387 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1388 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1390 ScrollPageUpGenericList(LayoutList
);
1392 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1393 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1395 if (ConfirmQuit(Ir
) == TRUE
)
1400 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1401 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1403 RestoreGenericListState(LayoutList
);
1404 return DEVICE_SETTINGS_PAGE
;
1406 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1408 return DEVICE_SETTINGS_PAGE
;
1410 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1413 GenericListKeyPress(LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1417 return DISPLAY_SETTINGS_PAGE
;
1422 IsDiskSizeValid(PPARTENTRY PartEntry
)
1426 /* check for unpartitioned space */
1427 m1
= PartEntry
->UnpartitionedLength
;
1428 m1
= (m1
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1430 if( m1
> RequiredPartitionDiskSpace
)
1435 /* check for partitioned space */
1436 m2
= PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
;
1437 m2
= (m2
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1438 if (m2
< RequiredPartitionDiskSpace
)
1440 /* partition is too small so ask for another partion */
1441 DPRINT1("Partition is too small(unpartitioned: %I64u MB, partitioned: %I64u MB), required disk space is %lu MB\n", m1
, m2
, RequiredPartitionDiskSpace
);
1452 SelectPartitionPage(PINPUT_RECORD Ir
)
1454 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1456 if (PartitionList
== NULL
)
1458 PartitionList
= CreatePartitionList(2,
1462 if (PartitionList
== NULL
)
1464 /* FIXME: show an error dialog */
1469 DrawPartitionList(PartitionList
);
1471 /* Warn about partitions created by Linux Fdisk */
1472 if (WarnLinuxPartitions
== TRUE
&&
1473 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1475 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1479 CONSOLE_ConInKey(Ir
);
1481 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1482 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1486 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1488 WarnLinuxPartitions
= FALSE
;
1489 return SELECT_PARTITION_PAGE
;
1494 if (IsUnattendedSetup
)
1496 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1500 PPARTENTRY PartEntry
= PartitionList
->CurrentPartition
;
1501 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1502 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1504 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1505 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1508 CreateNewPartition(PartitionList
,
1512 return SELECT_FILE_SYSTEM_PAGE
;
1517 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1519 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1520 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1523 return SELECT_FILE_SYSTEM_PAGE
;
1529 /* Update status text */
1530 if (PartitionList
->CurrentPartition
== NULL
||
1531 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1533 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1537 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1540 CONSOLE_ConInKey(Ir
);
1542 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1543 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1545 if (ConfirmQuit(Ir
) == TRUE
)
1547 DestroyPartitionList(PartitionList
);
1548 PartitionList
= NULL
;
1554 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1555 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1557 ScrollDownPartitionList(PartitionList
);
1559 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1560 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1562 ScrollUpPartitionList(PartitionList
);
1564 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1566 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1568 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1569 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1571 if (PartitionList
->CurrentPartition
== NULL
||
1572 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1574 CreateNewPartition(PartitionList
,
1579 return SELECT_FILE_SYSTEM_PAGE
;
1581 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1583 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1585 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1586 return SELECT_PARTITION_PAGE
;
1589 return CREATE_PARTITION_PAGE
;
1591 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1593 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1595 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1596 return SELECT_PARTITION_PAGE
;
1599 return DELETE_PARTITION_PAGE
;
1603 return SELECT_PARTITION_PAGE
;
1608 DrawInputField(ULONG FieldLength
,
1619 memset(buf
, '_', sizeof(buf
));
1620 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1621 strcat(buf
, FieldContent
);
1623 WriteConsoleOutputCharacterA(StdOutput
,
1631 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1632 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1633 #define PARTITION_MAXSIZE 999999
1636 ShowPartitionSizeInputBox(SHORT Left
,
1660 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1665 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1666 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1669 WriteConsoleOutputCharacterA(StdOutput
,
1675 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1676 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1678 WriteConsoleOutputCharacterA(StdOutput
,
1684 sprintf(Buffer
, "%lu", MaxSize
);
1685 Index
= strlen(Buffer
);
1686 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1693 CONSOLE_ConInKey(&Ir
);
1695 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1696 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1704 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1708 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1716 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1722 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1727 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1728 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1730 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1732 if ((ch
>= '0') && (ch
<= '9'))
1738 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1746 strcpy(InputBuffer
, Buffer
);
1751 CreatePartitionPage(PINPUT_RECORD Ir
)
1753 PDISKENTRY DiskEntry
;
1754 PPARTENTRY PartEntry
;
1757 CHAR InputBuffer
[50];
1763 if (PartitionList
== NULL
||
1764 PartitionList
->CurrentDisk
== NULL
||
1765 PartitionList
->CurrentPartition
== NULL
)
1767 /* FIXME: show an error dialog */
1771 DiskEntry
= PartitionList
->CurrentDisk
;
1772 PartEntry
= PartitionList
->CurrentPartition
;
1774 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1776 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1779 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1781 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1782 Unit
= MUIGetString(STRING_GB
);
1787 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1792 Unit
= MUIGetString(STRING_MB
);
1795 if (DiskEntry
->DriverName
.Length
> 0)
1797 CONSOLE_PrintTextXY(6, 10,
1798 MUIGetString(STRING_HDINFOPARTCREATE
),
1801 DiskEntry
->DiskNumber
,
1805 &DiskEntry
->DriverName
);
1809 CONSOLE_PrintTextXY(6, 10,
1810 MUIGetString(STRING_HDDINFOUNK1
),
1813 DiskEntry
->DiskNumber
,
1819 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1822 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1823 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1826 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1828 PartEntry
= PartitionList
->CurrentPartition
;
1831 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1833 if (MaxSize
> PARTITION_MAXSIZE
) MaxSize
= PARTITION_MAXSIZE
;
1835 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1836 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1840 if (ConfirmQuit (Ir
) == TRUE
)
1845 else if (Cancel
== TRUE
)
1847 return SELECT_PARTITION_PAGE
;
1851 PartSize
= atoi(InputBuffer
);
1859 if (PartSize
> MaxSize
)
1865 /* Convert to bytes */
1866 if (PartSize
== MaxSize
)
1868 /* Use all of the unpartitioned disk space */
1869 PartSize
= PartEntry
->UnpartitionedLength
;
1873 /* Round-up by cylinder size */
1874 PartSize
= (PartSize
* 1024 * 1024 + DiskEntry
->CylinderSize
- 1) /
1875 DiskEntry
->CylinderSize
* DiskEntry
->CylinderSize
;
1877 /* But never get larger than the unpartitioned disk space */
1878 if (PartSize
> PartEntry
->UnpartitionedLength
)
1879 PartSize
= PartEntry
->UnpartitionedLength
;
1882 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1884 CreateNewPartition(PartitionList
,
1888 return SELECT_PARTITION_PAGE
;
1892 return CREATE_PARTITION_PAGE
;
1897 DeletePartitionPage(PINPUT_RECORD Ir
)
1899 PDISKENTRY DiskEntry
;
1900 PPARTENTRY PartEntry
;
1907 if (PartitionList
== NULL
||
1908 PartitionList
->CurrentDisk
== NULL
||
1909 PartitionList
->CurrentPartition
== NULL
)
1911 /* FIXME: show an error dialog */
1915 DiskEntry
= PartitionList
->CurrentDisk
;
1916 PartEntry
= PartitionList
->CurrentPartition
;
1917 PartNumber
= PartitionList
->CurrentPartitionNumber
;
1919 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1921 /* Determine partition type */
1923 if (PartEntry
->New
== TRUE
)
1925 PartType
= MUIGetString(STRING_UNFORMATTED
);
1927 else if (PartEntry
->Unpartitioned
== FALSE
)
1929 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
1930 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
1931 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
1932 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
1936 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
1937 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
1941 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
1945 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
1947 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1952 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1954 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1955 Unit
= MUIGetString(STRING_GB
);
1959 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1961 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1962 Unit
= MUIGetString(STRING_MB
);
1966 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1967 Unit
= MUIGetString(STRING_KB
);
1970 if (PartType
== NULL
)
1972 CONSOLE_PrintTextXY(6, 10,
1973 MUIGetString(STRING_HDDINFOUNK2
),
1974 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1975 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1976 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
1982 CONSOLE_PrintTextXY(6, 10,
1983 " %c%c %s %I64u %s",
1984 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1985 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1992 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1994 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1995 Unit
= MUIGetString(STRING_GB
);
2000 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
2005 Unit
= MUIGetString(STRING_MB
);
2008 if (DiskEntry
->DriverName
.Length
> 0)
2010 CONSOLE_PrintTextXY(6, 12,
2011 MUIGetString(STRING_HDINFOPARTDELETE
),
2014 DiskEntry
->DiskNumber
,
2018 &DiskEntry
->DriverName
);
2022 CONSOLE_PrintTextXY(6, 12,
2023 MUIGetString(STRING_HDDINFOUNK3
),
2026 DiskEntry
->DiskNumber
,
2034 CONSOLE_ConInKey(Ir
);
2036 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2037 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2039 if (ConfirmQuit(Ir
) == TRUE
)
2046 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2048 return SELECT_PARTITION_PAGE
;
2050 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2052 DeleteCurrentPartition(PartitionList
);
2054 return SELECT_PARTITION_PAGE
;
2058 return DELETE_PARTITION_PAGE
;
2063 SelectFileSystemPage(PINPUT_RECORD Ir
)
2065 PDISKENTRY DiskEntry
;
2066 PPARTENTRY PartEntry
;
2074 if (PartitionList
== NULL
||
2075 PartitionList
->CurrentDisk
== NULL
||
2076 PartitionList
->CurrentPartition
== NULL
)
2078 /* FIXME: show an error dialog */
2082 DiskEntry
= PartitionList
->CurrentDisk
;
2083 PartEntry
= PartitionList
->CurrentPartition
;
2084 PartNumber
= PartitionList
->CurrentPartitionNumber
;
2086 /* adjust disk size */
2087 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
2089 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
2090 DiskUnit
= MUIGetString(STRING_GB
);
2094 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
2095 DiskUnit
= MUIGetString(STRING_MB
);
2098 /* adjust partition size */
2099 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
2101 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
2102 PartUnit
= MUIGetString(STRING_GB
);
2106 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
2107 PartUnit
= MUIGetString(STRING_MB
);
2110 /* adjust partition type */
2111 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
2112 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
2113 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
2114 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
2118 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
2119 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
2123 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
2127 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
2129 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2131 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_ENTRY_UNUSED
)
2133 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2137 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2140 if (PartEntry
->AutoCreate
== TRUE
)
2142 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2145 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2146 PartEntry
->PartInfo
[PartNumber
].PartitionNumber
,
2152 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2153 DiskEntry
->DiskNumber
,
2159 &DiskEntry
->DriverName
);
2161 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2164 PartEntry
->AutoCreate
= FALSE
;
2166 else if (PartEntry
->New
== TRUE
)
2168 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2169 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2173 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2175 if (PartType
== NULL
)
2177 CONSOLE_PrintTextXY(8, 10,
2178 MUIGetString(STRING_HDDINFOUNK4
),
2179 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2180 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2181 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
2187 CONSOLE_PrintTextXY(8, 10,
2189 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2190 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2196 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2197 DiskEntry
->DiskNumber
,
2203 &DiskEntry
->DriverName
);
2206 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2208 if (FileSystemList
== NULL
)
2210 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2211 if (FileSystemList
== NULL
)
2213 /* FIXME: show an error dialog */
2217 /* FIXME: Add file systems to list */
2219 DrawFileSystemList(FileSystemList
);
2221 if (RepairUpdateFlag
)
2223 return CHECK_FILE_SYSTEM_PAGE
;
2224 //return SELECT_PARTITION_PAGE;
2227 if (IsUnattendedSetup
)
2229 if (UnattendFormatPartition
)
2231 return FORMAT_PARTITION_PAGE
;
2234 return CHECK_FILE_SYSTEM_PAGE
;
2239 CONSOLE_ConInKey(Ir
);
2241 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2242 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2244 if (ConfirmQuit(Ir
) == TRUE
)
2251 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2252 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2254 return SELECT_PARTITION_PAGE
;
2256 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2257 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2259 ScrollDownFileSystemList(FileSystemList
);
2261 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2262 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2264 ScrollUpFileSystemList(FileSystemList
);
2266 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2268 if (!FileSystemList
->Selected
->FormatFunc
)
2270 return CHECK_FILE_SYSTEM_PAGE
;
2274 return FORMAT_PARTITION_PAGE
;
2279 return SELECT_FILE_SYSTEM_PAGE
;
2284 FormatPartitionPage(PINPUT_RECORD Ir
)
2286 WCHAR PathBuffer
[MAX_PATH
];
2287 PPARTENTRY PartEntry
;
2292 PDISKENTRY DiskEntry
;
2298 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2300 if (PartitionList
== NULL
||
2301 PartitionList
->CurrentDisk
== NULL
||
2302 PartitionList
->CurrentPartition
== NULL
)
2304 /* FIXME: show an error dialog */
2309 DiskEntry
= PartitionList
->CurrentDisk
;
2311 PartEntry
= PartitionList
->CurrentPartition
;
2312 PartNum
= PartitionList
->CurrentPartitionNumber
;
2316 if (!IsUnattendedSetup
)
2318 CONSOLE_ConInKey(Ir
);
2321 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2322 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2324 if (ConfirmQuit(Ir
) == TRUE
)
2331 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2333 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2335 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2337 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2339 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2340 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_12
;
2342 else if (PartEntry
->PartInfo
[PartNum
].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2344 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2346 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2348 /* FAT16 CHS partition (partiton size < 32MB) */
2349 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_16
;
2351 else if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2353 /* FAT16 CHS partition (partition size < 512MB) */
2354 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_HUGE
;
2358 /* FAT32 CHS partition (partition size >= 512MB) */
2359 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32
;
2364 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2366 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2368 /* FAT16 LBA partition (partition size < 512MB) */
2369 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_XINT13
;
2373 /* FAT32 LBA partition (partition size >= 512MB) */
2374 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32_XINT13
;
2378 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2379 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_EXT2
;
2380 else if (!FileSystemList
->Selected
->FormatFunc
)
2384 CONSOLE_PrintTextXY(6, 12,
2385 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2386 DiskEntry
->DiskSize
,
2387 DiskEntry
->CylinderSize
,
2388 DiskEntry
->TrackSize
);
2391 DiskEntry
= PartitionList
->CurrentDisk
;
2392 Entry
= DiskEntry
->PartListHead
.Flink
;
2394 while (Entry
!= &DiskEntry
->PartListHead
)
2396 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2398 if (PartEntry
->Unpartitioned
== FALSE
)
2400 for (i
= 0; i
< 4; i
++)
2402 CONSOLE_PrintTextXY(6, Line
,
2403 "%2u: %2u %c %12I64u %12I64u %2u %c",
2405 PartEntry
->PartInfo
[i
].PartitionNumber
,
2406 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2407 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2408 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2409 PartEntry
->PartInfo
[i
].PartitionType
,
2410 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2418 Entry
= Entry
->Flink
;
2421 /* Restore the old entry */
2422 PartEntry
= PartitionList
->CurrentPartition
;
2425 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2427 DPRINT("WritePartitionsToDisk() failed\n");
2428 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2432 /* Set DestinationRootPath */
2433 RtlFreeUnicodeString(&DestinationRootPath
);
2434 swprintf(PathBuffer
,
2435 L
"\\Device\\Harddisk%lu\\Partition%lu",
2436 PartitionList
->CurrentDisk
->DiskNumber
,
2437 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2438 RtlCreateUnicodeString(&DestinationRootPath
,
2440 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2442 if (FileSystemList
->Selected
->FormatFunc
)
2444 Status
= FormatPartition(&DestinationRootPath
,
2445 FileSystemList
->Selected
);
2446 if (!NT_SUCCESS(Status
))
2448 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2449 /* FIXME: show an error dialog */
2453 PartEntry
->New
= FALSE
;
2455 CheckActiveBootPartition(PartitionList
);
2459 CONSOLE_SetStatusText(" Done. Press any key ...");
2460 CONSOLE_ConInKey(Ir
);
2463 DestroyFileSystemList(FileSystemList
);
2464 FileSystemList
= NULL
;
2465 return INSTALL_DIRECTORY_PAGE
;
2469 return FORMAT_PARTITION_PAGE
;
2474 CheckFileSystemPage(PINPUT_RECORD Ir
)
2476 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2477 WCHAR PathBuffer
[MAX_PATH
];
2478 CHAR Buffer
[MAX_PATH
];
2480 UCHAR PartNum
= PartitionList
->CurrentPartitionNumber
;
2482 /* FIXME: code duplicated in FormatPartitionPage */
2483 /* Set DestinationRootPath */
2484 RtlFreeUnicodeString(&DestinationRootPath
);
2485 swprintf(PathBuffer
,
2486 L
"\\Device\\Harddisk%lu\\Partition%lu",
2487 PartitionList
->CurrentDisk
->DiskNumber
,
2488 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2489 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2490 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2492 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2494 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2496 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2497 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2499 if (!CurrentFileSystem
->ChkdskFunc
)
2502 "Setup is currently unable to check a partition formatted in %S.\n"
2504 " \x07 Press ENTER to continue Setup.\n"
2505 " \x07 Press F3 to quit Setup.",
2506 CurrentFileSystem
->FileSystem
);
2509 MUIGetString(STRING_QUITCONTINUE
),
2510 NULL
, POPUP_WAIT_NONE
);
2514 CONSOLE_ConInKey(Ir
);
2516 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2517 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2519 if (ConfirmQuit(Ir
))
2522 return CHECK_FILE_SYSTEM_PAGE
;
2524 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2526 return INSTALL_DIRECTORY_PAGE
;
2532 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2533 if (!NT_SUCCESS(Status
))
2535 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2536 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2537 "(Status 0x%08lx).\n", Status
);
2540 MUIGetString(STRING_REBOOTCOMPUTER
),
2541 Ir
, POPUP_WAIT_ENTER
);
2546 return INSTALL_DIRECTORY_PAGE
;
2552 InstallDirectoryPage1(PWCHAR InstallDir
,
2553 PDISKENTRY DiskEntry
,
2554 PPARTENTRY PartEntry
,
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
,
2638 PartitionList
->CurrentPartitionNumber
);
2643 CONSOLE_ConInKey(Ir
);
2645 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2646 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2648 if (ConfirmQuit(Ir
) == TRUE
)
2653 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2655 return InstallDirectoryPage1(InstallDir
,
2658 PartitionList
->CurrentPartitionNumber
);
2660 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2665 InstallDir
[Length
] = 0;
2666 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2669 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2673 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2675 InstallDir
[Length
] = 0;
2676 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2681 return INSTALL_DIRECTORY_PAGE
;
2686 AddSectionToCopyQueueCab(HINF InfFile
,
2688 PWCHAR SourceCabinet
,
2689 PCUNICODE_STRING DestinationPath
,
2692 INFCONTEXT FilesContext
;
2693 INFCONTEXT DirContext
;
2695 PWCHAR FileKeyValue
;
2697 PWCHAR TargetFileName
;
2699 /* Search for the SectionName section */
2700 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
2703 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2704 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2709 * Enumerate the files in the section
2710 * and add them to the file queue.
2714 /* Get source file name and target directory id */
2715 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
2717 /* FIXME: Handle error! */
2718 DPRINT1("INF_GetData() failed\n");
2722 /* Get optional target file name */
2723 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
2724 TargetFileName
= NULL
;
2726 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2728 /* Lookup target directory */
2729 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2731 /* FIXME: Handle error! */
2732 DPRINT1("SetupFindFirstLine() failed\n");
2736 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
2738 /* FIXME: Handle error! */
2739 DPRINT1("INF_GetData() failed\n");
2743 if (!SetupQueueCopy(SetupFileQueue
,
2745 SourceRootPath
.Buffer
,
2746 SourceRootDir
.Buffer
,
2751 /* FIXME: Handle error! */
2752 DPRINT1("SetupQueueCopy() failed\n");
2754 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2761 AddSectionToCopyQueue(HINF InfFile
,
2763 PWCHAR SourceCabinet
,
2764 PCUNICODE_STRING DestinationPath
,
2767 INFCONTEXT FilesContext
;
2768 INFCONTEXT DirContext
;
2770 PWCHAR FileKeyValue
;
2772 PWCHAR TargetFileName
;
2773 WCHAR CompleteOrigFileName
[512];
2776 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2778 /* Search for the SectionName section */
2779 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
2782 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2783 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2788 * Enumerate the files in the section
2789 * and add them to the file queue.
2793 /* Get source file name and target directory id */
2794 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
2796 /* FIXME: Handle error! */
2797 DPRINT1("INF_GetData() failed\n");
2801 /* Get target directory id */
2802 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
2804 /* FIXME: Handle error! */
2805 DPRINT1("INF_GetData() failed\n");
2809 /* Get optional target file name */
2810 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
2811 TargetFileName
= NULL
;
2812 else if (!*TargetFileName
)
2813 TargetFileName
= NULL
;
2815 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2817 /* Lookup target directory */
2818 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2820 /* FIXME: Handle error! */
2821 DPRINT1("SetupFindFirstLine() failed\n");
2825 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
2827 /* FIXME: Handle error! */
2828 DPRINT1("INF_GetData() failed\n");
2832 wcscpy(CompleteOrigFileName
, SourceRootDir
.Buffer
);
2833 wcscat(CompleteOrigFileName
, L
"\\");
2834 wcscat(CompleteOrigFileName
, DirKeyValue
);
2836 if (!SetupQueueCopy(SetupFileQueue
,
2838 SourceRootPath
.Buffer
,
2839 CompleteOrigFileName
,
2844 /* FIXME: Handle error! */
2845 DPRINT1("SetupQueueCopy() failed\n");
2847 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2854 PrepareCopyPageInfFile(HINF InfFile
,
2855 PWCHAR SourceCabinet
,
2858 WCHAR PathBuffer
[MAX_PATH
];
2859 INFCONTEXT DirContext
;
2860 PWCHAR AdditionalSectionName
= NULL
;
2865 /* Add common files */
2866 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2869 /* Add specific files depending of computer type */
2870 if (SourceCabinet
== NULL
)
2872 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2875 if (AdditionalSectionName
)
2877 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2882 /* Create directories */
2886 * Install directories like '\reactos\test' are not handled yet.
2889 /* Get destination path */
2890 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2892 /* Remove trailing backslash */
2893 Length
= wcslen(PathBuffer
);
2894 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2896 PathBuffer
[Length
- 1] = 0;
2899 /* Create the install directory */
2900 Status
= SetupCreateDirectory(PathBuffer
);
2901 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2903 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2904 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2908 /* Search for the 'Directories' section */
2909 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2913 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2917 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2923 /* Enumerate the directory values and create the subdirectories */
2926 if (!INF_GetData(&DirContext
, NULL
, &KeyValue
))
2932 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2934 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2936 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2937 wcscat(PathBuffer
, KeyValue
);
2939 DPRINT("FullPath: '%S'\n", PathBuffer
);
2941 else if (KeyValue
[0] != L
'\\')
2943 DPRINT("RelativePath: '%S'\n", KeyValue
);
2944 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2945 wcscat(PathBuffer
, L
"\\");
2946 wcscat(PathBuffer
, KeyValue
);
2948 DPRINT("FullPath: '%S'\n", PathBuffer
);
2950 Status
= SetupCreateDirectory(PathBuffer
);
2951 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2953 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2954 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2958 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2965 PrepareCopyPage(PINPUT_RECORD Ir
)
2968 WCHAR PathBuffer
[MAX_PATH
];
2969 INFCONTEXT CabinetsContext
;
2975 MUIDisplayPage(PREPARE_COPY_PAGE
);
2977 /* Create the file queue */
2978 SetupFileQueue
= SetupOpenFileQueue();
2979 if (SetupFileQueue
== NULL
)
2981 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2985 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2990 /* Search for the 'Cabinets' section */
2991 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2993 return FILE_COPY_PAGE
;
2997 * Enumerate the directory values in the 'Cabinets'
2998 * section and parse their inf files.
3002 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3005 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3006 wcscat(PathBuffer
, L
"\\");
3007 wcscat(PathBuffer
, KeyValue
);
3010 CabinetInitialize();
3011 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3012 CabinetSetCabinetName(PathBuffer
);
3014 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3016 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3018 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3019 if (InfFileData
== NULL
)
3021 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3027 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3028 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3032 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3039 if (InfHandle
== INVALID_HANDLE_VALUE
)
3041 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3047 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3052 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3054 return FILE_COPY_PAGE
;
3060 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3063 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3065 /* Get the memory information from the system */
3066 NtQuerySystemInformation(SystemPerformanceInformation
,
3071 /* Check if this is initial setup */
3074 /* Set maximum limits to be total RAM pages */
3075 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3076 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3077 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3080 /* Set current values */
3081 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3082 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3083 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3089 FileCopyCallback(PVOID Context
,
3094 PCOPYCONTEXT CopyContext
;
3096 CopyContext
= (PCOPYCONTEXT
)Context
;
3098 switch (Notification
)
3100 case SPFILENOTIFY_STARTSUBQUEUE
:
3101 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3102 ProgressSetStepCount(CopyContext
->ProgressBar
,
3103 CopyContext
->TotalOperations
);
3104 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3107 case SPFILENOTIFY_STARTCOPY
:
3108 /* Display copy message */
3109 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3110 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3113 case SPFILENOTIFY_ENDCOPY
:
3114 CopyContext
->CompletedOperations
++;
3115 ProgressNextStep(CopyContext
->ProgressBar
);
3116 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3126 FileCopyPage(PINPUT_RECORD Ir
)
3128 COPYCONTEXT CopyContext
;
3129 unsigned int mem_bar_width
;
3131 MUIDisplayPage(FILE_COPY_PAGE
);
3133 /* Create context for the copy process */
3134 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3135 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3136 CopyContext
.TotalOperations
= 0;
3137 CopyContext
.CompletedOperations
= 0;
3139 /* Create the progress bar as well */
3140 CopyContext
.ProgressBar
= CreateProgressBar(13,
3147 MUIGetString(STRING_SETUPCOPYINGFILES
));
3149 // fit memory bars to screen width, distribute them uniform
3150 mem_bar_width
= (xScreen
- 26) / 5;
3151 mem_bar_width
-= mem_bar_width
% 2; // make even
3152 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3153 /* Create the paged pool progress bar */
3154 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3163 /* Create the non paged pool progress bar */
3164 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3166 (xScreen
/ 2) + (mem_bar_width
/ 2),
3168 (xScreen
/ 2)- (mem_bar_width
/ 2),
3173 /* Create the global memory progress bar */
3174 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3178 xScreen
- 13 - mem_bar_width
,
3183 /* Do the file copying */
3184 SetupCommitFileQueueW(NULL
,
3189 /* If we get here, we're done, so cleanup the queue and progress bar */
3190 SetupCloseFileQueue(SetupFileQueue
);
3191 DestroyProgressBar(CopyContext
.ProgressBar
);
3192 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3193 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3194 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3196 /* Go display the next page */
3197 return REGISTRY_PAGE
;
3202 RegistryPage(PINPUT_RECORD Ir
)
3204 INFCONTEXT InfContext
;
3211 MUIDisplayPage(REGISTRY_PAGE
);
3213 if (RepairUpdateFlag
)
3215 return SUCCESS_PAGE
;
3218 if (!SetInstallPathValue(&DestinationPath
))
3220 DPRINT("SetInstallPathValue() failed\n");
3221 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3225 /* Create the default hives */
3227 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3228 if (!NT_SUCCESS(Status
))
3230 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3231 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3235 RegInitializeRegistry();
3238 /* Update registry */
3239 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3241 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3243 DPRINT1("SetupFindFirstLine() failed\n");
3244 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3250 INF_GetDataField (&InfContext
, 0, &Action
);
3251 INF_GetDataField (&InfContext
, 1, &File
);
3252 INF_GetDataField (&InfContext
, 2, &Section
);
3254 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3259 if (!_wcsicmp (Action
, L
"AddReg"))
3263 else if (!_wcsicmp (Action
, L
"DelReg"))
3272 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3274 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3276 DPRINT("Importing %S failed\n", File
);
3278 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3281 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3283 /* Update display registry settings */
3284 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3285 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3287 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3291 /* Set the locale */
3292 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3293 if (!ProcessLocaleRegistry(LanguageList
))
3295 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3299 /* Add keyboard layouts */
3300 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3301 if (!AddKeyboardLayouts())
3303 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3309 if (!SetGeoID(MUIGetGeoID()))
3311 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3315 if (!IsUnattendedSetup
)
3317 /* Update keyboard layout settings */
3318 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3319 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3321 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3326 /* Add codepage information to registry */
3327 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3330 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3334 /* Update the mounted devices list */
3335 SetMountedDeviceValues(PartitionList
);
3337 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3339 return BOOT_LOADER_PAGE
;
3344 BootLoaderPage(PINPUT_RECORD Ir
)
3346 UCHAR PartitionType
;
3347 BOOLEAN InstallOnFloppy
;
3349 WCHAR PathBuffer
[MAX_PATH
];
3351 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3353 CheckActiveBootPartition(PartitionList
);
3355 RtlFreeUnicodeString(&SystemRootPath
);
3356 swprintf(PathBuffer
,
3357 L
"\\Device\\Harddisk%lu\\Partition%lu",
3358 PartitionList
->ActiveBootDisk
->DiskNumber
,
3359 PartitionList
->ActiveBootPartition
->
3360 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionNumber
);
3361 RtlCreateUnicodeString(&SystemRootPath
,
3363 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3365 PartitionType
= PartitionList
->ActiveBootPartition
->
3366 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3368 if (IsUnattendedSetup
)
3370 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3372 return SUCCESS_PAGE
;
3374 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3376 return BOOT_LOADER_FLOPPY_PAGE
;
3380 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3382 DPRINT("Error: active partition invalid (unused)\n");
3383 InstallOnFloppy
= TRUE
;
3385 else if (PartitionType
== 0x0A)
3387 /* OS/2 boot manager partition */
3388 DPRINT("Found OS/2 boot manager partition\n");
3389 InstallOnFloppy
= TRUE
;
3391 else if (PartitionType
== 0x83)
3393 /* Linux ext2 partition */
3394 DPRINT("Found Linux ext2 partition\n");
3395 InstallOnFloppy
= TRUE
;
3397 else if (PartitionType
== PARTITION_IFS
)
3399 /* NTFS partition */
3400 DPRINT("Found NTFS partition\n");
3401 InstallOnFloppy
= TRUE
;
3403 else if ((PartitionType
== PARTITION_FAT_12
) ||
3404 (PartitionType
== PARTITION_FAT_16
) ||
3405 (PartitionType
== PARTITION_HUGE
) ||
3406 (PartitionType
== PARTITION_XINT13
) ||
3407 (PartitionType
== PARTITION_FAT32
) ||
3408 (PartitionType
== PARTITION_FAT32_XINT13
))
3410 DPRINT("Found FAT partition\n");
3411 InstallOnFloppy
= FALSE
;
3415 /* Unknown partition */
3416 DPRINT("Unknown partition found\n");
3417 InstallOnFloppy
= TRUE
;
3420 if (InstallOnFloppy
== TRUE
)
3422 return BOOT_LOADER_FLOPPY_PAGE
;
3425 /* Unattended install on hdd? */
3426 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3428 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3431 MUIDisplayPage(BOOT_LOADER_PAGE
);
3432 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3436 CONSOLE_ConInKey(Ir
);
3438 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3439 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3441 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3450 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3452 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3453 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3455 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3464 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3466 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3467 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3469 if (ConfirmQuit(Ir
) == TRUE
)
3474 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3478 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3480 else if (Line
== 13)
3482 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
3484 else if (Line
== 14)
3486 return BOOT_LOADER_FLOPPY_PAGE
;
3488 else if (Line
== 15)
3490 return SUCCESS_PAGE
;
3493 return BOOT_LOADER_PAGE
;
3497 return BOOT_LOADER_PAGE
;
3502 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3506 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3508 // SetStatusText(" Please wait...");
3512 CONSOLE_ConInKey(Ir
);
3514 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3515 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3517 if (ConfirmQuit(Ir
) == TRUE
)
3522 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3524 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3526 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3527 return BOOT_LOADER_FLOPPY_PAGE
;
3530 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3531 if (!NT_SUCCESS(Status
))
3533 /* Print error message */
3534 return BOOT_LOADER_FLOPPY_PAGE
;
3537 return SUCCESS_PAGE
;
3541 return BOOT_LOADER_FLOPPY_PAGE
;
3545 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
3547 UCHAR PartitionType
;
3550 PartitionType
= PartitionList
->ActiveBootPartition
->
3551 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3553 Status
= InstallVBRToPartition(&SystemRootPath
,
3555 &DestinationArcPath
,
3557 if (!NT_SUCCESS(Status
))
3559 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3563 return SUCCESS_PAGE
;
3567 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
3569 UCHAR PartitionType
;
3571 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
3572 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
3574 /* Step 1: Write the VBR */
3575 PartitionType
= PartitionList
->ActiveBootPartition
->
3576 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3578 Status
= InstallVBRToPartition(&SystemRootPath
,
3580 &DestinationArcPath
,
3582 if (!NT_SUCCESS(Status
))
3584 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3588 /* Step 2: Write the MBR */
3589 swprintf(DestinationDevicePathBuffer
,
3590 L
"\\Device\\Harddisk%d\\Partition0",
3591 PartitionList
->ActiveBootDisk
->DiskNumber
);
3593 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
3594 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
3596 DPRINT("Install MBR bootcode: %S ==> %S\n",
3597 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
3599 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
3600 DestinationDevicePathBuffer
);
3601 if (!NT_SUCCESS (Status
))
3603 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
3605 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3609 return SUCCESS_PAGE
;
3614 QuitPage(PINPUT_RECORD Ir
)
3616 MUIDisplayPage(QUIT_PAGE
);
3618 /* Destroy partition list */
3619 if (PartitionList
!= NULL
)
3621 DestroyPartitionList (PartitionList
);
3622 PartitionList
= NULL
;
3625 /* Destroy filesystem list */
3626 if (FileSystemList
!= NULL
)
3628 DestroyFileSystemList (FileSystemList
);
3629 FileSystemList
= NULL
;
3632 /* Destroy computer settings list */
3633 if (ComputerList
!= NULL
)
3635 DestroyGenericList(ComputerList
, TRUE
);
3636 ComputerList
= NULL
;
3639 /* Destroy display settings list */
3640 if (DisplayList
!= NULL
)
3642 DestroyGenericList(DisplayList
, TRUE
);
3646 /* Destroy keyboard settings list */
3647 if (KeyboardList
!= NULL
)
3649 DestroyGenericList(KeyboardList
, TRUE
);
3650 KeyboardList
= NULL
;
3653 /* Destroy keyboard layout list */
3654 if (LayoutList
!= NULL
)
3656 DestroyGenericList(LayoutList
, TRUE
);
3660 if (LanguageList
!= NULL
)
3662 DestroyGenericList(LanguageList
, FALSE
);
3663 LanguageList
= NULL
;
3666 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3670 CONSOLE_ConInKey(Ir
);
3672 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3681 SuccessPage(PINPUT_RECORD Ir
)
3683 MUIDisplayPage(SUCCESS_PAGE
);
3685 if (IsUnattendedSetup
)
3692 CONSOLE_ConInKey(Ir
);
3694 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3703 FlushPage(PINPUT_RECORD Ir
)
3705 MUIDisplayPage(FLUSH_PAGE
);
3711 PnpEventThread(IN LPVOID lpParameter
);
3721 NtQuerySystemTime(&Time
);
3723 Status
= RtlCreateUserThread(NtCurrentProcess(),
3733 if (!NT_SUCCESS(Status
))
3734 hPnpThread
= INVALID_HANDLE_VALUE
;
3736 if (!CONSOLE_Init())
3738 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3739 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3740 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3742 /* Raise a hard error (crash the system/BSOD) */
3743 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3747 /* Initialize global unicode strings */
3748 RtlInitUnicodeString(&SourcePath
, NULL
);
3749 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3750 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3751 RtlInitUnicodeString(&InstallPath
, NULL
);
3752 RtlInitUnicodeString(&DestinationPath
, NULL
);
3753 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3754 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3755 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3757 /* Hide the cursor */
3758 CONSOLE_SetCursorType(TRUE
, FALSE
);
3761 while (Page
!= REBOOT_PAGE
)
3763 CONSOLE_ClearScreen();
3766 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3773 Page
= SetupStartPage(&Ir
);
3778 Page
= LanguagePage(&Ir
);
3783 Page
= LicensePage(&Ir
);
3788 Page
= IntroPage(&Ir
);
3792 case INSTALL_INTRO_PAGE
:
3793 Page
= InstallIntroPage(&Ir
);
3797 case SCSI_CONTROLLER_PAGE
:
3798 Page
= ScsiControllerPage(&Ir
);
3803 case OEM_DRIVER_PAGE
:
3804 Page
= OemDriverPage(&Ir
);
3808 case DEVICE_SETTINGS_PAGE
:
3809 Page
= DeviceSettingsPage(&Ir
);
3812 case COMPUTER_SETTINGS_PAGE
:
3813 Page
= ComputerSettingsPage(&Ir
);
3816 case DISPLAY_SETTINGS_PAGE
:
3817 Page
= DisplaySettingsPage(&Ir
);
3820 case KEYBOARD_SETTINGS_PAGE
:
3821 Page
= KeyboardSettingsPage(&Ir
);
3824 case LAYOUT_SETTINGS_PAGE
:
3825 Page
= LayoutSettingsPage(&Ir
);
3828 case SELECT_PARTITION_PAGE
:
3829 Page
= SelectPartitionPage(&Ir
);
3832 case CREATE_PARTITION_PAGE
:
3833 Page
= CreatePartitionPage(&Ir
);
3836 case DELETE_PARTITION_PAGE
:
3837 Page
= DeletePartitionPage(&Ir
);
3840 case SELECT_FILE_SYSTEM_PAGE
:
3841 Page
= SelectFileSystemPage(&Ir
);
3844 case FORMAT_PARTITION_PAGE
:
3845 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3848 case CHECK_FILE_SYSTEM_PAGE
:
3849 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3852 case INSTALL_DIRECTORY_PAGE
:
3853 Page
= InstallDirectoryPage(&Ir
);
3856 case PREPARE_COPY_PAGE
:
3857 Page
= PrepareCopyPage(&Ir
);
3860 case FILE_COPY_PAGE
:
3861 Page
= FileCopyPage(&Ir
);
3865 Page
= RegistryPage(&Ir
);
3868 case BOOT_LOADER_PAGE
:
3869 Page
= BootLoaderPage(&Ir
);
3872 case BOOT_LOADER_FLOPPY_PAGE
:
3873 Page
= BootLoaderFloppyPage(&Ir
);
3876 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
3877 Page
= BootLoaderHarddiskMbrPage(&Ir
);
3880 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
3881 Page
= BootLoaderHarddiskVbrPage(&Ir
);
3885 case REPAIR_INTRO_PAGE
:
3886 Page
= RepairIntroPage(&Ir
);
3890 Page
= SuccessPage(&Ir
);
3894 Page
= FlushPage(&Ir
);
3898 Page
= QuitPage(&Ir
);
3908 /* Avoid bugcheck */
3909 Time
.QuadPart
+= 50000000;
3910 NtDelayExecution(FALSE
, &Time
);
3913 NtShutdownSystem(ShutdownReboot
);
3914 NtTerminateProcess(NtCurrentProcess(), 0);
3921 NtProcessStartup(PPEB Peb
)
3923 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3925 ProcessHeap
= Peb
->ProcessHeap
;
3926 InfSetHeap(ProcessHeap
);
3929 #endif /* __REACTOS__ */