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)
42 /* GLOBALS ******************************************************************/
45 UNICODE_STRING SourceRootPath
;
46 UNICODE_STRING SourceRootDir
;
47 UNICODE_STRING SourcePath
;
48 BOOLEAN IsUnattendedSetup
= FALSE
;
49 LONG UnattendDestinationDiskNumber
;
50 LONG UnattendDestinationPartitionNumber
;
51 LONG UnattendMBRInstallType
= -1;
52 LONG UnattendFormatPartition
= 0;
53 LONG AutoPartition
= 0;
54 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
55 PWCHAR SelectedLanguageId
;
57 WCHAR DefaultLanguage
[20];
58 WCHAR DefaultKBLayout
[20];
59 BOOLEAN RepairUpdateFlag
= FALSE
;
60 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
61 PPARTLIST PartitionList
= NULL
;
63 /* LOCALS *******************************************************************/
65 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
67 static UNICODE_STRING InstallPath
;
69 /* Path to the install directory */
70 static UNICODE_STRING DestinationPath
;
71 static UNICODE_STRING DestinationArcPath
;
72 static UNICODE_STRING DestinationRootPath
;
74 static WCHAR DestinationDriveLetter
;
76 /* Path to the active partition (boot manager) */
77 static UNICODE_STRING SystemRootPath
;
81 static HSPFILEQ SetupFileQueue
= NULL
;
83 static BOOLEAN WarnLinuxPartitions
= TRUE
;
85 static PGENERIC_LIST ComputerList
= NULL
;
86 static PGENERIC_LIST DisplayList
= NULL
;
87 static PGENERIC_LIST KeyboardList
= NULL
;
88 static PGENERIC_LIST LayoutList
= NULL
;
89 static PGENERIC_LIST LanguageList
= NULL
;
91 static LANGID LanguageId
= 0;
93 static ULONG RequiredPartitionDiskSpace
= ~0;
95 /* FUNCTIONS ****************************************************************/
98 PrintString(char* fmt
,...)
102 UNICODE_STRING UnicodeString
;
103 ANSI_STRING AnsiString
;
106 vsprintf(buffer
, fmt
, ap
);
109 RtlInitAnsiString(&AnsiString
, buffer
);
110 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
111 NtDisplayString(&UnicodeString
);
112 RtlFreeUnicodeString(&UnicodeString
);
117 DrawBox(IN SHORT xLeft
,
125 /* draw upper left corner */
128 FillConsoleOutputCharacterA(StdOutput
,
134 /* draw upper edge */
137 FillConsoleOutputCharacterA(StdOutput
,
143 /* draw upper right corner */
144 coPos
.X
= xLeft
+ Width
- 1;
146 FillConsoleOutputCharacterA(StdOutput
,
152 /* Draw right edge, inner space and left edge */
153 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
156 FillConsoleOutputCharacterA(StdOutput
,
163 FillConsoleOutputCharacterA(StdOutput
,
169 coPos
.X
= xLeft
+ Width
- 1;
170 FillConsoleOutputCharacterA(StdOutput
,
177 /* draw lower left corner */
179 coPos
.Y
= yTop
+ Height
- 1;
180 FillConsoleOutputCharacterA(StdOutput
,
186 /* draw lower edge */
188 coPos
.Y
= yTop
+ Height
- 1;
189 FillConsoleOutputCharacterA(StdOutput
,
195 /* draw lower right corner */
196 coPos
.X
= xLeft
+ Width
- 1;
197 coPos
.Y
= yTop
+ Height
- 1;
198 FillConsoleOutputCharacterA(StdOutput
,
207 PopupError(PCCH Text
,
225 /* Count text lines and longest line */
232 p
= strchr(pnext
, '\n');
236 Length
= strlen(pnext
);
241 Length
= (ULONG
)(p
- pnext
);
247 if (Length
> MaxLength
)
250 if (LastLine
== TRUE
)
256 /* Check length of status line */
259 Length
= strlen(Status
);
261 if (Length
> MaxLength
)
265 Width
= MaxLength
+ 4;
271 yTop
= (yScreen
- Height
) / 2;
272 xLeft
= (xScreen
- Width
) / 2;
275 /* Set screen attributes */
277 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
279 FillConsoleOutputAttribute(StdOutput
,
280 FOREGROUND_RED
| BACKGROUND_WHITE
,
286 DrawBox(xLeft
, yTop
, Width
, Height
);
288 /* Print message text */
293 p
= strchr(pnext
, '\n');
297 Length
= strlen(pnext
);
302 Length
= (ULONG
)(p
- pnext
);
309 WriteConsoleOutputCharacterA(StdOutput
,
316 if (LastLine
== TRUE
)
323 /* Print separator line and status text */
326 coPos
.Y
= yTop
+ Height
- 3;
328 FillConsoleOutputCharacterA(StdOutput
,
335 FillConsoleOutputCharacterA(StdOutput
,
341 coPos
.X
= xLeft
+ Width
- 1;
342 FillConsoleOutputCharacterA(StdOutput
,
350 WriteConsoleOutputCharacterA(StdOutput
,
352 min(strlen(Status
), (SIZE_T
)Width
- 4),
357 if (WaitEvent
== POPUP_WAIT_NONE
)
362 CONSOLE_ConInKey(Ir
);
364 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
365 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
377 * FALSE: Don't quit setup.
380 ConfirmQuit(PINPUT_RECORD Ir
)
383 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
387 CONSOLE_ConInKey(Ir
);
389 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
390 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
395 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
407 CheckUnattendedSetup(VOID
)
409 WCHAR UnattendInfPath
[MAX_PATH
];
416 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
418 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
422 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
423 wcscat(UnattendInfPath
, L
"\\unattend.inf");
425 /* Load 'unattend.inf' from install media. */
426 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
432 if (UnattendInf
== INVALID_HANDLE_VALUE
)
434 DPRINT("SetupOpenInfFileW() failed\n");
438 /* Open 'Unattend' section */
439 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
441 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
442 SetupCloseInfFile(UnattendInf
);
446 /* Get pointer 'Signature' key */
447 if (!INF_GetData(&Context
, NULL
, &Value
))
449 DPRINT("INF_GetData() failed for key 'Signature'\n");
450 SetupCloseInfFile(UnattendInf
);
454 /* Check 'Signature' string */
455 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
457 DPRINT("Signature not $ReactOS$\n");
458 SetupCloseInfFile(UnattendInf
);
462 /* Check if Unattend setup is enabled */
463 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
465 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
466 SetupCloseInfFile(UnattendInf
);
470 if (!INF_GetData(&Context
, NULL
, &Value
))
472 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
473 SetupCloseInfFile(UnattendInf
);
477 if (_wcsicmp(Value
, L
"yes") != 0)
479 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
480 SetupCloseInfFile(UnattendInf
);
484 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
485 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
487 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
488 SetupCloseInfFile(UnattendInf
);
492 if (!SetupGetIntField(&Context
, 1, &IntValue
))
494 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
495 SetupCloseInfFile(UnattendInf
);
499 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
501 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
502 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
504 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
505 SetupCloseInfFile(UnattendInf
);
509 if (!SetupGetIntField(&Context
, 1, &IntValue
))
511 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
512 SetupCloseInfFile(UnattendInf
);
516 UnattendDestinationPartitionNumber
= IntValue
;
518 /* Search for 'InstallationDirectory' in the 'Unattend' section */
519 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"InstallationDirectory", &Context
))
521 DPRINT("SetupFindFirstLine() failed for key 'InstallationDirectory'\n");
522 SetupCloseInfFile(UnattendInf
);
526 /* Get pointer 'InstallationDirectory' key */
527 if (!INF_GetData(&Context
, NULL
, &Value
))
529 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
530 SetupCloseInfFile(UnattendInf
);
534 wcscpy(UnattendInstallationDirectory
, Value
);
536 IsUnattendedSetup
= TRUE
;
538 /* Search for 'MBRInstallType' in the 'Unattend' section */
539 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
541 if (SetupGetIntField(&Context
, 1, &IntValue
))
543 UnattendMBRInstallType
= IntValue
;
547 /* Search for 'FormatPartition' in the 'Unattend' section */
548 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
550 if (SetupGetIntField(&Context
, 1, &IntValue
))
552 UnattendFormatPartition
= IntValue
;
556 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
558 if (SetupGetIntField(&Context
, 1, &IntValue
))
560 AutoPartition
= IntValue
;
564 /* search for LocaleID in the 'Unattend' section*/
565 if (SetupFindFirstLineW (UnattendInf
, L
"Unattend", L
"LocaleID", &Context
))
567 if (INF_GetData (&Context
, NULL
, &Value
))
569 LONG Id
= wcstol(Value
, NULL
, 16);
570 swprintf(LocaleID
,L
"%08lx", Id
);
574 SetupCloseInfFile(UnattendInf
);
576 DPRINT("Running unattended setup\n");
583 PGENERIC_LIST_ENTRY ListEntry
;
584 LPCWSTR pszNewLayout
;
586 pszNewLayout
= MUIDefaultKeyboardLayout();
588 if (LayoutList
== NULL
)
590 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
591 if (LayoutList
== NULL
)
593 /* FIXME: Handle error! */
598 ListEntry
= GetFirstListEntry(LayoutList
);
600 /* Search for default layout (if provided) */
601 if (pszNewLayout
!= NULL
)
603 while (ListEntry
!= NULL
)
605 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
607 SetCurrentListEntry(LayoutList
, ListEntry
);
611 ListEntry
= GetNextListEntry(ListEntry
);
618 LanguagePage(PINPUT_RECORD Ir
)
620 PWCHAR NewLanguageId
;
621 BOOL RefreshPage
= FALSE
;
623 /* Initialize the computer settings list */
624 if (LanguageList
== NULL
)
626 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
628 if (LanguageList
== NULL
)
630 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
636 SelectedLanguageId
= DefaultLanguage
;
637 SetConsoleCodePage();
639 DrawGenericList(LanguageList
,
645 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
647 MUIDisplayPage(LANGUAGE_PAGE
);
651 CONSOLE_ConInKey(Ir
);
653 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
654 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
656 ScrollDownGenericList (LanguageList
);
659 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
660 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
662 ScrollUpGenericList(LanguageList
);
665 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
666 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
668 ScrollPageDownGenericList(LanguageList
);
671 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
672 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
674 ScrollPageUpGenericList(LanguageList
);
677 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
678 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
680 if (ConfirmQuit(Ir
) == TRUE
)
683 RedrawGenericList(LanguageList
);
685 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
687 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
689 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
691 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
697 SetConsoleCodePage();
701 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
704 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
710 NewLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
712 if (SelectedLanguageId
!= NewLanguageId
)
714 /* Clear the language page */
715 MUIClearPage(LANGUAGE_PAGE
);
717 SelectedLanguageId
= NewLanguageId
;
720 SetConsoleCodePage();
722 /* Redraw language selection page in native language */
723 MUIDisplayPage(LANGUAGE_PAGE
);
737 * Number of the next page.
740 SetupStartPage(PINPUT_RECORD Ir
)
742 //SYSTEM_DEVICE_INFORMATION Sdi;
744 WCHAR FileNameBuffer
[MAX_PATH
];
749 PGENERIC_LIST_ENTRY ListEntry
;
752 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
755 /* Check whether a harddisk is available */
756 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
758 sizeof(SYSTEM_DEVICE_INFORMATION
),
761 if (!NT_SUCCESS(Status
))
763 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
764 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
768 if (Sdi
.NumberOfDisks
== 0)
770 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
775 /* Get the source path and source root path */
776 Status
= GetSourcePaths(&SourcePath
,
780 if (!NT_SUCCESS(Status
))
782 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
783 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
789 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
790 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
791 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
795 /* Load txtsetup.sif from install media. */
796 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
797 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
799 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
805 if (SetupInf
== INVALID_HANDLE_VALUE
)
807 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
811 /* Open 'Version' section */
812 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
814 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
818 /* Get pointer 'Signature' key */
819 if (!INF_GetData(&Context
, NULL
, &Value
))
821 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
825 /* Check 'Signature' string */
826 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
828 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
832 /* Open 'DiskSpaceRequirements' section */
833 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
835 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
839 /* Get the 'FreeSysPartDiskSpace' value */
840 if (!SetupGetIntField(&Context
, 1, &IntValue
))
842 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
846 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
848 /* Start PnP thread */
849 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
851 NtResumeThread(hPnpThread
, NULL
);
852 hPnpThread
= INVALID_HANDLE_VALUE
;
855 CheckUnattendedSetup();
857 if (IsUnattendedSetup
)
860 //read options from inf
861 ComputerList
= CreateComputerTypeList(SetupInf
);
862 DisplayList
= CreateDisplayDriverList(SetupInf
);
863 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
864 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
865 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
868 wcscpy(SelectedLanguageId
,LocaleID
);
870 /* first we hack LanguageList */
871 ListEntry
= GetFirstListEntry(LanguageList
);
873 while (ListEntry
!= NULL
)
875 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
877 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
878 SetCurrentListEntry(LanguageList
, ListEntry
);
882 ListEntry
= GetNextListEntry(ListEntry
);
886 ListEntry
= GetFirstListEntry(LayoutList
);
888 while (ListEntry
!= NULL
)
890 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
892 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
893 SetCurrentListEntry(LayoutList
, ListEntry
);
897 ListEntry
= GetNextListEntry(ListEntry
);
900 SetConsoleCodePage();
902 return INSTALL_INTRO_PAGE
;
905 return LANGUAGE_PAGE
;
915 IntroPage(PINPUT_RECORD Ir
)
917 MUIDisplayPage(START_PAGE
);
921 CONSOLE_ConInKey(Ir
);
923 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
924 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
926 if (ConfirmQuit(Ir
) == TRUE
)
931 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
933 return INSTALL_INTRO_PAGE
;
935 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
937 return REPAIR_INTRO_PAGE
;
939 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
952 * Back to main setup page.
955 LicensePage(PINPUT_RECORD Ir
)
957 MUIDisplayPage(LICENSE_PAGE
);
961 CONSOLE_ConInKey(Ir
);
963 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
974 RepairIntroPage(PINPUT_RECORD Ir
)
976 MUIDisplayPage(REPAIR_INTRO_PAGE
);
980 CONSOLE_ConInKey(Ir
);
982 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
986 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
988 RepairUpdateFlag
= TRUE
;
989 return INSTALL_INTRO_PAGE
;
991 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
993 return RECOVERY_PAGE
;
995 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
996 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1002 return REPAIR_INTRO_PAGE
;
1007 InstallIntroPage(PINPUT_RECORD Ir
)
1009 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1011 if (RepairUpdateFlag
)
1013 //return SELECT_PARTITION_PAGE;
1014 return DEVICE_SETTINGS_PAGE
;
1017 if (IsUnattendedSetup
)
1019 return SELECT_PARTITION_PAGE
;
1024 CONSOLE_ConInKey(Ir
);
1026 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1027 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1029 if (ConfirmQuit(Ir
) == TRUE
)
1034 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1036 return DEVICE_SETTINGS_PAGE
;
1037 // return SCSI_CONTROLLER_PAGE;
1041 return INSTALL_INTRO_PAGE
;
1047 ScsiControllerPage(PINPUT_RECORD Ir
)
1049 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1051 /* FIXME: print loaded mass storage driver descriptions */
1053 SetTextXY(8, 10, "TEST device");
1057 SetStatusText(" ENTER = Continue F3 = Quit");
1063 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1064 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1066 if (ConfirmQuit(Ir
) == TRUE
)
1071 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1073 return DEVICE_SETTINGS_PAGE
;
1077 return SCSI_CONTROLLER_PAGE
;
1083 DeviceSettingsPage(PINPUT_RECORD Ir
)
1085 static ULONG Line
= 16;
1086 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1088 /* Initialize the computer settings list */
1089 if (ComputerList
== NULL
)
1091 ComputerList
= CreateComputerTypeList(SetupInf
);
1092 if (ComputerList
== NULL
)
1094 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1099 /* Initialize the display settings list */
1100 if (DisplayList
== NULL
)
1102 DisplayList
= CreateDisplayDriverList(SetupInf
);
1103 if (DisplayList
== NULL
)
1105 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1110 /* Initialize the keyboard settings list */
1111 if (KeyboardList
== NULL
)
1113 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1114 if (KeyboardList
== NULL
)
1116 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1121 /* Initialize the keyboard layout list */
1122 if (LayoutList
== NULL
)
1124 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1125 if (LayoutList
== NULL
)
1127 /* FIXME: report error */
1128 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1133 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1136 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1137 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1138 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1139 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1141 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1143 if (RepairUpdateFlag
)
1145 return SELECT_PARTITION_PAGE
;
1150 CONSOLE_ConInKey(Ir
);
1152 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1153 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1155 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1159 else if (Line
== 16)
1164 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1166 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1167 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1169 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1173 else if (Line
== 16)
1178 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1180 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1181 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1183 if (ConfirmQuit(Ir
) == TRUE
)
1188 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1191 return COMPUTER_SETTINGS_PAGE
;
1192 else if (Line
== 12)
1193 return DISPLAY_SETTINGS_PAGE
;
1194 else if (Line
== 13)
1195 return KEYBOARD_SETTINGS_PAGE
;
1196 else if (Line
== 14)
1197 return LAYOUT_SETTINGS_PAGE
;
1198 else if (Line
== 16)
1199 return SELECT_PARTITION_PAGE
;
1203 return DEVICE_SETTINGS_PAGE
;
1208 ComputerSettingsPage(PINPUT_RECORD Ir
)
1210 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1212 DrawGenericList(ComputerList
,
1218 SaveGenericListState(ComputerList
);
1222 CONSOLE_ConInKey(Ir
);
1224 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1225 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1227 ScrollDownGenericList(ComputerList
);
1229 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1230 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1232 ScrollUpGenericList(ComputerList
);
1234 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1235 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1237 if (ConfirmQuit(Ir
) == TRUE
)
1242 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1243 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1245 RestoreGenericListState(ComputerList
);
1246 return DEVICE_SETTINGS_PAGE
;
1248 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1250 return DEVICE_SETTINGS_PAGE
;
1254 return COMPUTER_SETTINGS_PAGE
;
1259 DisplaySettingsPage(PINPUT_RECORD Ir
)
1261 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1263 DrawGenericList(DisplayList
,
1269 SaveGenericListState(DisplayList
);
1273 CONSOLE_ConInKey(Ir
);
1275 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1276 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1278 ScrollDownGenericList(DisplayList
);
1280 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1281 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1283 ScrollUpGenericList(DisplayList
);
1285 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1286 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1288 if (ConfirmQuit(Ir
) == TRUE
)
1295 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1296 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1298 RestoreGenericListState(DisplayList
);
1299 return DEVICE_SETTINGS_PAGE
;
1301 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1303 return DEVICE_SETTINGS_PAGE
;
1307 return DISPLAY_SETTINGS_PAGE
;
1312 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1314 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1316 DrawGenericList(KeyboardList
,
1322 SaveGenericListState(KeyboardList
);
1326 CONSOLE_ConInKey(Ir
);
1328 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1329 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1331 ScrollDownGenericList(KeyboardList
);
1333 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1334 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1336 ScrollUpGenericList(KeyboardList
);
1338 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1339 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1341 if (ConfirmQuit(Ir
) == TRUE
)
1346 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1347 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1349 RestoreGenericListState(KeyboardList
);
1350 return DEVICE_SETTINGS_PAGE
;
1352 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1354 return DEVICE_SETTINGS_PAGE
;
1358 return KEYBOARD_SETTINGS_PAGE
;
1363 LayoutSettingsPage(PINPUT_RECORD Ir
)
1365 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1367 DrawGenericList(LayoutList
,
1373 SaveGenericListState(LayoutList
);
1377 CONSOLE_ConInKey(Ir
);
1379 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1380 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1382 ScrollDownGenericList(LayoutList
);
1384 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1385 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1387 ScrollUpGenericList(LayoutList
);
1389 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1390 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1392 ScrollPageDownGenericList(LayoutList
);
1394 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1395 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1397 ScrollPageUpGenericList(LayoutList
);
1399 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1400 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1402 if (ConfirmQuit(Ir
) == TRUE
)
1407 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1408 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1410 RestoreGenericListState(LayoutList
);
1411 return DEVICE_SETTINGS_PAGE
;
1413 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1415 return DEVICE_SETTINGS_PAGE
;
1417 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1420 GenericListKeyPress(LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1424 return LAYOUT_SETTINGS_PAGE
;
1429 IsDiskSizeValid(PPARTENTRY PartEntry
)
1433 size
= PartEntry
->SectorCount
.QuadPart
* PartEntry
->DiskEntry
->BytesPerSector
;
1434 size
= (size
+ 524288) / 1048576; /* in MBytes */
1436 if (size
< RequiredPartitionDiskSpace
)
1438 /* partition is too small so ask for another partion */
1439 DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size
, RequiredPartitionDiskSpace
);
1450 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 */
1467 else if (IsListEmpty (&PartitionList
->DiskListHead
))
1469 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
1474 DrawPartitionList(PartitionList
);
1476 /* Warn about partitions created by Linux Fdisk */
1477 if (WarnLinuxPartitions
== TRUE
&&
1478 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1480 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1484 CONSOLE_ConInKey(Ir
);
1486 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1487 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1491 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1493 WarnLinuxPartitions
= FALSE
;
1494 return SELECT_PARTITION_PAGE
;
1499 if (IsUnattendedSetup
)
1501 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1505 CreatePrimaryPartition(PartitionList
,
1506 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1509 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1511 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1512 RequiredPartitionDiskSpace
);
1513 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1516 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1518 return SELECT_FILE_SYSTEM_PAGE
;
1523 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1525 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1526 RequiredPartitionDiskSpace
);
1527 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1530 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1532 return SELECT_FILE_SYSTEM_PAGE
;
1538 /* Update status text */
1539 if (PartitionList
->CurrentPartition
== NULL
)
1541 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1543 else if (PartitionList
->CurrentPartition
->LogicalPartition
)
1545 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1547 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1551 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL
));
1556 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1558 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1560 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1564 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1569 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1573 CONSOLE_ConInKey(Ir
);
1575 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1576 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1578 if (ConfirmQuit(Ir
) == TRUE
)
1580 DestroyPartitionList(PartitionList
);
1581 PartitionList
= NULL
;
1587 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1588 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1590 if (ScrollDownPartitionList(PartitionList
))
1591 DrawPartitionList(PartitionList
);
1593 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1594 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1596 if (ScrollUpPartitionList(PartitionList
))
1597 DrawPartitionList(PartitionList
);
1599 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1601 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1602 continue; //return SELECT_PARTITION_PAGE;
1604 if (PartitionList
->CurrentPartition
== NULL
||
1605 PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1607 CreatePrimaryPartition(PartitionList
,
1612 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1614 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1615 RequiredPartitionDiskSpace
);
1616 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1619 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1621 return SELECT_FILE_SYSTEM_PAGE
;
1623 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'P') /* P */
1625 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1627 Error
= PrimaryPartitionCreationChecks(PartitionList
);
1628 if (Error
!= NOT_AN_ERROR
)
1630 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1631 return SELECT_PARTITION_PAGE
;
1634 return CREATE_PRIMARY_PARTITION_PAGE
;
1637 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'E') /* E */
1639 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1641 Error
= ExtendedPartitionCreationChecks(PartitionList
);
1642 if (Error
!= NOT_AN_ERROR
)
1644 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1645 return SELECT_PARTITION_PAGE
;
1648 return CREATE_EXTENDED_PARTITION_PAGE
;
1651 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'L') /* L */
1653 if (PartitionList
->CurrentPartition
->LogicalPartition
== TRUE
)
1655 Error
= LogicalPartitionCreationChecks(PartitionList
);
1656 if (Error
!= NOT_AN_ERROR
)
1658 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1659 return SELECT_PARTITION_PAGE
;
1662 return CREATE_LOGICAL_PARTITION_PAGE
;
1665 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1667 if (PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1669 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1670 return SELECT_PARTITION_PAGE
;
1673 return DELETE_PARTITION_PAGE
;
1677 return SELECT_PARTITION_PAGE
;
1682 DrawInputField(ULONG FieldLength
,
1693 memset(buf
, '_', sizeof(buf
));
1694 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1695 strcat(buf
, FieldContent
);
1697 WriteConsoleOutputCharacterA(StdOutput
,
1705 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1706 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1707 #define PARTITION_MAXSIZE 999999
1710 ShowPartitionSizeInputBox(SHORT Left
,
1734 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1739 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1740 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1743 WriteConsoleOutputCharacterA(StdOutput
,
1749 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1750 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1752 WriteConsoleOutputCharacterA(StdOutput
,
1758 sprintf(Buffer
, "%lu", MaxSize
);
1759 Index
= strlen(Buffer
);
1760 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1767 CONSOLE_ConInKey(&Ir
);
1769 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1770 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1778 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1782 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1790 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1796 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1801 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1802 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1804 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1806 if ((ch
>= '0') && (ch
<= '9'))
1812 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1820 strcpy(InputBuffer
, Buffer
);
1825 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1827 PDISKENTRY DiskEntry
;
1828 PPARTENTRY PartEntry
;
1831 CHAR InputBuffer
[50];
1835 ULONGLONG SectorCount
;
1838 if (PartitionList
== NULL
||
1839 PartitionList
->CurrentDisk
== NULL
||
1840 PartitionList
->CurrentPartition
== NULL
)
1842 /* FIXME: show an error dialog */
1846 DiskEntry
= PartitionList
->CurrentDisk
;
1847 PartEntry
= PartitionList
->CurrentPartition
;
1849 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1851 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1853 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1855 if (DiskSize
>= 10737418240) /* 10 GB */
1857 DiskSize
= DiskSize
/ 1073741824;
1858 Unit
= MUIGetString(STRING_GB
);
1863 DiskSize
= DiskSize
/ 1048576;
1867 Unit
= MUIGetString(STRING_MB
);
1870 if (DiskEntry
->DriverName
.Length
> 0)
1872 CONSOLE_PrintTextXY(6, 10,
1873 MUIGetString(STRING_HDINFOPARTCREATE
),
1876 DiskEntry
->DiskNumber
,
1880 &DiskEntry
->DriverName
);
1884 CONSOLE_PrintTextXY(6, 10,
1885 MUIGetString(STRING_HDDINFOUNK1
),
1888 DiskEntry
->DiskNumber
,
1894 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1897 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1898 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
1901 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1903 PartEntry
= PartitionList
->CurrentPartition
;
1906 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
1908 if (MaxSize
> PARTITION_MAXSIZE
)
1909 MaxSize
= PARTITION_MAXSIZE
;
1911 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1912 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1916 if (ConfirmQuit (Ir
) == TRUE
)
1921 else if (Cancel
== TRUE
)
1923 return SELECT_PARTITION_PAGE
;
1927 PartSize
= atoi(InputBuffer
);
1935 if (PartSize
> MaxSize
)
1941 /* Convert to bytes */
1942 if (PartSize
== MaxSize
)
1944 /* Use all of the unpartitioned disk space */
1945 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1949 /* Calculate the sector count from the size in MB */
1950 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
1952 /* But never get larger than the unpartitioned disk space */
1953 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
1954 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1957 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1959 CreatePrimaryPartition(PartitionList
,
1963 return SELECT_PARTITION_PAGE
;
1967 return CREATE_PRIMARY_PARTITION_PAGE
;
1972 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
1974 PDISKENTRY DiskEntry
;
1975 PPARTENTRY PartEntry
;
1978 CHAR InputBuffer
[50];
1982 ULONGLONG SectorCount
;
1985 if (PartitionList
== NULL
||
1986 PartitionList
->CurrentDisk
== NULL
||
1987 PartitionList
->CurrentPartition
== NULL
)
1989 /* FIXME: show an error dialog */
1993 DiskEntry
= PartitionList
->CurrentDisk
;
1994 PartEntry
= PartitionList
->CurrentPartition
;
1996 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1998 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
2000 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2002 if (DiskSize
>= 10737418240) /* 10 GB */
2004 DiskSize
= DiskSize
/ 1073741824;
2005 Unit
= MUIGetString(STRING_GB
);
2010 DiskSize
= DiskSize
/ 1048576;
2014 Unit
= MUIGetString(STRING_MB
);
2017 if (DiskEntry
->DriverName
.Length
> 0)
2019 CONSOLE_PrintTextXY(6, 10,
2020 MUIGetString(STRING_HDINFOPARTCREATE
),
2023 DiskEntry
->DiskNumber
,
2027 &DiskEntry
->DriverName
);
2031 CONSOLE_PrintTextXY(6, 10,
2032 MUIGetString(STRING_HDDINFOUNK1
),
2035 DiskEntry
->DiskNumber
,
2041 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2044 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2045 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2048 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2050 PartEntry
= PartitionList
->CurrentPartition
;
2053 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2055 if (MaxSize
> PARTITION_MAXSIZE
)
2056 MaxSize
= PARTITION_MAXSIZE
;
2058 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2059 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2063 if (ConfirmQuit (Ir
) == TRUE
)
2068 else if (Cancel
== TRUE
)
2070 return SELECT_PARTITION_PAGE
;
2074 PartSize
= atoi(InputBuffer
);
2082 if (PartSize
> MaxSize
)
2088 /* Convert to bytes */
2089 if (PartSize
== MaxSize
)
2091 /* Use all of the unpartitioned disk space */
2092 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2096 /* Calculate the sector count from the size in MB */
2097 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2099 /* But never get larger than the unpartitioned disk space */
2100 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2101 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2104 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2106 CreateExtendedPartition(PartitionList
,
2109 return SELECT_PARTITION_PAGE
;
2113 return CREATE_EXTENDED_PARTITION_PAGE
;
2118 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2120 PDISKENTRY DiskEntry
;
2121 PPARTENTRY PartEntry
;
2124 CHAR InputBuffer
[50];
2128 ULONGLONG SectorCount
;
2131 if (PartitionList
== NULL
||
2132 PartitionList
->CurrentDisk
== NULL
||
2133 PartitionList
->CurrentPartition
== NULL
)
2135 /* FIXME: show an error dialog */
2139 DiskEntry
= PartitionList
->CurrentDisk
;
2140 PartEntry
= PartitionList
->CurrentPartition
;
2142 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2144 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2146 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2148 if (DiskSize
>= 10737418240) /* 10 GB */
2150 DiskSize
= DiskSize
/ 1073741824;
2151 Unit
= MUIGetString(STRING_GB
);
2156 DiskSize
= DiskSize
/ 1048576;
2160 Unit
= MUIGetString(STRING_MB
);
2163 if (DiskEntry
->DriverName
.Length
> 0)
2165 CONSOLE_PrintTextXY(6, 10,
2166 MUIGetString(STRING_HDINFOPARTCREATE
),
2169 DiskEntry
->DiskNumber
,
2173 &DiskEntry
->DriverName
);
2177 CONSOLE_PrintTextXY(6, 10,
2178 MUIGetString(STRING_HDDINFOUNK1
),
2181 DiskEntry
->DiskNumber
,
2187 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2190 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2191 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2194 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2196 PartEntry
= PartitionList
->CurrentPartition
;
2199 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2201 if (MaxSize
> PARTITION_MAXSIZE
)
2202 MaxSize
= PARTITION_MAXSIZE
;
2204 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2205 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2209 if (ConfirmQuit (Ir
) == TRUE
)
2214 else if (Cancel
== TRUE
)
2216 return SELECT_PARTITION_PAGE
;
2220 PartSize
= atoi(InputBuffer
);
2228 if (PartSize
> MaxSize
)
2234 /* Convert to bytes */
2235 if (PartSize
== MaxSize
)
2237 /* Use all of the unpartitioned disk space */
2238 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2242 /* Calculate the sector count from the size in MB */
2243 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2245 /* But never get larger than the unpartitioned disk space */
2246 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2247 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2250 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2252 CreateLogicalPartition(PartitionList
,
2255 return SELECT_PARTITION_PAGE
;
2259 return CREATE_LOGICAL_PARTITION_PAGE
;
2264 DeletePartitionPage(PINPUT_RECORD Ir
)
2266 PDISKENTRY DiskEntry
;
2267 PPARTENTRY PartEntry
;
2273 if (PartitionList
== NULL
||
2274 PartitionList
->CurrentDisk
== NULL
||
2275 PartitionList
->CurrentPartition
== NULL
)
2277 /* FIXME: show an error dialog */
2281 DiskEntry
= PartitionList
->CurrentDisk
;
2282 PartEntry
= PartitionList
->CurrentPartition
;
2284 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2286 /* Determine partition type */
2288 if (PartEntry
->New
== TRUE
)
2290 PartType
= MUIGetString(STRING_UNFORMATTED
);
2292 else if (PartEntry
->IsPartitioned
== TRUE
)
2294 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2295 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2296 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2297 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2301 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2302 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2306 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2310 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2312 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2314 else if (IsContainerPartition(PartEntry
->PartitionType
))
2316 PartType
= MUIGetString(STRING_EXTENDED_PARTITION
);
2320 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2322 if (PartSize
>= 10737418240) /* 10 GB */
2324 PartSize
= PartSize
/ 1073741824;
2325 Unit
= MUIGetString(STRING_GB
);
2329 if (PartSize
>= 10485760) /* 10 MB */
2331 PartSize
= PartSize
/ 1048576;
2332 Unit
= MUIGetString(STRING_MB
);
2336 PartSize
= PartSize
/ 1024;
2337 Unit
= MUIGetString(STRING_KB
);
2340 if (PartType
== NULL
)
2342 CONSOLE_PrintTextXY(6, 10,
2343 MUIGetString(STRING_HDDINFOUNK2
),
2344 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2345 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2346 PartEntry
->PartitionType
,
2352 CONSOLE_PrintTextXY(6, 10,
2353 " %c%c %s %I64u %s",
2354 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2355 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2361 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2363 if (DiskSize
>= 10737418240) /* 10 GB */
2365 DiskSize
= DiskSize
/ 1073741824;
2366 Unit
= MUIGetString(STRING_GB
);
2371 DiskSize
= DiskSize
/ 1048576;
2375 Unit
= MUIGetString(STRING_MB
);
2378 if (DiskEntry
->DriverName
.Length
> 0)
2380 CONSOLE_PrintTextXY(6, 12,
2381 MUIGetString(STRING_HDINFOPARTDELETE
),
2384 DiskEntry
->DiskNumber
,
2388 &DiskEntry
->DriverName
);
2392 CONSOLE_PrintTextXY(6, 12,
2393 MUIGetString(STRING_HDDINFOUNK3
),
2396 DiskEntry
->DiskNumber
,
2404 CONSOLE_ConInKey(Ir
);
2406 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2407 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2409 if (ConfirmQuit(Ir
) == TRUE
)
2416 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2418 return SELECT_PARTITION_PAGE
;
2420 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2422 DeleteCurrentPartition(PartitionList
);
2424 return SELECT_PARTITION_PAGE
;
2428 return DELETE_PARTITION_PAGE
;
2433 SelectFileSystemPage(PINPUT_RECORD Ir
)
2435 PDISKENTRY DiskEntry
;
2436 PPARTENTRY PartEntry
;
2443 if (PartitionList
== NULL
||
2444 PartitionList
->CurrentDisk
== NULL
||
2445 PartitionList
->CurrentPartition
== NULL
)
2447 /* FIXME: show an error dialog */
2451 DiskEntry
= PartitionList
->CurrentDisk
;
2452 PartEntry
= PartitionList
->CurrentPartition
;
2454 /* adjust disk size */
2455 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2456 if (DiskSize
>= 10737418240) /* 10 GB */
2458 DiskSize
= DiskSize
/ 1073741824;
2459 DiskUnit
= MUIGetString(STRING_GB
);
2463 DiskSize
= DiskSize
/ 1048576;
2464 DiskUnit
= MUIGetString(STRING_MB
);
2467 /* adjust partition size */
2468 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2469 if (PartSize
>= 10737418240) /* 10 GB */
2471 PartSize
= PartSize
/ 1073741824;
2472 PartUnit
= MUIGetString(STRING_GB
);
2476 PartSize
= PartSize
/ 1048576;
2477 PartUnit
= MUIGetString(STRING_MB
);
2480 /* adjust partition type */
2481 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2482 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2483 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2484 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2488 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2489 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2493 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2497 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2499 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2501 else if (PartEntry
->PartitionType
== PARTITION_ENTRY_UNUSED
)
2503 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2507 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2510 if (PartEntry
->AutoCreate
== TRUE
)
2512 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2515 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2516 PartEntry
->PartitionNumber
,
2522 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2523 DiskEntry
->DiskNumber
,
2529 &DiskEntry
->DriverName
);
2531 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2534 PartEntry
->AutoCreate
= FALSE
;
2536 else if (PartEntry
->New
== TRUE
)
2538 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2539 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2543 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2545 if (PartType
== NULL
)
2547 CONSOLE_PrintTextXY(8, 10,
2548 MUIGetString(STRING_HDDINFOUNK4
),
2549 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2550 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2551 PartEntry
->PartitionType
,
2557 CONSOLE_PrintTextXY(8, 10,
2559 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2560 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2566 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2567 DiskEntry
->DiskNumber
,
2573 &DiskEntry
->DriverName
);
2576 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2578 if (FileSystemList
== NULL
)
2580 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2581 if (FileSystemList
== NULL
)
2583 /* FIXME: show an error dialog */
2587 /* FIXME: Add file systems to list */
2590 DrawFileSystemList(FileSystemList
);
2592 if (RepairUpdateFlag
)
2594 return CHECK_FILE_SYSTEM_PAGE
;
2595 //return SELECT_PARTITION_PAGE;
2598 if (IsUnattendedSetup
)
2600 if (UnattendFormatPartition
)
2602 return FORMAT_PARTITION_PAGE
;
2605 return CHECK_FILE_SYSTEM_PAGE
;
2610 CONSOLE_ConInKey(Ir
);
2612 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2613 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2615 if (ConfirmQuit(Ir
) == TRUE
)
2622 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2623 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2625 return SELECT_PARTITION_PAGE
;
2627 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2628 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2630 ScrollDownFileSystemList(FileSystemList
);
2632 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2633 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2635 ScrollUpFileSystemList(FileSystemList
);
2637 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2639 if (!FileSystemList
->Selected
->FormatFunc
)
2641 return CHECK_FILE_SYSTEM_PAGE
;
2645 return FORMAT_PARTITION_PAGE
;
2650 return SELECT_FILE_SYSTEM_PAGE
;
2655 FormatPartitionPage(PINPUT_RECORD Ir
)
2657 WCHAR PathBuffer
[MAX_PATH
];
2658 PDISKENTRY DiskEntry
;
2659 PPARTENTRY PartEntry
;
2668 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2670 if (PartitionList
== NULL
||
2671 PartitionList
->CurrentDisk
== NULL
||
2672 PartitionList
->CurrentPartition
== NULL
)
2674 /* FIXME: show an error dialog */
2678 DiskEntry
= PartitionList
->CurrentDisk
;
2679 PartEntry
= PartitionList
->CurrentPartition
;
2683 if (!IsUnattendedSetup
)
2685 CONSOLE_ConInKey(Ir
);
2688 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2689 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2691 if (ConfirmQuit(Ir
) == TRUE
)
2698 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2700 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2702 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2704 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2706 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2707 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2709 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2711 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2713 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2715 /* FAT16 CHS partition (partiton size < 32MB) */
2716 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2718 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2720 /* FAT16 CHS partition (partition size < 512MB) */
2721 PartEntry
->PartitionType
= PARTITION_HUGE
;
2725 /* FAT32 CHS partition (partition size >= 512MB) */
2726 PartEntry
->PartitionType
= PARTITION_FAT32
;
2731 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2733 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2735 /* FAT16 LBA partition (partition size < 512MB) */
2736 PartEntry
->PartitionType
= PARTITION_XINT13
;
2740 /* FAT32 LBA partition (partition size >= 512MB) */
2741 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2745 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2748 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2750 PartEntry
->PartitionType
= PARTITION_EXT2
;
2751 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2754 else if (!FileSystemList
->Selected
->FormatFunc
)
2758 CONSOLE_PrintTextXY(6, 12,
2759 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2760 DiskEntry
->DiskSize
,
2761 DiskEntry
->CylinderSize
,
2762 DiskEntry
->TrackSize
);
2765 DiskEntry
= PartitionList
->CurrentDisk
;
2766 Entry
= DiskEntry
->PartListHead
.Flink
;
2768 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2770 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2772 if (PartEntry
->IsPartitioned
== TRUE
)
2774 CONSOLE_PrintTextXY(6, Line
,
2775 "%2u: %2u %c %12I64u %12I64u %2u %c",
2777 PartEntry
->PartitionNumber
,
2778 PartEntry
->BootIndicator
? 'A' : '-',
2779 PartEntry
->StartSector
.QuadPart
,
2780 PartEntry
->SectorCount
.QuadPart
,
2781 PartEntry
->PartitionType
,
2782 PartEntry
->Dirty
? '*' : ' ');
2786 Entry
= Entry
->Flink
;
2789 /* Restore the old entry */
2790 PartEntry
= PartitionList
->CurrentPartition
;
2793 CheckActiveBootPartition(PartitionList
);
2795 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2797 DPRINT("WritePartitionsToDisk() failed\n");
2798 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2802 /* Set DestinationRootPath */
2803 RtlFreeUnicodeString(&DestinationRootPath
);
2804 swprintf(PathBuffer
,
2805 L
"\\Device\\Harddisk%lu\\Partition%lu",
2806 PartitionList
->CurrentDisk
->DiskNumber
,
2807 PartitionList
->CurrentPartition
->PartitionNumber
);
2808 RtlCreateUnicodeString(&DestinationRootPath
,
2810 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2812 if (FileSystemList
->Selected
->FormatFunc
)
2814 Status
= FormatPartition(&DestinationRootPath
,
2815 FileSystemList
->Selected
);
2816 if (!NT_SUCCESS(Status
))
2818 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2819 /* FIXME: show an error dialog */
2823 PartEntry
->New
= FALSE
;
2828 CONSOLE_SetStatusText(" Done. Press any key ...");
2829 CONSOLE_ConInKey(Ir
);
2832 DestroyFileSystemList(FileSystemList
);
2833 FileSystemList
= NULL
;
2834 return INSTALL_DIRECTORY_PAGE
;
2838 return FORMAT_PARTITION_PAGE
;
2843 CheckFileSystemPage(PINPUT_RECORD Ir
)
2845 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2846 WCHAR PathBuffer
[MAX_PATH
];
2847 CHAR Buffer
[MAX_PATH
];
2850 /* FIXME: code duplicated in FormatPartitionPage */
2851 /* Set DestinationRootPath */
2852 RtlFreeUnicodeString(&DestinationRootPath
);
2853 swprintf(PathBuffer
,
2854 L
"\\Device\\Harddisk%lu\\Partition%lu",
2855 PartitionList
->CurrentDisk
->DiskNumber
,
2856 PartitionList
->CurrentPartition
->PartitionNumber
);
2857 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2858 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2860 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2862 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2864 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2865 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2867 if (!CurrentFileSystem
->ChkdskFunc
)
2870 "Setup is currently unable to check a partition formatted in %S.\n"
2872 " \x07 Press ENTER to continue Setup.\n"
2873 " \x07 Press F3 to quit Setup.",
2874 CurrentFileSystem
->FileSystem
);
2877 MUIGetString(STRING_QUITCONTINUE
),
2878 NULL
, POPUP_WAIT_NONE
);
2882 CONSOLE_ConInKey(Ir
);
2884 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2885 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2887 if (ConfirmQuit(Ir
))
2890 return CHECK_FILE_SYSTEM_PAGE
;
2892 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2894 return INSTALL_DIRECTORY_PAGE
;
2900 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2901 if (!NT_SUCCESS(Status
))
2903 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2904 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2905 "(Status 0x%08lx).\n", Status
);
2908 MUIGetString(STRING_REBOOTCOMPUTER
),
2909 Ir
, POPUP_WAIT_ENTER
);
2914 return INSTALL_DIRECTORY_PAGE
;
2920 InstallDirectoryPage1(PWCHAR InstallDir
,
2921 PDISKENTRY DiskEntry
,
2922 PPARTENTRY PartEntry
)
2924 WCHAR PathBuffer
[MAX_PATH
];
2926 /* Create 'InstallPath' string */
2927 RtlFreeUnicodeString(&InstallPath
);
2928 RtlCreateUnicodeString(&InstallPath
,
2931 /* Create 'DestinationPath' string */
2932 RtlFreeUnicodeString(&DestinationPath
);
2933 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2935 if (InstallDir
[0] != L
'\\')
2936 wcscat(PathBuffer
, L
"\\");
2938 wcscat(PathBuffer
, InstallDir
);
2939 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2941 /* Create 'DestinationArcPath' */
2942 RtlFreeUnicodeString(&DestinationArcPath
);
2943 swprintf(PathBuffer
,
2944 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2945 DiskEntry
->BiosDiskNumber
,
2946 PartEntry
->PartitionNumber
);
2948 if (InstallDir
[0] != L
'\\')
2949 wcscat(PathBuffer
, L
"\\");
2951 wcscat(PathBuffer
, InstallDir
);
2952 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2954 return PREPARE_COPY_PAGE
;
2959 InstallDirectoryPage(PINPUT_RECORD Ir
)
2961 PDISKENTRY DiskEntry
;
2962 PPARTENTRY PartEntry
;
2963 WCHAR InstallDir
[51];
2966 if (PartitionList
== NULL
||
2967 PartitionList
->CurrentDisk
== NULL
||
2968 PartitionList
->CurrentPartition
== NULL
)
2970 /* FIXME: show an error dialog */
2974 DiskEntry
= PartitionList
->CurrentDisk
;
2975 PartEntry
= PartitionList
->CurrentPartition
;
2977 if (IsUnattendedSetup
)
2978 wcscpy(InstallDir
, UnattendInstallationDirectory
);
2980 wcscpy(InstallDir
, L
"\\ReactOS");
2982 Length
= wcslen(InstallDir
);
2983 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2984 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2986 if (IsUnattendedSetup
)
2988 return InstallDirectoryPage1(InstallDir
,
2995 CONSOLE_ConInKey(Ir
);
2997 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2998 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3000 if (ConfirmQuit(Ir
) == TRUE
)
3005 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3007 return InstallDirectoryPage1(InstallDir
,
3011 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3016 InstallDir
[Length
] = 0;
3017 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3020 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3024 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3026 InstallDir
[Length
] = 0;
3027 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3032 return INSTALL_DIRECTORY_PAGE
;
3037 AddSectionToCopyQueueCab(HINF InfFile
,
3039 PWCHAR SourceCabinet
,
3040 PCUNICODE_STRING DestinationPath
,
3043 INFCONTEXT FilesContext
;
3044 INFCONTEXT DirContext
;
3046 PWCHAR FileKeyValue
;
3048 PWCHAR TargetFileName
;
3050 /* Search for the SectionName section */
3051 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3054 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3055 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3060 * Enumerate the files in the section
3061 * and add them to the file queue.
3065 /* Get source file name and target directory id */
3066 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3068 /* FIXME: Handle error! */
3069 DPRINT1("INF_GetData() failed\n");
3073 /* Get optional target file name */
3074 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3075 TargetFileName
= NULL
;
3077 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3079 /* Lookup target directory */
3080 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3082 /* FIXME: Handle error! */
3083 DPRINT1("SetupFindFirstLine() failed\n");
3087 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3089 /* FIXME: Handle error! */
3090 DPRINT1("INF_GetData() failed\n");
3094 if (!SetupQueueCopy(SetupFileQueue
,
3096 SourceRootPath
.Buffer
,
3097 SourceRootDir
.Buffer
,
3102 /* FIXME: Handle error! */
3103 DPRINT1("SetupQueueCopy() failed\n");
3105 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3112 AddSectionToCopyQueue(HINF InfFile
,
3114 PWCHAR SourceCabinet
,
3115 PCUNICODE_STRING DestinationPath
,
3118 INFCONTEXT FilesContext
;
3119 INFCONTEXT DirContext
;
3121 PWCHAR FileKeyValue
;
3123 PWCHAR TargetFileName
;
3124 WCHAR CompleteOrigFileName
[512];
3127 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3129 /* Search for the SectionName section */
3130 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3133 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3134 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3139 * Enumerate the files in the section
3140 * and add them to the file queue.
3144 /* Get source file name and target directory id */
3145 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3147 /* FIXME: Handle error! */
3148 DPRINT1("INF_GetData() failed\n");
3152 /* Get target directory id */
3153 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3155 /* FIXME: Handle error! */
3156 DPRINT1("INF_GetData() failed\n");
3160 /* Get optional target file name */
3161 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3162 TargetFileName
= NULL
;
3163 else if (!*TargetFileName
)
3164 TargetFileName
= NULL
;
3166 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3168 /* Lookup target directory */
3169 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3171 /* FIXME: Handle error! */
3172 DPRINT1("SetupFindFirstLine() failed\n");
3176 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3178 /* FIXME: Handle error! */
3179 DPRINT1("INF_GetData() failed\n");
3183 wcscpy(CompleteOrigFileName
, SourceRootDir
.Buffer
);
3184 wcscat(CompleteOrigFileName
, L
"\\");
3185 wcscat(CompleteOrigFileName
, DirKeyValue
);
3187 if (!SetupQueueCopy(SetupFileQueue
,
3189 SourceRootPath
.Buffer
,
3190 CompleteOrigFileName
,
3195 /* FIXME: Handle error! */
3196 DPRINT1("SetupQueueCopy() failed\n");
3198 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3205 PrepareCopyPageInfFile(HINF InfFile
,
3206 PWCHAR SourceCabinet
,
3209 WCHAR PathBuffer
[MAX_PATH
];
3210 INFCONTEXT DirContext
;
3211 PWCHAR AdditionalSectionName
= NULL
;
3216 /* Add common files */
3217 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3220 /* Add specific files depending of computer type */
3221 if (SourceCabinet
== NULL
)
3223 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3226 if (AdditionalSectionName
)
3228 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3233 /* Create directories */
3237 * Install directories like '\reactos\test' are not handled yet.
3240 /* Get destination path */
3241 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3243 /* Remove trailing backslash */
3244 Length
= wcslen(PathBuffer
);
3245 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
3247 PathBuffer
[Length
- 1] = 0;
3250 /* Create the install directory */
3251 Status
= SetupCreateDirectory(PathBuffer
);
3252 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3254 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3255 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3259 /* Search for the 'Directories' section */
3260 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3264 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3268 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3274 /* Enumerate the directory values and create the subdirectories */
3277 if (!INF_GetData(&DirContext
, NULL
, &KeyValue
))
3283 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
3285 DPRINT("Absolute Path: '%S'\n", KeyValue
);
3287 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3288 wcscat(PathBuffer
, KeyValue
);
3290 DPRINT("FullPath: '%S'\n", PathBuffer
);
3292 else if (KeyValue
[0] != L
'\\')
3294 DPRINT("RelativePath: '%S'\n", KeyValue
);
3295 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3296 wcscat(PathBuffer
, L
"\\");
3297 wcscat(PathBuffer
, KeyValue
);
3299 DPRINT("FullPath: '%S'\n", PathBuffer
);
3301 Status
= SetupCreateDirectory(PathBuffer
);
3302 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3304 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3305 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3309 } while (SetupFindNextLine (&DirContext
, &DirContext
));
3316 PrepareCopyPage(PINPUT_RECORD Ir
)
3319 WCHAR PathBuffer
[MAX_PATH
];
3320 INFCONTEXT CabinetsContext
;
3326 MUIDisplayPage(PREPARE_COPY_PAGE
);
3328 /* Create the file queue */
3329 SetupFileQueue
= SetupOpenFileQueue();
3330 if (SetupFileQueue
== NULL
)
3332 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3336 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3341 /* Search for the 'Cabinets' section */
3342 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3344 return FILE_COPY_PAGE
;
3348 * Enumerate the directory values in the 'Cabinets'
3349 * section and parse their inf files.
3353 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3356 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3357 wcscat(PathBuffer
, L
"\\");
3358 wcscat(PathBuffer
, KeyValue
);
3361 CabinetInitialize();
3362 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3363 CabinetSetCabinetName(PathBuffer
);
3365 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3367 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3369 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3370 if (InfFileData
== NULL
)
3372 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3378 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3379 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3383 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3390 if (InfHandle
== INVALID_HANDLE_VALUE
)
3392 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3398 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3403 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3405 return FILE_COPY_PAGE
;
3411 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3414 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3416 /* Get the memory information from the system */
3417 NtQuerySystemInformation(SystemPerformanceInformation
,
3422 /* Check if this is initial setup */
3425 /* Set maximum limits to be total RAM pages */
3426 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3427 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3428 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3431 /* Set current values */
3432 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3433 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3434 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3440 FileCopyCallback(PVOID Context
,
3445 PCOPYCONTEXT CopyContext
;
3447 CopyContext
= (PCOPYCONTEXT
)Context
;
3449 switch (Notification
)
3451 case SPFILENOTIFY_STARTSUBQUEUE
:
3452 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3453 ProgressSetStepCount(CopyContext
->ProgressBar
,
3454 CopyContext
->TotalOperations
);
3455 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3458 case SPFILENOTIFY_STARTCOPY
:
3459 /* Display copy message */
3460 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3461 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3464 case SPFILENOTIFY_ENDCOPY
:
3465 CopyContext
->CompletedOperations
++;
3467 /* SYSREG checkpoint */
3468 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3469 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3471 ProgressNextStep(CopyContext
->ProgressBar
);
3472 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3482 FileCopyPage(PINPUT_RECORD Ir
)
3484 COPYCONTEXT CopyContext
;
3485 unsigned int mem_bar_width
;
3487 MUIDisplayPage(FILE_COPY_PAGE
);
3489 /* Create context for the copy process */
3490 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3491 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3492 CopyContext
.TotalOperations
= 0;
3493 CopyContext
.CompletedOperations
= 0;
3495 /* Create the progress bar as well */
3496 CopyContext
.ProgressBar
= CreateProgressBar(13,
3503 MUIGetString(STRING_SETUPCOPYINGFILES
));
3505 // fit memory bars to screen width, distribute them uniform
3506 mem_bar_width
= (xScreen
- 26) / 5;
3507 mem_bar_width
-= mem_bar_width
% 2; // make even
3508 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3509 /* Create the paged pool progress bar */
3510 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3519 /* Create the non paged pool progress bar */
3520 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3522 (xScreen
/ 2) + (mem_bar_width
/ 2),
3524 (xScreen
/ 2)- (mem_bar_width
/ 2),
3529 /* Create the global memory progress bar */
3530 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3534 xScreen
- 13 - mem_bar_width
,
3539 /* Do the file copying */
3540 SetupCommitFileQueueW(NULL
,
3545 /* If we get here, we're done, so cleanup the queue and progress bar */
3546 SetupCloseFileQueue(SetupFileQueue
);
3547 DestroyProgressBar(CopyContext
.ProgressBar
);
3548 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3549 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3550 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3552 /* Go display the next page */
3553 return REGISTRY_PAGE
;
3558 RegistryPage(PINPUT_RECORD Ir
)
3560 INFCONTEXT InfContext
;
3567 MUIDisplayPage(REGISTRY_PAGE
);
3569 if (RepairUpdateFlag
)
3571 return SUCCESS_PAGE
;
3574 if (!SetInstallPathValue(&DestinationPath
))
3576 DPRINT("SetInstallPathValue() failed\n");
3577 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3581 /* Create the default hives */
3583 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3584 if (!NT_SUCCESS(Status
))
3586 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3587 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3591 RegInitializeRegistry();
3594 /* Update registry */
3595 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3597 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3599 DPRINT1("SetupFindFirstLine() failed\n");
3600 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3606 INF_GetDataField (&InfContext
, 0, &Action
);
3607 INF_GetDataField (&InfContext
, 1, &File
);
3608 INF_GetDataField (&InfContext
, 2, &Section
);
3610 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3615 if (!_wcsicmp (Action
, L
"AddReg"))
3619 else if (!_wcsicmp (Action
, L
"DelReg"))
3628 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3630 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3632 DPRINT("Importing %S failed\n", File
);
3634 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3637 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3639 /* Update display registry settings */
3640 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3641 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3643 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3647 /* Set the locale */
3648 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3649 if (!ProcessLocaleRegistry(LanguageList
))
3651 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3655 /* Add keyboard layouts */
3656 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3657 if (!AddKeyboardLayouts())
3659 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3665 if (!SetGeoID(MUIGetGeoID()))
3667 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3671 if (!IsUnattendedSetup
)
3673 /* Update keyboard layout settings */
3674 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3675 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3677 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3682 /* Add codepage information to registry */
3683 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3686 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3690 /* Set the default pagefile entry */
3691 SetDefaultPagefile(DestinationDriveLetter
);
3693 /* Update the mounted devices list */
3694 SetMountedDeviceValues(PartitionList
);
3696 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3698 return BOOT_LOADER_PAGE
;
3703 BootLoaderPage(PINPUT_RECORD Ir
)
3705 UCHAR PartitionType
;
3706 BOOLEAN InstallOnFloppy
;
3708 WCHAR PathBuffer
[MAX_PATH
];
3710 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3712 /* Find or set the active partition */
3713 CheckActiveBootPartition(PartitionList
);
3715 /* Update the partition table because we may have changed the active partition */
3716 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
3718 DPRINT("WritePartitionsToDisk() failed\n");
3719 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
3723 RtlFreeUnicodeString(&SystemRootPath
);
3724 swprintf(PathBuffer
,
3725 L
"\\Device\\Harddisk%lu\\Partition%lu",
3726 PartitionList
->ActiveBootDisk
->DiskNumber
,
3727 PartitionList
->ActiveBootPartition
->PartitionNumber
);
3728 RtlCreateUnicodeString(&SystemRootPath
,
3730 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3732 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3734 if (IsUnattendedSetup
)
3736 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3738 return SUCCESS_PAGE
;
3740 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3742 return BOOT_LOADER_FLOPPY_PAGE
;
3746 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3748 DPRINT("Error: active partition invalid (unused)\n");
3749 InstallOnFloppy
= TRUE
;
3751 else if (PartitionType
== 0x0A)
3753 /* OS/2 boot manager partition */
3754 DPRINT("Found OS/2 boot manager partition\n");
3755 InstallOnFloppy
= TRUE
;
3757 else if (PartitionType
== 0x83)
3759 /* Linux ext2 partition */
3760 DPRINT("Found Linux ext2 partition\n");
3761 InstallOnFloppy
= TRUE
;
3763 else if (PartitionType
== PARTITION_IFS
)
3765 /* NTFS partition */
3766 DPRINT("Found NTFS partition\n");
3767 InstallOnFloppy
= TRUE
;
3769 else if ((PartitionType
== PARTITION_FAT_12
) ||
3770 (PartitionType
== PARTITION_FAT_16
) ||
3771 (PartitionType
== PARTITION_HUGE
) ||
3772 (PartitionType
== PARTITION_XINT13
) ||
3773 (PartitionType
== PARTITION_FAT32
) ||
3774 (PartitionType
== PARTITION_FAT32_XINT13
))
3776 DPRINT("Found FAT partition\n");
3777 InstallOnFloppy
= FALSE
;
3781 /* Unknown partition */
3782 DPRINT("Unknown partition found\n");
3783 InstallOnFloppy
= TRUE
;
3786 if (InstallOnFloppy
== TRUE
)
3788 return BOOT_LOADER_FLOPPY_PAGE
;
3791 /* Unattended install on hdd? */
3792 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3794 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3797 MUIDisplayPage(BOOT_LOADER_PAGE
);
3798 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3802 CONSOLE_ConInKey(Ir
);
3804 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3805 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3807 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3816 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3818 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3819 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3821 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3830 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3832 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3833 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3835 if (ConfirmQuit(Ir
) == TRUE
)
3840 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3844 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3846 else if (Line
== 13)
3848 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
3850 else if (Line
== 14)
3852 return BOOT_LOADER_FLOPPY_PAGE
;
3854 else if (Line
== 15)
3856 return SUCCESS_PAGE
;
3859 return BOOT_LOADER_PAGE
;
3863 return BOOT_LOADER_PAGE
;
3868 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3872 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3874 // SetStatusText(" Please wait...");
3878 CONSOLE_ConInKey(Ir
);
3880 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3881 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3883 if (ConfirmQuit(Ir
) == TRUE
)
3888 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3890 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3892 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3893 return BOOT_LOADER_FLOPPY_PAGE
;
3896 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3897 if (!NT_SUCCESS(Status
))
3899 /* Print error message */
3900 return BOOT_LOADER_FLOPPY_PAGE
;
3903 return SUCCESS_PAGE
;
3907 return BOOT_LOADER_FLOPPY_PAGE
;
3911 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
3913 UCHAR PartitionType
;
3916 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3918 Status
= InstallVBRToPartition(&SystemRootPath
,
3920 &DestinationArcPath
,
3922 if (!NT_SUCCESS(Status
))
3924 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3928 return SUCCESS_PAGE
;
3932 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
3934 UCHAR PartitionType
;
3936 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
3937 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
3939 /* Step 1: Write the VBR */
3940 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3942 Status
= InstallVBRToPartition(&SystemRootPath
,
3944 &DestinationArcPath
,
3946 if (!NT_SUCCESS(Status
))
3948 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3952 /* Step 2: Write the MBR */
3953 swprintf(DestinationDevicePathBuffer
,
3954 L
"\\Device\\Harddisk%d\\Partition0",
3955 PartitionList
->ActiveBootDisk
->DiskNumber
);
3957 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
3958 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
3960 DPRINT("Install MBR bootcode: %S ==> %S\n",
3961 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
3963 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
3964 DestinationDevicePathBuffer
);
3965 if (!NT_SUCCESS (Status
))
3967 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
3969 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3973 return SUCCESS_PAGE
;
3978 QuitPage(PINPUT_RECORD Ir
)
3980 MUIDisplayPage(QUIT_PAGE
);
3982 /* Destroy partition list */
3983 if (PartitionList
!= NULL
)
3985 DestroyPartitionList (PartitionList
);
3986 PartitionList
= NULL
;
3989 /* Destroy filesystem list */
3990 if (FileSystemList
!= NULL
)
3992 DestroyFileSystemList (FileSystemList
);
3993 FileSystemList
= NULL
;
3996 /* Destroy computer settings list */
3997 if (ComputerList
!= NULL
)
3999 DestroyGenericList(ComputerList
, TRUE
);
4000 ComputerList
= NULL
;
4003 /* Destroy display settings list */
4004 if (DisplayList
!= NULL
)
4006 DestroyGenericList(DisplayList
, TRUE
);
4010 /* Destroy keyboard settings list */
4011 if (KeyboardList
!= NULL
)
4013 DestroyGenericList(KeyboardList
, TRUE
);
4014 KeyboardList
= NULL
;
4017 /* Destroy keyboard layout list */
4018 if (LayoutList
!= NULL
)
4020 DestroyGenericList(LayoutList
, TRUE
);
4024 if (LanguageList
!= NULL
)
4026 DestroyGenericList(LanguageList
, FALSE
);
4027 LanguageList
= NULL
;
4030 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4034 CONSOLE_ConInKey(Ir
);
4036 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4045 SuccessPage(PINPUT_RECORD Ir
)
4047 MUIDisplayPage(SUCCESS_PAGE
);
4049 if (IsUnattendedSetup
)
4056 CONSOLE_ConInKey(Ir
);
4058 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4067 FlushPage(PINPUT_RECORD Ir
)
4069 MUIDisplayPage(FLUSH_PAGE
);
4075 PnpEventThread(IN LPVOID lpParameter
);
4086 NtQuerySystemTime(&Time
);
4088 Status
= RtlCreateUserThread(NtCurrentProcess(),
4098 if (!NT_SUCCESS(Status
))
4099 hPnpThread
= INVALID_HANDLE_VALUE
;
4101 if (!CONSOLE_Init())
4103 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4104 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4105 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4107 /* Raise a hard error (crash the system/BSOD) */
4108 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4112 /* Initialize global unicode strings */
4113 RtlInitUnicodeString(&SourcePath
, NULL
);
4114 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4115 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4116 RtlInitUnicodeString(&InstallPath
, NULL
);
4117 RtlInitUnicodeString(&DestinationPath
, NULL
);
4118 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4119 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4120 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4122 /* Hide the cursor */
4123 CONSOLE_SetCursorType(TRUE
, FALSE
);
4126 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4128 CONSOLE_ClearScreen();
4131 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4138 Page
= SetupStartPage(&Ir
);
4143 Page
= LanguagePage(&Ir
);
4148 Page
= LicensePage(&Ir
);
4153 Page
= IntroPage(&Ir
);
4157 case INSTALL_INTRO_PAGE
:
4158 Page
= InstallIntroPage(&Ir
);
4162 case SCSI_CONTROLLER_PAGE
:
4163 Page
= ScsiControllerPage(&Ir
);
4168 case OEM_DRIVER_PAGE
:
4169 Page
= OemDriverPage(&Ir
);
4173 case DEVICE_SETTINGS_PAGE
:
4174 Page
= DeviceSettingsPage(&Ir
);
4177 case COMPUTER_SETTINGS_PAGE
:
4178 Page
= ComputerSettingsPage(&Ir
);
4181 case DISPLAY_SETTINGS_PAGE
:
4182 Page
= DisplaySettingsPage(&Ir
);
4185 case KEYBOARD_SETTINGS_PAGE
:
4186 Page
= KeyboardSettingsPage(&Ir
);
4189 case LAYOUT_SETTINGS_PAGE
:
4190 Page
= LayoutSettingsPage(&Ir
);
4193 case SELECT_PARTITION_PAGE
:
4194 Page
= SelectPartitionPage(&Ir
);
4197 case CREATE_PRIMARY_PARTITION_PAGE
:
4198 Page
= CreatePrimaryPartitionPage(&Ir
);
4201 case CREATE_EXTENDED_PARTITION_PAGE
:
4202 Page
= CreateExtendedPartitionPage(&Ir
);
4205 case CREATE_LOGICAL_PARTITION_PAGE
:
4206 Page
= CreateLogicalPartitionPage(&Ir
);
4209 case DELETE_PARTITION_PAGE
:
4210 Page
= DeletePartitionPage(&Ir
);
4213 case SELECT_FILE_SYSTEM_PAGE
:
4214 Page
= SelectFileSystemPage(&Ir
);
4217 case FORMAT_PARTITION_PAGE
:
4218 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4221 case CHECK_FILE_SYSTEM_PAGE
:
4222 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4225 case INSTALL_DIRECTORY_PAGE
:
4226 Page
= InstallDirectoryPage(&Ir
);
4229 case PREPARE_COPY_PAGE
:
4230 Page
= PrepareCopyPage(&Ir
);
4233 case FILE_COPY_PAGE
:
4234 Page
= FileCopyPage(&Ir
);
4238 Page
= RegistryPage(&Ir
);
4241 case BOOT_LOADER_PAGE
:
4242 Page
= BootLoaderPage(&Ir
);
4245 case BOOT_LOADER_FLOPPY_PAGE
:
4246 Page
= BootLoaderFloppyPage(&Ir
);
4249 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4250 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4253 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4254 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4258 case REPAIR_INTRO_PAGE
:
4259 Page
= RepairIntroPage(&Ir
);
4263 Page
= SuccessPage(&Ir
);
4267 Page
= FlushPage(&Ir
);
4271 Page
= QuitPage(&Ir
);
4280 if (Page
== RECOVERY_PAGE
)
4285 /* Avoid bugcheck */
4286 Time
.QuadPart
+= 50000000;
4287 NtDelayExecution(FALSE
, &Time
);
4290 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4291 NtShutdownSystem(ShutdownReboot
);
4292 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4293 NtTerminateProcess(NtCurrentProcess(), 0);
4300 NtProcessStartup(PPEB Peb
)
4302 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4304 ProcessHeap
= Peb
->ProcessHeap
;
4305 InfSetHeap(ProcessHeap
);
4308 #endif /* __REACTOS__ */