3 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/usetup.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMER: Eric Kohl
25 * Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * Hervé Poussineau (hpoussin@reactos.org)
41 /* GLOBALS ******************************************************************/
44 UNICODE_STRING SourceRootPath
;
45 UNICODE_STRING SourceRootDir
;
46 UNICODE_STRING SourcePath
;
47 BOOLEAN IsUnattendedSetup
= FALSE
;
48 LONG UnattendDestinationDiskNumber
;
49 LONG UnattendDestinationPartitionNumber
;
50 LONG UnattendMBRInstallType
= -1;
51 LONG UnattendFormatPartition
= 0;
52 LONG AutoPartition
= 0;
53 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
54 PWCHAR SelectedLanguageId
;
56 WCHAR DefaultLanguage
[20];
57 WCHAR DefaultKBLayout
[20];
58 BOOLEAN RepairUpdateFlag
= FALSE
;
59 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
60 PPARTLIST PartitionList
= NULL
;
62 /* LOCALS *******************************************************************/
64 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
66 static UNICODE_STRING InstallPath
;
68 /* Path to the install directory */
69 static UNICODE_STRING DestinationPath
;
70 static UNICODE_STRING DestinationArcPath
;
71 static UNICODE_STRING DestinationRootPath
;
73 static WCHAR DestinationDriveLetter
;
75 /* Path to the active partition (boot manager) */
76 static UNICODE_STRING SystemRootPath
;
80 static HSPFILEQ SetupFileQueue
= NULL
;
82 static BOOLEAN WarnLinuxPartitions
= TRUE
;
84 static PGENERIC_LIST ComputerList
= NULL
;
85 static PGENERIC_LIST DisplayList
= NULL
;
86 static PGENERIC_LIST KeyboardList
= NULL
;
87 static PGENERIC_LIST LayoutList
= NULL
;
88 static PGENERIC_LIST LanguageList
= NULL
;
90 static LANGID LanguageId
= 0;
92 static ULONG RequiredPartitionDiskSpace
= ~0;
94 /* FUNCTIONS ****************************************************************/
97 PrintString(char* fmt
,...)
101 UNICODE_STRING UnicodeString
;
102 ANSI_STRING AnsiString
;
105 vsprintf(buffer
, fmt
, ap
);
108 RtlInitAnsiString(&AnsiString
, buffer
);
109 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
110 NtDisplayString(&UnicodeString
);
111 RtlFreeUnicodeString(&UnicodeString
);
116 DrawBox(IN SHORT xLeft
,
124 /* draw upper left corner */
127 FillConsoleOutputCharacterA(StdOutput
,
133 /* draw upper edge */
136 FillConsoleOutputCharacterA(StdOutput
,
142 /* draw upper right corner */
143 coPos
.X
= xLeft
+ Width
- 1;
145 FillConsoleOutputCharacterA(StdOutput
,
151 /* Draw right edge, inner space and left edge */
152 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
155 FillConsoleOutputCharacterA(StdOutput
,
162 FillConsoleOutputCharacterA(StdOutput
,
168 coPos
.X
= xLeft
+ Width
- 1;
169 FillConsoleOutputCharacterA(StdOutput
,
176 /* draw lower left corner */
178 coPos
.Y
= yTop
+ Height
- 1;
179 FillConsoleOutputCharacterA(StdOutput
,
185 /* draw lower edge */
187 coPos
.Y
= yTop
+ Height
- 1;
188 FillConsoleOutputCharacterA(StdOutput
,
194 /* draw lower right corner */
195 coPos
.X
= xLeft
+ Width
- 1;
196 coPos
.Y
= yTop
+ Height
- 1;
197 FillConsoleOutputCharacterA(StdOutput
,
206 PopupError(PCCH Text
,
224 /* Count text lines and longest line */
231 p
= strchr(pnext
, '\n');
235 Length
= strlen(pnext
);
240 Length
= (ULONG
)(p
- pnext
);
246 if (Length
> MaxLength
)
249 if (LastLine
== TRUE
)
255 /* Check length of status line */
258 Length
= strlen(Status
);
260 if (Length
> MaxLength
)
264 Width
= MaxLength
+ 4;
270 yTop
= (yScreen
- Height
) / 2;
271 xLeft
= (xScreen
- Width
) / 2;
274 /* Set screen attributes */
276 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
278 FillConsoleOutputAttribute(StdOutput
,
279 FOREGROUND_RED
| BACKGROUND_WHITE
,
285 DrawBox(xLeft
, yTop
, Width
, Height
);
287 /* Print message text */
292 p
= strchr(pnext
, '\n');
296 Length
= strlen(pnext
);
301 Length
= (ULONG
)(p
- pnext
);
308 WriteConsoleOutputCharacterA(StdOutput
,
315 if (LastLine
== TRUE
)
322 /* Print separator line and status text */
325 coPos
.Y
= yTop
+ Height
- 3;
327 FillConsoleOutputCharacterA(StdOutput
,
334 FillConsoleOutputCharacterA(StdOutput
,
340 coPos
.X
= xLeft
+ Width
- 1;
341 FillConsoleOutputCharacterA(StdOutput
,
349 WriteConsoleOutputCharacterA(StdOutput
,
351 min(strlen(Status
), (SIZE_T
)Width
- 4),
356 if (WaitEvent
== POPUP_WAIT_NONE
)
361 CONSOLE_ConInKey(Ir
);
363 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
364 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
376 * FALSE: Don't quit setup.
379 ConfirmQuit(PINPUT_RECORD Ir
)
382 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
386 CONSOLE_ConInKey(Ir
);
388 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
389 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
394 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
406 CheckUnattendedSetup(VOID
)
408 WCHAR UnattendInfPath
[MAX_PATH
];
415 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
417 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
421 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
422 wcscat(UnattendInfPath
, L
"\\unattend.inf");
424 /* Load 'unattend.inf' from install media. */
425 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
431 if (UnattendInf
== INVALID_HANDLE_VALUE
)
433 DPRINT("SetupOpenInfFileW() failed\n");
437 /* Open 'Unattend' section */
438 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
440 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
441 SetupCloseInfFile(UnattendInf
);
445 /* Get pointer 'Signature' key */
446 if (!INF_GetData(&Context
, NULL
, &Value
))
448 DPRINT("INF_GetData() failed for key 'Signature'\n");
449 SetupCloseInfFile(UnattendInf
);
453 /* Check 'Signature' string */
454 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
456 DPRINT("Signature not $ReactOS$\n");
457 SetupCloseInfFile(UnattendInf
);
461 /* Check if Unattend setup is enabled */
462 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
464 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
465 SetupCloseInfFile(UnattendInf
);
469 if (!INF_GetData(&Context
, NULL
, &Value
))
471 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
472 SetupCloseInfFile(UnattendInf
);
476 if (_wcsicmp(Value
, L
"yes") != 0)
478 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
479 SetupCloseInfFile(UnattendInf
);
483 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
484 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
486 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
487 SetupCloseInfFile(UnattendInf
);
491 if (!SetupGetIntField(&Context
, 1, &IntValue
))
493 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
494 SetupCloseInfFile(UnattendInf
);
498 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
500 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
501 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
503 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
504 SetupCloseInfFile(UnattendInf
);
508 if (!SetupGetIntField(&Context
, 1, &IntValue
))
510 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
511 SetupCloseInfFile(UnattendInf
);
515 UnattendDestinationPartitionNumber
= IntValue
;
517 /* Search for 'InstallationDirectory' in the 'Unattend' section */
518 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"InstallationDirectory", &Context
))
520 DPRINT("SetupFindFirstLine() failed for key 'InstallationDirectory'\n");
521 SetupCloseInfFile(UnattendInf
);
525 /* Get pointer 'InstallationDirectory' key */
526 if (!INF_GetData(&Context
, NULL
, &Value
))
528 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
529 SetupCloseInfFile(UnattendInf
);
533 wcscpy(UnattendInstallationDirectory
, Value
);
535 IsUnattendedSetup
= TRUE
;
537 /* Search for 'MBRInstallType' in the 'Unattend' section */
538 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
540 if (SetupGetIntField(&Context
, 1, &IntValue
))
542 UnattendMBRInstallType
= IntValue
;
546 /* Search for 'FormatPartition' in the 'Unattend' section */
547 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
549 if (SetupGetIntField(&Context
, 1, &IntValue
))
551 UnattendFormatPartition
= IntValue
;
555 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
557 if (SetupGetIntField(&Context
, 1, &IntValue
))
559 AutoPartition
= IntValue
;
563 /* search for LocaleID in the 'Unattend' section*/
564 if (SetupFindFirstLineW (UnattendInf
, L
"Unattend", L
"LocaleID", &Context
))
566 if (INF_GetData (&Context
, NULL
, &Value
))
568 LONG Id
= wcstol(Value
, NULL
, 16);
569 swprintf(LocaleID
,L
"%08lx", Id
);
573 SetupCloseInfFile(UnattendInf
);
575 DPRINT("Running unattended setup\n");
582 PGENERIC_LIST_ENTRY ListEntry
;
583 LPCWSTR pszNewLayout
;
585 pszNewLayout
= MUIDefaultKeyboardLayout();
587 if (LayoutList
== NULL
)
589 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
590 if (LayoutList
== NULL
)
592 /* FIXME: Handle error! */
597 ListEntry
= GetFirstListEntry(LayoutList
);
599 /* Search for default layout (if provided) */
600 if (pszNewLayout
!= NULL
)
602 while (ListEntry
!= NULL
)
604 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
606 SetCurrentListEntry(LayoutList
, ListEntry
);
610 ListEntry
= GetNextListEntry(ListEntry
);
617 LanguagePage(PINPUT_RECORD Ir
)
619 PWCHAR NewLanguageId
;
620 BOOL RefreshPage
= FALSE
;
622 /* Initialize the computer settings list */
623 if (LanguageList
== NULL
)
625 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
627 if (LanguageList
== NULL
)
629 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
635 SelectedLanguageId
= DefaultLanguage
;
636 SetConsoleCodePage();
638 DrawGenericList(LanguageList
,
644 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
646 MUIDisplayPage(LANGUAGE_PAGE
);
650 CONSOLE_ConInKey(Ir
);
652 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
653 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
655 ScrollDownGenericList (LanguageList
);
658 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
659 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
661 ScrollUpGenericList(LanguageList
);
664 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
665 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
667 ScrollPageDownGenericList(LanguageList
);
670 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
671 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
673 ScrollPageUpGenericList(LanguageList
);
676 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
677 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
679 if (ConfirmQuit(Ir
) == TRUE
)
682 RedrawGenericList(LanguageList
);
684 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
686 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
688 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
690 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
696 SetConsoleCodePage();
700 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
703 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
709 NewLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
711 if (SelectedLanguageId
!= NewLanguageId
)
713 /* Clear the language page */
714 MUIClearPage(LANGUAGE_PAGE
);
716 SelectedLanguageId
= NewLanguageId
;
719 SetConsoleCodePage();
721 /* Redraw language selection page in native language */
722 MUIDisplayPage(LANGUAGE_PAGE
);
736 * Number of the next page.
739 SetupStartPage(PINPUT_RECORD Ir
)
741 //SYSTEM_DEVICE_INFORMATION Sdi;
743 WCHAR FileNameBuffer
[MAX_PATH
];
748 PGENERIC_LIST_ENTRY ListEntry
;
751 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
754 /* Check whether a harddisk is available */
755 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
757 sizeof(SYSTEM_DEVICE_INFORMATION
),
760 if (!NT_SUCCESS(Status
))
762 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
763 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
767 if (Sdi
.NumberOfDisks
== 0)
769 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
774 /* Get the source path and source root path */
775 Status
= GetSourcePaths(&SourcePath
,
779 if (!NT_SUCCESS(Status
))
781 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
782 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
788 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
789 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
790 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
794 /* Load txtsetup.sif from install media. */
795 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
796 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
798 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
804 if (SetupInf
== INVALID_HANDLE_VALUE
)
806 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
810 /* Open 'Version' section */
811 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
813 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
817 /* Get pointer 'Signature' key */
818 if (!INF_GetData(&Context
, NULL
, &Value
))
820 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
824 /* Check 'Signature' string */
825 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
827 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
831 /* Open 'DiskSpaceRequirements' section */
832 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
834 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
838 /* Get the 'FreeSysPartDiskSpace' value */
839 if (!SetupGetIntField(&Context
, 1, &IntValue
))
841 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
845 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
847 /* Start PnP thread */
848 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
850 NtResumeThread(hPnpThread
, NULL
);
851 hPnpThread
= INVALID_HANDLE_VALUE
;
854 CheckUnattendedSetup();
856 if (IsUnattendedSetup
)
859 //read options from inf
860 ComputerList
= CreateComputerTypeList(SetupInf
);
861 DisplayList
= CreateDisplayDriverList(SetupInf
);
862 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
863 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
864 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
867 wcscpy(SelectedLanguageId
,LocaleID
);
869 /* first we hack LanguageList */
870 ListEntry
= GetFirstListEntry(LanguageList
);
872 while (ListEntry
!= NULL
)
874 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
876 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
877 SetCurrentListEntry(LanguageList
, ListEntry
);
881 ListEntry
= GetNextListEntry(ListEntry
);
885 ListEntry
= GetFirstListEntry(LayoutList
);
887 while (ListEntry
!= NULL
)
889 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
891 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
892 SetCurrentListEntry(LayoutList
, ListEntry
);
896 ListEntry
= GetNextListEntry(ListEntry
);
899 SetConsoleCodePage();
901 return INSTALL_INTRO_PAGE
;
904 return LANGUAGE_PAGE
;
914 IntroPage(PINPUT_RECORD Ir
)
916 MUIDisplayPage(START_PAGE
);
920 CONSOLE_ConInKey(Ir
);
922 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
923 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
925 if (ConfirmQuit(Ir
) == TRUE
)
930 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
932 return INSTALL_INTRO_PAGE
;
934 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
936 return REPAIR_INTRO_PAGE
;
938 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
951 * Back to main setup page.
954 LicensePage(PINPUT_RECORD Ir
)
956 MUIDisplayPage(LICENSE_PAGE
);
960 CONSOLE_ConInKey(Ir
);
962 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
973 RepairIntroPage(PINPUT_RECORD Ir
)
975 MUIDisplayPage(REPAIR_INTRO_PAGE
);
979 CONSOLE_ConInKey(Ir
);
981 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
985 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
987 RepairUpdateFlag
= TRUE
;
988 return INSTALL_INTRO_PAGE
;
990 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
994 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
995 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1001 return REPAIR_INTRO_PAGE
;
1006 InstallIntroPage(PINPUT_RECORD Ir
)
1008 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1010 if (RepairUpdateFlag
)
1012 //return SELECT_PARTITION_PAGE;
1013 return DEVICE_SETTINGS_PAGE
;
1016 if (IsUnattendedSetup
)
1018 return SELECT_PARTITION_PAGE
;
1023 CONSOLE_ConInKey(Ir
);
1025 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1026 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1028 if (ConfirmQuit(Ir
) == TRUE
)
1033 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1035 return DEVICE_SETTINGS_PAGE
;
1036 // return SCSI_CONTROLLER_PAGE;
1040 return INSTALL_INTRO_PAGE
;
1046 ScsiControllerPage(PINPUT_RECORD Ir
)
1048 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1050 /* FIXME: print loaded mass storage driver descriptions */
1052 SetTextXY(8, 10, "TEST device");
1056 SetStatusText(" ENTER = Continue F3 = Quit");
1062 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1063 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1065 if (ConfirmQuit(Ir
) == TRUE
)
1070 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1072 return DEVICE_SETTINGS_PAGE
;
1076 return SCSI_CONTROLLER_PAGE
;
1082 DeviceSettingsPage(PINPUT_RECORD Ir
)
1084 static ULONG Line
= 16;
1085 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1087 /* Initialize the computer settings list */
1088 if (ComputerList
== NULL
)
1090 ComputerList
= CreateComputerTypeList(SetupInf
);
1091 if (ComputerList
== NULL
)
1093 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1098 /* Initialize the display settings list */
1099 if (DisplayList
== NULL
)
1101 DisplayList
= CreateDisplayDriverList(SetupInf
);
1102 if (DisplayList
== NULL
)
1104 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1109 /* Initialize the keyboard settings list */
1110 if (KeyboardList
== NULL
)
1112 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1113 if (KeyboardList
== NULL
)
1115 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1120 /* Initialize the keyboard layout list */
1121 if (LayoutList
== NULL
)
1123 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1124 if (LayoutList
== NULL
)
1126 /* FIXME: report error */
1127 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1132 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1135 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1136 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1137 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1138 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1140 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1142 if (RepairUpdateFlag
)
1144 return SELECT_PARTITION_PAGE
;
1149 CONSOLE_ConInKey(Ir
);
1151 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1152 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1154 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1158 else if (Line
== 16)
1163 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1165 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1166 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1168 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1172 else if (Line
== 16)
1177 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1179 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1180 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1182 if (ConfirmQuit(Ir
) == TRUE
)
1187 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1190 return COMPUTER_SETTINGS_PAGE
;
1191 else if (Line
== 12)
1192 return DISPLAY_SETTINGS_PAGE
;
1193 else if (Line
== 13)
1194 return KEYBOARD_SETTINGS_PAGE
;
1195 else if (Line
== 14)
1196 return LAYOUT_SETTINGS_PAGE
;
1197 else if (Line
== 16)
1198 return SELECT_PARTITION_PAGE
;
1202 return DEVICE_SETTINGS_PAGE
;
1207 ComputerSettingsPage(PINPUT_RECORD Ir
)
1209 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1211 DrawGenericList(ComputerList
,
1217 SaveGenericListState(ComputerList
);
1221 CONSOLE_ConInKey(Ir
);
1223 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1224 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1226 ScrollDownGenericList(ComputerList
);
1228 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1229 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1231 ScrollUpGenericList(ComputerList
);
1233 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1234 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1236 if (ConfirmQuit(Ir
) == TRUE
)
1241 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1242 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1244 RestoreGenericListState(ComputerList
);
1245 return DEVICE_SETTINGS_PAGE
;
1247 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1249 return DEVICE_SETTINGS_PAGE
;
1253 return COMPUTER_SETTINGS_PAGE
;
1258 DisplaySettingsPage(PINPUT_RECORD Ir
)
1260 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1262 DrawGenericList(DisplayList
,
1268 SaveGenericListState(DisplayList
);
1272 CONSOLE_ConInKey(Ir
);
1274 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1275 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1277 ScrollDownGenericList(DisplayList
);
1279 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1280 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1282 ScrollUpGenericList(DisplayList
);
1284 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1285 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1287 if (ConfirmQuit(Ir
) == TRUE
)
1294 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1295 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1297 RestoreGenericListState(DisplayList
);
1298 return DEVICE_SETTINGS_PAGE
;
1300 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1302 return DEVICE_SETTINGS_PAGE
;
1306 return DISPLAY_SETTINGS_PAGE
;
1311 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1313 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1315 DrawGenericList(KeyboardList
,
1321 SaveGenericListState(KeyboardList
);
1325 CONSOLE_ConInKey(Ir
);
1327 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1328 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1330 ScrollDownGenericList(KeyboardList
);
1332 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1333 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1335 ScrollUpGenericList(KeyboardList
);
1337 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1338 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1340 if (ConfirmQuit(Ir
) == TRUE
)
1345 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1346 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1348 RestoreGenericListState(KeyboardList
);
1349 return DEVICE_SETTINGS_PAGE
;
1351 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1353 return DEVICE_SETTINGS_PAGE
;
1357 return KEYBOARD_SETTINGS_PAGE
;
1362 LayoutSettingsPage(PINPUT_RECORD Ir
)
1364 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1366 DrawGenericList(LayoutList
,
1372 SaveGenericListState(LayoutList
);
1376 CONSOLE_ConInKey(Ir
);
1378 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1379 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1381 ScrollDownGenericList(LayoutList
);
1383 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1384 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1386 ScrollUpGenericList(LayoutList
);
1388 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1389 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1391 ScrollPageDownGenericList(LayoutList
);
1393 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1394 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1396 ScrollPageUpGenericList(LayoutList
);
1398 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1399 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1401 if (ConfirmQuit(Ir
) == TRUE
)
1406 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1407 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1409 RestoreGenericListState(LayoutList
);
1410 return DEVICE_SETTINGS_PAGE
;
1412 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1414 return DEVICE_SETTINGS_PAGE
;
1416 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1419 GenericListKeyPress(LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1423 return LAYOUT_SETTINGS_PAGE
;
1429 IsDiskSizeValid(PPARTENTRY PartEntry
)
1433 /* check for unpartitioned space */
1434 m1
= PartEntry
->UnpartitionedLength
;
1435 m1
= (m1
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1437 if( m1
> RequiredPartitionDiskSpace
)
1442 /* check for partitioned space */
1443 m2
= PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
;
1444 m2
= (m2
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1445 if (m2
< RequiredPartitionDiskSpace
)
1447 /* partition is too small so ask for another partion */
1448 DPRINT1("Partition is too small(unpartitioned: %I64u MB, partitioned: %I64u MB), required disk space is %lu MB\n", m1
, m2
, RequiredPartitionDiskSpace
);
1460 SelectPartitionPage(PINPUT_RECORD Ir
)
1464 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1466 if (PartitionList
== NULL
)
1468 PartitionList
= CreatePartitionList(2,
1472 if (PartitionList
== NULL
)
1474 /* FIXME: show an error dialog */
1477 else if (IsListEmpty (&PartitionList
->DiskListHead
))
1479 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
1484 DrawPartitionList(PartitionList
);
1486 /* Warn about partitions created by Linux Fdisk */
1487 if (WarnLinuxPartitions
== TRUE
&&
1488 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1490 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1494 CONSOLE_ConInKey(Ir
);
1496 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1497 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1501 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1503 WarnLinuxPartitions
= FALSE
;
1504 return SELECT_PARTITION_PAGE
;
1509 if (IsUnattendedSetup
)
1511 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1516 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1518 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1519 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1522 CreatePrimaryPartition(PartitionList
,
1523 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1526 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1528 return SELECT_FILE_SYSTEM_PAGE
;
1534 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1536 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1537 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1540 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1542 return SELECT_FILE_SYSTEM_PAGE
;
1548 /* Update status text */
1549 if (PartitionList
->CurrentPartition
== NULL
)
1551 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1553 else if (PartitionList
->CurrentPartition
->LogicalPartition
)
1555 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1557 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1561 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL
));
1566 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1568 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1570 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1574 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1579 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1583 CONSOLE_ConInKey(Ir
);
1585 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1586 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1588 if (ConfirmQuit(Ir
) == TRUE
)
1590 DestroyPartitionList(PartitionList
);
1591 PartitionList
= NULL
;
1597 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1598 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1600 if (ScrollDownPartitionList(PartitionList
))
1601 DrawPartitionList(PartitionList
);
1603 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1604 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1606 if (ScrollUpPartitionList(PartitionList
))
1607 DrawPartitionList(PartitionList
);
1609 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1612 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1614 MUIDisplayError(ERROR_INSUFFICIENT_DISKSPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1615 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1618 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1619 continue; //return SELECT_PARTITION_PAGE;
1621 if (PartitionList
->CurrentPartition
== NULL
||
1622 PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1624 CreatePrimaryPartition(PartitionList
,
1629 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1631 return SELECT_FILE_SYSTEM_PAGE
;
1633 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'P') /* P */
1635 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1637 Error
= PrimaryPartitionCreationChecks(PartitionList
);
1638 if (Error
!= NOT_AN_ERROR
)
1640 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1641 return SELECT_PARTITION_PAGE
;
1644 return CREATE_PRIMARY_PARTITION_PAGE
;
1647 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'E') /* E */
1649 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1651 Error
= ExtendedPartitionCreationChecks(PartitionList
);
1652 if (Error
!= NOT_AN_ERROR
)
1654 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1655 return SELECT_PARTITION_PAGE
;
1658 return CREATE_EXTENDED_PARTITION_PAGE
;
1661 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'L') /* L */
1663 if (PartitionList
->CurrentPartition
->LogicalPartition
== TRUE
)
1665 Error
= LogicalPartitionCreationChecks(PartitionList
);
1666 if (Error
!= NOT_AN_ERROR
)
1668 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1669 return SELECT_PARTITION_PAGE
;
1672 return CREATE_LOGICAL_PARTITION_PAGE
;
1675 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1677 if (PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1679 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1680 return SELECT_PARTITION_PAGE
;
1683 return DELETE_PARTITION_PAGE
;
1687 return SELECT_PARTITION_PAGE
;
1692 DrawInputField(ULONG FieldLength
,
1703 memset(buf
, '_', sizeof(buf
));
1704 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1705 strcat(buf
, FieldContent
);
1707 WriteConsoleOutputCharacterA(StdOutput
,
1715 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1716 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1717 #define PARTITION_MAXSIZE 999999
1720 ShowPartitionSizeInputBox(SHORT Left
,
1744 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1749 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1750 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1753 WriteConsoleOutputCharacterA(StdOutput
,
1759 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1760 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1762 WriteConsoleOutputCharacterA(StdOutput
,
1768 sprintf(Buffer
, "%lu", MaxSize
);
1769 Index
= strlen(Buffer
);
1770 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1777 CONSOLE_ConInKey(&Ir
);
1779 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1780 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1788 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1792 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1800 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1806 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1811 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1812 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1814 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1816 if ((ch
>= '0') && (ch
<= '9'))
1822 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1830 strcpy(InputBuffer
, Buffer
);
1835 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1837 PDISKENTRY DiskEntry
;
1838 PPARTENTRY PartEntry
;
1841 CHAR InputBuffer
[50];
1845 ULONGLONG SectorCount
;
1848 if (PartitionList
== NULL
||
1849 PartitionList
->CurrentDisk
== NULL
||
1850 PartitionList
->CurrentPartition
== NULL
)
1852 /* FIXME: show an error dialog */
1856 DiskEntry
= PartitionList
->CurrentDisk
;
1857 PartEntry
= PartitionList
->CurrentPartition
;
1859 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1861 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1863 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1865 if (DiskSize
>= 10737418240) /* 10 GB */
1867 DiskSize
= DiskSize
/ 1073741824;
1868 Unit
= MUIGetString(STRING_GB
);
1873 DiskSize
= DiskSize
/ 1048576;
1877 Unit
= MUIGetString(STRING_MB
);
1880 if (DiskEntry
->DriverName
.Length
> 0)
1882 CONSOLE_PrintTextXY(6, 10,
1883 MUIGetString(STRING_HDINFOPARTCREATE
),
1886 DiskEntry
->DiskNumber
,
1890 &DiskEntry
->DriverName
);
1894 CONSOLE_PrintTextXY(6, 10,
1895 MUIGetString(STRING_HDDINFOUNK1
),
1898 DiskEntry
->DiskNumber
,
1904 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1907 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1908 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
1911 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1913 PartEntry
= PartitionList
->CurrentPartition
;
1916 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
1918 if (MaxSize
> PARTITION_MAXSIZE
)
1919 MaxSize
= PARTITION_MAXSIZE
;
1921 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1922 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1926 if (ConfirmQuit (Ir
) == TRUE
)
1931 else if (Cancel
== TRUE
)
1933 return SELECT_PARTITION_PAGE
;
1937 PartSize
= atoi(InputBuffer
);
1945 if (PartSize
> MaxSize
)
1951 /* Convert to bytes */
1952 if (PartSize
== MaxSize
)
1954 /* Use all of the unpartitioned disk space */
1955 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1959 /* Calculate the sector count from the size in MB */
1960 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
1962 /* But never get larger than the unpartitioned disk space */
1963 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
1964 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1967 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1969 CreatePrimaryPartition(PartitionList
,
1973 return SELECT_PARTITION_PAGE
;
1977 return CREATE_PRIMARY_PARTITION_PAGE
;
1982 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
1984 PDISKENTRY DiskEntry
;
1985 PPARTENTRY PartEntry
;
1988 CHAR InputBuffer
[50];
1992 ULONGLONG SectorCount
;
1995 if (PartitionList
== NULL
||
1996 PartitionList
->CurrentDisk
== NULL
||
1997 PartitionList
->CurrentPartition
== NULL
)
1999 /* FIXME: show an error dialog */
2003 DiskEntry
= PartitionList
->CurrentDisk
;
2004 PartEntry
= PartitionList
->CurrentPartition
;
2006 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2008 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
2010 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2012 if (DiskSize
>= 10737418240) /* 10 GB */
2014 DiskSize
= DiskSize
/ 1073741824;
2015 Unit
= MUIGetString(STRING_GB
);
2020 DiskSize
= DiskSize
/ 1048576;
2024 Unit
= MUIGetString(STRING_MB
);
2027 if (DiskEntry
->DriverName
.Length
> 0)
2029 CONSOLE_PrintTextXY(6, 10,
2030 MUIGetString(STRING_HDINFOPARTCREATE
),
2033 DiskEntry
->DiskNumber
,
2037 &DiskEntry
->DriverName
);
2041 CONSOLE_PrintTextXY(6, 10,
2042 MUIGetString(STRING_HDDINFOUNK1
),
2045 DiskEntry
->DiskNumber
,
2051 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2054 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2055 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2058 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2060 PartEntry
= PartitionList
->CurrentPartition
;
2063 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2065 if (MaxSize
> PARTITION_MAXSIZE
)
2066 MaxSize
= PARTITION_MAXSIZE
;
2068 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2069 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2073 if (ConfirmQuit (Ir
) == TRUE
)
2078 else if (Cancel
== TRUE
)
2080 return SELECT_PARTITION_PAGE
;
2084 PartSize
= atoi(InputBuffer
);
2092 if (PartSize
> MaxSize
)
2098 /* Convert to bytes */
2099 if (PartSize
== MaxSize
)
2101 /* Use all of the unpartitioned disk space */
2102 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2106 /* Calculate the sector count from the size in MB */
2107 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2109 /* But never get larger than the unpartitioned disk space */
2110 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2111 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2114 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2116 CreateExtendedPartition(PartitionList
,
2119 return SELECT_PARTITION_PAGE
;
2123 return CREATE_EXTENDED_PARTITION_PAGE
;
2128 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2130 PDISKENTRY DiskEntry
;
2131 PPARTENTRY PartEntry
;
2134 CHAR InputBuffer
[50];
2138 ULONGLONG SectorCount
;
2141 if (PartitionList
== NULL
||
2142 PartitionList
->CurrentDisk
== NULL
||
2143 PartitionList
->CurrentPartition
== NULL
)
2145 /* FIXME: show an error dialog */
2149 DiskEntry
= PartitionList
->CurrentDisk
;
2150 PartEntry
= PartitionList
->CurrentPartition
;
2152 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2154 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2156 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2158 if (DiskSize
>= 10737418240) /* 10 GB */
2160 DiskSize
= DiskSize
/ 1073741824;
2161 Unit
= MUIGetString(STRING_GB
);
2166 DiskSize
= DiskSize
/ 1048576;
2170 Unit
= MUIGetString(STRING_MB
);
2173 if (DiskEntry
->DriverName
.Length
> 0)
2175 CONSOLE_PrintTextXY(6, 10,
2176 MUIGetString(STRING_HDINFOPARTCREATE
),
2179 DiskEntry
->DiskNumber
,
2183 &DiskEntry
->DriverName
);
2187 CONSOLE_PrintTextXY(6, 10,
2188 MUIGetString(STRING_HDDINFOUNK1
),
2191 DiskEntry
->DiskNumber
,
2197 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2200 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2201 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2204 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2206 PartEntry
= PartitionList
->CurrentPartition
;
2209 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2211 if (MaxSize
> PARTITION_MAXSIZE
)
2212 MaxSize
= PARTITION_MAXSIZE
;
2214 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2215 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2219 if (ConfirmQuit (Ir
) == TRUE
)
2224 else if (Cancel
== TRUE
)
2226 return SELECT_PARTITION_PAGE
;
2230 PartSize
= atoi(InputBuffer
);
2238 if (PartSize
> MaxSize
)
2244 /* Convert to bytes */
2245 if (PartSize
== MaxSize
)
2247 /* Use all of the unpartitioned disk space */
2248 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2252 /* Calculate the sector count from the size in MB */
2253 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2255 /* But never get larger than the unpartitioned disk space */
2256 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2257 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2260 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2262 CreateLogicalPartition(PartitionList
,
2265 return SELECT_PARTITION_PAGE
;
2269 return CREATE_LOGICAL_PARTITION_PAGE
;
2274 DeletePartitionPage(PINPUT_RECORD Ir
)
2276 PDISKENTRY DiskEntry
;
2277 PPARTENTRY PartEntry
;
2283 if (PartitionList
== NULL
||
2284 PartitionList
->CurrentDisk
== NULL
||
2285 PartitionList
->CurrentPartition
== NULL
)
2287 /* FIXME: show an error dialog */
2291 DiskEntry
= PartitionList
->CurrentDisk
;
2292 PartEntry
= PartitionList
->CurrentPartition
;
2294 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2296 /* Determine partition type */
2298 if (PartEntry
->New
== TRUE
)
2300 PartType
= MUIGetString(STRING_UNFORMATTED
);
2302 else if (PartEntry
->IsPartitioned
== TRUE
)
2304 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2305 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2306 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2307 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2311 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2312 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2316 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2320 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2322 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2324 else if (IsContainerPartition(PartEntry
->PartitionType
))
2326 PartType
= MUIGetString(STRING_EXTENDED_PARTITION
);
2330 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2332 if (PartSize
>= 10737418240) /* 10 GB */
2334 PartSize
= PartSize
/ 1073741824;
2335 Unit
= MUIGetString(STRING_GB
);
2339 if (PartSize
>= 10485760) /* 10 MB */
2341 PartSize
= PartSize
/ 1048576;
2342 Unit
= MUIGetString(STRING_MB
);
2346 PartSize
= PartSize
/ 1024;
2347 Unit
= MUIGetString(STRING_KB
);
2350 if (PartType
== NULL
)
2352 CONSOLE_PrintTextXY(6, 10,
2353 MUIGetString(STRING_HDDINFOUNK2
),
2354 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2355 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2356 PartEntry
->PartitionType
,
2362 CONSOLE_PrintTextXY(6, 10,
2363 " %c%c %s %I64u %s",
2364 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2365 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2371 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2373 if (DiskSize
>= 10737418240) /* 10 GB */
2375 DiskSize
= DiskSize
/ 1073741824;
2376 Unit
= MUIGetString(STRING_GB
);
2381 DiskSize
= DiskSize
/ 1048576;
2385 Unit
= MUIGetString(STRING_MB
);
2388 if (DiskEntry
->DriverName
.Length
> 0)
2390 CONSOLE_PrintTextXY(6, 12,
2391 MUIGetString(STRING_HDINFOPARTDELETE
),
2394 DiskEntry
->DiskNumber
,
2398 &DiskEntry
->DriverName
);
2402 CONSOLE_PrintTextXY(6, 12,
2403 MUIGetString(STRING_HDDINFOUNK3
),
2406 DiskEntry
->DiskNumber
,
2414 CONSOLE_ConInKey(Ir
);
2416 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2417 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2419 if (ConfirmQuit(Ir
) == TRUE
)
2426 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2428 return SELECT_PARTITION_PAGE
;
2430 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2432 DeleteCurrentPartition(PartitionList
);
2434 return SELECT_PARTITION_PAGE
;
2438 return DELETE_PARTITION_PAGE
;
2443 SelectFileSystemPage(PINPUT_RECORD Ir
)
2445 PDISKENTRY DiskEntry
;
2446 PPARTENTRY PartEntry
;
2453 if (PartitionList
== NULL
||
2454 PartitionList
->CurrentDisk
== NULL
||
2455 PartitionList
->CurrentPartition
== NULL
)
2457 /* FIXME: show an error dialog */
2461 DiskEntry
= PartitionList
->CurrentDisk
;
2462 PartEntry
= PartitionList
->CurrentPartition
;
2464 /* adjust disk size */
2465 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2466 if (DiskSize
>= 10737418240) /* 10 GB */
2468 DiskSize
= DiskSize
/ 1073741824;
2469 DiskUnit
= MUIGetString(STRING_GB
);
2473 DiskSize
= DiskSize
/ 1048576;
2474 DiskUnit
= MUIGetString(STRING_MB
);
2477 /* adjust partition size */
2478 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2479 if (PartSize
>= 10737418240) /* 10 GB */
2481 PartSize
= PartSize
/ 1073741824;
2482 PartUnit
= MUIGetString(STRING_GB
);
2486 PartSize
= PartSize
/ 1048576;
2487 PartUnit
= MUIGetString(STRING_MB
);
2490 /* adjust partition type */
2491 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2492 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2493 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2494 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2498 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2499 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2503 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2507 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2509 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2511 else if (PartEntry
->PartitionType
== PARTITION_ENTRY_UNUSED
)
2513 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2517 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2520 if (PartEntry
->AutoCreate
== TRUE
)
2522 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2525 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2526 PartEntry
->PartitionNumber
,
2532 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2533 DiskEntry
->DiskNumber
,
2539 &DiskEntry
->DriverName
);
2541 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2544 PartEntry
->AutoCreate
= FALSE
;
2546 else if (PartEntry
->New
== TRUE
)
2548 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2549 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2553 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2555 if (PartType
== NULL
)
2557 CONSOLE_PrintTextXY(8, 10,
2558 MUIGetString(STRING_HDDINFOUNK4
),
2559 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2560 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2561 PartEntry
->PartitionType
,
2567 CONSOLE_PrintTextXY(8, 10,
2569 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2570 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2576 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2577 DiskEntry
->DiskNumber
,
2583 &DiskEntry
->DriverName
);
2586 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2588 if (FileSystemList
== NULL
)
2590 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2591 if (FileSystemList
== NULL
)
2593 /* FIXME: show an error dialog */
2597 /* FIXME: Add file systems to list */
2600 DrawFileSystemList(FileSystemList
);
2602 if (RepairUpdateFlag
)
2604 return CHECK_FILE_SYSTEM_PAGE
;
2605 //return SELECT_PARTITION_PAGE;
2608 if (IsUnattendedSetup
)
2610 if (UnattendFormatPartition
)
2612 return FORMAT_PARTITION_PAGE
;
2615 return CHECK_FILE_SYSTEM_PAGE
;
2620 CONSOLE_ConInKey(Ir
);
2622 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2623 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2625 if (ConfirmQuit(Ir
) == TRUE
)
2632 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2633 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2635 return SELECT_PARTITION_PAGE
;
2637 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2638 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2640 ScrollDownFileSystemList(FileSystemList
);
2642 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2643 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2645 ScrollUpFileSystemList(FileSystemList
);
2647 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2649 if (!FileSystemList
->Selected
->FormatFunc
)
2651 return CHECK_FILE_SYSTEM_PAGE
;
2655 return FORMAT_PARTITION_PAGE
;
2660 return SELECT_FILE_SYSTEM_PAGE
;
2665 FormatPartitionPage(PINPUT_RECORD Ir
)
2667 WCHAR PathBuffer
[MAX_PATH
];
2668 PDISKENTRY DiskEntry
;
2669 PPARTENTRY PartEntry
;
2678 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2680 if (PartitionList
== NULL
||
2681 PartitionList
->CurrentDisk
== NULL
||
2682 PartitionList
->CurrentPartition
== NULL
)
2684 /* FIXME: show an error dialog */
2688 DiskEntry
= PartitionList
->CurrentDisk
;
2689 PartEntry
= PartitionList
->CurrentPartition
;
2693 if (!IsUnattendedSetup
)
2695 CONSOLE_ConInKey(Ir
);
2698 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2699 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2701 if (ConfirmQuit(Ir
) == TRUE
)
2708 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2710 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2712 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2714 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2716 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2717 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2719 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2721 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2723 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2725 /* FAT16 CHS partition (partiton size < 32MB) */
2726 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2728 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2730 /* FAT16 CHS partition (partition size < 512MB) */
2731 PartEntry
->PartitionType
= PARTITION_HUGE
;
2735 /* FAT32 CHS partition (partition size >= 512MB) */
2736 PartEntry
->PartitionType
= PARTITION_FAT32
;
2741 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2743 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2745 /* FAT16 LBA partition (partition size < 512MB) */
2746 PartEntry
->PartitionType
= PARTITION_XINT13
;
2750 /* FAT32 LBA partition (partition size >= 512MB) */
2751 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2755 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2758 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2760 PartEntry
->PartInfo
[PartNum
].PartitionType
= PARTITION_EXT2
;
2761 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2764 else if (!FileSystemList
->Selected
->FormatFunc
)
2768 CONSOLE_PrintTextXY(6, 12,
2769 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2770 DiskEntry
->DiskSize
,
2771 DiskEntry
->CylinderSize
,
2772 DiskEntry
->TrackSize
);
2775 DiskEntry
= PartitionList
->CurrentDisk
;
2776 Entry
= DiskEntry
->PartListHead
.Flink
;
2778 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2780 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2782 if (PartEntry
->IsPartitioned
== TRUE
)
2784 CONSOLE_PrintTextXY(6, Line
,
2785 "%2u: %2u %c %12I64u %12I64u %2u %c",
2787 PartEntry
->PartitionNumber
,
2788 PartEntry
->BootIndicator
? 'A' : '-',
2789 PartEntry
->StartSector
.QuadPart
,
2790 PartEntry
->SectorCount
.QuadPart
,
2791 PartEntry
->PartitionType
,
2792 PartEntry
->Dirty
? '*' : ' ');
2796 Entry
= Entry
->Flink
;
2799 /* Restore the old entry */
2800 PartEntry
= PartitionList
->CurrentPartition
;
2803 CheckActiveBootPartition(PartitionList
);
2805 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2807 DPRINT("WritePartitionsToDisk() failed\n");
2808 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2812 /* Set DestinationRootPath */
2813 RtlFreeUnicodeString(&DestinationRootPath
);
2814 swprintf(PathBuffer
,
2815 L
"\\Device\\Harddisk%lu\\Partition%lu",
2816 PartitionList
->CurrentDisk
->DiskNumber
,
2817 PartitionList
->CurrentPartition
->PartitionNumber
);
2818 RtlCreateUnicodeString(&DestinationRootPath
,
2820 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2822 if (FileSystemList
->Selected
->FormatFunc
)
2824 Status
= FormatPartition(&DestinationRootPath
,
2825 FileSystemList
->Selected
);
2826 if (!NT_SUCCESS(Status
))
2828 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2829 /* FIXME: show an error dialog */
2833 PartEntry
->New
= FALSE
;
2838 CONSOLE_SetStatusText(" Done. Press any key ...");
2839 CONSOLE_ConInKey(Ir
);
2842 DestroyFileSystemList(FileSystemList
);
2843 FileSystemList
= NULL
;
2844 return INSTALL_DIRECTORY_PAGE
;
2848 return FORMAT_PARTITION_PAGE
;
2853 CheckFileSystemPage(PINPUT_RECORD Ir
)
2855 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2856 WCHAR PathBuffer
[MAX_PATH
];
2857 CHAR Buffer
[MAX_PATH
];
2860 /* FIXME: code duplicated in FormatPartitionPage */
2861 /* Set DestinationRootPath */
2862 RtlFreeUnicodeString(&DestinationRootPath
);
2863 swprintf(PathBuffer
,
2864 L
"\\Device\\Harddisk%lu\\Partition%lu",
2865 PartitionList
->CurrentDisk
->DiskNumber
,
2866 PartitionList
->CurrentPartition
->PartitionNumber
);
2867 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2868 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2870 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2872 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2874 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2875 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2877 if (!CurrentFileSystem
->ChkdskFunc
)
2880 "Setup is currently unable to check a partition formatted in %S.\n"
2882 " \x07 Press ENTER to continue Setup.\n"
2883 " \x07 Press F3 to quit Setup.",
2884 CurrentFileSystem
->FileSystem
);
2887 MUIGetString(STRING_QUITCONTINUE
),
2888 NULL
, POPUP_WAIT_NONE
);
2892 CONSOLE_ConInKey(Ir
);
2894 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2895 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2897 if (ConfirmQuit(Ir
))
2900 return CHECK_FILE_SYSTEM_PAGE
;
2902 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2904 return INSTALL_DIRECTORY_PAGE
;
2910 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2911 if (!NT_SUCCESS(Status
))
2913 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2914 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2915 "(Status 0x%08lx).\n", Status
);
2918 MUIGetString(STRING_REBOOTCOMPUTER
),
2919 Ir
, POPUP_WAIT_ENTER
);
2924 return INSTALL_DIRECTORY_PAGE
;
2930 InstallDirectoryPage1(PWCHAR InstallDir
,
2931 PDISKENTRY DiskEntry
,
2932 PPARTENTRY PartEntry
)
2934 WCHAR PathBuffer
[MAX_PATH
];
2936 /* Create 'InstallPath' string */
2937 RtlFreeUnicodeString(&InstallPath
);
2938 RtlCreateUnicodeString(&InstallPath
,
2941 /* Create 'DestinationPath' string */
2942 RtlFreeUnicodeString(&DestinationPath
);
2943 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2945 if (InstallDir
[0] != L
'\\')
2946 wcscat(PathBuffer
, L
"\\");
2948 wcscat(PathBuffer
, InstallDir
);
2949 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2951 /* Create 'DestinationArcPath' */
2952 RtlFreeUnicodeString(&DestinationArcPath
);
2953 swprintf(PathBuffer
,
2954 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2955 DiskEntry
->BiosDiskNumber
,
2956 PartEntry
->PartitionNumber
);
2958 if (InstallDir
[0] != L
'\\')
2959 wcscat(PathBuffer
, L
"\\");
2961 wcscat(PathBuffer
, InstallDir
);
2962 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2964 return PREPARE_COPY_PAGE
;
2969 InstallDirectoryPage(PINPUT_RECORD Ir
)
2971 PDISKENTRY DiskEntry
;
2972 PPARTENTRY PartEntry
;
2973 WCHAR InstallDir
[51];
2976 if (PartitionList
== NULL
||
2977 PartitionList
->CurrentDisk
== NULL
||
2978 PartitionList
->CurrentPartition
== NULL
)
2980 /* FIXME: show an error dialog */
2984 DiskEntry
= PartitionList
->CurrentDisk
;
2985 PartEntry
= PartitionList
->CurrentPartition
;
2987 if (IsUnattendedSetup
)
2988 wcscpy(InstallDir
, UnattendInstallationDirectory
);
2990 wcscpy(InstallDir
, L
"\\ReactOS");
2992 Length
= wcslen(InstallDir
);
2993 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2994 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2996 if (IsUnattendedSetup
)
2998 return InstallDirectoryPage1(InstallDir
,
3005 CONSOLE_ConInKey(Ir
);
3007 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3008 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3010 if (ConfirmQuit(Ir
) == TRUE
)
3015 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3017 return InstallDirectoryPage1(InstallDir
,
3021 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3026 InstallDir
[Length
] = 0;
3027 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3030 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3034 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3036 InstallDir
[Length
] = 0;
3037 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3042 return INSTALL_DIRECTORY_PAGE
;
3047 AddSectionToCopyQueueCab(HINF InfFile
,
3049 PWCHAR SourceCabinet
,
3050 PCUNICODE_STRING DestinationPath
,
3053 INFCONTEXT FilesContext
;
3054 INFCONTEXT DirContext
;
3056 PWCHAR FileKeyValue
;
3058 PWCHAR TargetFileName
;
3060 /* Search for the SectionName section */
3061 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3064 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3065 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3070 * Enumerate the files in the section
3071 * and add them to the file queue.
3075 /* Get source file name and target directory id */
3076 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3078 /* FIXME: Handle error! */
3079 DPRINT1("INF_GetData() failed\n");
3083 /* Get optional target file name */
3084 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3085 TargetFileName
= NULL
;
3087 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3089 /* Lookup target directory */
3090 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3092 /* FIXME: Handle error! */
3093 DPRINT1("SetupFindFirstLine() failed\n");
3097 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3099 /* FIXME: Handle error! */
3100 DPRINT1("INF_GetData() failed\n");
3104 if (!SetupQueueCopy(SetupFileQueue
,
3106 SourceRootPath
.Buffer
,
3107 SourceRootDir
.Buffer
,
3112 /* FIXME: Handle error! */
3113 DPRINT1("SetupQueueCopy() failed\n");
3115 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3122 AddSectionToCopyQueue(HINF InfFile
,
3124 PWCHAR SourceCabinet
,
3125 PCUNICODE_STRING DestinationPath
,
3128 INFCONTEXT FilesContext
;
3129 INFCONTEXT DirContext
;
3131 PWCHAR FileKeyValue
;
3133 PWCHAR TargetFileName
;
3134 WCHAR CompleteOrigFileName
[512];
3137 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3139 /* Search for the SectionName section */
3140 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3143 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3144 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3149 * Enumerate the files in the section
3150 * and add them to the file queue.
3154 /* Get source file name and target directory id */
3155 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3157 /* FIXME: Handle error! */
3158 DPRINT1("INF_GetData() failed\n");
3162 /* Get target directory id */
3163 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3165 /* FIXME: Handle error! */
3166 DPRINT1("INF_GetData() failed\n");
3170 /* Get optional target file name */
3171 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3172 TargetFileName
= NULL
;
3173 else if (!*TargetFileName
)
3174 TargetFileName
= NULL
;
3176 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3178 /* Lookup target directory */
3179 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3181 /* FIXME: Handle error! */
3182 DPRINT1("SetupFindFirstLine() failed\n");
3186 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3188 /* FIXME: Handle error! */
3189 DPRINT1("INF_GetData() failed\n");
3193 wcscpy(CompleteOrigFileName
, SourceRootDir
.Buffer
);
3194 wcscat(CompleteOrigFileName
, L
"\\");
3195 wcscat(CompleteOrigFileName
, DirKeyValue
);
3197 if (!SetupQueueCopy(SetupFileQueue
,
3199 SourceRootPath
.Buffer
,
3200 CompleteOrigFileName
,
3205 /* FIXME: Handle error! */
3206 DPRINT1("SetupQueueCopy() failed\n");
3208 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3215 PrepareCopyPageInfFile(HINF InfFile
,
3216 PWCHAR SourceCabinet
,
3219 WCHAR PathBuffer
[MAX_PATH
];
3220 INFCONTEXT DirContext
;
3221 PWCHAR AdditionalSectionName
= NULL
;
3226 /* Add common files */
3227 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3230 /* Add specific files depending of computer type */
3231 if (SourceCabinet
== NULL
)
3233 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3236 if (AdditionalSectionName
)
3238 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3243 /* Create directories */
3247 * Install directories like '\reactos\test' are not handled yet.
3250 /* Get destination path */
3251 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3253 /* Remove trailing backslash */
3254 Length
= wcslen(PathBuffer
);
3255 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
3257 PathBuffer
[Length
- 1] = 0;
3260 /* Create the install directory */
3261 Status
= SetupCreateDirectory(PathBuffer
);
3262 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3264 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3265 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3269 /* Search for the 'Directories' section */
3270 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3274 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3278 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3284 /* Enumerate the directory values and create the subdirectories */
3287 if (!INF_GetData(&DirContext
, NULL
, &KeyValue
))
3293 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
3295 DPRINT("Absolute Path: '%S'\n", KeyValue
);
3297 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3298 wcscat(PathBuffer
, KeyValue
);
3300 DPRINT("FullPath: '%S'\n", PathBuffer
);
3302 else if (KeyValue
[0] != L
'\\')
3304 DPRINT("RelativePath: '%S'\n", KeyValue
);
3305 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3306 wcscat(PathBuffer
, L
"\\");
3307 wcscat(PathBuffer
, KeyValue
);
3309 DPRINT("FullPath: '%S'\n", PathBuffer
);
3311 Status
= SetupCreateDirectory(PathBuffer
);
3312 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3314 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3315 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3319 } while (SetupFindNextLine (&DirContext
, &DirContext
));
3326 PrepareCopyPage(PINPUT_RECORD Ir
)
3329 WCHAR PathBuffer
[MAX_PATH
];
3330 INFCONTEXT CabinetsContext
;
3336 MUIDisplayPage(PREPARE_COPY_PAGE
);
3338 /* Create the file queue */
3339 SetupFileQueue
= SetupOpenFileQueue();
3340 if (SetupFileQueue
== NULL
)
3342 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3346 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3351 /* Search for the 'Cabinets' section */
3352 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3354 return FILE_COPY_PAGE
;
3358 * Enumerate the directory values in the 'Cabinets'
3359 * section and parse their inf files.
3363 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3366 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3367 wcscat(PathBuffer
, L
"\\");
3368 wcscat(PathBuffer
, KeyValue
);
3371 CabinetInitialize();
3372 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3373 CabinetSetCabinetName(PathBuffer
);
3375 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3377 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3379 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3380 if (InfFileData
== NULL
)
3382 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3388 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3389 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3393 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3400 if (InfHandle
== INVALID_HANDLE_VALUE
)
3402 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3408 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3413 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3415 return FILE_COPY_PAGE
;
3421 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3424 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3426 /* Get the memory information from the system */
3427 NtQuerySystemInformation(SystemPerformanceInformation
,
3432 /* Check if this is initial setup */
3435 /* Set maximum limits to be total RAM pages */
3436 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3437 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3438 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3441 /* Set current values */
3442 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3443 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3444 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3450 FileCopyCallback(PVOID Context
,
3455 PCOPYCONTEXT CopyContext
;
3457 CopyContext
= (PCOPYCONTEXT
)Context
;
3459 switch (Notification
)
3461 case SPFILENOTIFY_STARTSUBQUEUE
:
3462 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3463 ProgressSetStepCount(CopyContext
->ProgressBar
,
3464 CopyContext
->TotalOperations
);
3465 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3468 case SPFILENOTIFY_STARTCOPY
:
3469 /* Display copy message */
3470 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3471 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3474 case SPFILENOTIFY_ENDCOPY
:
3475 CopyContext
->CompletedOperations
++;
3477 /* SYSREG checkpoint */
3478 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3479 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3481 ProgressNextStep(CopyContext
->ProgressBar
);
3482 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3492 FileCopyPage(PINPUT_RECORD Ir
)
3494 COPYCONTEXT CopyContext
;
3495 unsigned int mem_bar_width
;
3497 MUIDisplayPage(FILE_COPY_PAGE
);
3499 /* Create context for the copy process */
3500 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3501 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3502 CopyContext
.TotalOperations
= 0;
3503 CopyContext
.CompletedOperations
= 0;
3505 /* Create the progress bar as well */
3506 CopyContext
.ProgressBar
= CreateProgressBar(13,
3513 MUIGetString(STRING_SETUPCOPYINGFILES
));
3515 // fit memory bars to screen width, distribute them uniform
3516 mem_bar_width
= (xScreen
- 26) / 5;
3517 mem_bar_width
-= mem_bar_width
% 2; // make even
3518 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3519 /* Create the paged pool progress bar */
3520 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3529 /* Create the non paged pool progress bar */
3530 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3532 (xScreen
/ 2) + (mem_bar_width
/ 2),
3534 (xScreen
/ 2)- (mem_bar_width
/ 2),
3539 /* Create the global memory progress bar */
3540 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3544 xScreen
- 13 - mem_bar_width
,
3549 /* Do the file copying */
3550 SetupCommitFileQueueW(NULL
,
3555 /* If we get here, we're done, so cleanup the queue and progress bar */
3556 SetupCloseFileQueue(SetupFileQueue
);
3557 DestroyProgressBar(CopyContext
.ProgressBar
);
3558 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3559 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3560 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3562 /* Go display the next page */
3563 return REGISTRY_PAGE
;
3568 RegistryPage(PINPUT_RECORD Ir
)
3570 INFCONTEXT InfContext
;
3577 MUIDisplayPage(REGISTRY_PAGE
);
3579 if (RepairUpdateFlag
)
3581 return SUCCESS_PAGE
;
3584 if (!SetInstallPathValue(&DestinationPath
))
3586 DPRINT("SetInstallPathValue() failed\n");
3587 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3591 /* Create the default hives */
3593 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3594 if (!NT_SUCCESS(Status
))
3596 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3597 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3601 RegInitializeRegistry();
3604 /* Update registry */
3605 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3607 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3609 DPRINT1("SetupFindFirstLine() failed\n");
3610 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3616 INF_GetDataField (&InfContext
, 0, &Action
);
3617 INF_GetDataField (&InfContext
, 1, &File
);
3618 INF_GetDataField (&InfContext
, 2, &Section
);
3620 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3625 if (!_wcsicmp (Action
, L
"AddReg"))
3629 else if (!_wcsicmp (Action
, L
"DelReg"))
3638 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3640 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3642 DPRINT("Importing %S failed\n", File
);
3644 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3647 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3649 /* Update display registry settings */
3650 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3651 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3653 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3657 /* Set the locale */
3658 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3659 if (!ProcessLocaleRegistry(LanguageList
))
3661 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3665 /* Add keyboard layouts */
3666 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3667 if (!AddKeyboardLayouts())
3669 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3675 if (!SetGeoID(MUIGetGeoID()))
3677 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3681 if (!IsUnattendedSetup
)
3683 /* Update keyboard layout settings */
3684 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3685 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3687 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3692 /* Add codepage information to registry */
3693 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3696 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3700 /* Set the default pagefile entry */
3701 SetDefaultPagefile(DestinationDriveLetter
);
3703 /* Update the mounted devices list */
3704 SetMountedDeviceValues(PartitionList
);
3706 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3708 return BOOT_LOADER_PAGE
;
3713 BootLoaderPage(PINPUT_RECORD Ir
)
3715 UCHAR PartitionType
;
3716 BOOLEAN InstallOnFloppy
;
3718 WCHAR PathBuffer
[MAX_PATH
];
3720 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3722 /* Find or set the active partition */
3723 CheckActiveBootPartition(PartitionList
);
3725 /* Update the partition table because we may have changed the active partition */
3726 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
3728 DPRINT("WritePartitionsToDisk() failed\n");
3729 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
3733 RtlFreeUnicodeString(&SystemRootPath
);
3734 swprintf(PathBuffer
,
3735 L
"\\Device\\Harddisk%lu\\Partition%lu",
3736 PartitionList
->ActiveBootDisk
->DiskNumber
,
3737 PartitionList
->ActiveBootPartition
->PartitionNumber
);
3738 RtlCreateUnicodeString(&SystemRootPath
,
3740 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3742 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3744 if (IsUnattendedSetup
)
3746 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3748 return SUCCESS_PAGE
;
3750 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3752 return BOOT_LOADER_FLOPPY_PAGE
;
3756 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3758 DPRINT("Error: active partition invalid (unused)\n");
3759 InstallOnFloppy
= TRUE
;
3761 else if (PartitionType
== 0x0A)
3763 /* OS/2 boot manager partition */
3764 DPRINT("Found OS/2 boot manager partition\n");
3765 InstallOnFloppy
= TRUE
;
3767 else if (PartitionType
== 0x83)
3769 /* Linux ext2 partition */
3770 DPRINT("Found Linux ext2 partition\n");
3771 InstallOnFloppy
= TRUE
;
3773 else if (PartitionType
== PARTITION_IFS
)
3775 /* NTFS partition */
3776 DPRINT("Found NTFS partition\n");
3777 InstallOnFloppy
= TRUE
;
3779 else if ((PartitionType
== PARTITION_FAT_12
) ||
3780 (PartitionType
== PARTITION_FAT_16
) ||
3781 (PartitionType
== PARTITION_HUGE
) ||
3782 (PartitionType
== PARTITION_XINT13
) ||
3783 (PartitionType
== PARTITION_FAT32
) ||
3784 (PartitionType
== PARTITION_FAT32_XINT13
))
3786 DPRINT("Found FAT partition\n");
3787 InstallOnFloppy
= FALSE
;
3791 /* Unknown partition */
3792 DPRINT("Unknown partition found\n");
3793 InstallOnFloppy
= TRUE
;
3796 if (InstallOnFloppy
== TRUE
)
3798 return BOOT_LOADER_FLOPPY_PAGE
;
3801 /* Unattended install on hdd? */
3802 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3804 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3807 MUIDisplayPage(BOOT_LOADER_PAGE
);
3808 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3812 CONSOLE_ConInKey(Ir
);
3814 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3815 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3817 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3826 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3828 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3829 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3831 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3840 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3842 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3843 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3845 if (ConfirmQuit(Ir
) == TRUE
)
3850 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3854 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3856 else if (Line
== 13)
3858 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
3860 else if (Line
== 14)
3862 return BOOT_LOADER_FLOPPY_PAGE
;
3864 else if (Line
== 15)
3866 return SUCCESS_PAGE
;
3869 return BOOT_LOADER_PAGE
;
3873 return BOOT_LOADER_PAGE
;
3878 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3882 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3884 // SetStatusText(" Please wait...");
3888 CONSOLE_ConInKey(Ir
);
3890 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3891 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3893 if (ConfirmQuit(Ir
) == TRUE
)
3898 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3900 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3902 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3903 return BOOT_LOADER_FLOPPY_PAGE
;
3906 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3907 if (!NT_SUCCESS(Status
))
3909 /* Print error message */
3910 return BOOT_LOADER_FLOPPY_PAGE
;
3913 return SUCCESS_PAGE
;
3917 return BOOT_LOADER_FLOPPY_PAGE
;
3921 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
3923 UCHAR PartitionType
;
3926 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3928 Status
= InstallVBRToPartition(&SystemRootPath
,
3930 &DestinationArcPath
,
3932 if (!NT_SUCCESS(Status
))
3934 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3938 return SUCCESS_PAGE
;
3942 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
3944 UCHAR PartitionType
;
3946 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
3947 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
3949 /* Step 1: Write the VBR */
3950 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3952 Status
= InstallVBRToPartition(&SystemRootPath
,
3954 &DestinationArcPath
,
3956 if (!NT_SUCCESS(Status
))
3958 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3962 /* Step 2: Write the MBR */
3963 swprintf(DestinationDevicePathBuffer
,
3964 L
"\\Device\\Harddisk%d\\Partition0",
3965 PartitionList
->ActiveBootDisk
->DiskNumber
);
3967 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
3968 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
3970 DPRINT("Install MBR bootcode: %S ==> %S\n",
3971 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
3973 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
3974 DestinationDevicePathBuffer
);
3975 if (!NT_SUCCESS (Status
))
3977 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
3979 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3983 return SUCCESS_PAGE
;
3988 QuitPage(PINPUT_RECORD Ir
)
3990 MUIDisplayPage(QUIT_PAGE
);
3992 /* Destroy partition list */
3993 if (PartitionList
!= NULL
)
3995 DestroyPartitionList (PartitionList
);
3996 PartitionList
= NULL
;
3999 /* Destroy filesystem list */
4000 if (FileSystemList
!= NULL
)
4002 DestroyFileSystemList (FileSystemList
);
4003 FileSystemList
= NULL
;
4006 /* Destroy computer settings list */
4007 if (ComputerList
!= NULL
)
4009 DestroyGenericList(ComputerList
, TRUE
);
4010 ComputerList
= NULL
;
4013 /* Destroy display settings list */
4014 if (DisplayList
!= NULL
)
4016 DestroyGenericList(DisplayList
, TRUE
);
4020 /* Destroy keyboard settings list */
4021 if (KeyboardList
!= NULL
)
4023 DestroyGenericList(KeyboardList
, TRUE
);
4024 KeyboardList
= NULL
;
4027 /* Destroy keyboard layout list */
4028 if (LayoutList
!= NULL
)
4030 DestroyGenericList(LayoutList
, TRUE
);
4034 if (LanguageList
!= NULL
)
4036 DestroyGenericList(LanguageList
, FALSE
);
4037 LanguageList
= NULL
;
4040 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4044 CONSOLE_ConInKey(Ir
);
4046 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4055 SuccessPage(PINPUT_RECORD Ir
)
4057 MUIDisplayPage(SUCCESS_PAGE
);
4059 if (IsUnattendedSetup
)
4066 CONSOLE_ConInKey(Ir
);
4068 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4077 FlushPage(PINPUT_RECORD Ir
)
4079 MUIDisplayPage(FLUSH_PAGE
);
4085 PnpEventThread(IN LPVOID lpParameter
);
4096 NtQuerySystemTime(&Time
);
4098 Status
= RtlCreateUserThread(NtCurrentProcess(),
4108 if (!NT_SUCCESS(Status
))
4109 hPnpThread
= INVALID_HANDLE_VALUE
;
4111 if (!CONSOLE_Init())
4113 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4114 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4115 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4117 /* Raise a hard error (crash the system/BSOD) */
4118 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4122 /* Initialize global unicode strings */
4123 RtlInitUnicodeString(&SourcePath
, NULL
);
4124 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4125 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4126 RtlInitUnicodeString(&InstallPath
, NULL
);
4127 RtlInitUnicodeString(&DestinationPath
, NULL
);
4128 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4129 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4130 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4132 /* Hide the cursor */
4133 CONSOLE_SetCursorType(TRUE
, FALSE
);
4136 while (Page
!= REBOOT_PAGE
)
4138 CONSOLE_ClearScreen();
4141 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4148 Page
= SetupStartPage(&Ir
);
4153 Page
= LanguagePage(&Ir
);
4158 Page
= LicensePage(&Ir
);
4163 Page
= IntroPage(&Ir
);
4167 case INSTALL_INTRO_PAGE
:
4168 Page
= InstallIntroPage(&Ir
);
4172 case SCSI_CONTROLLER_PAGE
:
4173 Page
= ScsiControllerPage(&Ir
);
4178 case OEM_DRIVER_PAGE
:
4179 Page
= OemDriverPage(&Ir
);
4183 case DEVICE_SETTINGS_PAGE
:
4184 Page
= DeviceSettingsPage(&Ir
);
4187 case COMPUTER_SETTINGS_PAGE
:
4188 Page
= ComputerSettingsPage(&Ir
);
4191 case DISPLAY_SETTINGS_PAGE
:
4192 Page
= DisplaySettingsPage(&Ir
);
4195 case KEYBOARD_SETTINGS_PAGE
:
4196 Page
= KeyboardSettingsPage(&Ir
);
4199 case LAYOUT_SETTINGS_PAGE
:
4200 Page
= LayoutSettingsPage(&Ir
);
4203 case SELECT_PARTITION_PAGE
:
4204 Page
= SelectPartitionPage(&Ir
);
4207 case CREATE_PRIMARY_PARTITION_PAGE
:
4208 Page
= CreatePrimaryPartitionPage(&Ir
);
4211 case CREATE_EXTENDED_PARTITION_PAGE
:
4212 Page
= CreateExtendedPartitionPage(&Ir
);
4215 case CREATE_LOGICAL_PARTITION_PAGE
:
4216 Page
= CreateLogicalPartitionPage(&Ir
);
4219 case DELETE_PARTITION_PAGE
:
4220 Page
= DeletePartitionPage(&Ir
);
4223 case SELECT_FILE_SYSTEM_PAGE
:
4224 Page
= SelectFileSystemPage(&Ir
);
4227 case FORMAT_PARTITION_PAGE
:
4228 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4231 case CHECK_FILE_SYSTEM_PAGE
:
4232 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4235 case INSTALL_DIRECTORY_PAGE
:
4236 Page
= InstallDirectoryPage(&Ir
);
4239 case PREPARE_COPY_PAGE
:
4240 Page
= PrepareCopyPage(&Ir
);
4243 case FILE_COPY_PAGE
:
4244 Page
= FileCopyPage(&Ir
);
4248 Page
= RegistryPage(&Ir
);
4251 case BOOT_LOADER_PAGE
:
4252 Page
= BootLoaderPage(&Ir
);
4255 case BOOT_LOADER_FLOPPY_PAGE
:
4256 Page
= BootLoaderFloppyPage(&Ir
);
4259 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4260 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4263 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4264 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4268 case REPAIR_INTRO_PAGE
:
4269 Page
= RepairIntroPage(&Ir
);
4273 Page
= SuccessPage(&Ir
);
4277 Page
= FlushPage(&Ir
);
4281 Page
= QuitPage(&Ir
);
4291 /* Avoid bugcheck */
4292 Time
.QuadPart
+= 50000000;
4293 NtDelayExecution(FALSE
, &Time
);
4296 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4297 NtShutdownSystem(ShutdownReboot
);
4298 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4299 NtTerminateProcess(NtCurrentProcess(), 0);
4306 NtProcessStartup(PPEB Peb
)
4308 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4310 ProcessHeap
= Peb
->ProcessHeap
;
4311 InfSetHeap(ProcessHeap
);
4314 #endif /* __REACTOS__ */