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
;
1681 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1682 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1683 #define PARTITION_MAXSIZE 999999
1686 ShowPartitionSizeInputBox(SHORT Left
,
1699 WCHAR PartitionSizeBuffer
[100];
1711 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1716 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1717 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1720 WriteConsoleOutputCharacterA(StdOutput
,
1726 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1727 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1729 WriteConsoleOutputCharacterA(StdOutput
,
1735 swprintf(PartitionSizeBuffer
, L
"%lu", MaxSize
);
1736 Index
= wcslen(PartitionSizeBuffer
);
1737 CONSOLE_SetInputTextXY(iLeft
,
1739 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1740 PartitionSizeBuffer
);
1744 CONSOLE_ConInKey(&Ir
);
1746 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1747 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1752 PartitionSizeBuffer
[0] = 0;
1755 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1759 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1764 PartitionSizeBuffer
[0] = 0;
1767 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1771 PartitionSizeBuffer
[Index
] = 0;
1773 CONSOLE_SetInputTextXY(iLeft
,
1775 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1776 PartitionSizeBuffer
);
1778 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1779 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1781 ch
= (WCHAR
)Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1783 if ((ch
>= L
'0') && (ch
<= L
'9'))
1785 PartitionSizeBuffer
[Index
] = ch
;
1787 PartitionSizeBuffer
[Index
] = 0;
1789 CONSOLE_SetInputTextXY(iLeft
,
1791 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1792 PartitionSizeBuffer
);
1797 /* Convert UNICODE --> ANSI the poor man's way */
1798 sprintf(InputBuffer
, "%S", PartitionSizeBuffer
);
1803 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1805 PDISKENTRY DiskEntry
;
1806 PPARTENTRY PartEntry
;
1809 CHAR InputBuffer
[50];
1813 ULONGLONG SectorCount
;
1816 if (PartitionList
== NULL
||
1817 PartitionList
->CurrentDisk
== NULL
||
1818 PartitionList
->CurrentPartition
== NULL
)
1820 /* FIXME: show an error dialog */
1824 DiskEntry
= PartitionList
->CurrentDisk
;
1825 PartEntry
= PartitionList
->CurrentPartition
;
1827 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1829 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1831 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1833 if (DiskSize
>= 10737418240) /* 10 GB */
1835 DiskSize
= DiskSize
/ 1073741824;
1836 Unit
= MUIGetString(STRING_GB
);
1841 DiskSize
= DiskSize
/ 1048576;
1845 Unit
= MUIGetString(STRING_MB
);
1848 if (DiskEntry
->DriverName
.Length
> 0)
1850 CONSOLE_PrintTextXY(6, 10,
1851 MUIGetString(STRING_HDINFOPARTCREATE
),
1854 DiskEntry
->DiskNumber
,
1858 &DiskEntry
->DriverName
);
1862 CONSOLE_PrintTextXY(6, 10,
1863 MUIGetString(STRING_HDDINFOUNK1
),
1866 DiskEntry
->DiskNumber
,
1872 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1875 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1876 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
1879 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1881 PartEntry
= PartitionList
->CurrentPartition
;
1884 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
1886 if (MaxSize
> PARTITION_MAXSIZE
)
1887 MaxSize
= PARTITION_MAXSIZE
;
1889 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1890 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1894 if (ConfirmQuit (Ir
) == TRUE
)
1899 else if (Cancel
== TRUE
)
1901 return SELECT_PARTITION_PAGE
;
1905 PartSize
= atoi(InputBuffer
);
1913 if (PartSize
> MaxSize
)
1919 /* Convert to bytes */
1920 if (PartSize
== MaxSize
)
1922 /* Use all of the unpartitioned disk space */
1923 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1927 /* Calculate the sector count from the size in MB */
1928 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
1930 /* But never get larger than the unpartitioned disk space */
1931 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
1932 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1935 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1937 CreatePrimaryPartition(PartitionList
,
1941 return SELECT_PARTITION_PAGE
;
1945 return CREATE_PRIMARY_PARTITION_PAGE
;
1950 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
1952 PDISKENTRY DiskEntry
;
1953 PPARTENTRY PartEntry
;
1956 CHAR InputBuffer
[50];
1960 ULONGLONG SectorCount
;
1963 if (PartitionList
== NULL
||
1964 PartitionList
->CurrentDisk
== NULL
||
1965 PartitionList
->CurrentPartition
== NULL
)
1967 /* FIXME: show an error dialog */
1971 DiskEntry
= PartitionList
->CurrentDisk
;
1972 PartEntry
= PartitionList
->CurrentPartition
;
1974 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1976 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
1978 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1980 if (DiskSize
>= 10737418240) /* 10 GB */
1982 DiskSize
= DiskSize
/ 1073741824;
1983 Unit
= MUIGetString(STRING_GB
);
1988 DiskSize
= DiskSize
/ 1048576;
1992 Unit
= MUIGetString(STRING_MB
);
1995 if (DiskEntry
->DriverName
.Length
> 0)
1997 CONSOLE_PrintTextXY(6, 10,
1998 MUIGetString(STRING_HDINFOPARTCREATE
),
2001 DiskEntry
->DiskNumber
,
2005 &DiskEntry
->DriverName
);
2009 CONSOLE_PrintTextXY(6, 10,
2010 MUIGetString(STRING_HDDINFOUNK1
),
2013 DiskEntry
->DiskNumber
,
2019 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2022 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2023 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2026 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2028 PartEntry
= PartitionList
->CurrentPartition
;
2031 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2033 if (MaxSize
> PARTITION_MAXSIZE
)
2034 MaxSize
= PARTITION_MAXSIZE
;
2036 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2037 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2041 if (ConfirmQuit (Ir
) == TRUE
)
2046 else if (Cancel
== TRUE
)
2048 return SELECT_PARTITION_PAGE
;
2052 PartSize
= atoi(InputBuffer
);
2060 if (PartSize
> MaxSize
)
2066 /* Convert to bytes */
2067 if (PartSize
== MaxSize
)
2069 /* Use all of the unpartitioned disk space */
2070 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2074 /* Calculate the sector count from the size in MB */
2075 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2077 /* But never get larger than the unpartitioned disk space */
2078 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2079 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2082 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2084 CreateExtendedPartition(PartitionList
,
2087 return SELECT_PARTITION_PAGE
;
2091 return CREATE_EXTENDED_PARTITION_PAGE
;
2096 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2098 PDISKENTRY DiskEntry
;
2099 PPARTENTRY PartEntry
;
2102 CHAR InputBuffer
[50];
2106 ULONGLONG SectorCount
;
2109 if (PartitionList
== NULL
||
2110 PartitionList
->CurrentDisk
== NULL
||
2111 PartitionList
->CurrentPartition
== NULL
)
2113 /* FIXME: show an error dialog */
2117 DiskEntry
= PartitionList
->CurrentDisk
;
2118 PartEntry
= PartitionList
->CurrentPartition
;
2120 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2122 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2124 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2126 if (DiskSize
>= 10737418240) /* 10 GB */
2128 DiskSize
= DiskSize
/ 1073741824;
2129 Unit
= MUIGetString(STRING_GB
);
2134 DiskSize
= DiskSize
/ 1048576;
2138 Unit
= MUIGetString(STRING_MB
);
2141 if (DiskEntry
->DriverName
.Length
> 0)
2143 CONSOLE_PrintTextXY(6, 10,
2144 MUIGetString(STRING_HDINFOPARTCREATE
),
2147 DiskEntry
->DiskNumber
,
2151 &DiskEntry
->DriverName
);
2155 CONSOLE_PrintTextXY(6, 10,
2156 MUIGetString(STRING_HDDINFOUNK1
),
2159 DiskEntry
->DiskNumber
,
2165 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2168 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2169 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2172 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2174 PartEntry
= PartitionList
->CurrentPartition
;
2177 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2179 if (MaxSize
> PARTITION_MAXSIZE
)
2180 MaxSize
= PARTITION_MAXSIZE
;
2182 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2183 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2187 if (ConfirmQuit (Ir
) == TRUE
)
2192 else if (Cancel
== TRUE
)
2194 return SELECT_PARTITION_PAGE
;
2198 PartSize
= atoi(InputBuffer
);
2206 if (PartSize
> MaxSize
)
2212 /* Convert to bytes */
2213 if (PartSize
== MaxSize
)
2215 /* Use all of the unpartitioned disk space */
2216 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2220 /* Calculate the sector count from the size in MB */
2221 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2223 /* But never get larger than the unpartitioned disk space */
2224 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2225 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2228 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2230 CreateLogicalPartition(PartitionList
,
2233 return SELECT_PARTITION_PAGE
;
2237 return CREATE_LOGICAL_PARTITION_PAGE
;
2242 DeletePartitionPage(PINPUT_RECORD Ir
)
2244 PDISKENTRY DiskEntry
;
2245 PPARTENTRY PartEntry
;
2251 if (PartitionList
== NULL
||
2252 PartitionList
->CurrentDisk
== NULL
||
2253 PartitionList
->CurrentPartition
== NULL
)
2255 /* FIXME: show an error dialog */
2259 DiskEntry
= PartitionList
->CurrentDisk
;
2260 PartEntry
= PartitionList
->CurrentPartition
;
2262 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2264 /* Determine partition type */
2266 if (PartEntry
->New
== TRUE
)
2268 PartType
= MUIGetString(STRING_UNFORMATTED
);
2270 else if (PartEntry
->IsPartitioned
== TRUE
)
2272 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2273 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2274 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2275 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2279 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2280 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2284 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2288 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2290 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2292 else if (IsContainerPartition(PartEntry
->PartitionType
))
2294 PartType
= MUIGetString(STRING_EXTENDED_PARTITION
);
2298 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2300 if (PartSize
>= 10737418240) /* 10 GB */
2302 PartSize
= PartSize
/ 1073741824;
2303 Unit
= MUIGetString(STRING_GB
);
2307 if (PartSize
>= 10485760) /* 10 MB */
2309 PartSize
= PartSize
/ 1048576;
2310 Unit
= MUIGetString(STRING_MB
);
2314 PartSize
= PartSize
/ 1024;
2315 Unit
= MUIGetString(STRING_KB
);
2318 if (PartType
== NULL
)
2320 CONSOLE_PrintTextXY(6, 10,
2321 MUIGetString(STRING_HDDINFOUNK2
),
2322 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2323 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2324 PartEntry
->PartitionType
,
2330 CONSOLE_PrintTextXY(6, 10,
2331 " %c%c %s %I64u %s",
2332 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2333 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2339 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2341 if (DiskSize
>= 10737418240) /* 10 GB */
2343 DiskSize
= DiskSize
/ 1073741824;
2344 Unit
= MUIGetString(STRING_GB
);
2349 DiskSize
= DiskSize
/ 1048576;
2353 Unit
= MUIGetString(STRING_MB
);
2356 if (DiskEntry
->DriverName
.Length
> 0)
2358 CONSOLE_PrintTextXY(6, 12,
2359 MUIGetString(STRING_HDINFOPARTDELETE
),
2362 DiskEntry
->DiskNumber
,
2366 &DiskEntry
->DriverName
);
2370 CONSOLE_PrintTextXY(6, 12,
2371 MUIGetString(STRING_HDDINFOUNK3
),
2374 DiskEntry
->DiskNumber
,
2382 CONSOLE_ConInKey(Ir
);
2384 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2385 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2387 if (ConfirmQuit(Ir
) == TRUE
)
2394 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2396 return SELECT_PARTITION_PAGE
;
2398 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2400 DeleteCurrentPartition(PartitionList
);
2402 return SELECT_PARTITION_PAGE
;
2406 return DELETE_PARTITION_PAGE
;
2411 SelectFileSystemPage(PINPUT_RECORD Ir
)
2413 PDISKENTRY DiskEntry
;
2414 PPARTENTRY PartEntry
;
2421 DPRINT("SelectFileSystemPage()\n");
2423 if (PartitionList
== NULL
||
2424 PartitionList
->CurrentDisk
== NULL
||
2425 PartitionList
->CurrentPartition
== NULL
)
2427 /* FIXME: show an error dialog */
2431 /* Find or set the active partition */
2432 CheckActiveBootPartition(PartitionList
);
2434 if (PartitionList
->BootDisk
== NULL
||
2435 PartitionList
->BootPartition
== NULL
)
2437 /* FIXME: show an error dialog */
2441 switch (PartitionList
->FormatState
)
2444 if (PartitionList
->CurrentPartition
!= PartitionList
->BootPartition
)
2446 PartitionList
->TempDisk
= PartitionList
->BootDisk
;
2447 PartitionList
->TempPartition
= PartitionList
->BootPartition
;
2448 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2450 PartitionList
->FormatState
= FormatSystemPartition
;
2451 DPRINT1("FormatState: Start --> FormatSystemPartition\n");
2455 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2456 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2457 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2459 PartitionList
->FormatState
= FormatInstallPartition
;
2460 DPRINT1("FormatState: Start --> FormatInstallPartition\n");
2464 case FormatSystemPartition
:
2465 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2466 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2467 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2469 PartitionList
->FormatState
= FormatInstallPartition
;
2470 DPRINT1("FormatState: FormatSystemPartition --> FormatInstallPartition\n");
2473 case FormatInstallPartition
:
2474 if (GetNextUnformattedPartition(PartitionList
,
2475 &PartitionList
->TempDisk
,
2476 &PartitionList
->TempPartition
))
2478 PartitionList
->FormatState
= FormatOtherPartition
;
2479 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2480 DPRINT1("FormatState: FormatInstallPartition --> FormatOtherPartition\n");
2484 PartitionList
->FormatState
= FormatDone
;
2485 DPRINT1("FormatState: FormatInstallPartition --> FormatDone\n");
2486 return CHECK_FILE_SYSTEM_PAGE
;
2490 case FormatOtherPartition
:
2491 if (GetNextUnformattedPartition(PartitionList
,
2492 &PartitionList
->TempDisk
,
2493 &PartitionList
->TempPartition
))
2495 PartitionList
->FormatState
= FormatOtherPartition
;
2496 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2497 DPRINT1("FormatState: FormatOtherPartition --> FormatOtherPartition\n");
2501 PartitionList
->FormatState
= FormatDone
;
2502 DPRINT1("FormatState: FormatOtherPartition --> FormatDone\n");
2503 return CHECK_FILE_SYSTEM_PAGE
;
2508 DPRINT1("FormatState: Invalid value %ld\n", PartitionList
->FormatState
);
2509 /* FIXME: show an error dialog */
2513 DiskEntry
= PartitionList
->TempDisk
;
2514 PartEntry
= PartitionList
->TempPartition
;
2516 /* adjust disk size */
2517 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2518 if (DiskSize
>= 10737418240) /* 10 GB */
2520 DiskSize
= DiskSize
/ 1073741824;
2521 DiskUnit
= MUIGetString(STRING_GB
);
2525 DiskSize
= DiskSize
/ 1048576;
2526 DiskUnit
= MUIGetString(STRING_MB
);
2529 /* adjust partition size */
2530 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2531 if (PartSize
>= 10737418240) /* 10 GB */
2533 PartSize
= PartSize
/ 1073741824;
2534 PartUnit
= MUIGetString(STRING_GB
);
2538 PartSize
= PartSize
/ 1048576;
2539 PartUnit
= MUIGetString(STRING_MB
);
2542 /* adjust partition type */
2543 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2544 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2545 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2546 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2550 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2551 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2555 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2559 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2561 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2563 else if (PartEntry
->PartitionType
== PARTITION_ENTRY_UNUSED
)
2565 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2569 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2572 if (PartEntry
->AutoCreate
== TRUE
)
2574 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2577 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2578 PartEntry
->PartitionNumber
,
2584 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2585 DiskEntry
->DiskNumber
,
2591 &DiskEntry
->DriverName
);
2593 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2596 PartEntry
->AutoCreate
= FALSE
;
2598 else if (PartEntry
->New
== TRUE
)
2600 switch (PartitionList
->FormatState
)
2602 case FormatSystemPartition
:
2603 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2606 case FormatInstallPartition
:
2607 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2610 case FormatOtherPartition
:
2611 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2618 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2622 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2624 if (PartType
== NULL
)
2626 CONSOLE_PrintTextXY(8, 10,
2627 MUIGetString(STRING_HDDINFOUNK4
),
2628 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2629 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2630 PartEntry
->PartitionType
,
2636 CONSOLE_PrintTextXY(8, 10,
2638 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2639 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2645 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2646 DiskEntry
->DiskNumber
,
2652 &DiskEntry
->DriverName
);
2655 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2657 if (FileSystemList
== NULL
)
2659 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2660 if (FileSystemList
== NULL
)
2662 /* FIXME: show an error dialog */
2666 /* FIXME: Add file systems to list */
2669 DrawFileSystemList(FileSystemList
);
2671 if (RepairUpdateFlag
)
2673 return CHECK_FILE_SYSTEM_PAGE
;
2674 //return SELECT_PARTITION_PAGE;
2677 if (IsUnattendedSetup
)
2679 if (UnattendFormatPartition
)
2681 PartEntry
->FileSystem
= GetFileSystemByName(FileSystemList
,
2683 return FORMAT_PARTITION_PAGE
;
2686 return CHECK_FILE_SYSTEM_PAGE
;
2691 CONSOLE_ConInKey(Ir
);
2693 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2694 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2696 if (ConfirmQuit(Ir
) == TRUE
)
2703 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2704 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2706 return SELECT_PARTITION_PAGE
;
2708 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2709 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2711 ScrollDownFileSystemList(FileSystemList
);
2713 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2714 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2716 ScrollUpFileSystemList(FileSystemList
);
2718 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2720 if (!FileSystemList
->Selected
->FormatFunc
)
2722 return SELECT_FILE_SYSTEM_PAGE
;
2726 PartEntry
->FileSystem
= FileSystemList
->Selected
;
2727 return FORMAT_PARTITION_PAGE
;
2732 return SELECT_FILE_SYSTEM_PAGE
;
2737 FormatPartitionPage(PINPUT_RECORD Ir
)
2739 UNICODE_STRING PartitionRootPath
;
2740 WCHAR PathBuffer
[MAX_PATH
];
2741 PDISKENTRY DiskEntry
;
2742 PPARTENTRY PartEntry
;
2751 DPRINT("FormatPartitionPage()\n");
2753 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2755 if (PartitionList
== NULL
||
2756 PartitionList
->TempDisk
== NULL
||
2757 PartitionList
->TempPartition
== NULL
)
2759 /* FIXME: show an error dialog */
2763 DiskEntry
= PartitionList
->TempDisk
;
2764 PartEntry
= PartitionList
->TempPartition
;
2768 if (!IsUnattendedSetup
)
2770 CONSOLE_ConInKey(Ir
);
2773 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2774 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2776 if (ConfirmQuit(Ir
) == TRUE
)
2783 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2785 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2787 if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"FAT") == 0)
2789 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2791 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2792 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2794 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2796 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2798 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2800 /* FAT16 CHS partition (partiton size < 32MB) */
2801 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2803 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2805 /* FAT16 CHS partition (partition size < 512MB) */
2806 PartEntry
->PartitionType
= PARTITION_HUGE
;
2810 /* FAT32 CHS partition (partition size >= 512MB) */
2811 PartEntry
->PartitionType
= PARTITION_FAT32
;
2816 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2818 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2820 /* FAT16 LBA partition (partition size < 512MB) */
2821 PartEntry
->PartitionType
= PARTITION_XINT13
;
2825 /* FAT32 LBA partition (partition size >= 512MB) */
2826 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2830 DiskEntry
->Dirty
= TRUE
;
2831 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2832 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2835 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"EXT2") == 0)
2837 PartEntry
->PartitionType
= PARTITION_EXT2
;
2839 DiskEntry
->Dirty
= TRUE
;
2840 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2841 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2844 else if (!PartEntry
->FileSystem
->FormatFunc
)
2850 CONSOLE_PrintTextXY(6, 12,
2851 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2852 DiskEntry
->DiskSize
,
2853 DiskEntry
->CylinderSize
,
2854 DiskEntry
->TrackSize
);
2857 DiskEntry
= PartitionList
->TempDisk
;
2858 Entry
= DiskEntry
->PartListHead
.Flink
;
2860 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2862 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2864 if (PartEntry
->IsPartitioned
== TRUE
)
2866 CONSOLE_PrintTextXY(6, Line
,
2867 "%2u: %2u %c %12I64u %12I64u %2u %c",
2869 PartEntry
->PartitionNumber
,
2870 PartEntry
->BootIndicator
? 'A' : '-',
2871 PartEntry
->StartSector
.QuadPart
,
2872 PartEntry
->SectorCount
.QuadPart
,
2873 PartEntry
->PartitionType
,
2874 PartEntry
->Dirty
? '*' : ' ');
2878 Entry
= Entry
->Flink
;
2881 /* Restore the old entry */
2882 PartEntry
= PartitionList
->TempPartition
;
2885 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2887 DPRINT("WritePartitionsToDisk() failed\n");
2888 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2892 /* Set PartitionRootPath */
2893 swprintf(PathBuffer
,
2894 L
"\\Device\\Harddisk%lu\\Partition%lu",
2895 DiskEntry
->DiskNumber
,
2896 PartEntry
->PartitionNumber
);
2897 RtlInitUnicodeString(&PartitionRootPath
,
2899 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
2901 if (PartEntry
->FileSystem
->FormatFunc
)
2903 Status
= FormatPartition(&PartitionRootPath
,
2904 PartEntry
->FileSystem
);
2905 if (!NT_SUCCESS(Status
))
2907 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2908 /* FIXME: show an error dialog */
2912 PartEntry
->New
= FALSE
;
2916 CONSOLE_SetStatusText(" Done. Press any key ...");
2917 CONSOLE_ConInKey(Ir
);
2920 return SELECT_FILE_SYSTEM_PAGE
;
2924 return FORMAT_PARTITION_PAGE
;
2929 CheckFileSystemPage(PINPUT_RECORD Ir
)
2931 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2932 UNICODE_STRING PartitionRootPath
;
2933 WCHAR PathBuffer
[MAX_PATH
];
2934 CHAR Buffer
[MAX_PATH
];
2935 LPWSTR FileSystemName
= NULL
;
2936 PDISKENTRY DiskEntry
;
2937 PPARTENTRY PartEntry
;
2940 if (PartitionList
== NULL
)
2942 /* FIXME: show an error dialog */
2946 if (!GetNextUncheckedPartition(PartitionList
,
2950 return INSTALL_DIRECTORY_PAGE
;
2953 /* Set PartitionRootPath */
2954 swprintf(PathBuffer
,
2955 L
"\\Device\\Harddisk%lu\\Partition%lu",
2956 DiskEntry
->DiskNumber
,
2957 PartEntry
->PartitionNumber
);
2958 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
2959 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
2961 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2963 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2965 CurrentFileSystem
= PartEntry
->FileSystem
;
2966 if (CurrentFileSystem
->FileSystemName
== NULL
)
2968 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2969 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2970 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2971 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2973 FileSystemName
= L
"FAT";
2975 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2976 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2978 FileSystemName
= L
"FAT32";
2980 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2982 FileSystemName
= L
"EXT2";
2984 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2986 FileSystemName
= L
"NTFS"; /* FIXME: Not quite correct! */
2989 if (FileSystemName
!= NULL
)
2990 CurrentFileSystem
= GetFileSystemByName(FileSystemList
,
2994 if (CurrentFileSystem
== NULL
|| CurrentFileSystem
->ChkdskFunc
== NULL
)
2997 "Setup is currently unable to check a partition formatted in %S.\n"
2999 " \x07 Press ENTER to continue Setup.\n"
3000 " \x07 Press F3 to quit Setup.",
3001 CurrentFileSystem
->FileSystemName
);
3004 MUIGetString(STRING_QUITCONTINUE
),
3005 NULL
, POPUP_WAIT_NONE
);
3009 CONSOLE_ConInKey(Ir
);
3011 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3012 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3014 if (ConfirmQuit(Ir
))
3017 return CHECK_FILE_SYSTEM_PAGE
;
3019 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3021 PartEntry
->NeedsCheck
= FALSE
;
3022 return CHECK_FILE_SYSTEM_PAGE
;
3028 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3029 if (!NT_SUCCESS(Status
))
3031 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3032 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
3033 "(Status 0x%08lx).\n", Status
);
3036 MUIGetString(STRING_REBOOTCOMPUTER
),
3037 Ir
, POPUP_WAIT_ENTER
);
3042 PartEntry
->NeedsCheck
= FALSE
;
3043 return CHECK_FILE_SYSTEM_PAGE
;
3049 InstallDirectoryPage1(PWCHAR InstallDir
,
3050 PDISKENTRY DiskEntry
,
3051 PPARTENTRY PartEntry
)
3053 WCHAR PathBuffer
[MAX_PATH
];
3055 /* Create 'InstallPath' string */
3056 RtlFreeUnicodeString(&InstallPath
);
3057 RtlCreateUnicodeString(&InstallPath
,
3060 /* Create 'DestinationRootPath' string */
3061 RtlFreeUnicodeString(&DestinationRootPath
);
3062 swprintf(PathBuffer
,
3063 L
"\\Device\\Harddisk%lu\\Partition%lu",
3064 DiskEntry
->DiskNumber
,
3065 PartEntry
->PartitionNumber
);
3066 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
3067 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
3069 /* Create 'DestinationPath' string */
3070 RtlFreeUnicodeString(&DestinationPath
);
3071 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3073 if (InstallDir
[0] != L
'\\')
3074 wcscat(PathBuffer
, L
"\\");
3076 wcscat(PathBuffer
, InstallDir
);
3077 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
3079 /* Create 'DestinationArcPath' */
3080 RtlFreeUnicodeString(&DestinationArcPath
);
3081 swprintf(PathBuffer
,
3082 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
3083 DiskEntry
->BiosDiskNumber
,
3084 PartEntry
->PartitionNumber
);
3086 if (InstallDir
[0] != L
'\\')
3087 wcscat(PathBuffer
, L
"\\");
3089 wcscat(PathBuffer
, InstallDir
);
3090 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3092 return PREPARE_COPY_PAGE
;
3097 InstallDirectoryPage(PINPUT_RECORD Ir
)
3099 PDISKENTRY DiskEntry
;
3100 PPARTENTRY PartEntry
;
3101 WCHAR InstallDir
[51];
3104 /* We do not need the filsystem list any more */
3105 DestroyFileSystemList(FileSystemList
);
3106 FileSystemList
= NULL
;
3108 if (PartitionList
== NULL
||
3109 PartitionList
->CurrentDisk
== NULL
||
3110 PartitionList
->CurrentPartition
== NULL
)
3112 /* FIXME: show an error dialog */
3116 DiskEntry
= PartitionList
->CurrentDisk
;
3117 PartEntry
= PartitionList
->CurrentPartition
;
3119 if (IsUnattendedSetup
)
3120 wcscpy(InstallDir
, UnattendInstallationDirectory
);
3122 wcscpy(InstallDir
, L
"\\ReactOS");
3124 Length
= wcslen(InstallDir
);
3125 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3126 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3128 // FIXME: Check the validity of the InstallDir; however what to do
3129 // if it is invalid but we are in unattended setup? (case of somebody
3130 // specified an invalid installation directory in the unattended file).
3132 if (IsUnattendedSetup
)
3134 return InstallDirectoryPage1(InstallDir
,
3141 CONSOLE_ConInKey(Ir
);
3143 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3144 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3146 if (ConfirmQuit(Ir
) == TRUE
)
3151 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3154 * Check for the validity of the installation directory and pop up
3155 * an error if it is not the case. Then the user can fix its input.
3157 if (!IsValidPath(InstallDir
, Length
))
3159 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3160 return INSTALL_DIRECTORY_PAGE
;
3162 return InstallDirectoryPage1(InstallDir
,
3166 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3171 InstallDir
[Length
] = 0;
3172 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3175 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3179 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3181 InstallDir
[Length
] = 0;
3182 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3187 return INSTALL_DIRECTORY_PAGE
;
3192 AddSectionToCopyQueueCab(HINF InfFile
,
3194 PWCHAR SourceCabinet
,
3195 PCUNICODE_STRING DestinationPath
,
3198 INFCONTEXT FilesContext
;
3199 INFCONTEXT DirContext
;
3201 PWCHAR FileKeyValue
;
3203 PWCHAR TargetFileName
;
3205 /* Search for the SectionName section */
3206 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3209 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3210 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3215 * Enumerate the files in the section
3216 * and add them to the file queue.
3220 /* Get source file name and target directory id */
3221 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3223 /* FIXME: Handle error! */
3224 DPRINT1("INF_GetData() failed\n");
3228 /* Get optional target file name */
3229 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3230 TargetFileName
= NULL
;
3232 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3234 /* Lookup target directory */
3235 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3237 /* FIXME: Handle error! */
3238 DPRINT1("SetupFindFirstLine() failed\n");
3242 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3244 /* FIXME: Handle error! */
3245 DPRINT1("INF_GetData() failed\n");
3249 if (!SetupQueueCopy(SetupFileQueue
,
3251 SourceRootPath
.Buffer
,
3252 SourceRootDir
.Buffer
,
3257 /* FIXME: Handle error! */
3258 DPRINT1("SetupQueueCopy() failed\n");
3260 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3267 AddSectionToCopyQueue(HINF InfFile
,
3269 PWCHAR SourceCabinet
,
3270 PCUNICODE_STRING DestinationPath
,
3273 INFCONTEXT FilesContext
;
3274 INFCONTEXT DirContext
;
3276 PWCHAR FileKeyValue
;
3278 PWCHAR TargetFileName
;
3280 WCHAR CompleteOrigDirName
[512];
3283 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3285 /* Search for the SectionName section */
3286 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3289 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3290 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3295 * Enumerate the files in the section
3296 * and add them to the file queue.
3300 /* Get source file name and target directory id */
3301 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3303 /* FIXME: Handle error! */
3304 DPRINT1("INF_GetData() failed\n");
3308 /* Get target directory id */
3309 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3311 /* FIXME: Handle error! */
3312 DPRINT1("INF_GetData() failed\n");
3316 /* Get optional target file name */
3317 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3318 TargetFileName
= NULL
;
3319 else if (!*TargetFileName
)
3320 TargetFileName
= NULL
;
3322 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3324 /* Lookup target directory */
3325 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3327 /* FIXME: Handle error! */
3328 DPRINT1("SetupFindFirstLine() failed\n");
3332 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3334 /* FIXME: Handle error! */
3335 DPRINT1("INF_GetData() failed\n");
3339 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3341 /* Installation path */
3342 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3344 else if (DirKeyValue
[0] == L
'\\')
3347 wcscpy(CompleteOrigDirName
, DirKeyValue
);
3349 else // if (DirKeyValue[0] != L'\\')
3351 /* Path relative to the installation path */
3352 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3353 wcscat(CompleteOrigDirName
, L
"\\");
3354 wcscat(CompleteOrigDirName
, DirKeyValue
);
3357 /* Remove trailing backslash */
3358 Length
= wcslen(CompleteOrigDirName
);
3359 if ((Length
> 0) && (CompleteOrigDirName
[Length
- 1] == L
'\\'))
3361 CompleteOrigDirName
[Length
- 1] = 0;
3364 if (!SetupQueueCopy(SetupFileQueue
,
3366 SourceRootPath
.Buffer
,
3367 CompleteOrigDirName
,
3372 /* FIXME: Handle error! */
3373 DPRINT1("SetupQueueCopy() failed\n");
3375 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3382 PrepareCopyPageInfFile(HINF InfFile
,
3383 PWCHAR SourceCabinet
,
3386 WCHAR PathBuffer
[MAX_PATH
];
3387 INFCONTEXT DirContext
;
3388 PWCHAR AdditionalSectionName
= NULL
;
3393 /* Add common files */
3394 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3397 /* Add specific files depending of computer type */
3398 if (SourceCabinet
== NULL
)
3400 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3403 if (AdditionalSectionName
)
3405 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3410 /* Create directories */
3414 * - Install directories like '\reactos\test' are not handled yet.
3415 * - Copying files to DestinationRootPath should be done from within
3416 * the SystemPartitionFiles section.
3417 * At the moment we check whether we specify paths like '\foo' or '\\' for that.
3418 * For installing to DestinationPath specify just '\' .
3421 /* Get destination path */
3422 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3424 /* Remove trailing backslash */
3425 Length
= wcslen(PathBuffer
);
3426 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3428 PathBuffer
[Length
- 1] = 0;
3431 /* Create the install directory */
3432 Status
= SetupCreateDirectory(PathBuffer
);
3433 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3435 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3436 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3440 /* Search for the 'Directories' section */
3441 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3445 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3449 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3455 /* Enumerate the directory values and create the subdirectories */
3458 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3464 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3466 /* Installation path */
3467 DPRINT("InstallationPath: '%S'\n", DirKeyValue
);
3469 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3471 DPRINT("FullPath: '%S'\n", PathBuffer
);
3473 else if (DirKeyValue
[0] == L
'\\')
3476 DPRINT("Absolute Path: '%S'\n", DirKeyValue
);
3478 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3479 wcscat(PathBuffer
, DirKeyValue
);
3481 /* Remove trailing backslash */
3482 Length
= wcslen(PathBuffer
);
3483 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3485 PathBuffer
[Length
- 1] = 0;
3488 DPRINT("FullPath: '%S'\n", PathBuffer
);
3490 Status
= SetupCreateDirectory(PathBuffer
);
3491 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3493 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3494 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3498 else // if (DirKeyValue[0] != L'\\')
3500 /* Path relative to the installation path */
3501 DPRINT("RelativePath: '%S'\n", DirKeyValue
);
3503 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3504 wcscat(PathBuffer
, L
"\\");
3505 wcscat(PathBuffer
, DirKeyValue
);
3507 /* Remove trailing backslash */
3508 Length
= wcslen(PathBuffer
);
3509 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3511 PathBuffer
[Length
- 1] = 0;
3514 DPRINT("FullPath: '%S'\n", PathBuffer
);
3516 Status
= SetupCreateDirectory(PathBuffer
);
3517 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3519 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3520 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3524 } while (SetupFindNextLine(&DirContext
, &DirContext
));
3531 PrepareCopyPage(PINPUT_RECORD Ir
)
3534 WCHAR PathBuffer
[MAX_PATH
];
3535 INFCONTEXT CabinetsContext
;
3541 MUIDisplayPage(PREPARE_COPY_PAGE
);
3543 /* Create the file queue */
3544 SetupFileQueue
= SetupOpenFileQueue();
3545 if (SetupFileQueue
== NULL
)
3547 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3551 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3556 /* Search for the 'Cabinets' section */
3557 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3559 return FILE_COPY_PAGE
;
3563 * Enumerate the directory values in the 'Cabinets'
3564 * section and parse their inf files.
3568 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3571 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3572 wcscat(PathBuffer
, L
"\\");
3573 wcscat(PathBuffer
, KeyValue
);
3576 CabinetInitialize();
3577 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3578 CabinetSetCabinetName(PathBuffer
);
3580 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3582 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3584 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3585 if (InfFileData
== NULL
)
3587 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3593 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3594 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3598 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3605 if (InfHandle
== INVALID_HANDLE_VALUE
)
3607 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3613 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3618 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3620 return FILE_COPY_PAGE
;
3626 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3629 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3631 /* Get the memory information from the system */
3632 NtQuerySystemInformation(SystemPerformanceInformation
,
3637 /* Check if this is initial setup */
3640 /* Set maximum limits to be total RAM pages */
3641 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3642 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3643 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3646 /* Set current values */
3647 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3648 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3649 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3655 FileCopyCallback(PVOID Context
,
3660 PCOPYCONTEXT CopyContext
;
3662 CopyContext
= (PCOPYCONTEXT
)Context
;
3664 switch (Notification
)
3666 case SPFILENOTIFY_STARTSUBQUEUE
:
3667 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3668 ProgressSetStepCount(CopyContext
->ProgressBar
,
3669 CopyContext
->TotalOperations
);
3670 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3673 case SPFILENOTIFY_STARTCOPY
:
3674 /* Display copy message */
3675 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3676 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3679 case SPFILENOTIFY_ENDCOPY
:
3680 CopyContext
->CompletedOperations
++;
3682 /* SYSREG checkpoint */
3683 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3684 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3686 ProgressNextStep(CopyContext
->ProgressBar
);
3687 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3697 FileCopyPage(PINPUT_RECORD Ir
)
3699 COPYCONTEXT CopyContext
;
3700 unsigned int mem_bar_width
;
3702 MUIDisplayPage(FILE_COPY_PAGE
);
3704 /* Create context for the copy process */
3705 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3706 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3707 CopyContext
.TotalOperations
= 0;
3708 CopyContext
.CompletedOperations
= 0;
3710 /* Create the progress bar as well */
3711 CopyContext
.ProgressBar
= CreateProgressBar(13,
3718 MUIGetString(STRING_SETUPCOPYINGFILES
));
3720 // fit memory bars to screen width, distribute them uniform
3721 mem_bar_width
= (xScreen
- 26) / 5;
3722 mem_bar_width
-= mem_bar_width
% 2; // make even
3723 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3724 /* Create the paged pool progress bar */
3725 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3734 /* Create the non paged pool progress bar */
3735 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3737 (xScreen
/ 2) + (mem_bar_width
/ 2),
3739 (xScreen
/ 2)- (mem_bar_width
/ 2),
3744 /* Create the global memory progress bar */
3745 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3749 xScreen
- 13 - mem_bar_width
,
3754 /* Do the file copying */
3755 SetupCommitFileQueueW(NULL
,
3760 /* If we get here, we're done, so cleanup the queue and progress bar */
3761 SetupCloseFileQueue(SetupFileQueue
);
3762 DestroyProgressBar(CopyContext
.ProgressBar
);
3763 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3764 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3765 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3767 /* Go display the next page */
3768 return REGISTRY_PAGE
;
3773 RegistryPage(PINPUT_RECORD Ir
)
3775 INFCONTEXT InfContext
;
3782 MUIDisplayPage(REGISTRY_PAGE
);
3784 if (RepairUpdateFlag
)
3786 return SUCCESS_PAGE
;
3789 if (!SetInstallPathValue(&DestinationPath
))
3791 DPRINT1("SetInstallPathValue() failed\n");
3792 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3796 /* Create the default hives */
3798 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3799 if (!NT_SUCCESS(Status
))
3801 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3802 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3806 RegInitializeRegistry();
3809 /* Update registry */
3810 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3812 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3814 DPRINT1("SetupFindFirstLine() failed\n");
3815 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3821 INF_GetDataField (&InfContext
, 0, &Action
);
3822 INF_GetDataField (&InfContext
, 1, &File
);
3823 INF_GetDataField (&InfContext
, 2, &Section
);
3825 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3830 if (!_wcsicmp (Action
, L
"AddReg"))
3834 else if (!_wcsicmp (Action
, L
"DelReg"))
3843 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3845 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3847 DPRINT1("Importing %S failed\n", File
);
3849 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3852 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3854 /* Update display registry settings */
3855 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3856 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3858 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3862 /* Set the locale */
3863 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3864 if (!ProcessLocaleRegistry(LanguageList
))
3866 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3870 /* Add keyboard layouts */
3871 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3872 if (!AddKeyboardLayouts())
3874 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3880 if (!SetGeoID(MUIGetGeoID()))
3882 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3886 if (!IsUnattendedSetup
)
3888 /* Update keyboard layout settings */
3889 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3890 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3892 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3897 /* Add codepage information to registry */
3898 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3901 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3905 /* Set the default pagefile entry */
3906 SetDefaultPagefile(DestinationDriveLetter
);
3908 /* Update the mounted devices list */
3909 SetMountedDeviceValues(PartitionList
);
3911 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3913 return BOOT_LOADER_PAGE
;
3918 BootLoaderPage(PINPUT_RECORD Ir
)
3920 UCHAR PartitionType
;
3921 BOOLEAN InstallOnFloppy
;
3923 WCHAR PathBuffer
[MAX_PATH
];
3925 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3927 RtlFreeUnicodeString(&SystemRootPath
);
3928 swprintf(PathBuffer
,
3929 L
"\\Device\\Harddisk%lu\\Partition%lu",
3930 PartitionList
->BootDisk
->DiskNumber
,
3931 PartitionList
->BootPartition
->PartitionNumber
);
3932 RtlCreateUnicodeString(&SystemRootPath
,
3934 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3936 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
3938 if (IsUnattendedSetup
)
3940 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3942 return SUCCESS_PAGE
;
3944 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3946 return BOOT_LOADER_FLOPPY_PAGE
;
3950 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3952 DPRINT("Error: active partition invalid (unused)\n");
3953 InstallOnFloppy
= TRUE
;
3955 else if (PartitionType
== 0x0A)
3957 /* OS/2 boot manager partition */
3958 DPRINT("Found OS/2 boot manager partition\n");
3959 InstallOnFloppy
= TRUE
;
3961 else if (PartitionType
== 0x83)
3963 /* Linux ext2 partition */
3964 DPRINT("Found Linux ext2 partition\n");
3965 InstallOnFloppy
= TRUE
;
3967 else if (PartitionType
== PARTITION_IFS
)
3969 /* NTFS partition */
3970 DPRINT("Found NTFS partition\n");
3971 InstallOnFloppy
= TRUE
;
3973 else if ((PartitionType
== PARTITION_FAT_12
) ||
3974 (PartitionType
== PARTITION_FAT_16
) ||
3975 (PartitionType
== PARTITION_HUGE
) ||
3976 (PartitionType
== PARTITION_XINT13
) ||
3977 (PartitionType
== PARTITION_FAT32
) ||
3978 (PartitionType
== PARTITION_FAT32_XINT13
))
3980 DPRINT("Found FAT partition\n");
3981 InstallOnFloppy
= FALSE
;
3985 /* Unknown partition */
3986 DPRINT("Unknown partition found\n");
3987 InstallOnFloppy
= TRUE
;
3990 if (InstallOnFloppy
== TRUE
)
3992 return BOOT_LOADER_FLOPPY_PAGE
;
3995 /* Unattended install on hdd? */
3996 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3998 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4001 MUIDisplayPage(BOOT_LOADER_PAGE
);
4002 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4006 CONSOLE_ConInKey(Ir
);
4008 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4009 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
4011 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4020 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4022 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4023 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
4025 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4034 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4036 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4037 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4039 if (ConfirmQuit(Ir
) == TRUE
)
4044 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4048 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4050 else if (Line
== 13)
4052 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4054 else if (Line
== 14)
4056 return BOOT_LOADER_FLOPPY_PAGE
;
4058 else if (Line
== 15)
4060 return SUCCESS_PAGE
;
4063 return BOOT_LOADER_PAGE
;
4067 return BOOT_LOADER_PAGE
;
4072 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4076 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4078 // SetStatusText(" Please wait...");
4082 CONSOLE_ConInKey(Ir
);
4084 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4085 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4087 if (ConfirmQuit(Ir
) == TRUE
)
4092 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4094 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
4096 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4097 return BOOT_LOADER_FLOPPY_PAGE
;
4100 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
4101 if (!NT_SUCCESS(Status
))
4103 /* Print error message */
4104 return BOOT_LOADER_FLOPPY_PAGE
;
4107 return SUCCESS_PAGE
;
4111 return BOOT_LOADER_FLOPPY_PAGE
;
4116 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4118 UCHAR PartitionType
;
4121 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
4123 Status
= InstallVBRToPartition(&SystemRootPath
,
4125 &DestinationArcPath
,
4127 if (!NT_SUCCESS(Status
))
4129 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4133 return SUCCESS_PAGE
;
4138 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4140 UCHAR PartitionType
;
4142 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4143 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
4145 /* Step 1: Write the VBR */
4146 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
4148 Status
= InstallVBRToPartition(&SystemRootPath
,
4150 &DestinationArcPath
,
4152 if (!NT_SUCCESS(Status
))
4154 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4158 /* Step 2: Write the MBR */
4159 swprintf(DestinationDevicePathBuffer
,
4160 L
"\\Device\\Harddisk%d\\Partition0",
4161 PartitionList
->BootDisk
->DiskNumber
);
4163 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4164 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4166 DPRINT("Install MBR bootcode: %S ==> %S\n",
4167 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4169 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4170 DestinationDevicePathBuffer
);
4171 if (!NT_SUCCESS (Status
))
4173 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4175 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4179 return SUCCESS_PAGE
;
4184 QuitPage(PINPUT_RECORD Ir
)
4186 MUIDisplayPage(QUIT_PAGE
);
4188 /* Destroy partition list */
4189 if (PartitionList
!= NULL
)
4191 DestroyPartitionList (PartitionList
);
4192 PartitionList
= NULL
;
4195 /* Destroy filesystem list */
4196 if (FileSystemList
!= NULL
)
4198 DestroyFileSystemList (FileSystemList
);
4199 FileSystemList
= NULL
;
4202 /* Destroy computer settings list */
4203 if (ComputerList
!= NULL
)
4205 DestroyGenericList(ComputerList
, TRUE
);
4206 ComputerList
= NULL
;
4209 /* Destroy display settings list */
4210 if (DisplayList
!= NULL
)
4212 DestroyGenericList(DisplayList
, TRUE
);
4216 /* Destroy keyboard settings list */
4217 if (KeyboardList
!= NULL
)
4219 DestroyGenericList(KeyboardList
, TRUE
);
4220 KeyboardList
= NULL
;
4223 /* Destroy keyboard layout list */
4224 if (LayoutList
!= NULL
)
4226 DestroyGenericList(LayoutList
, TRUE
);
4230 if (LanguageList
!= NULL
)
4232 DestroyGenericList(LanguageList
, FALSE
);
4233 LanguageList
= NULL
;
4236 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4240 CONSOLE_ConInKey(Ir
);
4242 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4251 SuccessPage(PINPUT_RECORD Ir
)
4253 MUIDisplayPage(SUCCESS_PAGE
);
4255 if (IsUnattendedSetup
)
4262 CONSOLE_ConInKey(Ir
);
4264 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4273 FlushPage(PINPUT_RECORD Ir
)
4275 MUIDisplayPage(FLUSH_PAGE
);
4281 PnpEventThread(IN LPVOID lpParameter
);
4292 NtQuerySystemTime(&Time
);
4294 Status
= RtlCreateUserThread(NtCurrentProcess(),
4304 if (!NT_SUCCESS(Status
))
4305 hPnpThread
= INVALID_HANDLE_VALUE
;
4307 if (!CONSOLE_Init())
4309 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4310 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4311 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4313 /* Raise a hard error (crash the system/BSOD) */
4314 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4318 /* Initialize global unicode strings */
4319 RtlInitUnicodeString(&SourcePath
, NULL
);
4320 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4321 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4322 RtlInitUnicodeString(&InstallPath
, NULL
);
4323 RtlInitUnicodeString(&DestinationPath
, NULL
);
4324 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4325 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4326 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4328 /* Hide the cursor */
4329 CONSOLE_SetCursorType(TRUE
, FALSE
);
4332 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4334 CONSOLE_ClearScreen();
4337 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4344 Page
= SetupStartPage(&Ir
);
4349 Page
= LanguagePage(&Ir
);
4354 Page
= LicensePage(&Ir
);
4359 Page
= IntroPage(&Ir
);
4363 case INSTALL_INTRO_PAGE
:
4364 Page
= InstallIntroPage(&Ir
);
4368 case SCSI_CONTROLLER_PAGE
:
4369 Page
= ScsiControllerPage(&Ir
);
4374 case OEM_DRIVER_PAGE
:
4375 Page
= OemDriverPage(&Ir
);
4379 case DEVICE_SETTINGS_PAGE
:
4380 Page
= DeviceSettingsPage(&Ir
);
4383 case COMPUTER_SETTINGS_PAGE
:
4384 Page
= ComputerSettingsPage(&Ir
);
4387 case DISPLAY_SETTINGS_PAGE
:
4388 Page
= DisplaySettingsPage(&Ir
);
4391 case KEYBOARD_SETTINGS_PAGE
:
4392 Page
= KeyboardSettingsPage(&Ir
);
4395 case LAYOUT_SETTINGS_PAGE
:
4396 Page
= LayoutSettingsPage(&Ir
);
4399 case SELECT_PARTITION_PAGE
:
4400 Page
= SelectPartitionPage(&Ir
);
4403 case CREATE_PRIMARY_PARTITION_PAGE
:
4404 Page
= CreatePrimaryPartitionPage(&Ir
);
4407 case CREATE_EXTENDED_PARTITION_PAGE
:
4408 Page
= CreateExtendedPartitionPage(&Ir
);
4411 case CREATE_LOGICAL_PARTITION_PAGE
:
4412 Page
= CreateLogicalPartitionPage(&Ir
);
4415 case DELETE_PARTITION_PAGE
:
4416 Page
= DeletePartitionPage(&Ir
);
4419 case SELECT_FILE_SYSTEM_PAGE
:
4420 Page
= SelectFileSystemPage(&Ir
);
4423 case FORMAT_PARTITION_PAGE
:
4424 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4427 case CHECK_FILE_SYSTEM_PAGE
:
4428 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4431 case INSTALL_DIRECTORY_PAGE
:
4432 Page
= InstallDirectoryPage(&Ir
);
4435 case PREPARE_COPY_PAGE
:
4436 Page
= PrepareCopyPage(&Ir
);
4439 case FILE_COPY_PAGE
:
4440 Page
= FileCopyPage(&Ir
);
4444 Page
= RegistryPage(&Ir
);
4447 case BOOT_LOADER_PAGE
:
4448 Page
= BootLoaderPage(&Ir
);
4451 case BOOT_LOADER_FLOPPY_PAGE
:
4452 Page
= BootLoaderFloppyPage(&Ir
);
4455 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4456 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4459 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4460 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4464 case REPAIR_INTRO_PAGE
:
4465 Page
= RepairIntroPage(&Ir
);
4469 Page
= SuccessPage(&Ir
);
4473 Page
= FlushPage(&Ir
);
4477 Page
= QuitPage(&Ir
);
4486 if (Page
== RECOVERY_PAGE
)
4491 /* Avoid bugcheck */
4492 Time
.QuadPart
+= 50000000;
4493 NtDelayExecution(FALSE
, &Time
);
4496 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4497 NtShutdownSystem(ShutdownReboot
);
4498 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4499 NtTerminateProcess(NtCurrentProcess(), 0);
4506 NtProcessStartup(PPEB Peb
)
4508 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4510 ProcessHeap
= Peb
->ProcessHeap
;
4511 InfSetHeap(ProcessHeap
);
4514 #endif /* __REACTOS__ */