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: base/setup/usetup/interface/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
;
70 * Path to the system partition, where the boot manager resides.
71 * On x86 PCs, this is usually the active partition.
72 * On ARC, (u)EFI, ... platforms, this is a dedicated partition.
74 * For more information, see:
75 * https://en.wikipedia.org/wiki/System_partition_and_boot_partition
76 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/boot-and-system-volumes.html
77 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/arc-boot-process.html
78 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html
79 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-system-volume.html
80 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-boot-volume.html
82 static UNICODE_STRING SystemRootPath
;
84 /* Path to the install directory inside the ReactOS boot partition */
85 static UNICODE_STRING DestinationPath
;
86 static UNICODE_STRING DestinationArcPath
;
87 static UNICODE_STRING DestinationRootPath
;
89 static WCHAR DestinationDriveLetter
;
93 static HSPFILEQ SetupFileQueue
= NULL
;
95 static PGENERIC_LIST ComputerList
= NULL
;
96 static PGENERIC_LIST DisplayList
= NULL
;
97 static PGENERIC_LIST KeyboardList
= NULL
;
98 static PGENERIC_LIST LayoutList
= NULL
;
99 static PGENERIC_LIST LanguageList
= NULL
;
101 static LANGID LanguageId
= 0;
103 static ULONG RequiredPartitionDiskSpace
= ~0;
105 /* FUNCTIONS ****************************************************************/
108 PrintString(char* fmt
,...)
112 UNICODE_STRING UnicodeString
;
113 ANSI_STRING AnsiString
;
116 vsprintf(buffer
, fmt
, ap
);
119 RtlInitAnsiString(&AnsiString
, buffer
);
120 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
121 NtDisplayString(&UnicodeString
);
122 RtlFreeUnicodeString(&UnicodeString
);
127 DrawBox(IN SHORT xLeft
,
135 /* draw upper left corner */
138 FillConsoleOutputCharacterA(StdOutput
,
144 /* draw upper edge */
147 FillConsoleOutputCharacterA(StdOutput
,
153 /* draw upper right corner */
154 coPos
.X
= xLeft
+ Width
- 1;
156 FillConsoleOutputCharacterA(StdOutput
,
162 /* Draw right edge, inner space and left edge */
163 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
166 FillConsoleOutputCharacterA(StdOutput
,
173 FillConsoleOutputCharacterA(StdOutput
,
179 coPos
.X
= xLeft
+ Width
- 1;
180 FillConsoleOutputCharacterA(StdOutput
,
187 /* draw lower left corner */
189 coPos
.Y
= yTop
+ Height
- 1;
190 FillConsoleOutputCharacterA(StdOutput
,
196 /* draw lower edge */
198 coPos
.Y
= yTop
+ Height
- 1;
199 FillConsoleOutputCharacterA(StdOutput
,
205 /* draw lower right corner */
206 coPos
.X
= xLeft
+ Width
- 1;
207 coPos
.Y
= yTop
+ Height
- 1;
208 FillConsoleOutputCharacterA(StdOutput
,
217 PopupError(PCCH Text
,
235 /* Count text lines and longest line */
242 p
= strchr(pnext
, '\n');
246 Length
= strlen(pnext
);
251 Length
= (ULONG
)(p
- pnext
);
257 if (Length
> MaxLength
)
260 if (LastLine
== TRUE
)
266 /* Check length of status line */
269 Length
= strlen(Status
);
271 if (Length
> MaxLength
)
275 Width
= MaxLength
+ 4;
281 yTop
= (yScreen
- Height
) / 2;
282 xLeft
= (xScreen
- Width
) / 2;
285 /* Set screen attributes */
287 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
289 FillConsoleOutputAttribute(StdOutput
,
290 FOREGROUND_RED
| BACKGROUND_WHITE
,
296 DrawBox(xLeft
, yTop
, Width
, Height
);
298 /* Print message text */
303 p
= strchr(pnext
, '\n');
307 Length
= strlen(pnext
);
312 Length
= (ULONG
)(p
- pnext
);
319 WriteConsoleOutputCharacterA(StdOutput
,
326 if (LastLine
== TRUE
)
333 /* Print separator line and status text */
336 coPos
.Y
= yTop
+ Height
- 3;
338 FillConsoleOutputCharacterA(StdOutput
,
345 FillConsoleOutputCharacterA(StdOutput
,
351 coPos
.X
= xLeft
+ Width
- 1;
352 FillConsoleOutputCharacterA(StdOutput
,
360 WriteConsoleOutputCharacterA(StdOutput
,
362 min(strlen(Status
), (SIZE_T
)Width
- 4),
367 if (WaitEvent
== POPUP_WAIT_NONE
)
372 CONSOLE_ConInKey(Ir
);
374 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
375 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
387 * FALSE: Don't quit setup.
390 ConfirmQuit(PINPUT_RECORD Ir
)
393 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
397 CONSOLE_ConInKey(Ir
);
399 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
400 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
405 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
417 CheckUnattendedSetup(VOID
)
419 WCHAR UnattendInfPath
[MAX_PATH
];
426 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
428 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
432 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
433 wcscat(UnattendInfPath
, L
"\\unattend.inf");
435 /* Load 'unattend.inf' from install media. */
436 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
442 if (UnattendInf
== INVALID_HANDLE_VALUE
)
444 DPRINT("SetupOpenInfFileW() failed\n");
448 /* Open 'Unattend' section */
449 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
451 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
452 SetupCloseInfFile(UnattendInf
);
456 /* Get pointer 'Signature' key */
457 if (!INF_GetData(&Context
, NULL
, &Value
))
459 DPRINT("INF_GetData() failed for key 'Signature'\n");
460 SetupCloseInfFile(UnattendInf
);
464 /* Check 'Signature' string */
465 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
467 DPRINT("Signature not $ReactOS$\n");
468 SetupCloseInfFile(UnattendInf
);
472 /* Check if Unattend setup is enabled */
473 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
475 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
476 SetupCloseInfFile(UnattendInf
);
480 if (!INF_GetData(&Context
, NULL
, &Value
))
482 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
483 SetupCloseInfFile(UnattendInf
);
487 if (_wcsicmp(Value
, L
"yes") != 0)
489 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
490 SetupCloseInfFile(UnattendInf
);
494 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
495 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
497 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
498 SetupCloseInfFile(UnattendInf
);
502 if (!SetupGetIntField(&Context
, 1, &IntValue
))
504 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
505 SetupCloseInfFile(UnattendInf
);
509 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
511 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
512 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
514 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
515 SetupCloseInfFile(UnattendInf
);
519 if (!SetupGetIntField(&Context
, 1, &IntValue
))
521 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
522 SetupCloseInfFile(UnattendInf
);
526 UnattendDestinationPartitionNumber
= IntValue
;
528 /* Search for 'InstallationDirectory' in the 'Unattend' section */
529 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"InstallationDirectory", &Context
))
531 DPRINT("SetupFindFirstLine() failed for key 'InstallationDirectory'\n");
532 SetupCloseInfFile(UnattendInf
);
536 /* Get pointer 'InstallationDirectory' key */
537 if (!INF_GetData(&Context
, NULL
, &Value
))
539 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
540 SetupCloseInfFile(UnattendInf
);
544 wcscpy(UnattendInstallationDirectory
, Value
);
546 IsUnattendedSetup
= TRUE
;
548 /* Search for 'MBRInstallType' in the 'Unattend' section */
549 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
551 if (SetupGetIntField(&Context
, 1, &IntValue
))
553 UnattendMBRInstallType
= IntValue
;
557 /* Search for 'FormatPartition' in the 'Unattend' section */
558 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
560 if (SetupGetIntField(&Context
, 1, &IntValue
))
562 UnattendFormatPartition
= IntValue
;
566 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
568 if (SetupGetIntField(&Context
, 1, &IntValue
))
570 AutoPartition
= IntValue
;
574 /* search for LocaleID in the 'Unattend' section*/
575 if (SetupFindFirstLineW (UnattendInf
, L
"Unattend", L
"LocaleID", &Context
))
577 if (INF_GetData (&Context
, NULL
, &Value
))
579 LONG Id
= wcstol(Value
, NULL
, 16);
580 swprintf(LocaleID
,L
"%08lx", Id
);
584 SetupCloseInfFile(UnattendInf
);
586 DPRINT("Running unattended setup\n");
593 PGENERIC_LIST_ENTRY ListEntry
;
594 LPCWSTR pszNewLayout
;
596 pszNewLayout
= MUIDefaultKeyboardLayout();
598 if (LayoutList
== NULL
)
600 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
601 if (LayoutList
== NULL
)
603 /* FIXME: Handle error! */
608 ListEntry
= GetFirstListEntry(LayoutList
);
610 /* Search for default layout (if provided) */
611 if (pszNewLayout
!= NULL
)
613 while (ListEntry
!= NULL
)
615 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
617 SetCurrentListEntry(LayoutList
, ListEntry
);
621 ListEntry
= GetNextListEntry(ListEntry
);
628 * Displays the LanguagePage.
630 * Next pages: IntroPage, QuitPage
633 * Number of the next page.
636 LanguagePage(PINPUT_RECORD Ir
)
638 PWCHAR NewLanguageId
;
639 BOOL RefreshPage
= FALSE
;
641 /* Initialize the computer settings list */
642 if (LanguageList
== NULL
)
644 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
646 if (LanguageList
== NULL
)
648 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
654 SelectedLanguageId
= DefaultLanguage
;
655 SetConsoleCodePage();
658 /* If there's just a single language in the list skip
659 * the language selection process altogether! */
660 if (GenericListHasSingleEntry(LanguageList
))
663 DrawGenericList(LanguageList
,
669 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
671 MUIDisplayPage(LANGUAGE_PAGE
);
675 CONSOLE_ConInKey(Ir
);
677 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
678 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
680 ScrollDownGenericList (LanguageList
);
683 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
684 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
686 ScrollUpGenericList(LanguageList
);
689 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
690 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
692 ScrollPageDownGenericList(LanguageList
);
695 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
696 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
698 ScrollPageUpGenericList(LanguageList
);
701 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
702 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
704 if (ConfirmQuit(Ir
) == TRUE
)
707 RedrawGenericList(LanguageList
);
709 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
711 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
713 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
715 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
721 SetConsoleCodePage();
725 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
728 GenericListKeyPress(LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
734 NewLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
736 if (SelectedLanguageId
!= NewLanguageId
)
738 /* Clear the language page */
739 MUIClearPage(LANGUAGE_PAGE
);
741 SelectedLanguageId
= NewLanguageId
;
744 SetConsoleCodePage();
746 /* Redraw language selection page in native language */
747 MUIDisplayPage(LANGUAGE_PAGE
);
762 * LanguagePage (at once, default)
763 * InstallIntroPage (at once, if unattended)
769 * Init SourceRootPath
772 * Init RequiredPartitionDiskSpace
773 * Init IsUnattendedSetup
774 * If unattended, init *List and sets the Codepage
777 * Number of the next page.
780 SetupStartPage(PINPUT_RECORD Ir
)
782 //SYSTEM_DEVICE_INFORMATION Sdi;
784 WCHAR FileNameBuffer
[MAX_PATH
];
789 PGENERIC_LIST_ENTRY ListEntry
;
792 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
795 /* Check whether a harddisk is available */
796 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
798 sizeof(SYSTEM_DEVICE_INFORMATION
),
801 if (!NT_SUCCESS(Status
))
803 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
804 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
808 if (Sdi
.NumberOfDisks
== 0)
810 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
815 /* Get the source path and source root path */
816 Status
= GetSourcePaths(&SourcePath
,
820 if (!NT_SUCCESS(Status
))
822 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
823 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
829 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
830 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
831 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
835 /* Load txtsetup.sif from install media. */
836 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
837 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
839 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
845 if (SetupInf
== INVALID_HANDLE_VALUE
)
847 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
851 /* Open 'Version' section */
852 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
854 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
858 /* Get pointer 'Signature' key */
859 if (!INF_GetData(&Context
, NULL
, &Value
))
861 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
865 /* Check 'Signature' string */
866 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
868 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
872 /* Open 'DiskSpaceRequirements' section */
873 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
875 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
879 /* Get the 'FreeSysPartDiskSpace' value */
880 if (!SetupGetIntField(&Context
, 1, &IntValue
))
882 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
886 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
888 /* Start PnP thread */
889 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
891 NtResumeThread(hPnpThread
, NULL
);
892 hPnpThread
= INVALID_HANDLE_VALUE
;
895 CheckUnattendedSetup();
897 if (IsUnattendedSetup
)
900 //read options from inf
901 ComputerList
= CreateComputerTypeList(SetupInf
);
902 DisplayList
= CreateDisplayDriverList(SetupInf
);
903 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
904 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
905 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
908 wcscpy(SelectedLanguageId
,LocaleID
);
910 /* first we hack LanguageList */
911 ListEntry
= GetFirstListEntry(LanguageList
);
913 while (ListEntry
!= NULL
)
915 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
917 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
918 SetCurrentListEntry(LanguageList
, ListEntry
);
922 ListEntry
= GetNextListEntry(ListEntry
);
926 ListEntry
= GetFirstListEntry(LayoutList
);
928 while (ListEntry
!= NULL
)
930 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
932 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
933 SetCurrentListEntry(LayoutList
, ListEntry
);
937 ListEntry
= GetNextListEntry(ListEntry
);
940 SetConsoleCodePage();
942 return INSTALL_INTRO_PAGE
;
945 return LANGUAGE_PAGE
;
950 * Displays the IntroPage.
953 * InstallIntroPage (default)
959 * Number of the next page.
962 IntroPage(PINPUT_RECORD Ir
)
964 MUIDisplayPage(START_PAGE
);
968 CONSOLE_ConInKey(Ir
);
970 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
971 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
973 if (ConfirmQuit(Ir
) == TRUE
)
978 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
980 return INSTALL_INTRO_PAGE
;
982 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
984 return REPAIR_INTRO_PAGE
;
986 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
997 * Displays the License page.
1000 * IntroPage (default)
1003 * Number of the next page.
1006 LicensePage(PINPUT_RECORD Ir
)
1008 MUIDisplayPage(LICENSE_PAGE
);
1012 CONSOLE_ConInKey(Ir
);
1014 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1020 return LICENSE_PAGE
;
1025 * Displays the RepairIntroPage.
1028 * RebootPage (default)
1034 * Number of the next page.
1037 RepairIntroPage(PINPUT_RECORD Ir
)
1039 MUIDisplayPage(REPAIR_INTRO_PAGE
);
1043 CONSOLE_ConInKey(Ir
);
1045 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1049 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
1051 RepairUpdateFlag
= TRUE
;
1052 return INSTALL_INTRO_PAGE
;
1054 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
1056 return RECOVERY_PAGE
;
1058 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1059 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1065 return REPAIR_INTRO_PAGE
;
1069 * Displays the InstallIntroPage.
1072 * DeviceSettingsPage (At once if repair or update is selected)
1073 * SelectPartitionPage (At once if unattended setup)
1074 * DeviceSettingsPage (default)
1078 * Number of the next page.
1081 InstallIntroPage(PINPUT_RECORD Ir
)
1083 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1085 if (RepairUpdateFlag
)
1087 //return SELECT_PARTITION_PAGE;
1088 return DEVICE_SETTINGS_PAGE
;
1091 if (IsUnattendedSetup
)
1093 return SELECT_PARTITION_PAGE
;
1098 CONSOLE_ConInKey(Ir
);
1100 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1101 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1103 if (ConfirmQuit(Ir
) == TRUE
)
1108 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1110 return DEVICE_SETTINGS_PAGE
;
1111 // return SCSI_CONTROLLER_PAGE;
1115 return INSTALL_INTRO_PAGE
;
1121 ScsiControllerPage(PINPUT_RECORD Ir
)
1123 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1125 /* FIXME: print loaded mass storage driver descriptions */
1127 SetTextXY(8, 10, "TEST device");
1131 SetStatusText(" ENTER = Continue F3 = Quit");
1137 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1138 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1140 if (ConfirmQuit(Ir
) == TRUE
)
1145 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1147 return DEVICE_SETTINGS_PAGE
;
1151 return SCSI_CONTROLLER_PAGE
;
1157 * Displays the DeviceSettingsPage.
1160 * SelectPartitionPage (At once if repair or update is selected)
1161 * ComputerSettingsPage
1162 * DisplaySettingsPage
1163 * KeyboardSettingsPage
1164 * LayoutsettingsPage
1165 * SelectPartitionPage
1175 * Number of the next page.
1178 DeviceSettingsPage(PINPUT_RECORD Ir
)
1180 static ULONG Line
= 16;
1181 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1183 /* Initialize the computer settings list */
1184 if (ComputerList
== NULL
)
1186 ComputerList
= CreateComputerTypeList(SetupInf
);
1187 if (ComputerList
== NULL
)
1189 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1194 /* Initialize the display settings list */
1195 if (DisplayList
== NULL
)
1197 DisplayList
= CreateDisplayDriverList(SetupInf
);
1198 if (DisplayList
== NULL
)
1200 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1205 /* Initialize the keyboard settings list */
1206 if (KeyboardList
== NULL
)
1208 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1209 if (KeyboardList
== NULL
)
1211 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1216 /* Initialize the keyboard layout list */
1217 if (LayoutList
== NULL
)
1219 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1220 if (LayoutList
== NULL
)
1222 /* FIXME: report error */
1223 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1228 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1231 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1232 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1233 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1234 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1236 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1238 if (RepairUpdateFlag
)
1240 return SELECT_PARTITION_PAGE
;
1245 CONSOLE_ConInKey(Ir
);
1247 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1248 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1250 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1254 else if (Line
== 16)
1259 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1261 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1262 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1264 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1268 else if (Line
== 16)
1273 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1275 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1276 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1278 if (ConfirmQuit(Ir
) == TRUE
)
1283 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1286 return COMPUTER_SETTINGS_PAGE
;
1287 else if (Line
== 12)
1288 return DISPLAY_SETTINGS_PAGE
;
1289 else if (Line
== 13)
1290 return KEYBOARD_SETTINGS_PAGE
;
1291 else if (Line
== 14)
1292 return LAYOUT_SETTINGS_PAGE
;
1293 else if (Line
== 16)
1294 return SELECT_PARTITION_PAGE
;
1298 return DEVICE_SETTINGS_PAGE
;
1303 * Handles generic selection lists.
1306 * GenericList: The list to handle.
1307 * nextPage: The page it needs to jump to after this page.
1308 * Ir: The PINPUT_RECORD
1311 HandleGenericList(PGENERIC_LIST GenericList
,
1312 PAGE_NUMBER nextPage
,
1317 CONSOLE_ConInKey(Ir
);
1319 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1320 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1322 ScrollDownGenericList(GenericList
);
1324 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1325 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1327 ScrollUpGenericList(GenericList
);
1329 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1330 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1332 ScrollPageDownGenericList(GenericList
);
1334 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1335 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1337 ScrollPageUpGenericList(GenericList
);
1339 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1340 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1342 if (ConfirmQuit(Ir
) == TRUE
)
1347 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1348 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1350 RestoreGenericListState(GenericList
);
1353 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1357 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1360 GenericListKeyPress(GenericList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1367 * Displays the ComputerSettingsPage.
1370 * DeviceSettingsPage
1374 * Number of the next page.
1377 ComputerSettingsPage(PINPUT_RECORD Ir
)
1379 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1381 DrawGenericList(ComputerList
,
1387 SaveGenericListState(ComputerList
);
1389 return HandleGenericList(ComputerList
, DEVICE_SETTINGS_PAGE
, Ir
);
1394 * Displays the DisplaySettingsPage.
1397 * DeviceSettingsPage
1401 * Number of the next page.
1404 DisplaySettingsPage(PINPUT_RECORD Ir
)
1406 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1408 DrawGenericList(DisplayList
,
1414 SaveGenericListState(DisplayList
);
1416 return HandleGenericList(DisplayList
, DEVICE_SETTINGS_PAGE
, Ir
);
1421 * Displays the KeyboardSettingsPage.
1424 * DeviceSettingsPage
1428 * Number of the next page.
1431 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1433 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1435 DrawGenericList(KeyboardList
,
1441 SaveGenericListState(KeyboardList
);
1443 return HandleGenericList(KeyboardList
, DEVICE_SETTINGS_PAGE
, Ir
);
1448 * Displays the LayoutSettingsPage.
1451 * DeviceSettingsPage
1455 * Number of the next page.
1458 LayoutSettingsPage(PINPUT_RECORD Ir
)
1460 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1462 DrawGenericList(LayoutList
,
1468 SaveGenericListState(LayoutList
);
1470 return HandleGenericList(LayoutList
, DEVICE_SETTINGS_PAGE
, Ir
);
1475 IsDiskSizeValid(PPARTENTRY PartEntry
)
1479 size
= PartEntry
->SectorCount
.QuadPart
* PartEntry
->DiskEntry
->BytesPerSector
;
1480 size
= (size
+ 524288) / 1048576; /* in MBytes */
1482 if (size
< RequiredPartitionDiskSpace
)
1484 /* partition is too small so ask for another partion */
1485 DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size
, RequiredPartitionDiskSpace
);
1496 * Displays the SelectPartitionPage.
1499 * SelectFileSystemPage (At once if unattended)
1500 * SelectFileSystemPage (Default if free space is selected)
1501 * CreatePrimaryPartitionPage
1502 * CreateExtendedPartitionPage
1503 * CreateLogicalPartitionPage
1504 * ConfirmDeleteSystemPartitionPage (if the selected partition is the system partition, aka with the boot flag set)
1505 * DeletePartitionPage
1509 * Init DestinationDriveLetter (only if unattended or not free space is selected)
1510 * Set InstallShortcut (only if not unattended + free space is selected)
1513 * Number of the next page.
1516 SelectPartitionPage(PINPUT_RECORD Ir
)
1520 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1522 if (PartitionList
== NULL
)
1524 PartitionList
= CreatePartitionList(2,
1528 if (PartitionList
== NULL
)
1530 /* FIXME: show an error dialog */
1533 else if (IsListEmpty (&PartitionList
->DiskListHead
))
1535 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
1540 DrawPartitionList(PartitionList
);
1542 if (IsUnattendedSetup
)
1544 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1548 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1550 CreateLogicalPartition(PartitionList
,
1551 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1556 CreatePrimaryPartition(PartitionList
,
1557 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1561 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1563 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1564 RequiredPartitionDiskSpace
);
1565 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1568 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1570 return SELECT_FILE_SYSTEM_PAGE
;
1575 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1577 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1578 RequiredPartitionDiskSpace
);
1579 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1582 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1584 return SELECT_FILE_SYSTEM_PAGE
;
1590 /* Update status text */
1591 if (PartitionList
->CurrentPartition
== NULL
)
1593 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1595 else if (PartitionList
->CurrentPartition
->LogicalPartition
)
1597 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1599 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1603 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL
));
1608 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1610 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1612 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1616 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1621 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1625 CONSOLE_ConInKey(Ir
);
1627 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1628 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1630 if (ConfirmQuit(Ir
) == TRUE
)
1632 DestroyPartitionList(PartitionList
);
1633 PartitionList
= NULL
;
1639 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1640 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1642 if (ScrollDownPartitionList(PartitionList
))
1643 DrawPartitionList(PartitionList
);
1645 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1646 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1648 if (ScrollUpPartitionList(PartitionList
))
1649 DrawPartitionList(PartitionList
);
1651 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1653 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1654 continue; //return SELECT_PARTITION_PAGE;
1656 if (PartitionList
->CurrentPartition
== NULL
||
1657 PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1659 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1661 CreateLogicalPartition(PartitionList
,
1667 CreatePrimaryPartition(PartitionList
,
1673 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1675 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1676 RequiredPartitionDiskSpace
);
1677 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1680 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1682 return SELECT_FILE_SYSTEM_PAGE
;
1684 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'P') /* P */
1686 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1688 Error
= PrimaryPartitionCreationChecks(PartitionList
);
1689 if (Error
!= NOT_AN_ERROR
)
1691 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1692 return SELECT_PARTITION_PAGE
;
1695 return CREATE_PRIMARY_PARTITION_PAGE
;
1698 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'E') /* E */
1700 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1702 Error
= ExtendedPartitionCreationChecks(PartitionList
);
1703 if (Error
!= NOT_AN_ERROR
)
1705 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1706 return SELECT_PARTITION_PAGE
;
1709 return CREATE_EXTENDED_PARTITION_PAGE
;
1712 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'L') /* L */
1714 if (PartitionList
->CurrentPartition
->LogicalPartition
== TRUE
)
1716 Error
= LogicalPartitionCreationChecks(PartitionList
);
1717 if (Error
!= NOT_AN_ERROR
)
1719 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1720 return SELECT_PARTITION_PAGE
;
1723 return CREATE_LOGICAL_PARTITION_PAGE
;
1726 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1728 if (PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1730 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1731 return SELECT_PARTITION_PAGE
;
1734 if (PartitionList
->CurrentPartition
->BootIndicator
)
1735 return CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
;
1737 return DELETE_PARTITION_PAGE
;
1741 return SELECT_PARTITION_PAGE
;
1745 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1746 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1747 #define PARTITION_MAXSIZE 999999
1750 ShowPartitionSizeInputBox(SHORT Left
,
1763 WCHAR PartitionSizeBuffer
[100];
1775 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1780 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1781 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1784 WriteConsoleOutputCharacterA(StdOutput
,
1790 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1791 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1793 WriteConsoleOutputCharacterA(StdOutput
,
1799 swprintf(PartitionSizeBuffer
, L
"%lu", MaxSize
);
1800 Index
= wcslen(PartitionSizeBuffer
);
1801 CONSOLE_SetInputTextXY(iLeft
,
1803 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1804 PartitionSizeBuffer
);
1808 CONSOLE_ConInKey(&Ir
);
1810 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1811 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1816 PartitionSizeBuffer
[0] = 0;
1819 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1823 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1828 PartitionSizeBuffer
[0] = 0;
1831 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1835 PartitionSizeBuffer
[Index
] = 0;
1837 CONSOLE_SetInputTextXY(iLeft
,
1839 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1840 PartitionSizeBuffer
);
1842 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1843 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1845 ch
= (WCHAR
)Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1847 if ((ch
>= L
'0') && (ch
<= L
'9'))
1849 PartitionSizeBuffer
[Index
] = ch
;
1851 PartitionSizeBuffer
[Index
] = 0;
1853 CONSOLE_SetInputTextXY(iLeft
,
1855 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1856 PartitionSizeBuffer
);
1861 /* Convert UNICODE --> ANSI the poor man's way */
1862 sprintf(InputBuffer
, "%S", PartitionSizeBuffer
);
1867 * Displays the CreatePrimaryPartitionPage.
1870 * SelectPartitionPage
1871 * SelectFileSystemPage (default)
1875 * Number of the next page.
1878 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1880 PDISKENTRY DiskEntry
;
1881 PPARTENTRY PartEntry
;
1884 CHAR InputBuffer
[50];
1888 ULONGLONG SectorCount
;
1891 if (PartitionList
== NULL
||
1892 PartitionList
->CurrentDisk
== NULL
||
1893 PartitionList
->CurrentPartition
== NULL
)
1895 /* FIXME: show an error dialog */
1899 DiskEntry
= PartitionList
->CurrentDisk
;
1900 PartEntry
= PartitionList
->CurrentPartition
;
1902 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1904 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1906 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1908 if (DiskSize
>= 10737418240) /* 10 GB */
1910 DiskSize
= DiskSize
/ 1073741824;
1911 Unit
= MUIGetString(STRING_GB
);
1916 DiskSize
= DiskSize
/ 1048576;
1920 Unit
= MUIGetString(STRING_MB
);
1923 if (DiskEntry
->DriverName
.Length
> 0)
1925 CONSOLE_PrintTextXY(6, 10,
1926 MUIGetString(STRING_HDINFOPARTCREATE
),
1929 DiskEntry
->DiskNumber
,
1933 &DiskEntry
->DriverName
);
1937 CONSOLE_PrintTextXY(6, 10,
1938 MUIGetString(STRING_HDDINFOUNK1
),
1941 DiskEntry
->DiskNumber
,
1947 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1950 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1951 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
1954 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1956 PartEntry
= PartitionList
->CurrentPartition
;
1959 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
1961 if (MaxSize
> PARTITION_MAXSIZE
)
1962 MaxSize
= PARTITION_MAXSIZE
;
1964 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1965 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1969 if (ConfirmQuit (Ir
) == TRUE
)
1974 else if (Cancel
== TRUE
)
1976 return SELECT_PARTITION_PAGE
;
1980 PartSize
= atoi(InputBuffer
);
1988 if (PartSize
> MaxSize
)
1994 /* Convert to bytes */
1995 if (PartSize
== MaxSize
)
1997 /* Use all of the unpartitioned disk space */
1998 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2002 /* Calculate the sector count from the size in MB */
2003 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2005 /* But never get larger than the unpartitioned disk space */
2006 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2007 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2010 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2012 CreatePrimaryPartition(PartitionList
,
2016 return SELECT_PARTITION_PAGE
;
2020 return CREATE_PRIMARY_PARTITION_PAGE
;
2025 * Displays the CreateExtendedPartitionPage.
2028 * SelectPartitionPage (default)
2032 * Number of the next page.
2035 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
2037 PDISKENTRY DiskEntry
;
2038 PPARTENTRY PartEntry
;
2041 CHAR InputBuffer
[50];
2045 ULONGLONG SectorCount
;
2048 if (PartitionList
== NULL
||
2049 PartitionList
->CurrentDisk
== NULL
||
2050 PartitionList
->CurrentPartition
== NULL
)
2052 /* FIXME: show an error dialog */
2056 DiskEntry
= PartitionList
->CurrentDisk
;
2057 PartEntry
= PartitionList
->CurrentPartition
;
2059 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2061 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
2063 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2065 if (DiskSize
>= 10737418240) /* 10 GB */
2067 DiskSize
= DiskSize
/ 1073741824;
2068 Unit
= MUIGetString(STRING_GB
);
2073 DiskSize
= DiskSize
/ 1048576;
2077 Unit
= MUIGetString(STRING_MB
);
2080 if (DiskEntry
->DriverName
.Length
> 0)
2082 CONSOLE_PrintTextXY(6, 10,
2083 MUIGetString(STRING_HDINFOPARTCREATE
),
2086 DiskEntry
->DiskNumber
,
2090 &DiskEntry
->DriverName
);
2094 CONSOLE_PrintTextXY(6, 10,
2095 MUIGetString(STRING_HDDINFOUNK1
),
2098 DiskEntry
->DiskNumber
,
2104 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2107 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2108 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2111 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2113 PartEntry
= PartitionList
->CurrentPartition
;
2116 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2118 if (MaxSize
> PARTITION_MAXSIZE
)
2119 MaxSize
= PARTITION_MAXSIZE
;
2121 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2122 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2126 if (ConfirmQuit (Ir
) == TRUE
)
2131 else if (Cancel
== TRUE
)
2133 return SELECT_PARTITION_PAGE
;
2137 PartSize
= atoi(InputBuffer
);
2145 if (PartSize
> MaxSize
)
2151 /* Convert to bytes */
2152 if (PartSize
== MaxSize
)
2154 /* Use all of the unpartitioned disk space */
2155 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2159 /* Calculate the sector count from the size in MB */
2160 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2162 /* But never get larger than the unpartitioned disk space */
2163 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2164 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2167 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2169 CreateExtendedPartition(PartitionList
,
2172 return SELECT_PARTITION_PAGE
;
2176 return CREATE_EXTENDED_PARTITION_PAGE
;
2181 * Displays the CreateLogicalPartitionPage.
2184 * SelectFileSystemPage (default)
2188 * Number of the next page.
2191 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2193 PDISKENTRY DiskEntry
;
2194 PPARTENTRY PartEntry
;
2197 CHAR InputBuffer
[50];
2201 ULONGLONG SectorCount
;
2204 if (PartitionList
== NULL
||
2205 PartitionList
->CurrentDisk
== NULL
||
2206 PartitionList
->CurrentPartition
== NULL
)
2208 /* FIXME: show an error dialog */
2212 DiskEntry
= PartitionList
->CurrentDisk
;
2213 PartEntry
= PartitionList
->CurrentPartition
;
2215 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2217 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2219 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2221 if (DiskSize
>= 10737418240) /* 10 GB */
2223 DiskSize
= DiskSize
/ 1073741824;
2224 Unit
= MUIGetString(STRING_GB
);
2229 DiskSize
= DiskSize
/ 1048576;
2233 Unit
= MUIGetString(STRING_MB
);
2236 if (DiskEntry
->DriverName
.Length
> 0)
2238 CONSOLE_PrintTextXY(6, 10,
2239 MUIGetString(STRING_HDINFOPARTCREATE
),
2242 DiskEntry
->DiskNumber
,
2246 &DiskEntry
->DriverName
);
2250 CONSOLE_PrintTextXY(6, 10,
2251 MUIGetString(STRING_HDDINFOUNK1
),
2254 DiskEntry
->DiskNumber
,
2260 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2263 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2264 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2267 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2269 PartEntry
= PartitionList
->CurrentPartition
;
2272 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2274 if (MaxSize
> PARTITION_MAXSIZE
)
2275 MaxSize
= PARTITION_MAXSIZE
;
2277 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2278 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2282 if (ConfirmQuit (Ir
) == TRUE
)
2287 else if (Cancel
== TRUE
)
2289 return SELECT_PARTITION_PAGE
;
2293 PartSize
= atoi(InputBuffer
);
2301 if (PartSize
> MaxSize
)
2307 /* Convert to bytes */
2308 if (PartSize
== MaxSize
)
2310 /* Use all of the unpartitioned disk space */
2311 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2315 /* Calculate the sector count from the size in MB */
2316 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2318 /* But never get larger than the unpartitioned disk space */
2319 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2320 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2323 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2325 CreateLogicalPartition(PartitionList
,
2329 return SELECT_PARTITION_PAGE
;
2333 return CREATE_LOGICAL_PARTITION_PAGE
;
2338 * Displays the ConfirmDeleteSystemPartitionPage.
2341 * DeletePartitionPage (default)
2342 * SelectPartitionPage
2345 * Number of the next page.
2348 ConfirmDeleteSystemPartitionPage(PINPUT_RECORD Ir
)
2350 MUIDisplayPage(CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
);
2354 CONSOLE_ConInKey(Ir
);
2356 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2357 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2359 if (ConfirmQuit(Ir
) == TRUE
)
2366 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2368 return DELETE_PARTITION_PAGE
;
2370 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2372 return SELECT_PARTITION_PAGE
;
2376 return SELECT_PARTITION_PAGE
;
2381 * Displays the DeletePartitionPage.
2384 * SelectPartitionPage (default)
2388 * Number of the next page.
2391 DeletePartitionPage(PINPUT_RECORD Ir
)
2393 PDISKENTRY DiskEntry
;
2394 PPARTENTRY PartEntry
;
2400 if (PartitionList
== NULL
||
2401 PartitionList
->CurrentDisk
== NULL
||
2402 PartitionList
->CurrentPartition
== NULL
)
2404 /* FIXME: show an error dialog */
2408 DiskEntry
= PartitionList
->CurrentDisk
;
2409 PartEntry
= PartitionList
->CurrentPartition
;
2411 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2413 GetPartTypeStringFromPartitionType(PartEntry
->PartitionType
, PartType
, 30);
2415 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2417 if (PartSize
>= 10737418240) /* 10 GB */
2419 PartSize
= PartSize
/ 1073741824;
2420 Unit
= MUIGetString(STRING_GB
);
2424 if (PartSize
>= 10485760) /* 10 MB */
2426 PartSize
= PartSize
/ 1048576;
2427 Unit
= MUIGetString(STRING_MB
);
2431 PartSize
= PartSize
/ 1024;
2432 Unit
= MUIGetString(STRING_KB
);
2435 if (PartType
== NULL
)
2437 CONSOLE_PrintTextXY(6, 10,
2438 MUIGetString(STRING_HDDINFOUNK2
),
2439 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2440 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2441 PartEntry
->PartitionType
,
2447 CONSOLE_PrintTextXY(6, 10,
2448 " %c%c %s %I64u %s",
2449 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2450 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2456 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2458 if (DiskSize
>= 10737418240) /* 10 GB */
2460 DiskSize
= DiskSize
/ 1073741824;
2461 Unit
= MUIGetString(STRING_GB
);
2466 DiskSize
= DiskSize
/ 1048576;
2470 Unit
= MUIGetString(STRING_MB
);
2473 if (DiskEntry
->DriverName
.Length
> 0)
2475 CONSOLE_PrintTextXY(6, 12,
2476 MUIGetString(STRING_HDINFOPARTDELETE
),
2479 DiskEntry
->DiskNumber
,
2483 &DiskEntry
->DriverName
);
2487 CONSOLE_PrintTextXY(6, 12,
2488 MUIGetString(STRING_HDDINFOUNK3
),
2491 DiskEntry
->DiskNumber
,
2499 CONSOLE_ConInKey(Ir
);
2501 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2502 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2504 if (ConfirmQuit(Ir
) == TRUE
)
2511 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2513 return SELECT_PARTITION_PAGE
;
2515 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2517 DeleteCurrentPartition(PartitionList
);
2519 return SELECT_PARTITION_PAGE
;
2523 return DELETE_PARTITION_PAGE
;
2528 * Displays the SelectFileSystemPage.
2531 * CheckFileSystemPage (At once if RepairUpdate is selected)
2532 * CheckFileSystemPage (At once if Unattended and not UnattendFormatPartition)
2533 * FormatPartitionPage (At once if Unattended and UnattendFormatPartition)
2534 * SelectPartitionPage (If the user aborts)
2535 * FormatPartitionPage (Default)
2539 * Sets PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType (via UpdatePartitionType)
2540 * Calls CheckActiveSystemPartition()
2543 * Number of the next page.
2546 SelectFileSystemPage(PINPUT_RECORD Ir
)
2548 PDISKENTRY DiskEntry
;
2549 PPARTENTRY PartEntry
;
2554 CHAR PartTypeString
[32];
2556 DPRINT("SelectFileSystemPage()\n");
2558 if (PartitionList
== NULL
||
2559 PartitionList
->CurrentDisk
== NULL
||
2560 PartitionList
->CurrentPartition
== NULL
)
2562 /* FIXME: show an error dialog */
2566 /* Find or set the active system partition */
2567 CheckActiveSystemPartition(PartitionList
);
2569 if (PartitionList
->SystemDisk
== NULL
||
2570 PartitionList
->SystemPartition
== NULL
)
2572 /* FIXME: show an error dialog */
2576 switch (PartitionList
->FormatState
)
2579 if (PartitionList
->CurrentPartition
!= PartitionList
->SystemPartition
)
2581 PartitionList
->TempDisk
= PartitionList
->SystemDisk
;
2582 PartitionList
->TempPartition
= PartitionList
->SystemPartition
;
2583 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2585 PartitionList
->FormatState
= FormatSystemPartition
;
2586 DPRINT1("FormatState: Start --> FormatSystemPartition\n");
2590 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2591 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2592 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2594 PartitionList
->FormatState
= FormatInstallPartition
;
2595 DPRINT1("FormatState: Start --> FormatInstallPartition\n");
2599 case FormatSystemPartition
:
2600 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2601 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2602 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2604 PartitionList
->FormatState
= FormatInstallPartition
;
2605 DPRINT1("FormatState: FormatSystemPartition --> FormatInstallPartition\n");
2608 case FormatInstallPartition
:
2609 if (GetNextUnformattedPartition(PartitionList
,
2610 &PartitionList
->TempDisk
,
2611 &PartitionList
->TempPartition
))
2613 PartitionList
->FormatState
= FormatOtherPartition
;
2614 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2615 DPRINT1("FormatState: FormatInstallPartition --> FormatOtherPartition\n");
2619 PartitionList
->FormatState
= FormatDone
;
2620 DPRINT1("FormatState: FormatInstallPartition --> FormatDone\n");
2621 return CHECK_FILE_SYSTEM_PAGE
;
2625 case FormatOtherPartition
:
2626 if (GetNextUnformattedPartition(PartitionList
,
2627 &PartitionList
->TempDisk
,
2628 &PartitionList
->TempPartition
))
2630 PartitionList
->FormatState
= FormatOtherPartition
;
2631 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2632 DPRINT1("FormatState: FormatOtherPartition --> FormatOtherPartition\n");
2636 PartitionList
->FormatState
= FormatDone
;
2637 DPRINT1("FormatState: FormatOtherPartition --> FormatDone\n");
2638 return CHECK_FILE_SYSTEM_PAGE
;
2643 DPRINT1("FormatState: Invalid value %ld\n", PartitionList
->FormatState
);
2644 /* FIXME: show an error dialog */
2648 DiskEntry
= PartitionList
->TempDisk
;
2649 PartEntry
= PartitionList
->TempPartition
;
2651 /* adjust disk size */
2652 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2653 if (DiskSize
>= 10737418240) /* 10 GB */
2655 DiskSize
= DiskSize
/ 1073741824;
2656 DiskUnit
= MUIGetString(STRING_GB
);
2660 DiskSize
= DiskSize
/ 1048576;
2661 DiskUnit
= MUIGetString(STRING_MB
);
2664 /* adjust partition size */
2665 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2666 if (PartSize
>= 10737418240) /* 10 GB */
2668 PartSize
= PartSize
/ 1073741824;
2669 PartUnit
= MUIGetString(STRING_GB
);
2673 PartSize
= PartSize
/ 1048576;
2674 PartUnit
= MUIGetString(STRING_MB
);
2677 /* adjust partition type */
2678 GetPartTypeStringFromPartitionType(PartEntry
->PartitionType
, PartTypeString
, 30);
2680 if (PartEntry
->AutoCreate
== TRUE
)
2682 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2685 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2686 PartEntry
->PartitionNumber
,
2692 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2693 DiskEntry
->DiskNumber
,
2699 &DiskEntry
->DriverName
);
2701 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2704 PartEntry
->AutoCreate
= FALSE
;
2706 else if (PartEntry
->New
== TRUE
)
2708 switch (PartitionList
->FormatState
)
2710 case FormatSystemPartition
:
2711 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2714 case FormatInstallPartition
:
2715 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2718 case FormatOtherPartition
:
2719 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2726 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2730 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2732 if (PartTypeString
== NULL
)
2734 CONSOLE_PrintTextXY(8, 10,
2735 MUIGetString(STRING_HDDINFOUNK4
),
2736 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2737 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2738 PartEntry
->PartitionType
,
2744 CONSOLE_PrintTextXY(8, 10,
2746 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2747 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2753 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2754 DiskEntry
->DiskNumber
,
2760 &DiskEntry
->DriverName
);
2763 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2765 if (FileSystemList
== NULL
)
2767 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2768 if (FileSystemList
== NULL
)
2770 /* FIXME: show an error dialog */
2774 /* FIXME: Add file systems to list */
2777 DrawFileSystemList(FileSystemList
);
2779 if (RepairUpdateFlag
)
2781 return CHECK_FILE_SYSTEM_PAGE
;
2782 //return SELECT_PARTITION_PAGE;
2785 if (IsUnattendedSetup
)
2787 if (UnattendFormatPartition
)
2789 PartEntry
->FileSystem
= GetFileSystemByName(FileSystemList
, L
"FAT");
2790 return FORMAT_PARTITION_PAGE
;
2793 return CHECK_FILE_SYSTEM_PAGE
;
2798 CONSOLE_ConInKey(Ir
);
2800 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2801 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2803 if (ConfirmQuit(Ir
) == TRUE
)
2810 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2811 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2813 return SELECT_PARTITION_PAGE
;
2815 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2816 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2818 ScrollDownFileSystemList(FileSystemList
);
2820 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2821 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2823 ScrollUpFileSystemList(FileSystemList
);
2825 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2827 if (!FileSystemList
->Selected
->FormatFunc
)
2829 return SELECT_FILE_SYSTEM_PAGE
;
2833 PartEntry
->FileSystem
= FileSystemList
->Selected
;
2834 return FORMAT_PARTITION_PAGE
;
2839 return SELECT_FILE_SYSTEM_PAGE
;
2844 * Displays the FormatPartitionPage.
2847 * InstallDirectoryPage (At once if IsUnattendedSetup or InstallShortcut)
2848 * SelectPartitionPage (At once)
2852 * Sets PartitionList->CurrentPartition->FormatState
2853 * Sets DestinationRootPath
2856 * Number of the next page.
2859 FormatPartitionPage(PINPUT_RECORD Ir
)
2861 UNICODE_STRING PartitionRootPath
;
2862 WCHAR PathBuffer
[MAX_PATH
];
2863 PDISKENTRY DiskEntry
;
2864 PPARTENTRY PartEntry
;
2873 DPRINT("FormatPartitionPage()\n");
2875 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2877 if (PartitionList
== NULL
||
2878 PartitionList
->TempDisk
== NULL
||
2879 PartitionList
->TempPartition
== NULL
)
2881 /* FIXME: show an error dialog */
2885 DiskEntry
= PartitionList
->TempDisk
;
2886 PartEntry
= PartitionList
->TempPartition
;
2890 if (!IsUnattendedSetup
)
2892 CONSOLE_ConInKey(Ir
);
2895 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2896 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2898 if (ConfirmQuit(Ir
) == TRUE
)
2905 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2907 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2909 if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"FAT") == 0)
2911 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2913 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2914 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2916 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2918 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2920 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2922 /* FAT16 CHS partition (partiton size < 32MB) */
2923 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2925 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2927 /* FAT16 CHS partition (partition size < 512MB) */
2928 PartEntry
->PartitionType
= PARTITION_HUGE
;
2932 /* FAT32 CHS partition (partition size >= 512MB) */
2933 PartEntry
->PartitionType
= PARTITION_FAT32
;
2938 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2940 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2942 /* FAT16 LBA partition (partition size < 512MB) */
2943 PartEntry
->PartitionType
= PARTITION_XINT13
;
2947 /* FAT32 LBA partition (partition size >= 512MB) */
2948 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2952 DiskEntry
->Dirty
= TRUE
;
2953 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2954 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2957 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"EXT2") == 0)
2959 PartEntry
->PartitionType
= PARTITION_EXT2
;
2961 DiskEntry
->Dirty
= TRUE
;
2962 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2963 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2965 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"NTFS") == 0)
2967 PartEntry
->PartitionType
= PARTITION_IFS
;
2969 DiskEntry
->Dirty
= TRUE
;
2970 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2971 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2974 else if (!PartEntry
->FileSystem
->FormatFunc
)
2980 CONSOLE_PrintTextXY(6, 12,
2981 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2982 DiskEntry
->DiskSize
,
2983 DiskEntry
->CylinderSize
,
2984 DiskEntry
->TrackSize
);
2987 DiskEntry
= PartitionList
->TempDisk
;
2988 Entry
= DiskEntry
->PartListHead
.Flink
;
2990 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2992 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2994 if (PartEntry
->IsPartitioned
== TRUE
)
2996 CONSOLE_PrintTextXY(6, Line
,
2997 "%2u: %2u %c %12I64u %12I64u %2u %c",
2999 PartEntry
->PartitionNumber
,
3000 PartEntry
->BootIndicator
? 'A' : '-',
3001 PartEntry
->StartSector
.QuadPart
,
3002 PartEntry
->SectorCount
.QuadPart
,
3003 PartEntry
->PartitionType
,
3004 PartEntry
->Dirty
? '*' : ' ');
3008 Entry
= Entry
->Flink
;
3011 /* Restore the old entry */
3012 PartEntry
= PartitionList
->TempPartition
;
3015 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
3017 DPRINT("WritePartitionsToDisk() failed\n");
3018 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
3022 /* Set PartitionRootPath */
3023 swprintf(PathBuffer
,
3024 L
"\\Device\\Harddisk%lu\\Partition%lu",
3025 DiskEntry
->DiskNumber
,
3026 PartEntry
->PartitionNumber
);
3027 RtlInitUnicodeString(&PartitionRootPath
,
3029 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3031 if (PartEntry
->FileSystem
->FormatFunc
)
3033 Status
= FormatPartition(&PartitionRootPath
,
3034 PartEntry
->FileSystem
);
3035 if (!NT_SUCCESS(Status
))
3037 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
3038 MUIDisplayError(ERROR_FORMATTING_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
, PathBuffer
);
3042 PartEntry
->New
= FALSE
;
3046 CONSOLE_SetStatusText(" Done. Press any key ...");
3047 CONSOLE_ConInKey(Ir
);
3050 return SELECT_FILE_SYSTEM_PAGE
;
3054 return FORMAT_PARTITION_PAGE
;
3059 * Displays the CheckFileSystemPage.
3062 * InstallDirectoryPage (At once)
3066 * Inits or reloads FileSystemList
3069 * Number of the next page.
3072 CheckFileSystemPage(PINPUT_RECORD Ir
)
3074 PFILE_SYSTEM_ITEM CurrentFileSystem
;
3075 UNICODE_STRING PartitionRootPath
;
3076 WCHAR PathBuffer
[MAX_PATH
];
3077 CHAR Buffer
[MAX_PATH
];
3078 PDISKENTRY DiskEntry
;
3079 PPARTENTRY PartEntry
;
3082 if (PartitionList
== NULL
)
3084 /* FIXME: show an error dialog */
3088 if (!GetNextUncheckedPartition(PartitionList
, &DiskEntry
, &PartEntry
))
3090 return INSTALL_DIRECTORY_PAGE
;
3093 /* Set PartitionRootPath */
3094 swprintf(PathBuffer
,
3095 L
"\\Device\\Harddisk%lu\\Partition%lu",
3096 DiskEntry
->DiskNumber
,
3097 PartEntry
->PartitionNumber
);
3098 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
3099 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3101 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
3103 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3105 CurrentFileSystem
= GetFileSystem(FileSystemList
, PartEntry
);
3106 DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystemName: %S\n",
3107 PartEntry
->PartitionType
, (CurrentFileSystem
? CurrentFileSystem
->FileSystemName
: L
"n/a"));
3109 /* HACK: Do not try to check a partition with an unknown filesytem */
3110 if (CurrentFileSystem
== NULL
)
3112 PartEntry
->NeedsCheck
= FALSE
;
3113 return CHECK_FILE_SYSTEM_PAGE
;
3116 if (CurrentFileSystem
->ChkdskFunc
== NULL
)
3119 "Setup is currently unable to check a partition formatted in %S.\n"
3121 " \x07 Press ENTER to continue Setup.\n"
3122 " \x07 Press F3 to quit Setup.",
3123 CurrentFileSystem
->FileSystemName
);
3126 MUIGetString(STRING_QUITCONTINUE
),
3127 NULL
, POPUP_WAIT_NONE
);
3131 CONSOLE_ConInKey(Ir
);
3133 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3134 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3136 if (ConfirmQuit(Ir
))
3139 return CHECK_FILE_SYSTEM_PAGE
;
3141 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3143 PartEntry
->NeedsCheck
= FALSE
;
3144 return CHECK_FILE_SYSTEM_PAGE
;
3150 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3151 if (!NT_SUCCESS(Status
))
3153 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3154 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
3155 "(Status 0x%08lx).\n", Status
);
3157 MUIGetString(STRING_REBOOTCOMPUTER
),
3158 Ir
, POPUP_WAIT_ENTER
);
3163 PartEntry
->NeedsCheck
= FALSE
;
3164 return CHECK_FILE_SYSTEM_PAGE
;
3170 * Displays the InstallDirectoryPage1.
3173 * PrepareCopyPage (At once)
3176 * Inits DestinationRootPath
3177 * Inits DestinationPath
3178 * Inits DestinationArcPath
3181 * Number of the next page.
3184 InstallDirectoryPage1(PWCHAR InstallDir
,
3185 PDISKENTRY DiskEntry
,
3186 PPARTENTRY PartEntry
)
3188 WCHAR PathBuffer
[MAX_PATH
];
3190 /* Create 'InstallPath' string */
3191 RtlFreeUnicodeString(&InstallPath
);
3192 RtlCreateUnicodeString(&InstallPath
, InstallDir
);
3194 /* Create 'DestinationRootPath' string */
3195 RtlFreeUnicodeString(&DestinationRootPath
);
3196 swprintf(PathBuffer
,
3197 L
"\\Device\\Harddisk%lu\\Partition%lu",
3198 DiskEntry
->DiskNumber
,
3199 PartEntry
->PartitionNumber
);
3200 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
3201 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
3203 /* Create 'DestinationPath' string */
3204 RtlFreeUnicodeString(&DestinationPath
);
3205 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3207 if (InstallDir
[0] != L
'\\')
3208 wcscat(PathBuffer
, L
"\\");
3210 wcscat(PathBuffer
, InstallDir
);
3211 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
3213 /* Create 'DestinationArcPath' */
3214 RtlFreeUnicodeString(&DestinationArcPath
);
3215 swprintf(PathBuffer
,
3216 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
3217 DiskEntry
->BiosDiskNumber
,
3218 PartEntry
->PartitionNumber
);
3220 if (InstallDir
[0] != L
'\\')
3221 wcscat(PathBuffer
, L
"\\");
3223 wcscat(PathBuffer
, InstallDir
);
3224 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3226 return PREPARE_COPY_PAGE
;
3231 * Displays the InstallDirectoryPage.
3234 * PrepareCopyPage (As the direct result of InstallDirectoryPage1)
3238 * Number of the next page.
3241 InstallDirectoryPage(PINPUT_RECORD Ir
)
3243 PDISKENTRY DiskEntry
;
3244 PPARTENTRY PartEntry
;
3245 WCHAR InstallDir
[51];
3249 /* We do not need the filsystem list any more */
3250 DestroyFileSystemList(FileSystemList
);
3251 FileSystemList
= NULL
;
3253 if (PartitionList
== NULL
||
3254 PartitionList
->CurrentDisk
== NULL
||
3255 PartitionList
->CurrentPartition
== NULL
)
3257 /* FIXME: show an error dialog */
3261 DiskEntry
= PartitionList
->CurrentDisk
;
3262 PartEntry
= PartitionList
->CurrentPartition
;
3264 if (IsUnattendedSetup
)
3265 wcscpy(InstallDir
, UnattendInstallationDirectory
);
3267 wcscpy(InstallDir
, L
"\\ReactOS");
3269 Length
= wcslen(InstallDir
);
3270 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3271 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3273 // FIXME: Check the validity of the InstallDir; however what to do
3274 // if it is invalid but we are in unattended setup? (case of somebody
3275 // specified an invalid installation directory in the unattended file).
3277 if (IsUnattendedSetup
)
3279 return InstallDirectoryPage1(InstallDir
,
3286 CONSOLE_ConInKey(Ir
);
3288 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3289 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3291 if (ConfirmQuit(Ir
) == TRUE
)
3296 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3299 * Check for the validity of the installation directory and pop up
3300 * an error if it is not the case. Then the user can fix its input.
3302 if (!IsValidPath(InstallDir
, Length
))
3304 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3305 return INSTALL_DIRECTORY_PAGE
;
3307 return InstallDirectoryPage1(InstallDir
,
3311 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3316 InstallDir
[Length
] = 0;
3317 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3320 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3324 c
= (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3325 if (iswalpha(c
) || iswdigit(c
) || c
== '.' || c
== '\\' || c
== '-' || c
== '_')
3327 InstallDir
[Length
] = c
;
3329 InstallDir
[Length
] = 0;
3330 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3336 return INSTALL_DIRECTORY_PAGE
;
3341 AddSectionToCopyQueueCab(HINF InfFile
,
3343 PWCHAR SourceCabinet
,
3344 PCUNICODE_STRING DestinationPath
,
3347 INFCONTEXT FilesContext
;
3348 INFCONTEXT DirContext
;
3350 PWCHAR FileKeyValue
;
3352 PWCHAR TargetFileName
;
3354 /* Search for the SectionName section */
3355 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3358 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3359 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3364 * Enumerate the files in the section
3365 * and add them to the file queue.
3369 /* Get source file name and target directory id */
3370 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3372 /* FIXME: Handle error! */
3373 DPRINT1("INF_GetData() failed\n");
3377 /* Get optional target file name */
3378 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3379 TargetFileName
= NULL
;
3381 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3383 /* Lookup target directory */
3384 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3386 /* FIXME: Handle error! */
3387 DPRINT1("SetupFindFirstLine() failed\n");
3391 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3393 /* FIXME: Handle error! */
3394 DPRINT1("INF_GetData() failed\n");
3398 if (!SetupQueueCopy(SetupFileQueue
,
3400 SourceRootPath
.Buffer
,
3401 SourceRootDir
.Buffer
,
3406 /* FIXME: Handle error! */
3407 DPRINT1("SetupQueueCopy() failed\n");
3409 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3416 AddSectionToCopyQueue(HINF InfFile
,
3418 PWCHAR SourceCabinet
,
3419 PCUNICODE_STRING DestinationPath
,
3422 INFCONTEXT FilesContext
;
3423 INFCONTEXT DirContext
;
3425 PWCHAR FileKeyValue
;
3427 PWCHAR TargetFileName
;
3429 WCHAR CompleteOrigDirName
[512];
3432 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3434 /* Search for the SectionName section */
3435 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3438 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3439 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3444 * Enumerate the files in the section
3445 * and add them to the file queue.
3449 /* Get source file name and target directory id */
3450 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3452 /* FIXME: Handle error! */
3453 DPRINT1("INF_GetData() failed\n");
3457 /* Get target directory id */
3458 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3460 /* FIXME: Handle error! */
3461 DPRINT1("INF_GetData() failed\n");
3465 /* Get optional target file name */
3466 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3467 TargetFileName
= NULL
;
3468 else if (!*TargetFileName
)
3469 TargetFileName
= NULL
;
3471 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3473 /* Lookup target directory */
3474 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3476 /* FIXME: Handle error! */
3477 DPRINT1("SetupFindFirstLine() failed\n");
3481 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3483 /* FIXME: Handle error! */
3484 DPRINT1("INF_GetData() failed\n");
3488 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3490 /* Installation path */
3491 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3493 else if (DirKeyValue
[0] == L
'\\')
3496 wcscpy(CompleteOrigDirName
, DirKeyValue
);
3498 else // if (DirKeyValue[0] != L'\\')
3500 /* Path relative to the installation path */
3501 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3502 wcscat(CompleteOrigDirName
, L
"\\");
3503 wcscat(CompleteOrigDirName
, DirKeyValue
);
3506 /* Remove trailing backslash */
3507 Length
= wcslen(CompleteOrigDirName
);
3508 if ((Length
> 0) && (CompleteOrigDirName
[Length
- 1] == L
'\\'))
3510 CompleteOrigDirName
[Length
- 1] = 0;
3513 if (!SetupQueueCopy(SetupFileQueue
,
3515 SourceRootPath
.Buffer
,
3516 CompleteOrigDirName
,
3521 /* FIXME: Handle error! */
3522 DPRINT1("SetupQueueCopy() failed\n");
3524 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3531 PrepareCopyPageInfFile(HINF InfFile
,
3532 PWCHAR SourceCabinet
,
3535 WCHAR PathBuffer
[MAX_PATH
];
3536 INFCONTEXT DirContext
;
3537 PWCHAR AdditionalSectionName
= NULL
;
3542 /* Add common files */
3543 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3546 /* Add specific files depending of computer type */
3547 if (SourceCabinet
== NULL
)
3549 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3552 if (AdditionalSectionName
)
3554 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3559 /* Create directories */
3563 * - Install directories like '\reactos\test' are not handled yet.
3564 * - Copying files to DestinationRootPath should be done from within
3565 * the SystemPartitionFiles section.
3566 * At the moment we check whether we specify paths like '\foo' or '\\' for that.
3567 * For installing to DestinationPath specify just '\' .
3570 /* Get destination path */
3571 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3573 /* Remove trailing backslash */
3574 Length
= wcslen(PathBuffer
);
3575 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3577 PathBuffer
[Length
- 1] = 0;
3580 /* Create the install directory */
3581 Status
= SetupCreateDirectory(PathBuffer
);
3582 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3584 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3585 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3589 /* Search for the 'Directories' section */
3590 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3594 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3598 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3604 /* Enumerate the directory values and create the subdirectories */
3607 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3613 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3615 /* Installation path */
3616 DPRINT("InstallationPath: '%S'\n", DirKeyValue
);
3618 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3620 DPRINT("FullPath: '%S'\n", PathBuffer
);
3622 else if (DirKeyValue
[0] == L
'\\')
3625 DPRINT("Absolute Path: '%S'\n", DirKeyValue
);
3627 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3628 wcscat(PathBuffer
, DirKeyValue
);
3630 /* Remove trailing backslash */
3631 Length
= wcslen(PathBuffer
);
3632 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3634 PathBuffer
[Length
- 1] = 0;
3637 DPRINT("FullPath: '%S'\n", PathBuffer
);
3639 Status
= SetupCreateDirectory(PathBuffer
);
3640 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3642 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3643 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3647 else // if (DirKeyValue[0] != L'\\')
3649 /* Path relative to the installation path */
3650 DPRINT("RelativePath: '%S'\n", DirKeyValue
);
3652 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3653 wcscat(PathBuffer
, L
"\\");
3654 wcscat(PathBuffer
, DirKeyValue
);
3656 /* Remove trailing backslash */
3657 Length
= wcslen(PathBuffer
);
3658 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3660 PathBuffer
[Length
- 1] = 0;
3663 DPRINT("FullPath: '%S'\n", PathBuffer
);
3665 Status
= SetupCreateDirectory(PathBuffer
);
3666 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3668 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3669 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3673 } while (SetupFindNextLine(&DirContext
, &DirContext
));
3680 * Displays the PrepareCopyPage.
3683 * FileCopyPage(At once)
3687 * Inits SetupFileQueue
3688 * Calls PrepareCopyPageInfFile
3691 * Number of the next page.
3694 PrepareCopyPage(PINPUT_RECORD Ir
)
3697 WCHAR PathBuffer
[MAX_PATH
];
3698 INFCONTEXT CabinetsContext
;
3704 MUIDisplayPage(PREPARE_COPY_PAGE
);
3706 /* Create the file queue */
3707 SetupFileQueue
= SetupOpenFileQueue();
3708 if (SetupFileQueue
== NULL
)
3710 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3714 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3719 /* Search for the 'Cabinets' section */
3720 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3722 return FILE_COPY_PAGE
;
3726 * Enumerate the directory values in the 'Cabinets'
3727 * section and parse their inf files.
3731 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3734 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3735 wcscat(PathBuffer
, L
"\\");
3736 wcscat(PathBuffer
, KeyValue
);
3739 CabinetInitialize();
3740 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3741 CabinetSetCabinetName(PathBuffer
);
3743 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3745 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3747 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3748 if (InfFileData
== NULL
)
3750 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3756 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3757 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3761 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3768 if (InfHandle
== INVALID_HANDLE_VALUE
)
3770 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3776 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3781 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3783 return FILE_COPY_PAGE
;
3789 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3792 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3794 /* Get the memory information from the system */
3795 NtQuerySystemInformation(SystemPerformanceInformation
,
3800 /* Check if this is initial setup */
3803 /* Set maximum limits to be total RAM pages */
3804 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3805 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3806 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3809 /* Set current values */
3810 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3811 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3812 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3818 FileCopyCallback(PVOID Context
,
3823 PCOPYCONTEXT CopyContext
;
3825 CopyContext
= (PCOPYCONTEXT
)Context
;
3827 switch (Notification
)
3829 case SPFILENOTIFY_STARTSUBQUEUE
:
3830 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3831 ProgressSetStepCount(CopyContext
->ProgressBar
,
3832 CopyContext
->TotalOperations
);
3833 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3836 case SPFILENOTIFY_STARTCOPY
:
3837 /* Display copy message */
3838 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3839 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3842 case SPFILENOTIFY_ENDCOPY
:
3843 CopyContext
->CompletedOperations
++;
3845 /* SYSREG checkpoint */
3846 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3847 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3849 ProgressNextStep(CopyContext
->ProgressBar
);
3850 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3859 * Displays the FileCopyPage.
3862 * RegistryPage(At once)
3865 * Calls SetupCommitFileQueueW
3866 * Calls SetupCloseFileQueue
3869 * Number of the next page.
3873 FileCopyPage(PINPUT_RECORD Ir
)
3875 COPYCONTEXT CopyContext
;
3876 unsigned int mem_bar_width
;
3878 MUIDisplayPage(FILE_COPY_PAGE
);
3880 /* Create context for the copy process */
3881 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3882 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3883 CopyContext
.TotalOperations
= 0;
3884 CopyContext
.CompletedOperations
= 0;
3886 /* Create the progress bar as well */
3887 CopyContext
.ProgressBar
= CreateProgressBar(13,
3894 MUIGetString(STRING_SETUPCOPYINGFILES
));
3896 // fit memory bars to screen width, distribute them uniform
3897 mem_bar_width
= (xScreen
- 26) / 5;
3898 mem_bar_width
-= mem_bar_width
% 2; // make even
3899 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3900 /* Create the paged pool progress bar */
3901 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3910 /* Create the non paged pool progress bar */
3911 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3913 (xScreen
/ 2) + (mem_bar_width
/ 2),
3915 (xScreen
/ 2)- (mem_bar_width
/ 2),
3920 /* Create the global memory progress bar */
3921 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3925 xScreen
- 13 - mem_bar_width
,
3930 /* Do the file copying */
3931 SetupCommitFileQueueW(NULL
,
3936 /* If we get here, we're done, so cleanup the queue and progress bar */
3937 SetupCloseFileQueue(SetupFileQueue
);
3938 DestroyProgressBar(CopyContext
.ProgressBar
);
3939 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3940 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3941 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3943 /* Go display the next page */
3944 return REGISTRY_PAGE
;
3949 * Displays the RegistryPage.
3952 * SuccessPage (if RepairUpdate)
3953 * BootLoaderPage (default)
3957 * Calls SetInstallPathValue
3958 * Calls NtInitializeRegistry
3959 * Calls ImportRegistryFile
3960 * Calls SetDefaultPagefile
3961 * Calls SetMountedDeviceValues
3964 * Number of the next page.
3967 RegistryPage(PINPUT_RECORD Ir
)
3969 INFCONTEXT InfContext
;
3976 MUIDisplayPage(REGISTRY_PAGE
);
3978 if (RepairUpdateFlag
)
3980 return SUCCESS_PAGE
;
3983 if (!SetInstallPathValue(&DestinationPath
))
3985 DPRINT1("SetInstallPathValue() failed\n");
3986 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3990 /* Create the default hives */
3991 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3992 if (!NT_SUCCESS(Status
))
3994 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3995 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3999 /* Update registry */
4000 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
4002 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
4004 DPRINT1("SetupFindFirstLine() failed\n");
4005 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
4011 INF_GetDataField (&InfContext
, 0, &Action
);
4012 INF_GetDataField (&InfContext
, 1, &File
);
4013 INF_GetDataField (&InfContext
, 2, &Section
);
4015 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
4020 if (!_wcsicmp (Action
, L
"AddReg"))
4024 else if (!_wcsicmp (Action
, L
"DelReg"))
4033 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
4035 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
4037 DPRINT1("Importing %S failed\n", File
);
4039 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
4042 } while (SetupFindNextLine(&InfContext
, &InfContext
));
4044 /* Update display registry settings */
4045 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
4046 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
4048 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4052 /* Set the locale */
4053 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
4054 if (!ProcessLocaleRegistry(LanguageList
))
4056 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4060 /* Add keyboard layouts */
4061 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
4062 if (!AddKeyboardLayouts())
4064 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
4070 if (!SetGeoID(MUIGetGeoID()))
4072 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
4076 if (!IsUnattendedSetup
)
4078 /* Update keyboard layout settings */
4079 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
4080 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
4082 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4087 /* Add codepage information to registry */
4088 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
4091 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
4095 /* Set the default pagefile entry */
4096 SetDefaultPagefile(DestinationDriveLetter
);
4098 /* Update the mounted devices list */
4099 SetMountedDeviceValues(PartitionList
);
4101 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
4103 return BOOT_LOADER_PAGE
;
4108 * Displays the BootLoaderPage.
4111 * SuccessPage (if RepairUpdate)
4112 * BootLoaderHarddiskMbrPage
4113 * BootLoaderHarddiskVbrPage
4114 * BootLoaderFloppyPage
4119 * Calls SetInstallPathValue
4120 * Calls NtInitializeRegistry
4121 * Calls ImportRegistryFile
4122 * Calls SetDefaultPagefile
4123 * Calls SetMountedDeviceValues
4126 * Number of the next page.
4129 BootLoaderPage(PINPUT_RECORD Ir
)
4131 UCHAR PartitionType
;
4132 BOOLEAN InstallOnFloppy
;
4134 WCHAR PathBuffer
[MAX_PATH
];
4136 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
4138 RtlFreeUnicodeString(&SystemRootPath
);
4139 swprintf(PathBuffer
,
4140 L
"\\Device\\Harddisk%lu\\Partition%lu",
4141 PartitionList
->SystemDisk
->DiskNumber
,
4142 PartitionList
->SystemPartition
->PartitionNumber
);
4143 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
4144 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
4146 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4148 if (IsUnattendedSetup
)
4150 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
4152 return SUCCESS_PAGE
;
4154 else if (UnattendMBRInstallType
== 1) /* install on floppy */
4156 return BOOT_LOADER_FLOPPY_PAGE
;
4160 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
4162 DPRINT("Error: system partition invalid (unused)\n");
4163 InstallOnFloppy
= TRUE
;
4165 else if (PartitionType
== PARTITION_OS2BOOTMGR
)
4167 /* OS/2 boot manager partition */
4168 DPRINT("Found OS/2 boot manager partition\n");
4169 InstallOnFloppy
= TRUE
;
4171 else if (PartitionType
== PARTITION_EXT2
)
4173 /* Linux EXT2 partition */
4174 DPRINT("Found Linux EXT2 partition\n");
4175 InstallOnFloppy
= FALSE
;
4177 else if (PartitionType
== PARTITION_IFS
)
4179 /* NTFS partition */
4180 DPRINT("Found NTFS partition\n");
4182 // FIXME: Make it FALSE when we'll support NTFS installation!
4183 InstallOnFloppy
= TRUE
;
4185 else if ((PartitionType
== PARTITION_FAT_12
) ||
4186 (PartitionType
== PARTITION_FAT_16
) ||
4187 (PartitionType
== PARTITION_HUGE
) ||
4188 (PartitionType
== PARTITION_XINT13
) ||
4189 (PartitionType
== PARTITION_FAT32
) ||
4190 (PartitionType
== PARTITION_FAT32_XINT13
))
4192 DPRINT("Found FAT partition\n");
4193 InstallOnFloppy
= FALSE
;
4197 /* Unknown partition */
4198 DPRINT("Unknown partition found\n");
4199 InstallOnFloppy
= TRUE
;
4202 if (InstallOnFloppy
== TRUE
)
4204 return BOOT_LOADER_FLOPPY_PAGE
;
4207 /* Unattended install on hdd? */
4208 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
4210 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4213 MUIDisplayPage(BOOT_LOADER_PAGE
);
4214 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4218 CONSOLE_ConInKey(Ir
);
4220 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4221 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
4223 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4232 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4234 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4235 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
4237 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4246 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4248 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4249 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4251 if (ConfirmQuit(Ir
) == TRUE
)
4256 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4260 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4262 else if (Line
== 13)
4264 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4266 else if (Line
== 14)
4268 return BOOT_LOADER_FLOPPY_PAGE
;
4270 else if (Line
== 15)
4272 return SUCCESS_PAGE
;
4275 return BOOT_LOADER_PAGE
;
4279 return BOOT_LOADER_PAGE
;
4284 * Displays the BootLoaderFloppyPage.
4287 * SuccessPage (At once)
4291 * Calls InstallFatBootcodeToFloppy()
4294 * Number of the next page.
4297 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4301 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4303 // SetStatusText(" Please wait...");
4307 CONSOLE_ConInKey(Ir
);
4309 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4310 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4312 if (ConfirmQuit(Ir
) == TRUE
)
4317 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4319 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
4321 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4322 return BOOT_LOADER_FLOPPY_PAGE
;
4325 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
4326 if (!NT_SUCCESS(Status
))
4328 /* Print error message */
4329 return BOOT_LOADER_FLOPPY_PAGE
;
4332 return SUCCESS_PAGE
;
4336 return BOOT_LOADER_FLOPPY_PAGE
;
4341 * Displays the BootLoaderHarddiskVbrPage.
4344 * SuccessPage (At once)
4348 * Calls InstallVBRToPartition()
4351 * Number of the next page.
4354 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4356 UCHAR PartitionType
;
4359 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4361 Status
= InstallVBRToPartition(&SystemRootPath
,
4363 &DestinationArcPath
,
4365 if (!NT_SUCCESS(Status
))
4367 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4371 return SUCCESS_PAGE
;
4376 * Displays the BootLoaderHarddiskMbrPage.
4379 * SuccessPage (At once)
4383 * Calls InstallVBRToPartition()
4384 * CallsInstallMbrBootCodeToDisk()
4387 * Number of the next page.
4390 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4392 UCHAR PartitionType
;
4394 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4395 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
4397 /* Step 1: Write the VBR */
4398 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4400 Status
= InstallVBRToPartition(&SystemRootPath
,
4402 &DestinationArcPath
,
4404 if (!NT_SUCCESS(Status
))
4406 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4410 /* Step 2: Write the MBR */
4411 swprintf(DestinationDevicePathBuffer
,
4412 L
"\\Device\\Harddisk%d\\Partition0",
4413 PartitionList
->SystemDisk
->DiskNumber
);
4415 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4416 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4418 DPRINT("Install MBR bootcode: %S ==> %S\n",
4419 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4421 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4422 DestinationDevicePathBuffer
);
4423 if (!NT_SUCCESS (Status
))
4425 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4427 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4431 return SUCCESS_PAGE
;
4436 * Displays the QuitPage.
4439 * FlushPage (At once)
4445 * Number of the next page.
4448 QuitPage(PINPUT_RECORD Ir
)
4450 MUIDisplayPage(QUIT_PAGE
);
4452 /* Destroy partition list */
4453 if (PartitionList
!= NULL
)
4455 DestroyPartitionList (PartitionList
);
4456 PartitionList
= NULL
;
4459 /* Destroy filesystem list */
4460 if (FileSystemList
!= NULL
)
4462 DestroyFileSystemList (FileSystemList
);
4463 FileSystemList
= NULL
;
4466 /* Destroy computer settings list */
4467 if (ComputerList
!= NULL
)
4469 DestroyGenericList(ComputerList
, TRUE
);
4470 ComputerList
= NULL
;
4473 /* Destroy display settings list */
4474 if (DisplayList
!= NULL
)
4476 DestroyGenericList(DisplayList
, TRUE
);
4480 /* Destroy keyboard settings list */
4481 if (KeyboardList
!= NULL
)
4483 DestroyGenericList(KeyboardList
, TRUE
);
4484 KeyboardList
= NULL
;
4487 /* Destroy keyboard layout list */
4488 if (LayoutList
!= NULL
)
4490 DestroyGenericList(LayoutList
, TRUE
);
4494 if (LanguageList
!= NULL
)
4496 DestroyGenericList(LanguageList
, FALSE
);
4497 LanguageList
= NULL
;
4500 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4504 CONSOLE_ConInKey(Ir
);
4506 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4515 * Displays the SuccessPage.
4518 * FlushPage (At once)
4524 * Number of the next page.
4527 SuccessPage(PINPUT_RECORD Ir
)
4529 MUIDisplayPage(SUCCESS_PAGE
);
4531 if (IsUnattendedSetup
)
4538 CONSOLE_ConInKey(Ir
);
4540 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4549 * Displays the FlushPage.
4552 * RebootPage (At once)
4555 * Number of the next page.
4558 FlushPage(PINPUT_RECORD Ir
)
4560 MUIDisplayPage(FLUSH_PAGE
);
4566 PnpEventThread(IN LPVOID lpParameter
);
4570 * The start routine and page management
4581 NtQuerySystemTime(&Time
);
4583 Status
= RtlCreateUserThread(NtCurrentProcess(),
4593 if (!NT_SUCCESS(Status
))
4594 hPnpThread
= INVALID_HANDLE_VALUE
;
4596 if (!CONSOLE_Init())
4598 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4599 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4600 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4602 /* Raise a hard error (crash the system/BSOD) */
4603 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4607 /* Initialize global unicode strings */
4608 RtlInitUnicodeString(&SourcePath
, NULL
);
4609 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4610 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4611 RtlInitUnicodeString(&InstallPath
, NULL
);
4612 RtlInitUnicodeString(&DestinationPath
, NULL
);
4613 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4614 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4615 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4617 /* Hide the cursor */
4618 CONSOLE_SetCursorType(TRUE
, FALSE
);
4621 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4623 CONSOLE_ClearScreen();
4626 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4633 Page
= SetupStartPage(&Ir
);
4638 Page
= LanguagePage(&Ir
);
4643 Page
= LicensePage(&Ir
);
4648 Page
= IntroPage(&Ir
);
4652 case INSTALL_INTRO_PAGE
:
4653 Page
= InstallIntroPage(&Ir
);
4657 case SCSI_CONTROLLER_PAGE
:
4658 Page
= ScsiControllerPage(&Ir
);
4663 case OEM_DRIVER_PAGE
:
4664 Page
= OemDriverPage(&Ir
);
4668 case DEVICE_SETTINGS_PAGE
:
4669 Page
= DeviceSettingsPage(&Ir
);
4672 case COMPUTER_SETTINGS_PAGE
:
4673 Page
= ComputerSettingsPage(&Ir
);
4676 case DISPLAY_SETTINGS_PAGE
:
4677 Page
= DisplaySettingsPage(&Ir
);
4680 case KEYBOARD_SETTINGS_PAGE
:
4681 Page
= KeyboardSettingsPage(&Ir
);
4684 case LAYOUT_SETTINGS_PAGE
:
4685 Page
= LayoutSettingsPage(&Ir
);
4688 case SELECT_PARTITION_PAGE
:
4689 Page
= SelectPartitionPage(&Ir
);
4692 case CREATE_PRIMARY_PARTITION_PAGE
:
4693 Page
= CreatePrimaryPartitionPage(&Ir
);
4696 case CREATE_EXTENDED_PARTITION_PAGE
:
4697 Page
= CreateExtendedPartitionPage(&Ir
);
4700 case CREATE_LOGICAL_PARTITION_PAGE
:
4701 Page
= CreateLogicalPartitionPage(&Ir
);
4704 case CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
:
4705 Page
= ConfirmDeleteSystemPartitionPage(&Ir
);
4708 case DELETE_PARTITION_PAGE
:
4709 Page
= DeletePartitionPage(&Ir
);
4712 case SELECT_FILE_SYSTEM_PAGE
:
4713 Page
= SelectFileSystemPage(&Ir
);
4716 case FORMAT_PARTITION_PAGE
:
4717 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4720 case CHECK_FILE_SYSTEM_PAGE
:
4721 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4724 case INSTALL_DIRECTORY_PAGE
:
4725 Page
= InstallDirectoryPage(&Ir
);
4728 case PREPARE_COPY_PAGE
:
4729 Page
= PrepareCopyPage(&Ir
);
4732 case FILE_COPY_PAGE
:
4733 Page
= FileCopyPage(&Ir
);
4737 Page
= RegistryPage(&Ir
);
4740 case BOOT_LOADER_PAGE
:
4741 Page
= BootLoaderPage(&Ir
);
4744 case BOOT_LOADER_FLOPPY_PAGE
:
4745 Page
= BootLoaderFloppyPage(&Ir
);
4748 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4749 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4752 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4753 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4757 case REPAIR_INTRO_PAGE
:
4758 Page
= RepairIntroPage(&Ir
);
4762 Page
= SuccessPage(&Ir
);
4766 Page
= FlushPage(&Ir
);
4770 Page
= QuitPage(&Ir
);
4779 if (Page
== RECOVERY_PAGE
)
4784 /* Avoid bugcheck */
4785 Time
.QuadPart
+= 50000000;
4786 NtDelayExecution(FALSE
, &Time
);
4789 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4790 NtShutdownSystem(ShutdownReboot
);
4791 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4792 NtTerminateProcess(NtCurrentProcess(), 0);
4799 NtProcessStartup(PPEB Peb
)
4801 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4803 ProcessHeap
= Peb
->ProcessHeap
;
4804 InfSetHeap(ProcessHeap
);
4807 #endif /* __REACTOS__ */