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
);
763 /* Get the source path and source root path */
764 Status
= GetSourcePaths(&SourcePath
,
768 if (!NT_SUCCESS(Status
))
770 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
771 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
777 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
778 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
779 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
783 /* Load txtsetup.sif from install media. */
784 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
785 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
787 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
793 if (SetupInf
== INVALID_HANDLE_VALUE
)
795 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
799 /* Open 'Version' section */
800 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
802 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
806 /* Get pointer 'Signature' key */
807 if (!INF_GetData(&Context
, NULL
, &Value
))
809 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
813 /* Check 'Signature' string */
814 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
816 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
820 /* Open 'DiskSpaceRequirements' section */
821 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
823 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
827 /* Get the 'FreeSysPartDiskSpace' value */
828 if (!SetupGetIntField(&Context
, 1, &IntValue
))
830 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
834 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
836 /* Start PnP thread */
837 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
839 NtResumeThread(hPnpThread
, NULL
);
840 hPnpThread
= INVALID_HANDLE_VALUE
;
843 CheckUnattendedSetup();
845 if (IsUnattendedSetup
)
848 //read options from inf
849 ComputerList
= CreateComputerTypeList(SetupInf
);
850 DisplayList
= CreateDisplayDriverList(SetupInf
);
851 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
852 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
853 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
856 wcscpy(SelectedLanguageId
,LocaleID
);
858 /* first we hack LanguageList */
859 ListEntry
= GetFirstListEntry(LanguageList
);
861 while (ListEntry
!= NULL
)
863 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
865 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
866 SetCurrentListEntry(LanguageList
, ListEntry
);
870 ListEntry
= GetNextListEntry(ListEntry
);
874 ListEntry
= GetFirstListEntry(LayoutList
);
876 while (ListEntry
!= NULL
)
878 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
880 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
881 SetCurrentListEntry(LayoutList
, ListEntry
);
885 ListEntry
= GetNextListEntry(ListEntry
);
888 SetConsoleCodePage();
890 return INSTALL_INTRO_PAGE
;
893 return LANGUAGE_PAGE
;
903 IntroPage(PINPUT_RECORD Ir
)
905 MUIDisplayPage(START_PAGE
);
909 CONSOLE_ConInKey(Ir
);
911 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
912 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
914 if (ConfirmQuit(Ir
) == TRUE
)
919 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
921 return INSTALL_INTRO_PAGE
;
924 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
926 return REPAIR_INTRO_PAGE
;
929 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
943 * Back to main setup page.
946 LicensePage(PINPUT_RECORD Ir
)
948 MUIDisplayPage(LICENSE_PAGE
);
952 CONSOLE_ConInKey(Ir
);
954 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
966 RepairIntroPage(PINPUT_RECORD Ir
)
968 MUIDisplayPage(REPAIR_INTRO_PAGE
);
972 CONSOLE_ConInKey(Ir
);
974 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
978 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
980 RepairUpdateFlag
= TRUE
;
981 return INSTALL_INTRO_PAGE
;
983 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
987 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
988 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
994 return REPAIR_INTRO_PAGE
;
999 InstallIntroPage(PINPUT_RECORD Ir
)
1001 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1003 if (RepairUpdateFlag
)
1005 //return SELECT_PARTITION_PAGE;
1006 return DEVICE_SETTINGS_PAGE
;
1009 if (IsUnattendedSetup
)
1011 return SELECT_PARTITION_PAGE
;
1016 CONSOLE_ConInKey(Ir
);
1018 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1019 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1021 if (ConfirmQuit(Ir
) == TRUE
)
1026 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1028 return DEVICE_SETTINGS_PAGE
;
1029 // return SCSI_CONTROLLER_PAGE;
1033 return INSTALL_INTRO_PAGE
;
1039 ScsiControllerPage(PINPUT_RECORD Ir
)
1041 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1043 /* FIXME: print loaded mass storage driver descriptions */
1045 SetTextXY(8, 10, "TEST device");
1049 SetStatusText(" ENTER = Continue F3 = Quit");
1055 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1056 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1058 if (ConfirmQuit(Ir
) == TRUE
)
1063 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1065 return DEVICE_SETTINGS_PAGE
;
1069 return SCSI_CONTROLLER_PAGE
;
1075 DeviceSettingsPage(PINPUT_RECORD Ir
)
1077 static ULONG Line
= 16;
1078 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1080 /* Initialize the computer settings list */
1081 if (ComputerList
== NULL
)
1083 ComputerList
= CreateComputerTypeList(SetupInf
);
1084 if (ComputerList
== NULL
)
1086 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1091 /* Initialize the display settings list */
1092 if (DisplayList
== NULL
)
1094 DisplayList
= CreateDisplayDriverList(SetupInf
);
1095 if (DisplayList
== NULL
)
1097 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1102 /* Initialize the keyboard settings list */
1103 if (KeyboardList
== NULL
)
1105 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1106 if (KeyboardList
== NULL
)
1108 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1113 /* Initialize the keyboard layout list */
1114 if (LayoutList
== NULL
)
1116 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1117 if (LayoutList
== NULL
)
1119 /* FIXME: report error */
1120 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1125 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1128 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1129 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1130 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1131 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1133 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1135 if (RepairUpdateFlag
)
1137 return SELECT_PARTITION_PAGE
;
1142 CONSOLE_ConInKey(Ir
);
1144 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1145 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1147 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1151 else if (Line
== 16)
1156 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1158 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1159 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1161 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1165 else if (Line
== 16)
1170 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1172 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1173 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1175 if (ConfirmQuit(Ir
) == TRUE
)
1180 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1183 return COMPUTER_SETTINGS_PAGE
;
1184 else if (Line
== 12)
1185 return DISPLAY_SETTINGS_PAGE
;
1186 else if (Line
== 13)
1187 return KEYBOARD_SETTINGS_PAGE
;
1188 else if (Line
== 14)
1189 return LAYOUT_SETTINGS_PAGE
;
1190 else if (Line
== 16)
1191 return SELECT_PARTITION_PAGE
;
1195 return DEVICE_SETTINGS_PAGE
;
1200 ComputerSettingsPage(PINPUT_RECORD Ir
)
1202 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1204 DrawGenericList(ComputerList
,
1210 SaveGenericListState(ComputerList
);
1214 CONSOLE_ConInKey(Ir
);
1216 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1217 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1219 ScrollDownGenericList(ComputerList
);
1221 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1222 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1224 ScrollUpGenericList(ComputerList
);
1226 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1227 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1229 if (ConfirmQuit(Ir
) == TRUE
)
1234 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1235 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1237 RestoreGenericListState(ComputerList
);
1238 return DEVICE_SETTINGS_PAGE
;
1240 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1242 return DEVICE_SETTINGS_PAGE
;
1246 return COMPUTER_SETTINGS_PAGE
;
1251 DisplaySettingsPage(PINPUT_RECORD Ir
)
1253 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1255 DrawGenericList(DisplayList
,
1261 SaveGenericListState(DisplayList
);
1265 CONSOLE_ConInKey(Ir
);
1267 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1268 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1270 ScrollDownGenericList(DisplayList
);
1272 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1273 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1275 ScrollUpGenericList(DisplayList
);
1277 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1278 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1280 if (ConfirmQuit(Ir
) == TRUE
)
1287 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1288 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1290 RestoreGenericListState(DisplayList
);
1291 return DEVICE_SETTINGS_PAGE
;
1293 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1295 return DEVICE_SETTINGS_PAGE
;
1299 return DISPLAY_SETTINGS_PAGE
;
1304 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1306 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1308 DrawGenericList(KeyboardList
,
1314 SaveGenericListState(KeyboardList
);
1318 CONSOLE_ConInKey(Ir
);
1320 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1321 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1323 ScrollDownGenericList(KeyboardList
);
1325 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1326 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1328 ScrollUpGenericList(KeyboardList
);
1330 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1331 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1333 if (ConfirmQuit(Ir
) == TRUE
)
1338 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1339 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1341 RestoreGenericListState(KeyboardList
);
1342 return DEVICE_SETTINGS_PAGE
;
1344 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1346 return DEVICE_SETTINGS_PAGE
;
1350 return DISPLAY_SETTINGS_PAGE
;
1355 LayoutSettingsPage(PINPUT_RECORD Ir
)
1357 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1359 DrawGenericList(LayoutList
,
1365 SaveGenericListState(LayoutList
);
1369 CONSOLE_ConInKey(Ir
);
1371 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1372 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1374 ScrollDownGenericList(LayoutList
);
1376 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1377 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1379 ScrollUpGenericList(LayoutList
);
1381 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1382 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1384 ScrollPageDownGenericList(LayoutList
);
1386 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1387 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1389 ScrollPageUpGenericList(LayoutList
);
1391 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1392 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1394 if (ConfirmQuit(Ir
) == TRUE
)
1399 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1400 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1402 RestoreGenericListState(LayoutList
);
1403 return DEVICE_SETTINGS_PAGE
;
1405 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1407 return DEVICE_SETTINGS_PAGE
;
1409 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1412 GenericListKeyPress(LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1416 return DISPLAY_SETTINGS_PAGE
;
1421 IsDiskSizeValid(PPARTENTRY PartEntry
)
1425 /* check for unpartitioned space */
1426 m1
= PartEntry
->UnpartitionedLength
;
1427 m1
= (m1
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1429 if( m1
> RequiredPartitionDiskSpace
)
1434 /* check for partitioned space */
1435 m2
= PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
;
1436 m2
= (m2
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1437 if (m2
< RequiredPartitionDiskSpace
)
1439 /* partition is too small so ask for another partion */
1440 DPRINT1("Partition is too small(unpartitioned: %I64u MB, partitioned: %I64u MB), required disk space is %lu MB\n", m1
, m2
, RequiredPartitionDiskSpace
);
1451 SelectPartitionPage(PINPUT_RECORD Ir
)
1453 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1455 if (PartitionList
== NULL
)
1457 PartitionList
= CreatePartitionList(2,
1461 if (PartitionList
== NULL
)
1463 /* FIXME: show an error dialog */
1468 DrawPartitionList(PartitionList
);
1470 /* Warn about partitions created by Linux Fdisk */
1471 if (WarnLinuxPartitions
== TRUE
&&
1472 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1474 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1478 CONSOLE_ConInKey(Ir
);
1480 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1481 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1485 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1487 WarnLinuxPartitions
= FALSE
;
1488 return SELECT_PARTITION_PAGE
;
1493 if (IsUnattendedSetup
)
1495 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1499 PPARTENTRY PartEntry
= PartitionList
->CurrentPartition
;
1500 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1501 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1503 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1504 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1507 CreateNewPartition(PartitionList
,
1511 return SELECT_FILE_SYSTEM_PAGE
;
1516 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1518 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1519 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1522 return SELECT_FILE_SYSTEM_PAGE
;
1528 /* Update status text */
1529 if (PartitionList
->CurrentPartition
== NULL
||
1530 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1532 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1536 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1539 CONSOLE_ConInKey(Ir
);
1541 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1542 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1544 if (ConfirmQuit(Ir
) == TRUE
)
1546 DestroyPartitionList(PartitionList
);
1547 PartitionList
= NULL
;
1553 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1554 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1556 ScrollDownPartitionList(PartitionList
);
1558 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1559 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1561 ScrollUpPartitionList(PartitionList
);
1563 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1565 if(!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1567 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1568 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1570 if (PartitionList
->CurrentPartition
== NULL
||
1571 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1573 CreateNewPartition(PartitionList
,
1578 return SELECT_FILE_SYSTEM_PAGE
;
1580 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1582 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1584 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1585 return SELECT_PARTITION_PAGE
;
1588 return CREATE_PARTITION_PAGE
;
1590 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1592 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1594 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1595 return SELECT_PARTITION_PAGE
;
1598 return DELETE_PARTITION_PAGE
;
1602 return SELECT_PARTITION_PAGE
;
1607 DrawInputField(ULONG FieldLength
,
1618 memset(buf
, '_', sizeof(buf
));
1619 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1620 strcat(buf
, FieldContent
);
1622 WriteConsoleOutputCharacterA(StdOutput
,
1630 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1631 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1632 #define PARTITION_MAXSIZE 999999
1635 ShowPartitionSizeInputBox(SHORT Left
,
1659 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1664 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1665 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1668 WriteConsoleOutputCharacterA(StdOutput
,
1674 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1675 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1677 WriteConsoleOutputCharacterA(StdOutput
,
1683 sprintf(Buffer
, "%lu", MaxSize
);
1684 Index
= strlen(Buffer
);
1685 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1692 CONSOLE_ConInKey(&Ir
);
1694 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1695 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1703 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1707 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1715 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1721 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1726 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1727 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1729 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1731 if ((ch
>= '0') && (ch
<= '9'))
1737 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1745 strcpy(InputBuffer
, Buffer
);
1750 CreatePartitionPage(PINPUT_RECORD Ir
)
1752 PDISKENTRY DiskEntry
;
1753 PPARTENTRY PartEntry
;
1756 CHAR InputBuffer
[50];
1762 if (PartitionList
== NULL
||
1763 PartitionList
->CurrentDisk
== NULL
||
1764 PartitionList
->CurrentPartition
== NULL
)
1766 /* FIXME: show an error dialog */
1770 DiskEntry
= PartitionList
->CurrentDisk
;
1771 PartEntry
= PartitionList
->CurrentPartition
;
1773 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1775 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1778 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1780 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1781 Unit
= MUIGetString(STRING_GB
);
1786 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1791 Unit
= MUIGetString(STRING_MB
);
1794 if (DiskEntry
->DriverName
.Length
> 0)
1796 CONSOLE_PrintTextXY(6, 10,
1797 MUIGetString(STRING_HDINFOPARTCREATE
),
1800 DiskEntry
->DiskNumber
,
1804 &DiskEntry
->DriverName
);
1808 CONSOLE_PrintTextXY(6, 10,
1809 MUIGetString(STRING_HDDINFOUNK1
),
1812 DiskEntry
->DiskNumber
,
1818 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1821 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1822 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1825 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1827 PartEntry
= PartitionList
->CurrentPartition
;
1830 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1832 if (MaxSize
> PARTITION_MAXSIZE
) MaxSize
= PARTITION_MAXSIZE
;
1834 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1835 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1839 if (ConfirmQuit (Ir
) == TRUE
)
1844 else if (Cancel
== TRUE
)
1846 return SELECT_PARTITION_PAGE
;
1850 PartSize
= atoi(InputBuffer
);
1858 if (PartSize
> MaxSize
)
1864 /* Convert to bytes */
1865 if (PartSize
== MaxSize
)
1867 /* Use all of the unpartitioned disk space */
1868 PartSize
= PartEntry
->UnpartitionedLength
;
1872 /* Round-up by cylinder size */
1873 PartSize
= (PartSize
* 1024 * 1024 + DiskEntry
->CylinderSize
- 1) /
1874 DiskEntry
->CylinderSize
* DiskEntry
->CylinderSize
;
1876 /* But never get larger than the unpartitioned disk space */
1877 if (PartSize
> PartEntry
->UnpartitionedLength
)
1878 PartSize
= PartEntry
->UnpartitionedLength
;
1881 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1883 CreateNewPartition(PartitionList
,
1887 return SELECT_PARTITION_PAGE
;
1891 return CREATE_PARTITION_PAGE
;
1896 DeletePartitionPage(PINPUT_RECORD Ir
)
1898 PDISKENTRY DiskEntry
;
1899 PPARTENTRY PartEntry
;
1906 if (PartitionList
== NULL
||
1907 PartitionList
->CurrentDisk
== NULL
||
1908 PartitionList
->CurrentPartition
== NULL
)
1910 /* FIXME: show an error dialog */
1914 DiskEntry
= PartitionList
->CurrentDisk
;
1915 PartEntry
= PartitionList
->CurrentPartition
;
1916 PartNumber
= PartitionList
->CurrentPartitionNumber
;
1918 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1920 /* Determine partition type */
1922 if (PartEntry
->New
== TRUE
)
1924 PartType
= MUIGetString(STRING_UNFORMATTED
);
1926 else if (PartEntry
->Unpartitioned
== FALSE
)
1928 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
1929 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
1930 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
1931 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
1935 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
1936 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
1940 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
1944 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
1946 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1951 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1953 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1954 Unit
= MUIGetString(STRING_GB
);
1958 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1960 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1961 Unit
= MUIGetString(STRING_MB
);
1965 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1966 Unit
= MUIGetString(STRING_KB
);
1969 if (PartType
== NULL
)
1971 CONSOLE_PrintTextXY(6, 10,
1972 MUIGetString(STRING_HDDINFOUNK2
),
1973 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1974 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1975 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
1981 CONSOLE_PrintTextXY(6, 10,
1982 " %c%c %s %I64u %s",
1983 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
1984 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
1991 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1993 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1994 Unit
= MUIGetString(STRING_GB
);
1999 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
2004 Unit
= MUIGetString(STRING_MB
);
2007 if (DiskEntry
->DriverName
.Length
> 0)
2009 CONSOLE_PrintTextXY(6, 12,
2010 MUIGetString(STRING_HDINFOPARTDELETE
),
2013 DiskEntry
->DiskNumber
,
2017 &DiskEntry
->DriverName
);
2021 CONSOLE_PrintTextXY(6, 12,
2022 MUIGetString(STRING_HDDINFOUNK3
),
2025 DiskEntry
->DiskNumber
,
2033 CONSOLE_ConInKey(Ir
);
2035 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2036 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2038 if (ConfirmQuit(Ir
) == TRUE
)
2045 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2047 return SELECT_PARTITION_PAGE
;
2049 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2051 DeleteCurrentPartition(PartitionList
);
2053 return SELECT_PARTITION_PAGE
;
2057 return DELETE_PARTITION_PAGE
;
2062 SelectFileSystemPage(PINPUT_RECORD Ir
)
2064 PDISKENTRY DiskEntry
;
2065 PPARTENTRY PartEntry
;
2073 if (PartitionList
== NULL
||
2074 PartitionList
->CurrentDisk
== NULL
||
2075 PartitionList
->CurrentPartition
== NULL
)
2077 /* FIXME: show an error dialog */
2081 DiskEntry
= PartitionList
->CurrentDisk
;
2082 PartEntry
= PartitionList
->CurrentPartition
;
2083 PartNumber
= PartitionList
->CurrentPartitionNumber
;
2085 /* adjust disk size */
2086 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
2088 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
2089 DiskUnit
= MUIGetString(STRING_GB
);
2093 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
2094 DiskUnit
= MUIGetString(STRING_MB
);
2097 /* adjust partition size */
2098 if (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
2100 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
2101 PartUnit
= MUIGetString(STRING_GB
);
2105 PartSize
= (PartEntry
->PartInfo
[PartNumber
].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
2106 PartUnit
= MUIGetString(STRING_MB
);
2109 /* adjust partition type */
2110 if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_12
) ||
2111 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT_16
) ||
2112 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_HUGE
) ||
2113 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_XINT13
))
2117 else if ((PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32
) ||
2118 (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_FAT32_XINT13
))
2122 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_EXT2
)
2126 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_IFS
)
2128 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2130 else if (PartEntry
->PartInfo
[PartNumber
].PartitionType
== PARTITION_ENTRY_UNUSED
)
2132 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2136 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2139 if (PartEntry
->AutoCreate
== TRUE
)
2141 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2144 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2145 PartEntry
->PartInfo
[PartNumber
].PartitionNumber
,
2151 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2152 DiskEntry
->DiskNumber
,
2158 &DiskEntry
->DriverName
);
2160 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2163 PartEntry
->AutoCreate
= FALSE
;
2165 else if (PartEntry
->New
== TRUE
)
2167 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2168 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2172 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2174 if (PartType
== NULL
)
2176 CONSOLE_PrintTextXY(8, 10,
2177 MUIGetString(STRING_HDDINFOUNK4
),
2178 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2179 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2180 PartEntry
->PartInfo
[PartNumber
].PartitionType
,
2186 CONSOLE_PrintTextXY(8, 10,
2188 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : PartEntry
->DriveLetter
[PartNumber
],
2189 (PartEntry
->DriveLetter
[PartNumber
] == 0) ? '-' : ':',
2195 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2196 DiskEntry
->DiskNumber
,
2202 &DiskEntry
->DriverName
);
2205 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2207 if (FileSystemList
== NULL
)
2209 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2210 if (FileSystemList
== NULL
)
2212 /* FIXME: show an error dialog */
2216 /* FIXME: Add file systems to list */
2218 DrawFileSystemList(FileSystemList
);
2220 if (RepairUpdateFlag
)
2222 return CHECK_FILE_SYSTEM_PAGE
;
2223 //return SELECT_PARTITION_PAGE;
2226 if (IsUnattendedSetup
)
2228 if (UnattendFormatPartition
)
2230 return FORMAT_PARTITION_PAGE
;
2233 return CHECK_FILE_SYSTEM_PAGE
;
2238 CONSOLE_ConInKey(Ir
);
2240 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2241 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2243 if (ConfirmQuit(Ir
) == TRUE
)
2250 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2251 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2253 return SELECT_PARTITION_PAGE
;
2255 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2256 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2258 ScrollDownFileSystemList(FileSystemList
);
2260 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2261 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2263 ScrollUpFileSystemList(FileSystemList
);
2265 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2267 if (!FileSystemList
->Selected
->FormatFunc
)
2269 return CHECK_FILE_SYSTEM_PAGE
;
2273 return FORMAT_PARTITION_PAGE
;
2278 return SELECT_FILE_SYSTEM_PAGE
;
2283 FormatPartitionPage(PINPUT_RECORD Ir
)
2285 WCHAR PathBuffer
[MAX_PATH
];
2286 PPARTENTRY PartEntry
;
2291 PDISKENTRY DiskEntry
;
2297 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2299 if (PartitionList
== NULL
||
2300 PartitionList
->CurrentDisk
== NULL
||
2301 PartitionList
->CurrentPartition
== NULL
)
2303 /* FIXME: show an error dialog */
2308 DiskEntry
= PartitionList
->CurrentDisk
;
2310 PartEntry
= PartitionList
->CurrentPartition
;
2311 PartNum
= PartitionList
->CurrentPartitionNumber
;
2315 if (!IsUnattendedSetup
)
2317 CONSOLE_ConInKey(Ir
);
2320 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2321 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2323 if (ConfirmQuit(Ir
) == TRUE
)
2330 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2332 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2334 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2336 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2338 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2339 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_12
;
2341 else if (PartEntry
->PartInfo
[PartNum
].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2343 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2345 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2347 /* FAT16 CHS partition (partiton size < 32MB) */
2348 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT_16
;
2350 else if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2352 /* FAT16 CHS partition (partition size < 512MB) */
2353 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_HUGE
;
2357 /* FAT32 CHS partition (partition size >= 512MB) */
2358 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32
;
2363 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2365 if (PartEntry
->PartInfo
[PartNum
].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2367 /* FAT16 LBA partition (partition size < 512MB) */
2368 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_XINT13
;
2372 /* FAT32 LBA partition (partition size >= 512MB) */
2373 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_FAT32_XINT13
;
2377 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2378 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_EXT2
;
2379 else if (!FileSystemList
->Selected
->FormatFunc
)
2383 CONSOLE_PrintTextXY(6, 12,
2384 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2385 DiskEntry
->DiskSize
,
2386 DiskEntry
->CylinderSize
,
2387 DiskEntry
->TrackSize
);
2390 DiskEntry
= PartitionList
->CurrentDisk
;
2391 Entry
= DiskEntry
->PartListHead
.Flink
;
2393 while (Entry
!= &DiskEntry
->PartListHead
)
2395 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2397 if (PartEntry
->Unpartitioned
== FALSE
)
2399 for (i
= 0; i
< 4; i
++)
2401 CONSOLE_PrintTextXY(6, Line
,
2402 "%2u: %2u %c %12I64u %12I64u %2u %c",
2404 PartEntry
->PartInfo
[i
].PartitionNumber
,
2405 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2406 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2407 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2408 PartEntry
->PartInfo
[i
].PartitionType
,
2409 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2417 Entry
= Entry
->Flink
;
2420 /* Restore the old entry */
2421 PartEntry
= PartitionList
->CurrentPartition
;
2424 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2426 DPRINT("WritePartitionsToDisk() failed\n");
2427 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2431 /* Set DestinationRootPath */
2432 RtlFreeUnicodeString(&DestinationRootPath
);
2433 swprintf(PathBuffer
,
2434 L
"\\Device\\Harddisk%lu\\Partition%lu",
2435 PartitionList
->CurrentDisk
->DiskNumber
,
2436 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2437 RtlCreateUnicodeString(&DestinationRootPath
,
2439 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2441 if (FileSystemList
->Selected
->FormatFunc
)
2443 Status
= FormatPartition(&DestinationRootPath
,
2444 FileSystemList
->Selected
);
2445 if (!NT_SUCCESS(Status
))
2447 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2448 /* FIXME: show an error dialog */
2452 PartEntry
->New
= FALSE
;
2454 CheckActiveBootPartition(PartitionList
);
2458 CONSOLE_SetStatusText(" Done. Press any key ...");
2459 CONSOLE_ConInKey(Ir
);
2462 DestroyFileSystemList(FileSystemList
);
2463 FileSystemList
= NULL
;
2464 return INSTALL_DIRECTORY_PAGE
;
2468 return FORMAT_PARTITION_PAGE
;
2473 CheckFileSystemPage(PINPUT_RECORD Ir
)
2475 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2476 WCHAR PathBuffer
[MAX_PATH
];
2477 CHAR Buffer
[MAX_PATH
];
2479 UCHAR PartNum
= PartitionList
->CurrentPartitionNumber
;
2481 /* FIXME: code duplicated in FormatPartitionPage */
2482 /* Set DestinationRootPath */
2483 RtlFreeUnicodeString(&DestinationRootPath
);
2484 swprintf(PathBuffer
,
2485 L
"\\Device\\Harddisk%lu\\Partition%lu",
2486 PartitionList
->CurrentDisk
->DiskNumber
,
2487 PartitionList
->CurrentPartition
->PartInfo
[PartNum
].PartitionNumber
);
2488 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2489 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2491 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2493 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2495 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2496 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2498 if (!CurrentFileSystem
->ChkdskFunc
)
2501 "Setup is currently unable to check a partition formatted in %S.\n"
2503 " \x07 Press ENTER to continue Setup.\n"
2504 " \x07 Press F3 to quit Setup.",
2505 CurrentFileSystem
->FileSystem
);
2508 MUIGetString(STRING_QUITCONTINUE
),
2509 NULL
, POPUP_WAIT_NONE
);
2513 CONSOLE_ConInKey(Ir
);
2515 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2516 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2518 if (ConfirmQuit(Ir
))
2521 return CHECK_FILE_SYSTEM_PAGE
;
2523 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2525 return INSTALL_DIRECTORY_PAGE
;
2531 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2532 if (!NT_SUCCESS(Status
))
2534 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2535 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2536 "(Status 0x%08lx).\n", Status
);
2539 MUIGetString(STRING_REBOOTCOMPUTER
),
2540 Ir
, POPUP_WAIT_ENTER
);
2545 return INSTALL_DIRECTORY_PAGE
;
2551 InstallDirectoryPage1(PWCHAR InstallDir
,
2552 PDISKENTRY DiskEntry
,
2553 PPARTENTRY PartEntry
,
2556 WCHAR PathBuffer
[MAX_PATH
];
2558 /* Create 'InstallPath' string */
2559 RtlFreeUnicodeString(&InstallPath
);
2560 RtlCreateUnicodeString(&InstallPath
,
2563 /* Create 'DestinationPath' string */
2564 RtlFreeUnicodeString(&DestinationPath
);
2565 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2567 if (InstallDir
[0] != L
'\\')
2568 wcscat(PathBuffer
, L
"\\");
2570 wcscat(PathBuffer
, InstallDir
);
2571 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2573 /* Create 'DestinationArcPath' */
2574 RtlFreeUnicodeString(&DestinationArcPath
);
2575 swprintf(PathBuffer
,
2576 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2577 DiskEntry
->BiosDiskNumber
,
2578 PartEntry
->PartInfo
[PartNum
].PartitionNumber
);
2580 if (InstallDir
[0] != L
'\\')
2581 wcscat(PathBuffer
, L
"\\");
2583 wcscat(PathBuffer
, InstallDir
);
2584 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2586 return PREPARE_COPY_PAGE
;
2591 InstallDirectoryPage(PINPUT_RECORD Ir
)
2593 PDISKENTRY DiskEntry
;
2594 PPARTENTRY PartEntry
;
2595 WCHAR InstallDir
[51];
2600 if (PartitionList
== NULL
||
2601 PartitionList
->CurrentDisk
== NULL
||
2602 PartitionList
->CurrentPartition
== NULL
)
2604 /* FIXME: show an error dialog */
2608 DiskEntry
= PartitionList
->CurrentDisk
;
2609 PartEntry
= PartitionList
->CurrentPartition
;
2611 /* Search for 'DefaultPath' in the 'SetupData' section */
2612 if (!SetupFindFirstLineW(SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2614 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2618 /* Read the 'DefaultPath' data */
2619 if (INF_GetData(&Context
, NULL
, &DefaultPath
))
2621 wcscpy(InstallDir
, DefaultPath
);
2625 wcscpy(InstallDir
, L
"\\ReactOS");
2628 Length
= wcslen(InstallDir
);
2629 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2630 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2632 if (IsUnattendedSetup
)
2634 return InstallDirectoryPage1(InstallDir
,
2637 PartitionList
->CurrentPartitionNumber
);
2642 CONSOLE_ConInKey(Ir
);
2644 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2645 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2647 if (ConfirmQuit(Ir
) == TRUE
)
2652 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2654 return InstallDirectoryPage1(InstallDir
,
2657 PartitionList
->CurrentPartitionNumber
);
2659 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2664 InstallDir
[Length
] = 0;
2665 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2668 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2672 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2674 InstallDir
[Length
] = 0;
2675 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2680 return INSTALL_DIRECTORY_PAGE
;
2685 AddSectionToCopyQueueCab(HINF InfFile
,
2687 PWCHAR SourceCabinet
,
2688 PCUNICODE_STRING DestinationPath
,
2691 INFCONTEXT FilesContext
;
2692 INFCONTEXT DirContext
;
2694 PWCHAR FileKeyValue
;
2696 PWCHAR TargetFileName
;
2698 /* Search for the SectionName section */
2699 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
2702 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2703 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2708 * Enumerate the files in the section
2709 * and add them to the file queue.
2713 /* Get source file name and target directory id */
2714 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
2716 /* FIXME: Handle error! */
2717 DPRINT1("INF_GetData() failed\n");
2721 /* Get optional target file name */
2722 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
2723 TargetFileName
= NULL
;
2725 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2727 /* Lookup target directory */
2728 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2730 /* FIXME: Handle error! */
2731 DPRINT1("SetupFindFirstLine() failed\n");
2735 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
2737 /* FIXME: Handle error! */
2738 DPRINT1("INF_GetData() failed\n");
2742 if (!SetupQueueCopy(SetupFileQueue
,
2744 SourceRootPath
.Buffer
,
2745 SourceRootDir
.Buffer
,
2750 /* FIXME: Handle error! */
2751 DPRINT1("SetupQueueCopy() failed\n");
2753 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2760 AddSectionToCopyQueue(HINF InfFile
,
2762 PWCHAR SourceCabinet
,
2763 PCUNICODE_STRING DestinationPath
,
2766 INFCONTEXT FilesContext
;
2767 INFCONTEXT DirContext
;
2769 PWCHAR FileKeyValue
;
2771 PWCHAR TargetFileName
;
2772 WCHAR CompleteOrigFileName
[512];
2775 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2777 /* Search for the SectionName section */
2778 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
2781 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2782 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2787 * Enumerate the files in the section
2788 * and add them to the file queue.
2792 /* Get source file name and target directory id */
2793 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
2795 /* FIXME: Handle error! */
2796 DPRINT1("INF_GetData() failed\n");
2800 /* Get target directory id */
2801 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
2803 /* FIXME: Handle error! */
2804 DPRINT1("INF_GetData() failed\n");
2808 /* Get optional target file name */
2809 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
2810 TargetFileName
= NULL
;
2811 else if (!*TargetFileName
)
2812 TargetFileName
= NULL
;
2814 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2816 /* Lookup target directory */
2817 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2819 /* FIXME: Handle error! */
2820 DPRINT1("SetupFindFirstLine() failed\n");
2824 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
2826 /* FIXME: Handle error! */
2827 DPRINT1("INF_GetData() failed\n");
2831 wcscpy(CompleteOrigFileName
, SourceRootDir
.Buffer
);
2832 wcscat(CompleteOrigFileName
, L
"\\");
2833 wcscat(CompleteOrigFileName
, DirKeyValue
);
2835 if (!SetupQueueCopy(SetupFileQueue
,
2837 SourceRootPath
.Buffer
,
2838 CompleteOrigFileName
,
2843 /* FIXME: Handle error! */
2844 DPRINT1("SetupQueueCopy() failed\n");
2846 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2853 PrepareCopyPageInfFile(HINF InfFile
,
2854 PWCHAR SourceCabinet
,
2857 WCHAR PathBuffer
[MAX_PATH
];
2858 INFCONTEXT DirContext
;
2859 PWCHAR AdditionalSectionName
= NULL
;
2864 /* Add common files */
2865 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2868 /* Add specific files depending of computer type */
2869 if (SourceCabinet
== NULL
)
2871 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2874 if (AdditionalSectionName
)
2876 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2881 /* Create directories */
2885 * Install directories like '\reactos\test' are not handled yet.
2888 /* Get destination path */
2889 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2891 /* Remove trailing backslash */
2892 Length
= wcslen(PathBuffer
);
2893 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2895 PathBuffer
[Length
- 1] = 0;
2898 /* Create the install directory */
2899 Status
= SetupCreateDirectory(PathBuffer
);
2900 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2902 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2903 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2907 /* Search for the 'Directories' section */
2908 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2912 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2916 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2922 /* Enumerate the directory values and create the subdirectories */
2925 if (!INF_GetData(&DirContext
, NULL
, &KeyValue
))
2931 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2933 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2935 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2936 wcscat(PathBuffer
, KeyValue
);
2938 DPRINT("FullPath: '%S'\n", PathBuffer
);
2940 else if (KeyValue
[0] != L
'\\')
2942 DPRINT("RelativePath: '%S'\n", KeyValue
);
2943 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2944 wcscat(PathBuffer
, L
"\\");
2945 wcscat(PathBuffer
, KeyValue
);
2947 DPRINT("FullPath: '%S'\n", PathBuffer
);
2949 Status
= SetupCreateDirectory(PathBuffer
);
2950 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2952 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2953 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2957 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2964 PrepareCopyPage(PINPUT_RECORD Ir
)
2967 WCHAR PathBuffer
[MAX_PATH
];
2968 INFCONTEXT CabinetsContext
;
2974 MUIDisplayPage(PREPARE_COPY_PAGE
);
2976 /* Create the file queue */
2977 SetupFileQueue
= SetupOpenFileQueue();
2978 if (SetupFileQueue
== NULL
)
2980 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2984 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2989 /* Search for the 'Cabinets' section */
2990 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2992 return FILE_COPY_PAGE
;
2996 * Enumerate the directory values in the 'Cabinets'
2997 * section and parse their inf files.
3001 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3004 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3005 wcscat(PathBuffer
, L
"\\");
3006 wcscat(PathBuffer
, KeyValue
);
3009 CabinetInitialize();
3010 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3011 CabinetSetCabinetName(PathBuffer
);
3013 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3015 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3017 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3018 if (InfFileData
== NULL
)
3020 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3026 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3027 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3031 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3038 if (InfHandle
== INVALID_HANDLE_VALUE
)
3040 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3046 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3051 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3053 return FILE_COPY_PAGE
;
3059 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3062 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3064 /* Get the memory information from the system */
3065 NtQuerySystemInformation(SystemPerformanceInformation
,
3070 /* Check if this is initial setup */
3073 /* Set maximum limits to be total RAM pages */
3074 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3075 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3076 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3079 /* Set current values */
3080 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3081 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3082 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3088 FileCopyCallback(PVOID Context
,
3093 PCOPYCONTEXT CopyContext
;
3095 CopyContext
= (PCOPYCONTEXT
)Context
;
3097 switch (Notification
)
3099 case SPFILENOTIFY_STARTSUBQUEUE
:
3100 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3101 ProgressSetStepCount(CopyContext
->ProgressBar
,
3102 CopyContext
->TotalOperations
);
3103 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3106 case SPFILENOTIFY_STARTCOPY
:
3107 /* Display copy message */
3108 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3109 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3112 case SPFILENOTIFY_ENDCOPY
:
3113 CopyContext
->CompletedOperations
++;
3114 ProgressNextStep(CopyContext
->ProgressBar
);
3115 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3125 FileCopyPage(PINPUT_RECORD Ir
)
3127 COPYCONTEXT CopyContext
;
3128 unsigned int mem_bar_width
;
3130 MUIDisplayPage(FILE_COPY_PAGE
);
3132 /* Create context for the copy process */
3133 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3134 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3135 CopyContext
.TotalOperations
= 0;
3136 CopyContext
.CompletedOperations
= 0;
3138 /* Create the progress bar as well */
3139 CopyContext
.ProgressBar
= CreateProgressBar(13,
3146 MUIGetString(STRING_SETUPCOPYINGFILES
));
3148 // fit memory bars to screen width, distribute them uniform
3149 mem_bar_width
= (xScreen
- 26) / 5;
3150 mem_bar_width
-= mem_bar_width
% 2; // make even
3151 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3152 /* Create the paged pool progress bar */
3153 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3162 /* Create the non paged pool progress bar */
3163 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3165 (xScreen
/ 2) + (mem_bar_width
/ 2),
3167 (xScreen
/ 2)- (mem_bar_width
/ 2),
3172 /* Create the global memory progress bar */
3173 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3177 xScreen
- 13 - mem_bar_width
,
3182 /* Do the file copying */
3183 SetupCommitFileQueueW(NULL
,
3188 /* If we get here, we're done, so cleanup the queue and progress bar */
3189 SetupCloseFileQueue(SetupFileQueue
);
3190 DestroyProgressBar(CopyContext
.ProgressBar
);
3191 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3192 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3193 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3195 /* Go display the next page */
3196 return REGISTRY_PAGE
;
3201 RegistryPage(PINPUT_RECORD Ir
)
3203 INFCONTEXT InfContext
;
3210 MUIDisplayPage(REGISTRY_PAGE
);
3212 if (RepairUpdateFlag
)
3214 return SUCCESS_PAGE
;
3217 if (!SetInstallPathValue(&DestinationPath
))
3219 DPRINT("SetInstallPathValue() failed\n");
3220 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3224 /* Create the default hives */
3226 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3227 if (!NT_SUCCESS(Status
))
3229 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3230 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3234 RegInitializeRegistry();
3237 /* Update registry */
3238 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3240 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3242 DPRINT1("SetupFindFirstLine() failed\n");
3243 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3249 INF_GetDataField (&InfContext
, 0, &Action
);
3250 INF_GetDataField (&InfContext
, 1, &File
);
3251 INF_GetDataField (&InfContext
, 2, &Section
);
3253 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3258 if (!_wcsicmp (Action
, L
"AddReg"))
3262 else if (!_wcsicmp (Action
, L
"DelReg"))
3271 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3273 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3275 DPRINT("Importing %S failed\n", File
);
3277 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3280 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3282 /* Update display registry settings */
3283 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3284 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3286 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3290 /* Set the locale */
3291 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3292 if (!ProcessLocaleRegistry(LanguageList
))
3294 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3298 /* Add keyboard layouts */
3299 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3300 if (!AddKeyboardLayouts())
3302 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3308 if (!SetGeoID(MUIGetGeoID()))
3310 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3314 if (!IsUnattendedSetup
)
3316 /* Update keyboard layout settings */
3317 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3318 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3320 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3325 /* Add codepage information to registry */
3326 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3329 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3333 /* Update the mounted devices list */
3334 SetMountedDeviceValues(PartitionList
);
3336 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3338 return BOOT_LOADER_PAGE
;
3343 BootLoaderPage(PINPUT_RECORD Ir
)
3345 UCHAR PartitionType
;
3346 BOOLEAN InstallOnFloppy
;
3348 WCHAR PathBuffer
[MAX_PATH
];
3350 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3352 CheckActiveBootPartition(PartitionList
);
3354 RtlFreeUnicodeString(&SystemRootPath
);
3355 swprintf(PathBuffer
,
3356 L
"\\Device\\Harddisk%lu\\Partition%lu",
3357 PartitionList
->ActiveBootDisk
->DiskNumber
,
3358 PartitionList
->ActiveBootPartition
->
3359 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionNumber
);
3360 RtlCreateUnicodeString(&SystemRootPath
,
3362 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3364 PartitionType
= PartitionList
->ActiveBootPartition
->
3365 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3367 if (IsUnattendedSetup
)
3369 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3371 return SUCCESS_PAGE
;
3373 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3375 return BOOT_LOADER_FLOPPY_PAGE
;
3379 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3381 DPRINT("Error: active partition invalid (unused)\n");
3382 InstallOnFloppy
= TRUE
;
3384 else if (PartitionType
== 0x0A)
3386 /* OS/2 boot manager partition */
3387 DPRINT("Found OS/2 boot manager partition\n");
3388 InstallOnFloppy
= TRUE
;
3390 else if (PartitionType
== 0x83)
3392 /* Linux ext2 partition */
3393 DPRINT("Found Linux ext2 partition\n");
3394 InstallOnFloppy
= TRUE
;
3396 else if (PartitionType
== PARTITION_IFS
)
3398 /* NTFS partition */
3399 DPRINT("Found NTFS partition\n");
3400 InstallOnFloppy
= TRUE
;
3402 else if ((PartitionType
== PARTITION_FAT_12
) ||
3403 (PartitionType
== PARTITION_FAT_16
) ||
3404 (PartitionType
== PARTITION_HUGE
) ||
3405 (PartitionType
== PARTITION_XINT13
) ||
3406 (PartitionType
== PARTITION_FAT32
) ||
3407 (PartitionType
== PARTITION_FAT32_XINT13
))
3409 DPRINT("Found FAT partition\n");
3410 InstallOnFloppy
= FALSE
;
3414 /* Unknown partition */
3415 DPRINT("Unknown partition found\n");
3416 InstallOnFloppy
= TRUE
;
3419 if (InstallOnFloppy
== TRUE
)
3421 return BOOT_LOADER_FLOPPY_PAGE
;
3424 /* Unattended install on hdd? */
3425 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3427 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3430 MUIDisplayPage(BOOT_LOADER_PAGE
);
3431 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3435 CONSOLE_ConInKey(Ir
);
3437 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3438 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3440 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3449 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3451 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3452 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3454 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3463 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3465 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3466 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3468 if (ConfirmQuit(Ir
) == TRUE
)
3473 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3477 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3479 else if (Line
== 13)
3481 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
3483 else if (Line
== 14)
3485 return BOOT_LOADER_FLOPPY_PAGE
;
3487 else if (Line
== 15)
3489 return SUCCESS_PAGE
;
3492 return BOOT_LOADER_PAGE
;
3496 return BOOT_LOADER_PAGE
;
3501 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3505 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3507 // SetStatusText(" Please wait...");
3511 CONSOLE_ConInKey(Ir
);
3513 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3514 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3516 if (ConfirmQuit(Ir
) == TRUE
)
3521 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3523 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3525 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3526 return BOOT_LOADER_FLOPPY_PAGE
;
3529 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3530 if (!NT_SUCCESS(Status
))
3532 /* Print error message */
3533 return BOOT_LOADER_FLOPPY_PAGE
;
3536 return SUCCESS_PAGE
;
3540 return BOOT_LOADER_FLOPPY_PAGE
;
3544 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
3546 UCHAR PartitionType
;
3549 PartitionType
= PartitionList
->ActiveBootPartition
->
3550 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3552 Status
= InstallVBRToPartition(&SystemRootPath
,
3554 &DestinationArcPath
,
3556 if (!NT_SUCCESS(Status
))
3558 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3562 return SUCCESS_PAGE
;
3566 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
3568 UCHAR PartitionType
;
3570 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
3571 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
3573 /* Step 1: Write the VBR */
3574 PartitionType
= PartitionList
->ActiveBootPartition
->
3575 PartInfo
[PartitionList
->ActiveBootPartitionNumber
].PartitionType
;
3577 Status
= InstallVBRToPartition(&SystemRootPath
,
3579 &DestinationArcPath
,
3581 if (!NT_SUCCESS(Status
))
3583 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3587 /* Step 2: Write the MBR */
3588 swprintf(DestinationDevicePathBuffer
,
3589 L
"\\Device\\Harddisk%d\\Partition0",
3590 PartitionList
->ActiveBootDisk
->DiskNumber
);
3592 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
3593 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
3595 DPRINT("Install MBR bootcode: %S ==> %S\n",
3596 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
3598 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
3599 DestinationDevicePathBuffer
);
3600 if (!NT_SUCCESS (Status
))
3602 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
3604 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3608 return SUCCESS_PAGE
;
3613 QuitPage(PINPUT_RECORD Ir
)
3615 MUIDisplayPage(QUIT_PAGE
);
3617 /* Destroy partition list */
3618 if (PartitionList
!= NULL
)
3620 DestroyPartitionList (PartitionList
);
3621 PartitionList
= NULL
;
3624 /* Destroy filesystem list */
3625 if (FileSystemList
!= NULL
)
3627 DestroyFileSystemList (FileSystemList
);
3628 FileSystemList
= NULL
;
3631 /* Destroy computer settings list */
3632 if (ComputerList
!= NULL
)
3634 DestroyGenericList(ComputerList
, TRUE
);
3635 ComputerList
= NULL
;
3638 /* Destroy display settings list */
3639 if (DisplayList
!= NULL
)
3641 DestroyGenericList(DisplayList
, TRUE
);
3645 /* Destroy keyboard settings list */
3646 if (KeyboardList
!= NULL
)
3648 DestroyGenericList(KeyboardList
, TRUE
);
3649 KeyboardList
= NULL
;
3652 /* Destroy keyboard layout list */
3653 if (LayoutList
!= NULL
)
3655 DestroyGenericList(LayoutList
, TRUE
);
3659 if (LanguageList
!= NULL
)
3661 DestroyGenericList(LanguageList
, FALSE
);
3662 LanguageList
= NULL
;
3665 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3669 CONSOLE_ConInKey(Ir
);
3671 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3680 SuccessPage(PINPUT_RECORD Ir
)
3682 MUIDisplayPage(SUCCESS_PAGE
);
3684 if (IsUnattendedSetup
)
3691 CONSOLE_ConInKey(Ir
);
3693 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3702 FlushPage(PINPUT_RECORD Ir
)
3704 MUIDisplayPage(FLUSH_PAGE
);
3710 PnpEventThread(IN LPVOID lpParameter
);
3720 NtQuerySystemTime(&Time
);
3722 Status
= RtlCreateUserThread(NtCurrentProcess(),
3732 if (!NT_SUCCESS(Status
))
3733 hPnpThread
= INVALID_HANDLE_VALUE
;
3735 if (!CONSOLE_Init())
3737 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3738 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3739 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3741 /* Raise a hard error (crash the system/BSOD) */
3742 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3746 /* Initialize global unicode strings */
3747 RtlInitUnicodeString(&SourcePath
, NULL
);
3748 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3749 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3750 RtlInitUnicodeString(&InstallPath
, NULL
);
3751 RtlInitUnicodeString(&DestinationPath
, NULL
);
3752 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3753 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3754 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3756 /* Hide the cursor */
3757 CONSOLE_SetCursorType(TRUE
, FALSE
);
3760 while (Page
!= REBOOT_PAGE
)
3762 CONSOLE_ClearScreen();
3765 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3772 Page
= SetupStartPage(&Ir
);
3777 Page
= LanguagePage(&Ir
);
3782 Page
= LicensePage(&Ir
);
3787 Page
= IntroPage(&Ir
);
3791 case INSTALL_INTRO_PAGE
:
3792 Page
= InstallIntroPage(&Ir
);
3796 case SCSI_CONTROLLER_PAGE
:
3797 Page
= ScsiControllerPage(&Ir
);
3802 case OEM_DRIVER_PAGE
:
3803 Page
= OemDriverPage(&Ir
);
3807 case DEVICE_SETTINGS_PAGE
:
3808 Page
= DeviceSettingsPage(&Ir
);
3811 case COMPUTER_SETTINGS_PAGE
:
3812 Page
= ComputerSettingsPage(&Ir
);
3815 case DISPLAY_SETTINGS_PAGE
:
3816 Page
= DisplaySettingsPage(&Ir
);
3819 case KEYBOARD_SETTINGS_PAGE
:
3820 Page
= KeyboardSettingsPage(&Ir
);
3823 case LAYOUT_SETTINGS_PAGE
:
3824 Page
= LayoutSettingsPage(&Ir
);
3827 case SELECT_PARTITION_PAGE
:
3828 Page
= SelectPartitionPage(&Ir
);
3831 case CREATE_PARTITION_PAGE
:
3832 Page
= CreatePartitionPage(&Ir
);
3835 case DELETE_PARTITION_PAGE
:
3836 Page
= DeletePartitionPage(&Ir
);
3839 case SELECT_FILE_SYSTEM_PAGE
:
3840 Page
= SelectFileSystemPage(&Ir
);
3843 case FORMAT_PARTITION_PAGE
:
3844 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3847 case CHECK_FILE_SYSTEM_PAGE
:
3848 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3851 case INSTALL_DIRECTORY_PAGE
:
3852 Page
= InstallDirectoryPage(&Ir
);
3855 case PREPARE_COPY_PAGE
:
3856 Page
= PrepareCopyPage(&Ir
);
3859 case FILE_COPY_PAGE
:
3860 Page
= FileCopyPage(&Ir
);
3864 Page
= RegistryPage(&Ir
);
3867 case BOOT_LOADER_PAGE
:
3868 Page
= BootLoaderPage(&Ir
);
3871 case BOOT_LOADER_FLOPPY_PAGE
:
3872 Page
= BootLoaderFloppyPage(&Ir
);
3875 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
3876 Page
= BootLoaderHarddiskMbrPage(&Ir
);
3879 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
3880 Page
= BootLoaderHarddiskVbrPage(&Ir
);
3884 case REPAIR_INTRO_PAGE
:
3885 Page
= RepairIntroPage(&Ir
);
3889 Page
= SuccessPage(&Ir
);
3893 Page
= FlushPage(&Ir
);
3897 Page
= QuitPage(&Ir
);
3907 /* Avoid bugcheck */
3908 Time
.QuadPart
+= 50000000;
3909 NtDelayExecution(FALSE
, &Time
);
3912 NtShutdownSystem(ShutdownReboot
);
3913 NtTerminateProcess(NtCurrentProcess(), 0);
3920 NtProcessStartup(PPEB Peb
)
3922 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3924 ProcessHeap
= Peb
->ProcessHeap
;
3925 InfSetHeap(ProcessHeap
);
3928 #endif /* __REACTOS__ */