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
)
1972 else if (Cancel
== TRUE
)
1974 return SELECT_PARTITION_PAGE
;
1978 PartSize
= atoi(InputBuffer
);
1986 if (PartSize
> MaxSize
)
1992 /* Convert to bytes */
1993 if (PartSize
== MaxSize
)
1995 /* Use all of the unpartitioned disk space */
1996 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2000 /* Calculate the sector count from the size in MB */
2001 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2003 /* But never get larger than the unpartitioned disk space */
2004 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2005 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2008 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2010 CreatePrimaryPartition(PartitionList
,
2014 return SELECT_PARTITION_PAGE
;
2018 return CREATE_PRIMARY_PARTITION_PAGE
;
2023 * Displays the CreateExtendedPartitionPage.
2026 * SelectPartitionPage (default)
2030 * Number of the next page.
2033 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
2035 PDISKENTRY DiskEntry
;
2036 PPARTENTRY PartEntry
;
2039 CHAR InputBuffer
[50];
2043 ULONGLONG SectorCount
;
2046 if (PartitionList
== NULL
||
2047 PartitionList
->CurrentDisk
== NULL
||
2048 PartitionList
->CurrentPartition
== NULL
)
2050 /* FIXME: show an error dialog */
2054 DiskEntry
= PartitionList
->CurrentDisk
;
2055 PartEntry
= PartitionList
->CurrentPartition
;
2057 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2059 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
2061 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2063 if (DiskSize
>= 10737418240) /* 10 GB */
2065 DiskSize
= DiskSize
/ 1073741824;
2066 Unit
= MUIGetString(STRING_GB
);
2071 DiskSize
= DiskSize
/ 1048576;
2075 Unit
= MUIGetString(STRING_MB
);
2078 if (DiskEntry
->DriverName
.Length
> 0)
2080 CONSOLE_PrintTextXY(6, 10,
2081 MUIGetString(STRING_HDINFOPARTCREATE
),
2084 DiskEntry
->DiskNumber
,
2088 &DiskEntry
->DriverName
);
2092 CONSOLE_PrintTextXY(6, 10,
2093 MUIGetString(STRING_HDDINFOUNK1
),
2096 DiskEntry
->DiskNumber
,
2102 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2105 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2106 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2109 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2111 PartEntry
= PartitionList
->CurrentPartition
;
2114 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2116 if (MaxSize
> PARTITION_MAXSIZE
)
2117 MaxSize
= PARTITION_MAXSIZE
;
2119 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2120 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2124 if (ConfirmQuit(Ir
) == TRUE
)
2127 else if (Cancel
== TRUE
)
2129 return SELECT_PARTITION_PAGE
;
2133 PartSize
= atoi(InputBuffer
);
2141 if (PartSize
> MaxSize
)
2147 /* Convert to bytes */
2148 if (PartSize
== MaxSize
)
2150 /* Use all of the unpartitioned disk space */
2151 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2155 /* Calculate the sector count from the size in MB */
2156 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2158 /* But never get larger than the unpartitioned disk space */
2159 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2160 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2163 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2165 CreateExtendedPartition(PartitionList
,
2168 return SELECT_PARTITION_PAGE
;
2172 return CREATE_EXTENDED_PARTITION_PAGE
;
2177 * Displays the CreateLogicalPartitionPage.
2180 * SelectFileSystemPage (default)
2184 * Number of the next page.
2187 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2189 PDISKENTRY DiskEntry
;
2190 PPARTENTRY PartEntry
;
2193 CHAR InputBuffer
[50];
2197 ULONGLONG SectorCount
;
2200 if (PartitionList
== NULL
||
2201 PartitionList
->CurrentDisk
== NULL
||
2202 PartitionList
->CurrentPartition
== NULL
)
2204 /* FIXME: show an error dialog */
2208 DiskEntry
= PartitionList
->CurrentDisk
;
2209 PartEntry
= PartitionList
->CurrentPartition
;
2211 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2213 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2215 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2217 if (DiskSize
>= 10737418240) /* 10 GB */
2219 DiskSize
= DiskSize
/ 1073741824;
2220 Unit
= MUIGetString(STRING_GB
);
2225 DiskSize
= DiskSize
/ 1048576;
2229 Unit
= MUIGetString(STRING_MB
);
2232 if (DiskEntry
->DriverName
.Length
> 0)
2234 CONSOLE_PrintTextXY(6, 10,
2235 MUIGetString(STRING_HDINFOPARTCREATE
),
2238 DiskEntry
->DiskNumber
,
2242 &DiskEntry
->DriverName
);
2246 CONSOLE_PrintTextXY(6, 10,
2247 MUIGetString(STRING_HDDINFOUNK1
),
2250 DiskEntry
->DiskNumber
,
2256 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2259 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2260 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2263 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2265 PartEntry
= PartitionList
->CurrentPartition
;
2268 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2270 if (MaxSize
> PARTITION_MAXSIZE
)
2271 MaxSize
= PARTITION_MAXSIZE
;
2273 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2274 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2278 if (ConfirmQuit(Ir
) == TRUE
)
2281 else if (Cancel
== TRUE
)
2283 return SELECT_PARTITION_PAGE
;
2287 PartSize
= atoi(InputBuffer
);
2295 if (PartSize
> MaxSize
)
2301 /* Convert to bytes */
2302 if (PartSize
== MaxSize
)
2304 /* Use all of the unpartitioned disk space */
2305 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2309 /* Calculate the sector count from the size in MB */
2310 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2312 /* But never get larger than the unpartitioned disk space */
2313 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2314 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2317 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2319 CreateLogicalPartition(PartitionList
,
2323 return SELECT_PARTITION_PAGE
;
2327 return CREATE_LOGICAL_PARTITION_PAGE
;
2332 * Displays the ConfirmDeleteSystemPartitionPage.
2335 * DeletePartitionPage (default)
2336 * SelectPartitionPage
2339 * Number of the next page.
2342 ConfirmDeleteSystemPartitionPage(PINPUT_RECORD Ir
)
2344 MUIDisplayPage(CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
);
2348 CONSOLE_ConInKey(Ir
);
2350 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2351 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2353 if (ConfirmQuit(Ir
) == TRUE
)
2358 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2360 return DELETE_PARTITION_PAGE
;
2362 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2364 return SELECT_PARTITION_PAGE
;
2368 return SELECT_PARTITION_PAGE
;
2373 * Displays the DeletePartitionPage.
2376 * SelectPartitionPage (default)
2380 * Number of the next page.
2383 DeletePartitionPage(PINPUT_RECORD Ir
)
2385 PDISKENTRY DiskEntry
;
2386 PPARTENTRY PartEntry
;
2392 if (PartitionList
== NULL
||
2393 PartitionList
->CurrentDisk
== NULL
||
2394 PartitionList
->CurrentPartition
== NULL
)
2396 /* FIXME: show an error dialog */
2400 DiskEntry
= PartitionList
->CurrentDisk
;
2401 PartEntry
= PartitionList
->CurrentPartition
;
2403 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2405 GetPartTypeStringFromPartitionType(PartEntry
->PartitionType
, PartType
, 30);
2407 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2409 if (PartSize
>= 10737418240) /* 10 GB */
2411 PartSize
= PartSize
/ 1073741824;
2412 Unit
= MUIGetString(STRING_GB
);
2416 if (PartSize
>= 10485760) /* 10 MB */
2418 PartSize
= PartSize
/ 1048576;
2419 Unit
= MUIGetString(STRING_MB
);
2423 PartSize
= PartSize
/ 1024;
2424 Unit
= MUIGetString(STRING_KB
);
2427 if (PartType
== NULL
)
2429 CONSOLE_PrintTextXY(6, 10,
2430 MUIGetString(STRING_HDDINFOUNK2
),
2431 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2432 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2433 PartEntry
->PartitionType
,
2439 CONSOLE_PrintTextXY(6, 10,
2440 " %c%c %s %I64u %s",
2441 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2442 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2448 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2450 if (DiskSize
>= 10737418240) /* 10 GB */
2452 DiskSize
= DiskSize
/ 1073741824;
2453 Unit
= MUIGetString(STRING_GB
);
2458 DiskSize
= DiskSize
/ 1048576;
2462 Unit
= MUIGetString(STRING_MB
);
2465 if (DiskEntry
->DriverName
.Length
> 0)
2467 CONSOLE_PrintTextXY(6, 12,
2468 MUIGetString(STRING_HDINFOPARTDELETE
),
2471 DiskEntry
->DiskNumber
,
2475 &DiskEntry
->DriverName
);
2479 CONSOLE_PrintTextXY(6, 12,
2480 MUIGetString(STRING_HDDINFOUNK3
),
2483 DiskEntry
->DiskNumber
,
2491 CONSOLE_ConInKey(Ir
);
2493 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2494 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2496 if (ConfirmQuit(Ir
) == TRUE
)
2501 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2503 return SELECT_PARTITION_PAGE
;
2505 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2507 DeleteCurrentPartition(PartitionList
);
2509 return SELECT_PARTITION_PAGE
;
2513 return DELETE_PARTITION_PAGE
;
2518 * Displays the SelectFileSystemPage.
2521 * CheckFileSystemPage (At once if RepairUpdate is selected)
2522 * CheckFileSystemPage (At once if Unattended and not UnattendFormatPartition)
2523 * FormatPartitionPage (At once if Unattended and UnattendFormatPartition)
2524 * SelectPartitionPage (If the user aborts)
2525 * FormatPartitionPage (Default)
2529 * Sets PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType (via UpdatePartitionType)
2530 * Calls CheckActiveSystemPartition()
2533 * Number of the next page.
2536 SelectFileSystemPage(PINPUT_RECORD Ir
)
2538 PDISKENTRY DiskEntry
;
2539 PPARTENTRY PartEntry
;
2544 CHAR PartTypeString
[32];
2546 DPRINT("SelectFileSystemPage()\n");
2548 if (PartitionList
== NULL
||
2549 PartitionList
->CurrentDisk
== NULL
||
2550 PartitionList
->CurrentPartition
== NULL
)
2552 /* FIXME: show an error dialog */
2556 /* Find or set the active system partition */
2557 CheckActiveSystemPartition(PartitionList
);
2559 if (PartitionList
->SystemDisk
== NULL
||
2560 PartitionList
->SystemPartition
== NULL
)
2562 /* FIXME: show an error dialog */
2566 switch (PartitionList
->FormatState
)
2569 if (PartitionList
->CurrentPartition
!= PartitionList
->SystemPartition
)
2571 PartitionList
->TempDisk
= PartitionList
->SystemDisk
;
2572 PartitionList
->TempPartition
= PartitionList
->SystemPartition
;
2573 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2575 PartitionList
->FormatState
= FormatSystemPartition
;
2576 DPRINT1("FormatState: Start --> FormatSystemPartition\n");
2580 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2581 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2582 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2584 PartitionList
->FormatState
= FormatInstallPartition
;
2585 DPRINT1("FormatState: Start --> FormatInstallPartition\n");
2589 case FormatSystemPartition
:
2590 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2591 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2592 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2594 PartitionList
->FormatState
= FormatInstallPartition
;
2595 DPRINT1("FormatState: FormatSystemPartition --> FormatInstallPartition\n");
2598 case FormatInstallPartition
:
2599 if (GetNextUnformattedPartition(PartitionList
,
2600 &PartitionList
->TempDisk
,
2601 &PartitionList
->TempPartition
))
2603 PartitionList
->FormatState
= FormatOtherPartition
;
2604 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2605 DPRINT1("FormatState: FormatInstallPartition --> FormatOtherPartition\n");
2609 PartitionList
->FormatState
= FormatDone
;
2610 DPRINT1("FormatState: FormatInstallPartition --> FormatDone\n");
2611 return CHECK_FILE_SYSTEM_PAGE
;
2615 case FormatOtherPartition
:
2616 if (GetNextUnformattedPartition(PartitionList
,
2617 &PartitionList
->TempDisk
,
2618 &PartitionList
->TempPartition
))
2620 PartitionList
->FormatState
= FormatOtherPartition
;
2621 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2622 DPRINT1("FormatState: FormatOtherPartition --> FormatOtherPartition\n");
2626 PartitionList
->FormatState
= FormatDone
;
2627 DPRINT1("FormatState: FormatOtherPartition --> FormatDone\n");
2628 return CHECK_FILE_SYSTEM_PAGE
;
2633 DPRINT1("FormatState: Invalid value %ld\n", PartitionList
->FormatState
);
2634 /* FIXME: show an error dialog */
2638 DiskEntry
= PartitionList
->TempDisk
;
2639 PartEntry
= PartitionList
->TempPartition
;
2641 /* adjust disk size */
2642 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2643 if (DiskSize
>= 10737418240) /* 10 GB */
2645 DiskSize
= DiskSize
/ 1073741824;
2646 DiskUnit
= MUIGetString(STRING_GB
);
2650 DiskSize
= DiskSize
/ 1048576;
2651 DiskUnit
= MUIGetString(STRING_MB
);
2654 /* adjust partition size */
2655 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2656 if (PartSize
>= 10737418240) /* 10 GB */
2658 PartSize
= PartSize
/ 1073741824;
2659 PartUnit
= MUIGetString(STRING_GB
);
2663 PartSize
= PartSize
/ 1048576;
2664 PartUnit
= MUIGetString(STRING_MB
);
2667 /* adjust partition type */
2668 GetPartTypeStringFromPartitionType(PartEntry
->PartitionType
, PartTypeString
, 30);
2670 if (PartEntry
->AutoCreate
== TRUE
)
2672 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2675 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2676 PartEntry
->PartitionNumber
,
2682 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2683 DiskEntry
->DiskNumber
,
2689 &DiskEntry
->DriverName
);
2691 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2694 PartEntry
->AutoCreate
= FALSE
;
2696 else if (PartEntry
->New
== TRUE
)
2698 switch (PartitionList
->FormatState
)
2700 case FormatSystemPartition
:
2701 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2704 case FormatInstallPartition
:
2705 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2708 case FormatOtherPartition
:
2709 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2716 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2720 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2722 if (PartTypeString
== NULL
)
2724 CONSOLE_PrintTextXY(8, 10,
2725 MUIGetString(STRING_HDDINFOUNK4
),
2726 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2727 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2728 PartEntry
->PartitionType
,
2734 CONSOLE_PrintTextXY(8, 10,
2736 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2737 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2743 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2744 DiskEntry
->DiskNumber
,
2750 &DiskEntry
->DriverName
);
2753 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2755 if (FileSystemList
== NULL
)
2757 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2758 if (FileSystemList
== NULL
)
2760 /* FIXME: show an error dialog */
2764 /* FIXME: Add file systems to list */
2767 DrawFileSystemList(FileSystemList
);
2769 if (RepairUpdateFlag
)
2771 return CHECK_FILE_SYSTEM_PAGE
;
2772 //return SELECT_PARTITION_PAGE;
2775 if (IsUnattendedSetup
)
2777 if (UnattendFormatPartition
)
2779 PartEntry
->FileSystem
= GetFileSystemByName(FileSystemList
, L
"FAT");
2780 return FORMAT_PARTITION_PAGE
;
2783 return CHECK_FILE_SYSTEM_PAGE
;
2788 CONSOLE_ConInKey(Ir
);
2790 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2791 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2793 if (ConfirmQuit(Ir
) == TRUE
)
2798 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2799 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2801 return SELECT_PARTITION_PAGE
;
2803 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2804 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2806 ScrollDownFileSystemList(FileSystemList
);
2808 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2809 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2811 ScrollUpFileSystemList(FileSystemList
);
2813 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2815 if (!FileSystemList
->Selected
->FormatFunc
)
2817 return SELECT_FILE_SYSTEM_PAGE
;
2821 PartEntry
->FileSystem
= FileSystemList
->Selected
;
2822 return FORMAT_PARTITION_PAGE
;
2827 return SELECT_FILE_SYSTEM_PAGE
;
2832 * Displays the FormatPartitionPage.
2835 * InstallDirectoryPage (At once if IsUnattendedSetup or InstallShortcut)
2836 * SelectPartitionPage (At once)
2840 * Sets PartitionList->CurrentPartition->FormatState
2841 * Sets DestinationRootPath
2844 * Number of the next page.
2847 FormatPartitionPage(PINPUT_RECORD Ir
)
2849 UNICODE_STRING PartitionRootPath
;
2850 WCHAR PathBuffer
[MAX_PATH
];
2851 PDISKENTRY DiskEntry
;
2852 PPARTENTRY PartEntry
;
2861 DPRINT("FormatPartitionPage()\n");
2863 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2865 if (PartitionList
== NULL
||
2866 PartitionList
->TempDisk
== NULL
||
2867 PartitionList
->TempPartition
== NULL
)
2869 /* FIXME: show an error dialog */
2873 DiskEntry
= PartitionList
->TempDisk
;
2874 PartEntry
= PartitionList
->TempPartition
;
2878 if (!IsUnattendedSetup
)
2880 CONSOLE_ConInKey(Ir
);
2883 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2884 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2886 if (ConfirmQuit(Ir
) == TRUE
)
2891 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2893 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2895 if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"FAT") == 0)
2897 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2899 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2900 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2902 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2904 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2906 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2908 /* FAT16 CHS partition (partition size < 32MB) */
2909 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2911 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2913 /* FAT16 CHS partition (partition size < 512MB) */
2914 PartEntry
->PartitionType
= PARTITION_HUGE
;
2918 /* FAT32 CHS partition (partition size >= 512MB) */
2919 PartEntry
->PartitionType
= PARTITION_FAT32
;
2924 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2926 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2928 /* FAT16 LBA partition (partition size < 512MB) */
2929 PartEntry
->PartitionType
= PARTITION_XINT13
;
2933 /* FAT32 LBA partition (partition size >= 512MB) */
2934 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2938 DiskEntry
->Dirty
= TRUE
;
2939 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2940 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2943 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"EXT2") == 0)
2945 PartEntry
->PartitionType
= PARTITION_EXT2
;
2947 DiskEntry
->Dirty
= TRUE
;
2948 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2949 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2951 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"NTFS") == 0)
2953 PartEntry
->PartitionType
= PARTITION_IFS
;
2955 DiskEntry
->Dirty
= TRUE
;
2956 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2957 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2960 else if (!PartEntry
->FileSystem
->FormatFunc
)
2962 /* FIXME: show an error dialog */
2967 CONSOLE_PrintTextXY(6, 12,
2968 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2969 DiskEntry
->DiskSize
,
2970 DiskEntry
->CylinderSize
,
2971 DiskEntry
->TrackSize
);
2974 DiskEntry
= PartitionList
->TempDisk
;
2975 Entry
= DiskEntry
->PartListHead
.Flink
;
2977 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2979 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2981 if (PartEntry
->IsPartitioned
== TRUE
)
2983 CONSOLE_PrintTextXY(6, Line
,
2984 "%2u: %2u %c %12I64u %12I64u %2u %c",
2986 PartEntry
->PartitionNumber
,
2987 PartEntry
->BootIndicator
? 'A' : '-',
2988 PartEntry
->StartSector
.QuadPart
,
2989 PartEntry
->SectorCount
.QuadPart
,
2990 PartEntry
->PartitionType
,
2991 PartEntry
->Dirty
? '*' : ' ');
2995 Entry
= Entry
->Flink
;
2998 /* Restore the old entry */
2999 PartEntry
= PartitionList
->TempPartition
;
3002 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
3004 DPRINT("WritePartitionsToDisk() failed\n");
3005 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
3009 /* Set PartitionRootPath */
3010 swprintf(PathBuffer
,
3011 L
"\\Device\\Harddisk%lu\\Partition%lu",
3012 DiskEntry
->DiskNumber
,
3013 PartEntry
->PartitionNumber
);
3014 RtlInitUnicodeString(&PartitionRootPath
,
3016 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3018 if (PartEntry
->FileSystem
->FormatFunc
)
3020 Status
= FormatPartition(&PartitionRootPath
,
3021 PartEntry
->FileSystem
);
3022 if (!NT_SUCCESS(Status
))
3024 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
3025 MUIDisplayError(ERROR_FORMATTING_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
, PathBuffer
);
3029 PartEntry
->New
= FALSE
;
3033 CONSOLE_SetStatusText(" Done. Press any key ...");
3034 CONSOLE_ConInKey(Ir
);
3037 return SELECT_FILE_SYSTEM_PAGE
;
3041 return FORMAT_PARTITION_PAGE
;
3046 * Displays the CheckFileSystemPage.
3049 * InstallDirectoryPage (At once)
3053 * Inits or reloads FileSystemList
3056 * Number of the next page.
3059 CheckFileSystemPage(PINPUT_RECORD Ir
)
3061 PFILE_SYSTEM_ITEM CurrentFileSystem
;
3062 UNICODE_STRING PartitionRootPath
;
3063 WCHAR PathBuffer
[MAX_PATH
];
3064 CHAR Buffer
[MAX_PATH
];
3065 PDISKENTRY DiskEntry
;
3066 PPARTENTRY PartEntry
;
3069 if (PartitionList
== NULL
)
3071 /* FIXME: show an error dialog */
3075 if (!GetNextUncheckedPartition(PartitionList
, &DiskEntry
, &PartEntry
))
3077 return INSTALL_DIRECTORY_PAGE
;
3080 /* Set PartitionRootPath */
3081 swprintf(PathBuffer
,
3082 L
"\\Device\\Harddisk%lu\\Partition%lu",
3083 DiskEntry
->DiskNumber
,
3084 PartEntry
->PartitionNumber
);
3085 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
3086 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
3088 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
3090 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3092 CurrentFileSystem
= GetFileSystem(FileSystemList
, PartEntry
);
3093 DPRINT1("CheckFileSystemPage -- PartitionType: 0x%02X ; FileSystemName: %S\n",
3094 PartEntry
->PartitionType
, (CurrentFileSystem
? CurrentFileSystem
->FileSystemName
: L
"n/a"));
3096 /* HACK: Do not try to check a partition with an unknown filesytem */
3097 if (CurrentFileSystem
== NULL
)
3099 PartEntry
->NeedsCheck
= FALSE
;
3100 return CHECK_FILE_SYSTEM_PAGE
;
3103 if (CurrentFileSystem
->ChkdskFunc
== NULL
)
3106 "Setup is currently unable to check a partition formatted in %S.\n"
3108 " \x07 Press ENTER to continue Setup.\n"
3109 " \x07 Press F3 to quit Setup.",
3110 CurrentFileSystem
->FileSystemName
);
3113 MUIGetString(STRING_QUITCONTINUE
),
3114 NULL
, POPUP_WAIT_NONE
);
3118 CONSOLE_ConInKey(Ir
);
3120 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3121 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3123 if (ConfirmQuit(Ir
))
3126 return CHECK_FILE_SYSTEM_PAGE
;
3128 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3130 PartEntry
->NeedsCheck
= FALSE
;
3131 return CHECK_FILE_SYSTEM_PAGE
;
3137 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3138 if (!NT_SUCCESS(Status
))
3140 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3141 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
3142 "(Status 0x%08lx).\n", Status
);
3144 MUIGetString(STRING_REBOOTCOMPUTER
),
3145 Ir
, POPUP_WAIT_ENTER
);
3150 PartEntry
->NeedsCheck
= FALSE
;
3151 return CHECK_FILE_SYSTEM_PAGE
;
3157 * Displays the InstallDirectoryPage1.
3160 * PrepareCopyPage (At once)
3163 * Inits DestinationRootPath
3164 * Inits DestinationPath
3165 * Inits DestinationArcPath
3168 * Number of the next page.
3171 InstallDirectoryPage1(PWCHAR InstallDir
,
3172 PDISKENTRY DiskEntry
,
3173 PPARTENTRY PartEntry
)
3175 WCHAR PathBuffer
[MAX_PATH
];
3177 /* Create 'InstallPath' string */
3178 RtlFreeUnicodeString(&InstallPath
);
3179 RtlCreateUnicodeString(&InstallPath
, InstallDir
);
3181 /* Create 'DestinationRootPath' string */
3182 RtlFreeUnicodeString(&DestinationRootPath
);
3183 swprintf(PathBuffer
,
3184 L
"\\Device\\Harddisk%lu\\Partition%lu",
3185 DiskEntry
->DiskNumber
,
3186 PartEntry
->PartitionNumber
);
3187 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
3188 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
3190 /* Create 'DestinationPath' string */
3191 RtlFreeUnicodeString(&DestinationPath
);
3192 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3194 if (InstallDir
[0] != L
'\\')
3195 wcscat(PathBuffer
, L
"\\");
3197 wcscat(PathBuffer
, InstallDir
);
3198 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
3200 /* Create 'DestinationArcPath' */
3201 RtlFreeUnicodeString(&DestinationArcPath
);
3202 swprintf(PathBuffer
,
3203 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
3204 DiskEntry
->BiosDiskNumber
,
3205 PartEntry
->PartitionNumber
);
3207 if (InstallDir
[0] != L
'\\')
3208 wcscat(PathBuffer
, L
"\\");
3210 wcscat(PathBuffer
, InstallDir
);
3211 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3213 return PREPARE_COPY_PAGE
;
3218 * Displays the InstallDirectoryPage.
3221 * PrepareCopyPage (As the direct result of InstallDirectoryPage1)
3225 * Number of the next page.
3228 InstallDirectoryPage(PINPUT_RECORD Ir
)
3230 PDISKENTRY DiskEntry
;
3231 PPARTENTRY PartEntry
;
3232 WCHAR InstallDir
[51];
3236 /* We do not need the filsystem list any more */
3237 DestroyFileSystemList(FileSystemList
);
3238 FileSystemList
= NULL
;
3240 if (PartitionList
== NULL
||
3241 PartitionList
->CurrentDisk
== NULL
||
3242 PartitionList
->CurrentPartition
== NULL
)
3244 /* FIXME: show an error dialog */
3248 DiskEntry
= PartitionList
->CurrentDisk
;
3249 PartEntry
= PartitionList
->CurrentPartition
;
3251 if (IsUnattendedSetup
)
3252 wcscpy(InstallDir
, UnattendInstallationDirectory
);
3254 wcscpy(InstallDir
, L
"\\ReactOS");
3256 Length
= wcslen(InstallDir
);
3257 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3258 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3260 // FIXME: Check the validity of the InstallDir; however what to do
3261 // if it is invalid but we are in unattended setup? (case of somebody
3262 // specified an invalid installation directory in the unattended file).
3264 if (IsUnattendedSetup
)
3266 return InstallDirectoryPage1(InstallDir
,
3273 CONSOLE_ConInKey(Ir
);
3275 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3276 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3278 if (ConfirmQuit(Ir
) == TRUE
)
3283 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3286 * Check for the validity of the installation directory and pop up
3287 * an error if it is not the case. Then the user can fix its input.
3289 if (!IsValidPath(InstallDir
, Length
))
3291 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3292 return INSTALL_DIRECTORY_PAGE
;
3294 return InstallDirectoryPage1(InstallDir
,
3298 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3303 InstallDir
[Length
] = 0;
3304 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3307 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3311 c
= (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3312 if (iswalpha(c
) || iswdigit(c
) || c
== '.' || c
== '\\' || c
== '-' || c
== '_')
3314 InstallDir
[Length
] = c
;
3316 InstallDir
[Length
] = 0;
3317 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3323 return INSTALL_DIRECTORY_PAGE
;
3328 AddSectionToCopyQueueCab(HINF InfFile
,
3330 PWCHAR SourceCabinet
,
3331 PCUNICODE_STRING DestinationPath
,
3334 INFCONTEXT FilesContext
;
3335 INFCONTEXT DirContext
;
3337 PWCHAR FileKeyValue
;
3339 PWCHAR TargetFileName
;
3341 /* Search for the SectionName section */
3342 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3345 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3346 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3351 * Enumerate the files in the section
3352 * and add them to the file queue.
3356 /* Get source file name and target directory id */
3357 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3359 /* FIXME: Handle error! */
3360 DPRINT1("INF_GetData() failed\n");
3364 /* Get optional target file name */
3365 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3366 TargetFileName
= NULL
;
3368 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3370 /* Lookup target directory */
3371 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3373 /* FIXME: Handle error! */
3374 DPRINT1("SetupFindFirstLine() failed\n");
3378 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3380 /* FIXME: Handle error! */
3381 DPRINT1("INF_GetData() failed\n");
3385 if (!SetupQueueCopy(SetupFileQueue
,
3387 SourceRootPath
.Buffer
,
3388 SourceRootDir
.Buffer
,
3393 /* FIXME: Handle error! */
3394 DPRINT1("SetupQueueCopy() failed\n");
3396 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3403 AddSectionToCopyQueue(HINF InfFile
,
3405 PWCHAR SourceCabinet
,
3406 PCUNICODE_STRING DestinationPath
,
3409 INFCONTEXT FilesContext
;
3410 INFCONTEXT DirContext
;
3412 PWCHAR FileKeyValue
;
3414 PWCHAR TargetFileName
;
3416 WCHAR CompleteOrigDirName
[512];
3419 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3421 /* Search for the SectionName section */
3422 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3425 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3426 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3431 * Enumerate the files in the section
3432 * and add them to the file queue.
3436 /* Get source file name and target directory id */
3437 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3439 /* FIXME: Handle error! */
3440 DPRINT1("INF_GetData() failed\n");
3444 /* Get target directory id */
3445 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3447 /* FIXME: Handle error! */
3448 DPRINT1("INF_GetData() failed\n");
3452 /* Get optional target file name */
3453 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3454 TargetFileName
= NULL
;
3455 else if (!*TargetFileName
)
3456 TargetFileName
= NULL
;
3458 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3460 /* Lookup target directory */
3461 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3463 /* FIXME: Handle error! */
3464 DPRINT1("SetupFindFirstLine() failed\n");
3468 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3470 /* FIXME: Handle error! */
3471 DPRINT1("INF_GetData() failed\n");
3475 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3477 /* Installation path */
3478 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3480 else if (DirKeyValue
[0] == L
'\\')
3483 wcscpy(CompleteOrigDirName
, DirKeyValue
);
3485 else // if (DirKeyValue[0] != L'\\')
3487 /* Path relative to the installation path */
3488 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3489 wcscat(CompleteOrigDirName
, L
"\\");
3490 wcscat(CompleteOrigDirName
, DirKeyValue
);
3493 /* Remove trailing backslash */
3494 Length
= wcslen(CompleteOrigDirName
);
3495 if ((Length
> 0) && (CompleteOrigDirName
[Length
- 1] == L
'\\'))
3497 CompleteOrigDirName
[Length
- 1] = 0;
3500 if (!SetupQueueCopy(SetupFileQueue
,
3502 SourceRootPath
.Buffer
,
3503 CompleteOrigDirName
,
3508 /* FIXME: Handle error! */
3509 DPRINT1("SetupQueueCopy() failed\n");
3511 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3518 PrepareCopyPageInfFile(HINF InfFile
,
3519 PWCHAR SourceCabinet
,
3522 WCHAR PathBuffer
[MAX_PATH
];
3523 INFCONTEXT DirContext
;
3524 PWCHAR AdditionalSectionName
= NULL
;
3529 /* Add common files */
3530 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3533 /* Add specific files depending of computer type */
3534 if (SourceCabinet
== NULL
)
3536 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3539 if (AdditionalSectionName
)
3541 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3546 /* Create directories */
3550 * - Install directories like '\reactos\test' are not handled yet.
3551 * - Copying files to DestinationRootPath should be done from within
3552 * the SystemPartitionFiles section.
3553 * At the moment we check whether we specify paths like '\foo' or '\\' for that.
3554 * For installing to DestinationPath specify just '\' .
3557 /* Get destination path */
3558 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3560 /* Remove trailing backslash */
3561 Length
= wcslen(PathBuffer
);
3562 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3564 PathBuffer
[Length
- 1] = 0;
3567 /* Create the install directory */
3568 Status
= SetupCreateDirectory(PathBuffer
);
3569 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3571 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3572 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3576 /* Search for the 'Directories' section */
3577 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3581 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3585 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3591 /* Enumerate the directory values and create the subdirectories */
3594 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3600 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3602 /* Installation path */
3603 DPRINT("InstallationPath: '%S'\n", DirKeyValue
);
3605 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3607 DPRINT("FullPath: '%S'\n", PathBuffer
);
3609 else if (DirKeyValue
[0] == L
'\\')
3612 DPRINT("Absolute Path: '%S'\n", DirKeyValue
);
3614 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3615 wcscat(PathBuffer
, DirKeyValue
);
3617 /* Remove trailing backslash */
3618 Length
= wcslen(PathBuffer
);
3619 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3621 PathBuffer
[Length
- 1] = 0;
3624 DPRINT("FullPath: '%S'\n", PathBuffer
);
3626 Status
= SetupCreateDirectory(PathBuffer
);
3627 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3629 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3630 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3634 else // if (DirKeyValue[0] != L'\\')
3636 /* Path relative to the installation path */
3637 DPRINT("RelativePath: '%S'\n", DirKeyValue
);
3639 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3640 wcscat(PathBuffer
, L
"\\");
3641 wcscat(PathBuffer
, DirKeyValue
);
3643 /* Remove trailing backslash */
3644 Length
= wcslen(PathBuffer
);
3645 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3647 PathBuffer
[Length
- 1] = 0;
3650 DPRINT("FullPath: '%S'\n", PathBuffer
);
3652 Status
= SetupCreateDirectory(PathBuffer
);
3653 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3655 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3656 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3660 } while (SetupFindNextLine(&DirContext
, &DirContext
));
3667 * Displays the PrepareCopyPage.
3670 * FileCopyPage(At once)
3674 * Inits SetupFileQueue
3675 * Calls PrepareCopyPageInfFile
3678 * Number of the next page.
3681 PrepareCopyPage(PINPUT_RECORD Ir
)
3684 WCHAR PathBuffer
[MAX_PATH
];
3685 INFCONTEXT CabinetsContext
;
3691 MUIDisplayPage(PREPARE_COPY_PAGE
);
3693 /* Create the file queue */
3694 SetupFileQueue
= SetupOpenFileQueue();
3695 if (SetupFileQueue
== NULL
)
3697 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3701 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3703 /* FIXME: show an error dialog */
3707 /* Search for the 'Cabinets' section */
3708 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3710 return FILE_COPY_PAGE
;
3714 * Enumerate the directory values in the 'Cabinets'
3715 * section and parse their inf files.
3719 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3722 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3723 wcscat(PathBuffer
, L
"\\");
3724 wcscat(PathBuffer
, KeyValue
);
3727 CabinetInitialize();
3728 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3729 CabinetSetCabinetName(PathBuffer
);
3731 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3733 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3735 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3736 if (InfFileData
== NULL
)
3738 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3744 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3745 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3749 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3756 if (InfHandle
== INVALID_HANDLE_VALUE
)
3758 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3764 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3766 /* FIXME: show an error dialog */
3770 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3772 return FILE_COPY_PAGE
;
3778 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3781 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3783 /* Get the memory information from the system */
3784 NtQuerySystemInformation(SystemPerformanceInformation
,
3789 /* Check if this is initial setup */
3792 /* Set maximum limits to be total RAM pages */
3793 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3794 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3795 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3798 /* Set current values */
3799 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3800 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3801 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3807 FileCopyCallback(PVOID Context
,
3812 PCOPYCONTEXT CopyContext
;
3814 CopyContext
= (PCOPYCONTEXT
)Context
;
3816 switch (Notification
)
3818 case SPFILENOTIFY_STARTSUBQUEUE
:
3819 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3820 ProgressSetStepCount(CopyContext
->ProgressBar
,
3821 CopyContext
->TotalOperations
);
3822 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3825 case SPFILENOTIFY_STARTCOPY
:
3826 /* Display copy message */
3827 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3828 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3831 case SPFILENOTIFY_ENDCOPY
:
3832 CopyContext
->CompletedOperations
++;
3834 /* SYSREG checkpoint */
3835 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3836 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3838 ProgressNextStep(CopyContext
->ProgressBar
);
3839 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3848 * Displays the FileCopyPage.
3851 * RegistryPage(At once)
3854 * Calls SetupCommitFileQueueW
3855 * Calls SetupCloseFileQueue
3858 * Number of the next page.
3862 FileCopyPage(PINPUT_RECORD Ir
)
3864 COPYCONTEXT CopyContext
;
3865 unsigned int mem_bar_width
;
3867 MUIDisplayPage(FILE_COPY_PAGE
);
3869 /* Create context for the copy process */
3870 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3871 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3872 CopyContext
.TotalOperations
= 0;
3873 CopyContext
.CompletedOperations
= 0;
3875 /* Create the progress bar as well */
3876 CopyContext
.ProgressBar
= CreateProgressBar(13,
3883 MUIGetString(STRING_SETUPCOPYINGFILES
));
3885 // fit memory bars to screen width, distribute them uniform
3886 mem_bar_width
= (xScreen
- 26) / 5;
3887 mem_bar_width
-= mem_bar_width
% 2; // make even
3888 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3889 /* Create the paged pool progress bar */
3890 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3899 /* Create the non paged pool progress bar */
3900 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3902 (xScreen
/ 2) + (mem_bar_width
/ 2),
3904 (xScreen
/ 2)- (mem_bar_width
/ 2),
3909 /* Create the global memory progress bar */
3910 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3914 xScreen
- 13 - mem_bar_width
,
3919 /* Do the file copying */
3920 SetupCommitFileQueueW(NULL
,
3925 /* If we get here, we're done, so cleanup the queue and progress bar */
3926 SetupCloseFileQueue(SetupFileQueue
);
3927 DestroyProgressBar(CopyContext
.ProgressBar
);
3928 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3929 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3930 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3932 /* Go display the next page */
3933 return REGISTRY_PAGE
;
3938 * Displays the RegistryPage.
3941 * SuccessPage (if RepairUpdate)
3942 * BootLoaderPage (default)
3946 * Calls SetInstallPathValue
3947 * Calls NtInitializeRegistry
3948 * Calls ImportRegistryFile
3949 * Calls SetDefaultPagefile
3950 * Calls SetMountedDeviceValues
3953 * Number of the next page.
3956 RegistryPage(PINPUT_RECORD Ir
)
3958 INFCONTEXT InfContext
;
3965 MUIDisplayPage(REGISTRY_PAGE
);
3967 if (RepairUpdateFlag
)
3969 return SUCCESS_PAGE
;
3972 if (!SetInstallPathValue(&DestinationPath
))
3974 DPRINT1("SetInstallPathValue() failed\n");
3975 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3979 /* Create the default hives */
3980 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3981 if (!NT_SUCCESS(Status
))
3983 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3984 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3988 /* Update registry */
3989 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3991 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3993 DPRINT1("SetupFindFirstLine() failed\n");
3994 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
4000 INF_GetDataField(&InfContext
, 0, &Action
);
4001 INF_GetDataField(&InfContext
, 1, &File
);
4002 INF_GetDataField(&InfContext
, 2, &Section
);
4004 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
4009 if (!_wcsicmp(Action
, L
"AddReg"))
4013 else if (!_wcsicmp(Action
, L
"DelReg"))
4022 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
4024 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
4026 DPRINT1("Importing %S failed\n", File
);
4028 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
4031 } while (SetupFindNextLine(&InfContext
, &InfContext
));
4033 /* Update display registry settings */
4034 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
4035 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
4037 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4041 /* Set the locale */
4042 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
4043 if (!ProcessLocaleRegistry(LanguageList
))
4045 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4049 /* Add keyboard layouts */
4050 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
4051 if (!AddKeyboardLayouts())
4053 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
4059 if (!SetGeoID(MUIGetGeoID()))
4061 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
4065 if (!IsUnattendedSetup
)
4067 /* Update keyboard layout settings */
4068 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
4069 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
4071 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
4076 /* Add codepage information to registry */
4077 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
4080 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
4084 /* Set the default pagefile entry */
4085 SetDefaultPagefile(DestinationDriveLetter
);
4087 /* Update the mounted devices list */
4088 SetMountedDeviceValues(PartitionList
);
4090 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
4092 return BOOT_LOADER_PAGE
;
4097 * Displays the BootLoaderPage.
4100 * SuccessPage (if RepairUpdate)
4101 * BootLoaderHarddiskMbrPage
4102 * BootLoaderHarddiskVbrPage
4103 * BootLoaderFloppyPage
4108 * Calls SetInstallPathValue
4109 * Calls NtInitializeRegistry
4110 * Calls ImportRegistryFile
4111 * Calls SetDefaultPagefile
4112 * Calls SetMountedDeviceValues
4115 * Number of the next page.
4118 BootLoaderPage(PINPUT_RECORD Ir
)
4120 UCHAR PartitionType
;
4121 BOOLEAN InstallOnFloppy
;
4123 WCHAR PathBuffer
[MAX_PATH
];
4125 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
4127 RtlFreeUnicodeString(&SystemRootPath
);
4128 swprintf(PathBuffer
,
4129 L
"\\Device\\Harddisk%lu\\Partition%lu",
4130 PartitionList
->SystemDisk
->DiskNumber
,
4131 PartitionList
->SystemPartition
->PartitionNumber
);
4132 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
4133 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
4135 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4137 if (IsUnattendedSetup
)
4139 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
4141 return SUCCESS_PAGE
;
4143 else if (UnattendMBRInstallType
== 1) /* install on floppy */
4145 return BOOT_LOADER_FLOPPY_PAGE
;
4149 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
4151 DPRINT("Error: system partition invalid (unused)\n");
4152 InstallOnFloppy
= TRUE
;
4154 else if (PartitionType
== PARTITION_OS2BOOTMGR
)
4156 /* OS/2 boot manager partition */
4157 DPRINT("Found OS/2 boot manager partition\n");
4158 InstallOnFloppy
= TRUE
;
4160 else if (PartitionType
== PARTITION_EXT2
)
4162 /* Linux EXT2 partition */
4163 DPRINT("Found Linux EXT2 partition\n");
4164 InstallOnFloppy
= FALSE
;
4166 else if (PartitionType
== PARTITION_IFS
)
4168 /* NTFS partition */
4169 DPRINT("Found NTFS partition\n");
4171 // FIXME: Make it FALSE when we'll support NTFS installation!
4172 InstallOnFloppy
= TRUE
;
4174 else if ((PartitionType
== PARTITION_FAT_12
) ||
4175 (PartitionType
== PARTITION_FAT_16
) ||
4176 (PartitionType
== PARTITION_HUGE
) ||
4177 (PartitionType
== PARTITION_XINT13
) ||
4178 (PartitionType
== PARTITION_FAT32
) ||
4179 (PartitionType
== PARTITION_FAT32_XINT13
))
4181 DPRINT("Found FAT partition\n");
4182 InstallOnFloppy
= FALSE
;
4186 /* Unknown partition */
4187 DPRINT("Unknown partition found\n");
4188 InstallOnFloppy
= TRUE
;
4191 if (InstallOnFloppy
== TRUE
)
4193 return BOOT_LOADER_FLOPPY_PAGE
;
4196 /* Unattended install on hdd? */
4197 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
4199 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4202 MUIDisplayPage(BOOT_LOADER_PAGE
);
4203 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4207 CONSOLE_ConInKey(Ir
);
4209 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4210 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
4212 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4221 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4223 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4224 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
4226 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4235 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4237 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4238 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4240 if (ConfirmQuit(Ir
) == TRUE
)
4245 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4249 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4251 else if (Line
== 13)
4253 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4255 else if (Line
== 14)
4257 return BOOT_LOADER_FLOPPY_PAGE
;
4259 else if (Line
== 15)
4261 return SUCCESS_PAGE
;
4264 return BOOT_LOADER_PAGE
;
4268 return BOOT_LOADER_PAGE
;
4273 * Displays the BootLoaderFloppyPage.
4276 * SuccessPage (At once)
4280 * Calls InstallFatBootcodeToFloppy()
4283 * Number of the next page.
4286 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4290 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4292 // SetStatusText(" Please wait...");
4296 CONSOLE_ConInKey(Ir
);
4298 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4299 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4301 if (ConfirmQuit(Ir
) == TRUE
)
4306 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4308 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
4310 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4311 return BOOT_LOADER_FLOPPY_PAGE
;
4314 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
4315 if (!NT_SUCCESS(Status
))
4317 /* Print error message */
4318 return BOOT_LOADER_FLOPPY_PAGE
;
4321 return SUCCESS_PAGE
;
4325 return BOOT_LOADER_FLOPPY_PAGE
;
4330 * Displays the BootLoaderHarddiskVbrPage.
4333 * SuccessPage (At once)
4337 * Calls InstallVBRToPartition()
4340 * Number of the next page.
4343 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4345 UCHAR PartitionType
;
4348 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4350 Status
= InstallVBRToPartition(&SystemRootPath
,
4352 &DestinationArcPath
,
4354 if (!NT_SUCCESS(Status
))
4356 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4360 return SUCCESS_PAGE
;
4365 * Displays the BootLoaderHarddiskMbrPage.
4368 * SuccessPage (At once)
4372 * Calls InstallVBRToPartition()
4373 * CallsInstallMbrBootCodeToDisk()
4376 * Number of the next page.
4379 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4381 UCHAR PartitionType
;
4383 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4384 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
4386 /* Step 1: Write the VBR */
4387 PartitionType
= PartitionList
->SystemPartition
->PartitionType
;
4389 Status
= InstallVBRToPartition(&SystemRootPath
,
4391 &DestinationArcPath
,
4393 if (!NT_SUCCESS(Status
))
4395 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4399 /* Step 2: Write the MBR */
4400 swprintf(DestinationDevicePathBuffer
,
4401 L
"\\Device\\Harddisk%d\\Partition0",
4402 PartitionList
->SystemDisk
->DiskNumber
);
4404 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4405 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4407 DPRINT("Install MBR bootcode: %S ==> %S\n",
4408 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4410 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4411 DestinationDevicePathBuffer
);
4412 if (!NT_SUCCESS(Status
))
4414 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4416 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4420 return SUCCESS_PAGE
;
4425 * Displays the QuitPage.
4428 * FlushPage (At once)
4434 * Number of the next page.
4437 QuitPage(PINPUT_RECORD Ir
)
4439 MUIDisplayPage(QUIT_PAGE
);
4441 /* Destroy partition list */
4442 if (PartitionList
!= NULL
)
4444 DestroyPartitionList(PartitionList
);
4445 PartitionList
= NULL
;
4448 /* Destroy filesystem list */
4449 if (FileSystemList
!= NULL
)
4451 DestroyFileSystemList(FileSystemList
);
4452 FileSystemList
= NULL
;
4455 /* Destroy computer settings list */
4456 if (ComputerList
!= NULL
)
4458 DestroyGenericList(ComputerList
, TRUE
);
4459 ComputerList
= NULL
;
4462 /* Destroy display settings list */
4463 if (DisplayList
!= NULL
)
4465 DestroyGenericList(DisplayList
, TRUE
);
4469 /* Destroy keyboard settings list */
4470 if (KeyboardList
!= NULL
)
4472 DestroyGenericList(KeyboardList
, TRUE
);
4473 KeyboardList
= NULL
;
4476 /* Destroy keyboard layout list */
4477 if (LayoutList
!= NULL
)
4479 DestroyGenericList(LayoutList
, TRUE
);
4483 if (LanguageList
!= NULL
)
4485 DestroyGenericList(LanguageList
, FALSE
);
4486 LanguageList
= NULL
;
4489 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4493 CONSOLE_ConInKey(Ir
);
4495 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4504 * Displays the SuccessPage.
4507 * FlushPage (At once)
4513 * Number of the next page.
4516 SuccessPage(PINPUT_RECORD Ir
)
4518 MUIDisplayPage(SUCCESS_PAGE
);
4520 if (IsUnattendedSetup
)
4527 CONSOLE_ConInKey(Ir
);
4529 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4538 * Displays the FlushPage.
4541 * RebootPage (At once)
4544 * Number of the next page.
4547 FlushPage(PINPUT_RECORD Ir
)
4549 MUIDisplayPage(FLUSH_PAGE
);
4555 PnpEventThread(IN LPVOID lpParameter
);
4559 * The start routine and page management
4570 NtQuerySystemTime(&Time
);
4572 Status
= RtlCreateUserThread(NtCurrentProcess(),
4582 if (!NT_SUCCESS(Status
))
4583 hPnpThread
= INVALID_HANDLE_VALUE
;
4585 if (!CONSOLE_Init())
4587 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4588 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4589 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4591 /* Raise a hard error (crash the system/BSOD) */
4592 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4596 /* Initialize global unicode strings */
4597 RtlInitUnicodeString(&SourcePath
, NULL
);
4598 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4599 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4600 RtlInitUnicodeString(&InstallPath
, NULL
);
4601 RtlInitUnicodeString(&DestinationPath
, NULL
);
4602 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4603 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4604 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4606 /* Hide the cursor */
4607 CONSOLE_SetCursorType(TRUE
, FALSE
);
4610 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4612 CONSOLE_ClearScreen();
4615 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4622 Page
= SetupStartPage(&Ir
);
4627 Page
= LanguagePage(&Ir
);
4632 Page
= LicensePage(&Ir
);
4637 Page
= IntroPage(&Ir
);
4641 case INSTALL_INTRO_PAGE
:
4642 Page
= InstallIntroPage(&Ir
);
4646 case SCSI_CONTROLLER_PAGE
:
4647 Page
= ScsiControllerPage(&Ir
);
4652 case OEM_DRIVER_PAGE
:
4653 Page
= OemDriverPage(&Ir
);
4657 case DEVICE_SETTINGS_PAGE
:
4658 Page
= DeviceSettingsPage(&Ir
);
4661 case COMPUTER_SETTINGS_PAGE
:
4662 Page
= ComputerSettingsPage(&Ir
);
4665 case DISPLAY_SETTINGS_PAGE
:
4666 Page
= DisplaySettingsPage(&Ir
);
4669 case KEYBOARD_SETTINGS_PAGE
:
4670 Page
= KeyboardSettingsPage(&Ir
);
4673 case LAYOUT_SETTINGS_PAGE
:
4674 Page
= LayoutSettingsPage(&Ir
);
4677 case SELECT_PARTITION_PAGE
:
4678 Page
= SelectPartitionPage(&Ir
);
4681 case CREATE_PRIMARY_PARTITION_PAGE
:
4682 Page
= CreatePrimaryPartitionPage(&Ir
);
4685 case CREATE_EXTENDED_PARTITION_PAGE
:
4686 Page
= CreateExtendedPartitionPage(&Ir
);
4689 case CREATE_LOGICAL_PARTITION_PAGE
:
4690 Page
= CreateLogicalPartitionPage(&Ir
);
4693 case CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
:
4694 Page
= ConfirmDeleteSystemPartitionPage(&Ir
);
4697 case DELETE_PARTITION_PAGE
:
4698 Page
= DeletePartitionPage(&Ir
);
4701 case SELECT_FILE_SYSTEM_PAGE
:
4702 Page
= SelectFileSystemPage(&Ir
);
4705 case FORMAT_PARTITION_PAGE
:
4706 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4709 case CHECK_FILE_SYSTEM_PAGE
:
4710 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4713 case INSTALL_DIRECTORY_PAGE
:
4714 Page
= InstallDirectoryPage(&Ir
);
4717 case PREPARE_COPY_PAGE
:
4718 Page
= PrepareCopyPage(&Ir
);
4721 case FILE_COPY_PAGE
:
4722 Page
= FileCopyPage(&Ir
);
4726 Page
= RegistryPage(&Ir
);
4729 case BOOT_LOADER_PAGE
:
4730 Page
= BootLoaderPage(&Ir
);
4733 case BOOT_LOADER_FLOPPY_PAGE
:
4734 Page
= BootLoaderFloppyPage(&Ir
);
4737 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4738 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4741 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4742 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4746 case REPAIR_INTRO_PAGE
:
4747 Page
= RepairIntroPage(&Ir
);
4751 Page
= SuccessPage(&Ir
);
4755 Page
= FlushPage(&Ir
);
4759 Page
= QuitPage(&Ir
);
4768 if (Page
== RECOVERY_PAGE
)
4773 /* Avoid bugcheck */
4774 Time
.QuadPart
+= 50000000;
4775 NtDelayExecution(FALSE
, &Time
);
4778 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4779 NtShutdownSystem(ShutdownReboot
);
4780 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4781 NtTerminateProcess(NtCurrentProcess(), 0);
4788 NtProcessStartup(PPEB Peb
)
4790 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4792 ProcessHeap
= Peb
->ProcessHeap
;
4793 InfSetHeap(ProcessHeap
);
4796 #endif /* __REACTOS__ */