3 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/usetup.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMER: Eric Kohl
25 * Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * Hervé Poussineau (hpoussin@reactos.org)
42 /* GLOBALS ******************************************************************/
45 UNICODE_STRING SourceRootPath
;
46 UNICODE_STRING SourceRootDir
;
47 UNICODE_STRING SourcePath
;
48 BOOLEAN IsUnattendedSetup
= FALSE
;
49 LONG UnattendDestinationDiskNumber
;
50 LONG UnattendDestinationPartitionNumber
;
51 LONG UnattendMBRInstallType
= -1;
52 LONG UnattendFormatPartition
= 0;
53 LONG AutoPartition
= 0;
54 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
55 PWCHAR SelectedLanguageId
;
57 WCHAR DefaultLanguage
[20];
58 WCHAR DefaultKBLayout
[20];
59 BOOLEAN RepairUpdateFlag
= FALSE
;
60 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
61 PPARTLIST PartitionList
= NULL
;
63 /* LOCALS *******************************************************************/
65 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
67 static UNICODE_STRING InstallPath
;
69 /* Path to the install directory */
70 static UNICODE_STRING DestinationPath
;
71 static UNICODE_STRING DestinationArcPath
;
72 static UNICODE_STRING DestinationRootPath
;
74 static WCHAR DestinationDriveLetter
;
76 /* Path to the active partition (boot manager) */
77 static UNICODE_STRING SystemRootPath
;
81 static HSPFILEQ SetupFileQueue
= NULL
;
83 static PGENERIC_LIST ComputerList
= NULL
;
84 static PGENERIC_LIST DisplayList
= NULL
;
85 static PGENERIC_LIST KeyboardList
= NULL
;
86 static PGENERIC_LIST LayoutList
= NULL
;
87 static PGENERIC_LIST LanguageList
= NULL
;
89 static LANGID LanguageId
= 0;
91 static ULONG RequiredPartitionDiskSpace
= ~0;
93 /* FUNCTIONS ****************************************************************/
96 PrintString(char* fmt
,...)
100 UNICODE_STRING UnicodeString
;
101 ANSI_STRING AnsiString
;
104 vsprintf(buffer
, fmt
, ap
);
107 RtlInitAnsiString(&AnsiString
, buffer
);
108 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
109 NtDisplayString(&UnicodeString
);
110 RtlFreeUnicodeString(&UnicodeString
);
115 DrawBox(IN SHORT xLeft
,
123 /* draw upper left corner */
126 FillConsoleOutputCharacterA(StdOutput
,
132 /* draw upper edge */
135 FillConsoleOutputCharacterA(StdOutput
,
141 /* draw upper right corner */
142 coPos
.X
= xLeft
+ Width
- 1;
144 FillConsoleOutputCharacterA(StdOutput
,
150 /* Draw right edge, inner space and left edge */
151 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
154 FillConsoleOutputCharacterA(StdOutput
,
161 FillConsoleOutputCharacterA(StdOutput
,
167 coPos
.X
= xLeft
+ Width
- 1;
168 FillConsoleOutputCharacterA(StdOutput
,
175 /* draw lower left corner */
177 coPos
.Y
= yTop
+ Height
- 1;
178 FillConsoleOutputCharacterA(StdOutput
,
184 /* draw lower edge */
186 coPos
.Y
= yTop
+ Height
- 1;
187 FillConsoleOutputCharacterA(StdOutput
,
193 /* draw lower right corner */
194 coPos
.X
= xLeft
+ Width
- 1;
195 coPos
.Y
= yTop
+ Height
- 1;
196 FillConsoleOutputCharacterA(StdOutput
,
205 PopupError(PCCH Text
,
223 /* Count text lines and longest line */
230 p
= strchr(pnext
, '\n');
234 Length
= strlen(pnext
);
239 Length
= (ULONG
)(p
- pnext
);
245 if (Length
> MaxLength
)
248 if (LastLine
== TRUE
)
254 /* Check length of status line */
257 Length
= strlen(Status
);
259 if (Length
> MaxLength
)
263 Width
= MaxLength
+ 4;
269 yTop
= (yScreen
- Height
) / 2;
270 xLeft
= (xScreen
- Width
) / 2;
273 /* Set screen attributes */
275 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
277 FillConsoleOutputAttribute(StdOutput
,
278 FOREGROUND_RED
| BACKGROUND_WHITE
,
284 DrawBox(xLeft
, yTop
, Width
, Height
);
286 /* Print message text */
291 p
= strchr(pnext
, '\n');
295 Length
= strlen(pnext
);
300 Length
= (ULONG
)(p
- pnext
);
307 WriteConsoleOutputCharacterA(StdOutput
,
314 if (LastLine
== TRUE
)
321 /* Print separator line and status text */
324 coPos
.Y
= yTop
+ Height
- 3;
326 FillConsoleOutputCharacterA(StdOutput
,
333 FillConsoleOutputCharacterA(StdOutput
,
339 coPos
.X
= xLeft
+ Width
- 1;
340 FillConsoleOutputCharacterA(StdOutput
,
348 WriteConsoleOutputCharacterA(StdOutput
,
350 min(strlen(Status
), (SIZE_T
)Width
- 4),
355 if (WaitEvent
== POPUP_WAIT_NONE
)
360 CONSOLE_ConInKey(Ir
);
362 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
363 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
375 * FALSE: Don't quit setup.
378 ConfirmQuit(PINPUT_RECORD Ir
)
381 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
385 CONSOLE_ConInKey(Ir
);
387 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
388 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
393 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
405 CheckUnattendedSetup(VOID
)
407 WCHAR UnattendInfPath
[MAX_PATH
];
414 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
416 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
420 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
421 wcscat(UnattendInfPath
, L
"\\unattend.inf");
423 /* Load 'unattend.inf' from install media. */
424 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
430 if (UnattendInf
== INVALID_HANDLE_VALUE
)
432 DPRINT("SetupOpenInfFileW() failed\n");
436 /* Open 'Unattend' section */
437 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
439 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
440 SetupCloseInfFile(UnattendInf
);
444 /* Get pointer 'Signature' key */
445 if (!INF_GetData(&Context
, NULL
, &Value
))
447 DPRINT("INF_GetData() failed for key 'Signature'\n");
448 SetupCloseInfFile(UnattendInf
);
452 /* Check 'Signature' string */
453 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
455 DPRINT("Signature not $ReactOS$\n");
456 SetupCloseInfFile(UnattendInf
);
460 /* Check if Unattend setup is enabled */
461 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
463 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
464 SetupCloseInfFile(UnattendInf
);
468 if (!INF_GetData(&Context
, NULL
, &Value
))
470 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
471 SetupCloseInfFile(UnattendInf
);
475 if (_wcsicmp(Value
, L
"yes") != 0)
477 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
478 SetupCloseInfFile(UnattendInf
);
482 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
483 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
485 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
486 SetupCloseInfFile(UnattendInf
);
490 if (!SetupGetIntField(&Context
, 1, &IntValue
))
492 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
493 SetupCloseInfFile(UnattendInf
);
497 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
499 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
500 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
502 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
503 SetupCloseInfFile(UnattendInf
);
507 if (!SetupGetIntField(&Context
, 1, &IntValue
))
509 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
510 SetupCloseInfFile(UnattendInf
);
514 UnattendDestinationPartitionNumber
= IntValue
;
516 /* Search for 'InstallationDirectory' in the 'Unattend' section */
517 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"InstallationDirectory", &Context
))
519 DPRINT("SetupFindFirstLine() failed for key 'InstallationDirectory'\n");
520 SetupCloseInfFile(UnattendInf
);
524 /* Get pointer 'InstallationDirectory' key */
525 if (!INF_GetData(&Context
, NULL
, &Value
))
527 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
528 SetupCloseInfFile(UnattendInf
);
532 wcscpy(UnattendInstallationDirectory
, Value
);
534 IsUnattendedSetup
= TRUE
;
536 /* Search for 'MBRInstallType' in the 'Unattend' section */
537 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
539 if (SetupGetIntField(&Context
, 1, &IntValue
))
541 UnattendMBRInstallType
= IntValue
;
545 /* Search for 'FormatPartition' in the 'Unattend' section */
546 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
548 if (SetupGetIntField(&Context
, 1, &IntValue
))
550 UnattendFormatPartition
= IntValue
;
554 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
556 if (SetupGetIntField(&Context
, 1, &IntValue
))
558 AutoPartition
= IntValue
;
562 /* search for LocaleID in the 'Unattend' section*/
563 if (SetupFindFirstLineW (UnattendInf
, L
"Unattend", L
"LocaleID", &Context
))
565 if (INF_GetData (&Context
, NULL
, &Value
))
567 LONG Id
= wcstol(Value
, NULL
, 16);
568 swprintf(LocaleID
,L
"%08lx", Id
);
572 SetupCloseInfFile(UnattendInf
);
574 DPRINT("Running unattended setup\n");
581 PGENERIC_LIST_ENTRY ListEntry
;
582 LPCWSTR pszNewLayout
;
584 pszNewLayout
= MUIDefaultKeyboardLayout();
586 if (LayoutList
== NULL
)
588 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
589 if (LayoutList
== NULL
)
591 /* FIXME: Handle error! */
596 ListEntry
= GetFirstListEntry(LayoutList
);
598 /* Search for default layout (if provided) */
599 if (pszNewLayout
!= NULL
)
601 while (ListEntry
!= NULL
)
603 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
605 SetCurrentListEntry(LayoutList
, ListEntry
);
609 ListEntry
= GetNextListEntry(ListEntry
);
616 LanguagePage(PINPUT_RECORD Ir
)
618 PWCHAR NewLanguageId
;
619 BOOL RefreshPage
= FALSE
;
621 /* Initialize the computer settings list */
622 if (LanguageList
== NULL
)
624 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
626 if (LanguageList
== NULL
)
628 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
634 SelectedLanguageId
= DefaultLanguage
;
635 SetConsoleCodePage();
637 DrawGenericList(LanguageList
,
643 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
645 MUIDisplayPage(LANGUAGE_PAGE
);
649 CONSOLE_ConInKey(Ir
);
651 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
652 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
654 ScrollDownGenericList (LanguageList
);
657 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
658 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
660 ScrollUpGenericList(LanguageList
);
663 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
664 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
666 ScrollPageDownGenericList(LanguageList
);
669 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
670 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
672 ScrollPageUpGenericList(LanguageList
);
675 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
676 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
678 if (ConfirmQuit(Ir
) == TRUE
)
681 RedrawGenericList(LanguageList
);
683 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
685 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
687 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
689 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
695 SetConsoleCodePage();
699 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
702 GenericListKeyPress(LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
708 NewLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
710 if (SelectedLanguageId
!= NewLanguageId
)
712 /* Clear the language page */
713 MUIClearPage(LANGUAGE_PAGE
);
715 SelectedLanguageId
= NewLanguageId
;
718 SetConsoleCodePage();
720 /* Redraw language selection page in native language */
721 MUIDisplayPage(LANGUAGE_PAGE
);
735 * Number of the next page.
738 SetupStartPage(PINPUT_RECORD Ir
)
740 //SYSTEM_DEVICE_INFORMATION Sdi;
742 WCHAR FileNameBuffer
[MAX_PATH
];
747 PGENERIC_LIST_ENTRY ListEntry
;
750 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
753 /* Check whether a harddisk is available */
754 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
756 sizeof(SYSTEM_DEVICE_INFORMATION
),
759 if (!NT_SUCCESS(Status
))
761 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
762 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
766 if (Sdi
.NumberOfDisks
== 0)
768 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
773 /* Get the source path and source root path */
774 Status
= GetSourcePaths(&SourcePath
,
778 if (!NT_SUCCESS(Status
))
780 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
781 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
787 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
788 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
789 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
793 /* Load txtsetup.sif from install media. */
794 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
795 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
797 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
803 if (SetupInf
== INVALID_HANDLE_VALUE
)
805 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
809 /* Open 'Version' section */
810 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
812 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
816 /* Get pointer 'Signature' key */
817 if (!INF_GetData(&Context
, NULL
, &Value
))
819 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
823 /* Check 'Signature' string */
824 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
826 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
830 /* Open 'DiskSpaceRequirements' section */
831 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
833 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
837 /* Get the 'FreeSysPartDiskSpace' value */
838 if (!SetupGetIntField(&Context
, 1, &IntValue
))
840 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
844 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
846 /* Start PnP thread */
847 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
849 NtResumeThread(hPnpThread
, NULL
);
850 hPnpThread
= INVALID_HANDLE_VALUE
;
853 CheckUnattendedSetup();
855 if (IsUnattendedSetup
)
858 //read options from inf
859 ComputerList
= CreateComputerTypeList(SetupInf
);
860 DisplayList
= CreateDisplayDriverList(SetupInf
);
861 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
862 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
863 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
866 wcscpy(SelectedLanguageId
,LocaleID
);
868 /* first we hack LanguageList */
869 ListEntry
= GetFirstListEntry(LanguageList
);
871 while (ListEntry
!= NULL
)
873 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
875 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
876 SetCurrentListEntry(LanguageList
, ListEntry
);
880 ListEntry
= GetNextListEntry(ListEntry
);
884 ListEntry
= GetFirstListEntry(LayoutList
);
886 while (ListEntry
!= NULL
)
888 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
890 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
891 SetCurrentListEntry(LayoutList
, ListEntry
);
895 ListEntry
= GetNextListEntry(ListEntry
);
898 SetConsoleCodePage();
900 return INSTALL_INTRO_PAGE
;
903 return LANGUAGE_PAGE
;
913 IntroPage(PINPUT_RECORD Ir
)
915 MUIDisplayPage(START_PAGE
);
919 CONSOLE_ConInKey(Ir
);
921 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
922 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
924 if (ConfirmQuit(Ir
) == TRUE
)
929 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
931 return INSTALL_INTRO_PAGE
;
933 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
935 return REPAIR_INTRO_PAGE
;
937 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
950 * Back to main setup page.
953 LicensePage(PINPUT_RECORD Ir
)
955 MUIDisplayPage(LICENSE_PAGE
);
959 CONSOLE_ConInKey(Ir
);
961 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
972 RepairIntroPage(PINPUT_RECORD Ir
)
974 MUIDisplayPage(REPAIR_INTRO_PAGE
);
978 CONSOLE_ConInKey(Ir
);
980 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
984 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
986 RepairUpdateFlag
= TRUE
;
987 return INSTALL_INTRO_PAGE
;
989 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
991 return RECOVERY_PAGE
;
993 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
994 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1000 return REPAIR_INTRO_PAGE
;
1005 InstallIntroPage(PINPUT_RECORD Ir
)
1007 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1009 if (RepairUpdateFlag
)
1011 //return SELECT_PARTITION_PAGE;
1012 return DEVICE_SETTINGS_PAGE
;
1015 if (IsUnattendedSetup
)
1017 return SELECT_PARTITION_PAGE
;
1022 CONSOLE_ConInKey(Ir
);
1024 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1025 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1027 if (ConfirmQuit(Ir
) == TRUE
)
1032 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1034 return DEVICE_SETTINGS_PAGE
;
1035 // return SCSI_CONTROLLER_PAGE;
1039 return INSTALL_INTRO_PAGE
;
1045 ScsiControllerPage(PINPUT_RECORD Ir
)
1047 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1049 /* FIXME: print loaded mass storage driver descriptions */
1051 SetTextXY(8, 10, "TEST device");
1055 SetStatusText(" ENTER = Continue F3 = Quit");
1061 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1062 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1064 if (ConfirmQuit(Ir
) == TRUE
)
1069 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1071 return DEVICE_SETTINGS_PAGE
;
1075 return SCSI_CONTROLLER_PAGE
;
1081 DeviceSettingsPage(PINPUT_RECORD Ir
)
1083 static ULONG Line
= 16;
1084 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1086 /* Initialize the computer settings list */
1087 if (ComputerList
== NULL
)
1089 ComputerList
= CreateComputerTypeList(SetupInf
);
1090 if (ComputerList
== NULL
)
1092 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1097 /* Initialize the display settings list */
1098 if (DisplayList
== NULL
)
1100 DisplayList
= CreateDisplayDriverList(SetupInf
);
1101 if (DisplayList
== NULL
)
1103 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1108 /* Initialize the keyboard settings list */
1109 if (KeyboardList
== NULL
)
1111 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1112 if (KeyboardList
== NULL
)
1114 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1119 /* Initialize the keyboard layout list */
1120 if (LayoutList
== NULL
)
1122 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1123 if (LayoutList
== NULL
)
1125 /* FIXME: report error */
1126 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1131 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1134 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1135 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1136 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1137 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1139 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1141 if (RepairUpdateFlag
)
1143 return SELECT_PARTITION_PAGE
;
1148 CONSOLE_ConInKey(Ir
);
1150 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1151 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1153 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1157 else if (Line
== 16)
1162 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1164 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1165 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1167 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1171 else if (Line
== 16)
1176 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1178 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1179 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1181 if (ConfirmQuit(Ir
) == TRUE
)
1186 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1189 return COMPUTER_SETTINGS_PAGE
;
1190 else if (Line
== 12)
1191 return DISPLAY_SETTINGS_PAGE
;
1192 else if (Line
== 13)
1193 return KEYBOARD_SETTINGS_PAGE
;
1194 else if (Line
== 14)
1195 return LAYOUT_SETTINGS_PAGE
;
1196 else if (Line
== 16)
1197 return SELECT_PARTITION_PAGE
;
1201 return DEVICE_SETTINGS_PAGE
;
1206 ComputerSettingsPage(PINPUT_RECORD Ir
)
1208 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1210 DrawGenericList(ComputerList
,
1216 SaveGenericListState(ComputerList
);
1220 CONSOLE_ConInKey(Ir
);
1222 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1223 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1225 ScrollDownGenericList(ComputerList
);
1227 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1228 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1230 ScrollUpGenericList(ComputerList
);
1232 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1233 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1235 if (ConfirmQuit(Ir
) == TRUE
)
1240 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1241 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1243 RestoreGenericListState(ComputerList
);
1244 return DEVICE_SETTINGS_PAGE
;
1246 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1248 return DEVICE_SETTINGS_PAGE
;
1252 return COMPUTER_SETTINGS_PAGE
;
1257 DisplaySettingsPage(PINPUT_RECORD Ir
)
1259 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1261 DrawGenericList(DisplayList
,
1267 SaveGenericListState(DisplayList
);
1271 CONSOLE_ConInKey(Ir
);
1273 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1274 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1276 ScrollDownGenericList(DisplayList
);
1278 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1279 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1281 ScrollUpGenericList(DisplayList
);
1283 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1284 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1286 if (ConfirmQuit(Ir
) == TRUE
)
1293 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1294 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1296 RestoreGenericListState(DisplayList
);
1297 return DEVICE_SETTINGS_PAGE
;
1299 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1301 return DEVICE_SETTINGS_PAGE
;
1305 return DISPLAY_SETTINGS_PAGE
;
1310 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1312 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1314 DrawGenericList(KeyboardList
,
1320 SaveGenericListState(KeyboardList
);
1324 CONSOLE_ConInKey(Ir
);
1326 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1327 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1329 ScrollDownGenericList(KeyboardList
);
1331 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1332 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1334 ScrollUpGenericList(KeyboardList
);
1336 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1337 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1339 if (ConfirmQuit(Ir
) == TRUE
)
1344 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1345 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1347 RestoreGenericListState(KeyboardList
);
1348 return DEVICE_SETTINGS_PAGE
;
1350 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1352 return DEVICE_SETTINGS_PAGE
;
1356 return KEYBOARD_SETTINGS_PAGE
;
1361 LayoutSettingsPage(PINPUT_RECORD Ir
)
1363 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1365 DrawGenericList(LayoutList
,
1371 SaveGenericListState(LayoutList
);
1375 CONSOLE_ConInKey(Ir
);
1377 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1378 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1380 ScrollDownGenericList(LayoutList
);
1382 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1383 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1385 ScrollUpGenericList(LayoutList
);
1387 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1388 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1390 ScrollPageDownGenericList(LayoutList
);
1392 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1393 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1395 ScrollPageUpGenericList(LayoutList
);
1397 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1398 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1400 if (ConfirmQuit(Ir
) == TRUE
)
1405 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1406 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1408 RestoreGenericListState(LayoutList
);
1409 return DEVICE_SETTINGS_PAGE
;
1411 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1413 return DEVICE_SETTINGS_PAGE
;
1415 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1418 GenericListKeyPress(LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1422 return LAYOUT_SETTINGS_PAGE
;
1427 IsDiskSizeValid(PPARTENTRY PartEntry
)
1431 size
= PartEntry
->SectorCount
.QuadPart
* PartEntry
->DiskEntry
->BytesPerSector
;
1432 size
= (size
+ 524288) / 1048576; /* in MBytes */
1434 if (size
< RequiredPartitionDiskSpace
)
1436 /* partition is too small so ask for another partion */
1437 DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size
, RequiredPartitionDiskSpace
);
1448 SelectPartitionPage(PINPUT_RECORD Ir
)
1452 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1454 if (PartitionList
== NULL
)
1456 PartitionList
= CreatePartitionList(2,
1460 if (PartitionList
== NULL
)
1462 /* FIXME: show an error dialog */
1465 else if (IsListEmpty (&PartitionList
->DiskListHead
))
1467 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
1472 DrawPartitionList(PartitionList
);
1474 if (IsUnattendedSetup
)
1476 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1480 CreatePrimaryPartition(PartitionList
,
1481 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1484 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1486 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1487 RequiredPartitionDiskSpace
);
1488 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1491 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1493 return SELECT_FILE_SYSTEM_PAGE
;
1498 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1500 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1501 RequiredPartitionDiskSpace
);
1502 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1505 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1507 return SELECT_FILE_SYSTEM_PAGE
;
1513 /* Update status text */
1514 if (PartitionList
->CurrentPartition
== NULL
)
1516 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1518 else if (PartitionList
->CurrentPartition
->LogicalPartition
)
1520 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1522 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1526 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL
));
1531 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1533 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1535 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1539 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1544 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1548 CONSOLE_ConInKey(Ir
);
1550 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1551 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1553 if (ConfirmQuit(Ir
) == TRUE
)
1555 DestroyPartitionList(PartitionList
);
1556 PartitionList
= NULL
;
1562 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1563 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1565 if (ScrollDownPartitionList(PartitionList
))
1566 DrawPartitionList(PartitionList
);
1568 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1569 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1571 if (ScrollUpPartitionList(PartitionList
))
1572 DrawPartitionList(PartitionList
);
1574 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1576 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1577 continue; //return SELECT_PARTITION_PAGE;
1579 if (PartitionList
->CurrentPartition
== NULL
||
1580 PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1582 CreatePrimaryPartition(PartitionList
,
1587 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1589 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1590 RequiredPartitionDiskSpace
);
1591 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1594 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1596 return SELECT_FILE_SYSTEM_PAGE
;
1598 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'P') /* P */
1600 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1602 Error
= PrimaryPartitionCreationChecks(PartitionList
);
1603 if (Error
!= NOT_AN_ERROR
)
1605 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1606 return SELECT_PARTITION_PAGE
;
1609 return CREATE_PRIMARY_PARTITION_PAGE
;
1612 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'E') /* E */
1614 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1616 Error
= ExtendedPartitionCreationChecks(PartitionList
);
1617 if (Error
!= NOT_AN_ERROR
)
1619 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1620 return SELECT_PARTITION_PAGE
;
1623 return CREATE_EXTENDED_PARTITION_PAGE
;
1626 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'L') /* L */
1628 if (PartitionList
->CurrentPartition
->LogicalPartition
== TRUE
)
1630 Error
= LogicalPartitionCreationChecks(PartitionList
);
1631 if (Error
!= NOT_AN_ERROR
)
1633 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1634 return SELECT_PARTITION_PAGE
;
1637 return CREATE_LOGICAL_PARTITION_PAGE
;
1640 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1642 if (PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1644 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1645 return SELECT_PARTITION_PAGE
;
1648 return DELETE_PARTITION_PAGE
;
1652 return SELECT_PARTITION_PAGE
;
1656 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1657 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1658 #define PARTITION_MAXSIZE 999999
1661 ShowPartitionSizeInputBox(SHORT Left
,
1674 WCHAR PartitionSizeBuffer
[100];
1686 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1691 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1692 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1695 WriteConsoleOutputCharacterA(StdOutput
,
1701 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1702 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1704 WriteConsoleOutputCharacterA(StdOutput
,
1710 swprintf(PartitionSizeBuffer
, L
"%lu", MaxSize
);
1711 Index
= wcslen(PartitionSizeBuffer
);
1712 CONSOLE_SetInputTextXY(iLeft
,
1714 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1715 PartitionSizeBuffer
);
1719 CONSOLE_ConInKey(&Ir
);
1721 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1722 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1727 PartitionSizeBuffer
[0] = 0;
1730 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1734 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1739 PartitionSizeBuffer
[0] = 0;
1742 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1746 PartitionSizeBuffer
[Index
] = 0;
1748 CONSOLE_SetInputTextXY(iLeft
,
1750 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1751 PartitionSizeBuffer
);
1753 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1754 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1756 ch
= (WCHAR
)Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1758 if ((ch
>= L
'0') && (ch
<= L
'9'))
1760 PartitionSizeBuffer
[Index
] = ch
;
1762 PartitionSizeBuffer
[Index
] = 0;
1764 CONSOLE_SetInputTextXY(iLeft
,
1766 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1767 PartitionSizeBuffer
);
1772 /* Convert UNICODE --> ANSI the poor man's way */
1773 sprintf(InputBuffer
, "%S", PartitionSizeBuffer
);
1778 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1780 PDISKENTRY DiskEntry
;
1781 PPARTENTRY PartEntry
;
1784 CHAR InputBuffer
[50];
1788 ULONGLONG SectorCount
;
1791 if (PartitionList
== NULL
||
1792 PartitionList
->CurrentDisk
== NULL
||
1793 PartitionList
->CurrentPartition
== NULL
)
1795 /* FIXME: show an error dialog */
1799 DiskEntry
= PartitionList
->CurrentDisk
;
1800 PartEntry
= PartitionList
->CurrentPartition
;
1802 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1804 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1806 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1808 if (DiskSize
>= 10737418240) /* 10 GB */
1810 DiskSize
= DiskSize
/ 1073741824;
1811 Unit
= MUIGetString(STRING_GB
);
1816 DiskSize
= DiskSize
/ 1048576;
1820 Unit
= MUIGetString(STRING_MB
);
1823 if (DiskEntry
->DriverName
.Length
> 0)
1825 CONSOLE_PrintTextXY(6, 10,
1826 MUIGetString(STRING_HDINFOPARTCREATE
),
1829 DiskEntry
->DiskNumber
,
1833 &DiskEntry
->DriverName
);
1837 CONSOLE_PrintTextXY(6, 10,
1838 MUIGetString(STRING_HDDINFOUNK1
),
1841 DiskEntry
->DiskNumber
,
1847 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1850 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1851 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
1854 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1856 PartEntry
= PartitionList
->CurrentPartition
;
1859 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
1861 if (MaxSize
> PARTITION_MAXSIZE
)
1862 MaxSize
= PARTITION_MAXSIZE
;
1864 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1865 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1869 if (ConfirmQuit (Ir
) == TRUE
)
1874 else if (Cancel
== TRUE
)
1876 return SELECT_PARTITION_PAGE
;
1880 PartSize
= atoi(InputBuffer
);
1888 if (PartSize
> MaxSize
)
1894 /* Convert to bytes */
1895 if (PartSize
== MaxSize
)
1897 /* Use all of the unpartitioned disk space */
1898 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1902 /* Calculate the sector count from the size in MB */
1903 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
1905 /* But never get larger than the unpartitioned disk space */
1906 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
1907 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1910 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1912 CreatePrimaryPartition(PartitionList
,
1916 return SELECT_PARTITION_PAGE
;
1920 return CREATE_PRIMARY_PARTITION_PAGE
;
1925 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
1927 PDISKENTRY DiskEntry
;
1928 PPARTENTRY PartEntry
;
1931 CHAR InputBuffer
[50];
1935 ULONGLONG SectorCount
;
1938 if (PartitionList
== NULL
||
1939 PartitionList
->CurrentDisk
== NULL
||
1940 PartitionList
->CurrentPartition
== NULL
)
1942 /* FIXME: show an error dialog */
1946 DiskEntry
= PartitionList
->CurrentDisk
;
1947 PartEntry
= PartitionList
->CurrentPartition
;
1949 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1951 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
1953 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1955 if (DiskSize
>= 10737418240) /* 10 GB */
1957 DiskSize
= DiskSize
/ 1073741824;
1958 Unit
= MUIGetString(STRING_GB
);
1963 DiskSize
= DiskSize
/ 1048576;
1967 Unit
= MUIGetString(STRING_MB
);
1970 if (DiskEntry
->DriverName
.Length
> 0)
1972 CONSOLE_PrintTextXY(6, 10,
1973 MUIGetString(STRING_HDINFOPARTCREATE
),
1976 DiskEntry
->DiskNumber
,
1980 &DiskEntry
->DriverName
);
1984 CONSOLE_PrintTextXY(6, 10,
1985 MUIGetString(STRING_HDDINFOUNK1
),
1988 DiskEntry
->DiskNumber
,
1994 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1997 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1998 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2001 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2003 PartEntry
= PartitionList
->CurrentPartition
;
2006 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2008 if (MaxSize
> PARTITION_MAXSIZE
)
2009 MaxSize
= PARTITION_MAXSIZE
;
2011 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2012 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2016 if (ConfirmQuit (Ir
) == TRUE
)
2021 else if (Cancel
== TRUE
)
2023 return SELECT_PARTITION_PAGE
;
2027 PartSize
= atoi(InputBuffer
);
2035 if (PartSize
> MaxSize
)
2041 /* Convert to bytes */
2042 if (PartSize
== MaxSize
)
2044 /* Use all of the unpartitioned disk space */
2045 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2049 /* Calculate the sector count from the size in MB */
2050 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2052 /* But never get larger than the unpartitioned disk space */
2053 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2054 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2057 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2059 CreateExtendedPartition(PartitionList
,
2062 return SELECT_PARTITION_PAGE
;
2066 return CREATE_EXTENDED_PARTITION_PAGE
;
2071 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2073 PDISKENTRY DiskEntry
;
2074 PPARTENTRY PartEntry
;
2077 CHAR InputBuffer
[50];
2081 ULONGLONG SectorCount
;
2084 if (PartitionList
== NULL
||
2085 PartitionList
->CurrentDisk
== NULL
||
2086 PartitionList
->CurrentPartition
== NULL
)
2088 /* FIXME: show an error dialog */
2092 DiskEntry
= PartitionList
->CurrentDisk
;
2093 PartEntry
= PartitionList
->CurrentPartition
;
2095 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2097 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2099 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2101 if (DiskSize
>= 10737418240) /* 10 GB */
2103 DiskSize
= DiskSize
/ 1073741824;
2104 Unit
= MUIGetString(STRING_GB
);
2109 DiskSize
= DiskSize
/ 1048576;
2113 Unit
= MUIGetString(STRING_MB
);
2116 if (DiskEntry
->DriverName
.Length
> 0)
2118 CONSOLE_PrintTextXY(6, 10,
2119 MUIGetString(STRING_HDINFOPARTCREATE
),
2122 DiskEntry
->DiskNumber
,
2126 &DiskEntry
->DriverName
);
2130 CONSOLE_PrintTextXY(6, 10,
2131 MUIGetString(STRING_HDDINFOUNK1
),
2134 DiskEntry
->DiskNumber
,
2140 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2143 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2144 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2147 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2149 PartEntry
= PartitionList
->CurrentPartition
;
2152 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2154 if (MaxSize
> PARTITION_MAXSIZE
)
2155 MaxSize
= PARTITION_MAXSIZE
;
2157 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2158 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2162 if (ConfirmQuit (Ir
) == TRUE
)
2167 else if (Cancel
== TRUE
)
2169 return SELECT_PARTITION_PAGE
;
2173 PartSize
= atoi(InputBuffer
);
2181 if (PartSize
> MaxSize
)
2187 /* Convert to bytes */
2188 if (PartSize
== MaxSize
)
2190 /* Use all of the unpartitioned disk space */
2191 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2195 /* Calculate the sector count from the size in MB */
2196 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2198 /* But never get larger than the unpartitioned disk space */
2199 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2200 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2203 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2205 CreateLogicalPartition(PartitionList
,
2208 return SELECT_PARTITION_PAGE
;
2212 return CREATE_LOGICAL_PARTITION_PAGE
;
2217 DeletePartitionPage(PINPUT_RECORD Ir
)
2219 PDISKENTRY DiskEntry
;
2220 PPARTENTRY PartEntry
;
2226 if (PartitionList
== NULL
||
2227 PartitionList
->CurrentDisk
== NULL
||
2228 PartitionList
->CurrentPartition
== NULL
)
2230 /* FIXME: show an error dialog */
2234 DiskEntry
= PartitionList
->CurrentDisk
;
2235 PartEntry
= PartitionList
->CurrentPartition
;
2237 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2239 /* Determine partition type */
2241 if (PartEntry
->New
== TRUE
)
2243 PartType
= MUIGetString(STRING_UNFORMATTED
);
2245 else if (PartEntry
->IsPartitioned
== TRUE
)
2247 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2248 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2249 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2250 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2254 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2255 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2259 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2263 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2265 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2267 else if (IsContainerPartition(PartEntry
->PartitionType
))
2269 PartType
= MUIGetString(STRING_EXTENDED_PARTITION
);
2273 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2275 if (PartSize
>= 10737418240) /* 10 GB */
2277 PartSize
= PartSize
/ 1073741824;
2278 Unit
= MUIGetString(STRING_GB
);
2282 if (PartSize
>= 10485760) /* 10 MB */
2284 PartSize
= PartSize
/ 1048576;
2285 Unit
= MUIGetString(STRING_MB
);
2289 PartSize
= PartSize
/ 1024;
2290 Unit
= MUIGetString(STRING_KB
);
2293 if (PartType
== NULL
)
2295 CONSOLE_PrintTextXY(6, 10,
2296 MUIGetString(STRING_HDDINFOUNK2
),
2297 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2298 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2299 PartEntry
->PartitionType
,
2305 CONSOLE_PrintTextXY(6, 10,
2306 " %c%c %s %I64u %s",
2307 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2308 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2314 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2316 if (DiskSize
>= 10737418240) /* 10 GB */
2318 DiskSize
= DiskSize
/ 1073741824;
2319 Unit
= MUIGetString(STRING_GB
);
2324 DiskSize
= DiskSize
/ 1048576;
2328 Unit
= MUIGetString(STRING_MB
);
2331 if (DiskEntry
->DriverName
.Length
> 0)
2333 CONSOLE_PrintTextXY(6, 12,
2334 MUIGetString(STRING_HDINFOPARTDELETE
),
2337 DiskEntry
->DiskNumber
,
2341 &DiskEntry
->DriverName
);
2345 CONSOLE_PrintTextXY(6, 12,
2346 MUIGetString(STRING_HDDINFOUNK3
),
2349 DiskEntry
->DiskNumber
,
2357 CONSOLE_ConInKey(Ir
);
2359 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2360 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2362 if (ConfirmQuit(Ir
) == TRUE
)
2369 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2371 return SELECT_PARTITION_PAGE
;
2373 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2375 DeleteCurrentPartition(PartitionList
);
2377 return SELECT_PARTITION_PAGE
;
2381 return DELETE_PARTITION_PAGE
;
2386 SelectFileSystemPage(PINPUT_RECORD Ir
)
2388 PDISKENTRY DiskEntry
;
2389 PPARTENTRY PartEntry
;
2396 DPRINT("SelectFileSystemPage()\n");
2398 if (PartitionList
== NULL
||
2399 PartitionList
->CurrentDisk
== NULL
||
2400 PartitionList
->CurrentPartition
== NULL
)
2402 /* FIXME: show an error dialog */
2406 /* Find or set the active partition */
2407 CheckActiveBootPartition(PartitionList
);
2409 if (PartitionList
->BootDisk
== NULL
||
2410 PartitionList
->BootPartition
== NULL
)
2412 /* FIXME: show an error dialog */
2416 switch (PartitionList
->FormatState
)
2419 if (PartitionList
->CurrentPartition
!= PartitionList
->BootPartition
)
2421 PartitionList
->TempDisk
= PartitionList
->BootDisk
;
2422 PartitionList
->TempPartition
= PartitionList
->BootPartition
;
2423 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2425 PartitionList
->FormatState
= FormatSystemPartition
;
2426 DPRINT1("FormatState: Start --> FormatSystemPartition\n");
2430 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2431 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2432 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2434 PartitionList
->FormatState
= FormatInstallPartition
;
2435 DPRINT1("FormatState: Start --> FormatInstallPartition\n");
2439 case FormatSystemPartition
:
2440 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2441 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2442 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2444 PartitionList
->FormatState
= FormatInstallPartition
;
2445 DPRINT1("FormatState: FormatSystemPartition --> FormatInstallPartition\n");
2448 case FormatInstallPartition
:
2449 if (GetNextUnformattedPartition(PartitionList
,
2450 &PartitionList
->TempDisk
,
2451 &PartitionList
->TempPartition
))
2453 PartitionList
->FormatState
= FormatOtherPartition
;
2454 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2455 DPRINT1("FormatState: FormatInstallPartition --> FormatOtherPartition\n");
2459 PartitionList
->FormatState
= FormatDone
;
2460 DPRINT1("FormatState: FormatInstallPartition --> FormatDone\n");
2461 return CHECK_FILE_SYSTEM_PAGE
;
2465 case FormatOtherPartition
:
2466 if (GetNextUnformattedPartition(PartitionList
,
2467 &PartitionList
->TempDisk
,
2468 &PartitionList
->TempPartition
))
2470 PartitionList
->FormatState
= FormatOtherPartition
;
2471 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2472 DPRINT1("FormatState: FormatOtherPartition --> FormatOtherPartition\n");
2476 PartitionList
->FormatState
= FormatDone
;
2477 DPRINT1("FormatState: FormatOtherPartition --> FormatDone\n");
2478 return CHECK_FILE_SYSTEM_PAGE
;
2483 DPRINT1("FormatState: Invalid value %ld\n", PartitionList
->FormatState
);
2484 /* FIXME: show an error dialog */
2488 DiskEntry
= PartitionList
->TempDisk
;
2489 PartEntry
= PartitionList
->TempPartition
;
2491 /* adjust disk size */
2492 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2493 if (DiskSize
>= 10737418240) /* 10 GB */
2495 DiskSize
= DiskSize
/ 1073741824;
2496 DiskUnit
= MUIGetString(STRING_GB
);
2500 DiskSize
= DiskSize
/ 1048576;
2501 DiskUnit
= MUIGetString(STRING_MB
);
2504 /* adjust partition size */
2505 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2506 if (PartSize
>= 10737418240) /* 10 GB */
2508 PartSize
= PartSize
/ 1073741824;
2509 PartUnit
= MUIGetString(STRING_GB
);
2513 PartSize
= PartSize
/ 1048576;
2514 PartUnit
= MUIGetString(STRING_MB
);
2517 /* adjust partition type */
2518 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2519 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2520 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2521 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2525 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2526 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2530 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2534 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2536 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2538 else if (PartEntry
->PartitionType
== PARTITION_ENTRY_UNUSED
)
2540 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2544 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2547 if (PartEntry
->AutoCreate
== TRUE
)
2549 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2552 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2553 PartEntry
->PartitionNumber
,
2559 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2560 DiskEntry
->DiskNumber
,
2566 &DiskEntry
->DriverName
);
2568 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2571 PartEntry
->AutoCreate
= FALSE
;
2573 else if (PartEntry
->New
== TRUE
)
2575 switch (PartitionList
->FormatState
)
2577 case FormatSystemPartition
:
2578 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2581 case FormatInstallPartition
:
2582 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2585 case FormatOtherPartition
:
2586 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2593 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2597 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2599 if (PartType
== NULL
)
2601 CONSOLE_PrintTextXY(8, 10,
2602 MUIGetString(STRING_HDDINFOUNK4
),
2603 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2604 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2605 PartEntry
->PartitionType
,
2611 CONSOLE_PrintTextXY(8, 10,
2613 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2614 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2620 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2621 DiskEntry
->DiskNumber
,
2627 &DiskEntry
->DriverName
);
2630 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2632 if (FileSystemList
== NULL
)
2634 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2635 if (FileSystemList
== NULL
)
2637 /* FIXME: show an error dialog */
2641 /* FIXME: Add file systems to list */
2644 DrawFileSystemList(FileSystemList
);
2646 if (RepairUpdateFlag
)
2648 return CHECK_FILE_SYSTEM_PAGE
;
2649 //return SELECT_PARTITION_PAGE;
2652 if (IsUnattendedSetup
)
2654 if (UnattendFormatPartition
)
2656 PartEntry
->FileSystem
= GetFileSystemByName(FileSystemList
,
2658 return FORMAT_PARTITION_PAGE
;
2661 return CHECK_FILE_SYSTEM_PAGE
;
2666 CONSOLE_ConInKey(Ir
);
2668 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2669 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2671 if (ConfirmQuit(Ir
) == TRUE
)
2678 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2679 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2681 return SELECT_PARTITION_PAGE
;
2683 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2684 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2686 ScrollDownFileSystemList(FileSystemList
);
2688 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2689 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2691 ScrollUpFileSystemList(FileSystemList
);
2693 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2695 if (!FileSystemList
->Selected
->FormatFunc
)
2697 return SELECT_FILE_SYSTEM_PAGE
;
2701 PartEntry
->FileSystem
= FileSystemList
->Selected
;
2702 return FORMAT_PARTITION_PAGE
;
2707 return SELECT_FILE_SYSTEM_PAGE
;
2712 FormatPartitionPage(PINPUT_RECORD Ir
)
2714 UNICODE_STRING PartitionRootPath
;
2715 WCHAR PathBuffer
[MAX_PATH
];
2716 PDISKENTRY DiskEntry
;
2717 PPARTENTRY PartEntry
;
2726 DPRINT("FormatPartitionPage()\n");
2728 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2730 if (PartitionList
== NULL
||
2731 PartitionList
->TempDisk
== NULL
||
2732 PartitionList
->TempPartition
== NULL
)
2734 /* FIXME: show an error dialog */
2738 DiskEntry
= PartitionList
->TempDisk
;
2739 PartEntry
= PartitionList
->TempPartition
;
2743 if (!IsUnattendedSetup
)
2745 CONSOLE_ConInKey(Ir
);
2748 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2749 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2751 if (ConfirmQuit(Ir
) == TRUE
)
2758 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2760 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2762 if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"FAT") == 0)
2764 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2766 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2767 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2769 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2771 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2773 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2775 /* FAT16 CHS partition (partiton size < 32MB) */
2776 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2778 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2780 /* FAT16 CHS partition (partition size < 512MB) */
2781 PartEntry
->PartitionType
= PARTITION_HUGE
;
2785 /* FAT32 CHS partition (partition size >= 512MB) */
2786 PartEntry
->PartitionType
= PARTITION_FAT32
;
2791 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2793 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2795 /* FAT16 LBA partition (partition size < 512MB) */
2796 PartEntry
->PartitionType
= PARTITION_XINT13
;
2800 /* FAT32 LBA partition (partition size >= 512MB) */
2801 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2805 DiskEntry
->Dirty
= TRUE
;
2806 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2807 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2810 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"EXT2") == 0)
2812 PartEntry
->PartitionType
= PARTITION_EXT2
;
2814 DiskEntry
->Dirty
= TRUE
;
2815 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2816 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2819 else if (!PartEntry
->FileSystem
->FormatFunc
)
2825 CONSOLE_PrintTextXY(6, 12,
2826 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2827 DiskEntry
->DiskSize
,
2828 DiskEntry
->CylinderSize
,
2829 DiskEntry
->TrackSize
);
2832 DiskEntry
= PartitionList
->TempDisk
;
2833 Entry
= DiskEntry
->PartListHead
.Flink
;
2835 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2837 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2839 if (PartEntry
->IsPartitioned
== TRUE
)
2841 CONSOLE_PrintTextXY(6, Line
,
2842 "%2u: %2u %c %12I64u %12I64u %2u %c",
2844 PartEntry
->PartitionNumber
,
2845 PartEntry
->BootIndicator
? 'A' : '-',
2846 PartEntry
->StartSector
.QuadPart
,
2847 PartEntry
->SectorCount
.QuadPart
,
2848 PartEntry
->PartitionType
,
2849 PartEntry
->Dirty
? '*' : ' ');
2853 Entry
= Entry
->Flink
;
2856 /* Restore the old entry */
2857 PartEntry
= PartitionList
->TempPartition
;
2860 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2862 DPRINT("WritePartitionsToDisk() failed\n");
2863 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2867 /* Set PartitionRootPath */
2868 swprintf(PathBuffer
,
2869 L
"\\Device\\Harddisk%lu\\Partition%lu",
2870 DiskEntry
->DiskNumber
,
2871 PartEntry
->PartitionNumber
);
2872 RtlInitUnicodeString(&PartitionRootPath
,
2874 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
2876 if (PartEntry
->FileSystem
->FormatFunc
)
2878 Status
= FormatPartition(&PartitionRootPath
,
2879 PartEntry
->FileSystem
);
2880 if (!NT_SUCCESS(Status
))
2882 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2883 /* FIXME: show an error dialog */
2887 PartEntry
->New
= FALSE
;
2891 CONSOLE_SetStatusText(" Done. Press any key ...");
2892 CONSOLE_ConInKey(Ir
);
2895 return SELECT_FILE_SYSTEM_PAGE
;
2899 return FORMAT_PARTITION_PAGE
;
2904 CheckFileSystemPage(PINPUT_RECORD Ir
)
2906 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2907 UNICODE_STRING PartitionRootPath
;
2908 WCHAR PathBuffer
[MAX_PATH
];
2909 CHAR Buffer
[MAX_PATH
];
2910 LPWSTR FileSystemName
= NULL
;
2911 PDISKENTRY DiskEntry
;
2912 PPARTENTRY PartEntry
;
2915 if (PartitionList
== NULL
)
2917 /* FIXME: show an error dialog */
2921 if (!GetNextUncheckedPartition(PartitionList
,
2925 return INSTALL_DIRECTORY_PAGE
;
2928 /* Set PartitionRootPath */
2929 swprintf(PathBuffer
,
2930 L
"\\Device\\Harddisk%lu\\Partition%lu",
2931 DiskEntry
->DiskNumber
,
2932 PartEntry
->PartitionNumber
);
2933 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
2934 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
2936 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2938 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2940 CurrentFileSystem
= PartEntry
->FileSystem
;
2941 if (CurrentFileSystem
->FileSystemName
== NULL
)
2943 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2944 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2945 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2946 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2948 FileSystemName
= L
"FAT";
2950 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2951 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2953 FileSystemName
= L
"FAT32";
2955 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2957 FileSystemName
= L
"EXT2";
2959 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2961 FileSystemName
= L
"NTFS"; /* FIXME: Not quite correct! */
2964 if (FileSystemName
!= NULL
)
2965 CurrentFileSystem
= GetFileSystemByName(FileSystemList
,
2969 if (CurrentFileSystem
== NULL
|| CurrentFileSystem
->ChkdskFunc
== NULL
)
2972 "Setup is currently unable to check a partition formatted in %S.\n"
2974 " \x07 Press ENTER to continue Setup.\n"
2975 " \x07 Press F3 to quit Setup.",
2976 CurrentFileSystem
->FileSystemName
);
2979 MUIGetString(STRING_QUITCONTINUE
),
2980 NULL
, POPUP_WAIT_NONE
);
2984 CONSOLE_ConInKey(Ir
);
2986 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2987 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2989 if (ConfirmQuit(Ir
))
2992 return CHECK_FILE_SYSTEM_PAGE
;
2994 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2996 PartEntry
->NeedsCheck
= FALSE
;
2997 return CHECK_FILE_SYSTEM_PAGE
;
3003 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3004 if (!NT_SUCCESS(Status
))
3006 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3007 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
3008 "(Status 0x%08lx).\n", Status
);
3011 MUIGetString(STRING_REBOOTCOMPUTER
),
3012 Ir
, POPUP_WAIT_ENTER
);
3017 PartEntry
->NeedsCheck
= FALSE
;
3018 return CHECK_FILE_SYSTEM_PAGE
;
3024 InstallDirectoryPage1(PWCHAR InstallDir
,
3025 PDISKENTRY DiskEntry
,
3026 PPARTENTRY PartEntry
)
3028 WCHAR PathBuffer
[MAX_PATH
];
3030 /* Create 'InstallPath' string */
3031 RtlFreeUnicodeString(&InstallPath
);
3032 RtlCreateUnicodeString(&InstallPath
,
3035 /* Create 'DestinationRootPath' string */
3036 RtlFreeUnicodeString(&DestinationRootPath
);
3037 swprintf(PathBuffer
,
3038 L
"\\Device\\Harddisk%lu\\Partition%lu",
3039 DiskEntry
->DiskNumber
,
3040 PartEntry
->PartitionNumber
);
3041 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
3042 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
3044 /* Create 'DestinationPath' string */
3045 RtlFreeUnicodeString(&DestinationPath
);
3046 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3048 if (InstallDir
[0] != L
'\\')
3049 wcscat(PathBuffer
, L
"\\");
3051 wcscat(PathBuffer
, InstallDir
);
3052 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
3054 /* Create 'DestinationArcPath' */
3055 RtlFreeUnicodeString(&DestinationArcPath
);
3056 swprintf(PathBuffer
,
3057 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
3058 DiskEntry
->BiosDiskNumber
,
3059 PartEntry
->PartitionNumber
);
3061 if (InstallDir
[0] != L
'\\')
3062 wcscat(PathBuffer
, L
"\\");
3064 wcscat(PathBuffer
, InstallDir
);
3065 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3067 return PREPARE_COPY_PAGE
;
3072 InstallDirectoryPage(PINPUT_RECORD Ir
)
3074 PDISKENTRY DiskEntry
;
3075 PPARTENTRY PartEntry
;
3076 WCHAR InstallDir
[51];
3079 /* We do not need the filsystem list any more */
3080 DestroyFileSystemList(FileSystemList
);
3081 FileSystemList
= NULL
;
3083 if (PartitionList
== NULL
||
3084 PartitionList
->CurrentDisk
== NULL
||
3085 PartitionList
->CurrentPartition
== NULL
)
3087 /* FIXME: show an error dialog */
3091 DiskEntry
= PartitionList
->CurrentDisk
;
3092 PartEntry
= PartitionList
->CurrentPartition
;
3094 if (IsUnattendedSetup
)
3095 wcscpy(InstallDir
, UnattendInstallationDirectory
);
3097 wcscpy(InstallDir
, L
"\\ReactOS");
3099 Length
= wcslen(InstallDir
);
3100 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3101 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3103 // FIXME: Check the validity of the InstallDir; however what to do
3104 // if it is invalid but we are in unattended setup? (case of somebody
3105 // specified an invalid installation directory in the unattended file).
3107 if (IsUnattendedSetup
)
3109 return InstallDirectoryPage1(InstallDir
,
3116 CONSOLE_ConInKey(Ir
);
3118 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3119 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3121 if (ConfirmQuit(Ir
) == TRUE
)
3126 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3129 * Check for the validity of the installation directory and pop up
3130 * an error if it is not the case. Then the user can fix its input.
3132 if (!IsValidPath(InstallDir
, Length
))
3134 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3135 return INSTALL_DIRECTORY_PAGE
;
3137 return InstallDirectoryPage1(InstallDir
,
3141 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3146 InstallDir
[Length
] = 0;
3147 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3150 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3154 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3156 InstallDir
[Length
] = 0;
3157 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3162 return INSTALL_DIRECTORY_PAGE
;
3167 AddSectionToCopyQueueCab(HINF InfFile
,
3169 PWCHAR SourceCabinet
,
3170 PCUNICODE_STRING DestinationPath
,
3173 INFCONTEXT FilesContext
;
3174 INFCONTEXT DirContext
;
3176 PWCHAR FileKeyValue
;
3178 PWCHAR TargetFileName
;
3180 /* Search for the SectionName section */
3181 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3184 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3185 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3190 * Enumerate the files in the section
3191 * and add them to the file queue.
3195 /* Get source file name and target directory id */
3196 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3198 /* FIXME: Handle error! */
3199 DPRINT1("INF_GetData() failed\n");
3203 /* Get optional target file name */
3204 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3205 TargetFileName
= NULL
;
3207 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3209 /* Lookup target directory */
3210 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3212 /* FIXME: Handle error! */
3213 DPRINT1("SetupFindFirstLine() failed\n");
3217 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3219 /* FIXME: Handle error! */
3220 DPRINT1("INF_GetData() failed\n");
3224 if (!SetupQueueCopy(SetupFileQueue
,
3226 SourceRootPath
.Buffer
,
3227 SourceRootDir
.Buffer
,
3232 /* FIXME: Handle error! */
3233 DPRINT1("SetupQueueCopy() failed\n");
3235 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3242 AddSectionToCopyQueue(HINF InfFile
,
3244 PWCHAR SourceCabinet
,
3245 PCUNICODE_STRING DestinationPath
,
3248 INFCONTEXT FilesContext
;
3249 INFCONTEXT DirContext
;
3251 PWCHAR FileKeyValue
;
3253 PWCHAR TargetFileName
;
3255 WCHAR CompleteOrigDirName
[512];
3258 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3260 /* Search for the SectionName section */
3261 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3264 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3265 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3270 * Enumerate the files in the section
3271 * and add them to the file queue.
3275 /* Get source file name and target directory id */
3276 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3278 /* FIXME: Handle error! */
3279 DPRINT1("INF_GetData() failed\n");
3283 /* Get target directory id */
3284 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3286 /* FIXME: Handle error! */
3287 DPRINT1("INF_GetData() failed\n");
3291 /* Get optional target file name */
3292 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3293 TargetFileName
= NULL
;
3294 else if (!*TargetFileName
)
3295 TargetFileName
= NULL
;
3297 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3299 /* Lookup target directory */
3300 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3302 /* FIXME: Handle error! */
3303 DPRINT1("SetupFindFirstLine() failed\n");
3307 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3309 /* FIXME: Handle error! */
3310 DPRINT1("INF_GetData() failed\n");
3314 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3316 /* Installation path */
3317 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3319 else if (DirKeyValue
[0] == L
'\\')
3322 wcscpy(CompleteOrigDirName
, DirKeyValue
);
3324 else // if (DirKeyValue[0] != L'\\')
3326 /* Path relative to the installation path */
3327 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3328 wcscat(CompleteOrigDirName
, L
"\\");
3329 wcscat(CompleteOrigDirName
, DirKeyValue
);
3332 /* Remove trailing backslash */
3333 Length
= wcslen(CompleteOrigDirName
);
3334 if ((Length
> 0) && (CompleteOrigDirName
[Length
- 1] == L
'\\'))
3336 CompleteOrigDirName
[Length
- 1] = 0;
3339 if (!SetupQueueCopy(SetupFileQueue
,
3341 SourceRootPath
.Buffer
,
3342 CompleteOrigDirName
,
3347 /* FIXME: Handle error! */
3348 DPRINT1("SetupQueueCopy() failed\n");
3350 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3357 PrepareCopyPageInfFile(HINF InfFile
,
3358 PWCHAR SourceCabinet
,
3361 WCHAR PathBuffer
[MAX_PATH
];
3362 INFCONTEXT DirContext
;
3363 PWCHAR AdditionalSectionName
= NULL
;
3368 /* Add common files */
3369 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3372 /* Add specific files depending of computer type */
3373 if (SourceCabinet
== NULL
)
3375 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3378 if (AdditionalSectionName
)
3380 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3385 /* Create directories */
3389 * - Install directories like '\reactos\test' are not handled yet.
3390 * - Copying files to DestinationRootPath should be done from within
3391 * the SystemPartitionFiles section.
3392 * At the moment we check whether we specify paths like '\foo' or '\\' for that.
3393 * For installing to DestinationPath specify just '\' .
3396 /* Get destination path */
3397 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3399 /* Remove trailing backslash */
3400 Length
= wcslen(PathBuffer
);
3401 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3403 PathBuffer
[Length
- 1] = 0;
3406 /* Create the install directory */
3407 Status
= SetupCreateDirectory(PathBuffer
);
3408 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3410 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3411 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3415 /* Search for the 'Directories' section */
3416 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3420 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3424 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3430 /* Enumerate the directory values and create the subdirectories */
3433 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3439 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3441 /* Installation path */
3442 DPRINT("InstallationPath: '%S'\n", DirKeyValue
);
3444 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3446 DPRINT("FullPath: '%S'\n", PathBuffer
);
3448 else if (DirKeyValue
[0] == L
'\\')
3451 DPRINT("Absolute Path: '%S'\n", DirKeyValue
);
3453 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3454 wcscat(PathBuffer
, DirKeyValue
);
3456 /* Remove trailing backslash */
3457 Length
= wcslen(PathBuffer
);
3458 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3460 PathBuffer
[Length
- 1] = 0;
3463 DPRINT("FullPath: '%S'\n", PathBuffer
);
3465 Status
= SetupCreateDirectory(PathBuffer
);
3466 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3468 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3469 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3473 else // if (DirKeyValue[0] != L'\\')
3475 /* Path relative to the installation path */
3476 DPRINT("RelativePath: '%S'\n", DirKeyValue
);
3478 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3479 wcscat(PathBuffer
, L
"\\");
3480 wcscat(PathBuffer
, DirKeyValue
);
3482 /* Remove trailing backslash */
3483 Length
= wcslen(PathBuffer
);
3484 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3486 PathBuffer
[Length
- 1] = 0;
3489 DPRINT("FullPath: '%S'\n", PathBuffer
);
3491 Status
= SetupCreateDirectory(PathBuffer
);
3492 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3494 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3495 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3499 } while (SetupFindNextLine(&DirContext
, &DirContext
));
3506 PrepareCopyPage(PINPUT_RECORD Ir
)
3509 WCHAR PathBuffer
[MAX_PATH
];
3510 INFCONTEXT CabinetsContext
;
3516 MUIDisplayPage(PREPARE_COPY_PAGE
);
3518 /* Create the file queue */
3519 SetupFileQueue
= SetupOpenFileQueue();
3520 if (SetupFileQueue
== NULL
)
3522 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3526 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3531 /* Search for the 'Cabinets' section */
3532 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3534 return FILE_COPY_PAGE
;
3538 * Enumerate the directory values in the 'Cabinets'
3539 * section and parse their inf files.
3543 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3546 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3547 wcscat(PathBuffer
, L
"\\");
3548 wcscat(PathBuffer
, KeyValue
);
3551 CabinetInitialize();
3552 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3553 CabinetSetCabinetName(PathBuffer
);
3555 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3557 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3559 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3560 if (InfFileData
== NULL
)
3562 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3568 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3569 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3573 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3580 if (InfHandle
== INVALID_HANDLE_VALUE
)
3582 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3588 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3593 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3595 return FILE_COPY_PAGE
;
3601 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3604 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3606 /* Get the memory information from the system */
3607 NtQuerySystemInformation(SystemPerformanceInformation
,
3612 /* Check if this is initial setup */
3615 /* Set maximum limits to be total RAM pages */
3616 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3617 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3618 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3621 /* Set current values */
3622 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3623 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3624 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3630 FileCopyCallback(PVOID Context
,
3635 PCOPYCONTEXT CopyContext
;
3637 CopyContext
= (PCOPYCONTEXT
)Context
;
3639 switch (Notification
)
3641 case SPFILENOTIFY_STARTSUBQUEUE
:
3642 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3643 ProgressSetStepCount(CopyContext
->ProgressBar
,
3644 CopyContext
->TotalOperations
);
3645 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3648 case SPFILENOTIFY_STARTCOPY
:
3649 /* Display copy message */
3650 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3651 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3654 case SPFILENOTIFY_ENDCOPY
:
3655 CopyContext
->CompletedOperations
++;
3657 /* SYSREG checkpoint */
3658 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3659 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3661 ProgressNextStep(CopyContext
->ProgressBar
);
3662 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3672 FileCopyPage(PINPUT_RECORD Ir
)
3674 COPYCONTEXT CopyContext
;
3675 unsigned int mem_bar_width
;
3677 MUIDisplayPage(FILE_COPY_PAGE
);
3679 /* Create context for the copy process */
3680 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3681 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3682 CopyContext
.TotalOperations
= 0;
3683 CopyContext
.CompletedOperations
= 0;
3685 /* Create the progress bar as well */
3686 CopyContext
.ProgressBar
= CreateProgressBar(13,
3693 MUIGetString(STRING_SETUPCOPYINGFILES
));
3695 // fit memory bars to screen width, distribute them uniform
3696 mem_bar_width
= (xScreen
- 26) / 5;
3697 mem_bar_width
-= mem_bar_width
% 2; // make even
3698 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3699 /* Create the paged pool progress bar */
3700 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3709 /* Create the non paged pool progress bar */
3710 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3712 (xScreen
/ 2) + (mem_bar_width
/ 2),
3714 (xScreen
/ 2)- (mem_bar_width
/ 2),
3719 /* Create the global memory progress bar */
3720 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3724 xScreen
- 13 - mem_bar_width
,
3729 /* Do the file copying */
3730 SetupCommitFileQueueW(NULL
,
3735 /* If we get here, we're done, so cleanup the queue and progress bar */
3736 SetupCloseFileQueue(SetupFileQueue
);
3737 DestroyProgressBar(CopyContext
.ProgressBar
);
3738 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3739 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3740 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3742 /* Go display the next page */
3743 return REGISTRY_PAGE
;
3748 RegistryPage(PINPUT_RECORD Ir
)
3750 INFCONTEXT InfContext
;
3757 MUIDisplayPage(REGISTRY_PAGE
);
3759 if (RepairUpdateFlag
)
3761 return SUCCESS_PAGE
;
3764 if (!SetInstallPathValue(&DestinationPath
))
3766 DPRINT1("SetInstallPathValue() failed\n");
3767 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3771 /* Create the default hives */
3773 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3774 if (!NT_SUCCESS(Status
))
3776 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3777 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3781 RegInitializeRegistry();
3784 /* Update registry */
3785 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3787 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3789 DPRINT1("SetupFindFirstLine() failed\n");
3790 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3796 INF_GetDataField (&InfContext
, 0, &Action
);
3797 INF_GetDataField (&InfContext
, 1, &File
);
3798 INF_GetDataField (&InfContext
, 2, &Section
);
3800 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3805 if (!_wcsicmp (Action
, L
"AddReg"))
3809 else if (!_wcsicmp (Action
, L
"DelReg"))
3818 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3820 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3822 DPRINT1("Importing %S failed\n", File
);
3824 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3827 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3829 /* Update display registry settings */
3830 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3831 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3833 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3837 /* Set the locale */
3838 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3839 if (!ProcessLocaleRegistry(LanguageList
))
3841 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3845 /* Add keyboard layouts */
3846 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3847 if (!AddKeyboardLayouts())
3849 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3855 if (!SetGeoID(MUIGetGeoID()))
3857 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3861 if (!IsUnattendedSetup
)
3863 /* Update keyboard layout settings */
3864 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3865 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3867 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3872 /* Add codepage information to registry */
3873 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3876 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3880 /* Set the default pagefile entry */
3881 SetDefaultPagefile(DestinationDriveLetter
);
3883 /* Update the mounted devices list */
3884 SetMountedDeviceValues(PartitionList
);
3886 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3888 return BOOT_LOADER_PAGE
;
3893 BootLoaderPage(PINPUT_RECORD Ir
)
3895 UCHAR PartitionType
;
3896 BOOLEAN InstallOnFloppy
;
3898 WCHAR PathBuffer
[MAX_PATH
];
3900 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3902 RtlFreeUnicodeString(&SystemRootPath
);
3903 swprintf(PathBuffer
,
3904 L
"\\Device\\Harddisk%lu\\Partition%lu",
3905 PartitionList
->BootDisk
->DiskNumber
,
3906 PartitionList
->BootPartition
->PartitionNumber
);
3907 RtlCreateUnicodeString(&SystemRootPath
,
3909 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3911 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
3913 if (IsUnattendedSetup
)
3915 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3917 return SUCCESS_PAGE
;
3919 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3921 return BOOT_LOADER_FLOPPY_PAGE
;
3925 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3927 DPRINT("Error: active partition invalid (unused)\n");
3928 InstallOnFloppy
= TRUE
;
3930 else if (PartitionType
== 0x0A)
3932 /* OS/2 boot manager partition */
3933 DPRINT("Found OS/2 boot manager partition\n");
3934 InstallOnFloppy
= TRUE
;
3936 else if (PartitionType
== 0x83)
3938 /* Linux ext2 partition */
3939 DPRINT("Found Linux ext2 partition\n");
3940 InstallOnFloppy
= TRUE
;
3942 else if (PartitionType
== PARTITION_IFS
)
3944 /* NTFS partition */
3945 DPRINT("Found NTFS partition\n");
3946 InstallOnFloppy
= TRUE
;
3948 else if ((PartitionType
== PARTITION_FAT_12
) ||
3949 (PartitionType
== PARTITION_FAT_16
) ||
3950 (PartitionType
== PARTITION_HUGE
) ||
3951 (PartitionType
== PARTITION_XINT13
) ||
3952 (PartitionType
== PARTITION_FAT32
) ||
3953 (PartitionType
== PARTITION_FAT32_XINT13
))
3955 DPRINT("Found FAT partition\n");
3956 InstallOnFloppy
= FALSE
;
3960 /* Unknown partition */
3961 DPRINT("Unknown partition found\n");
3962 InstallOnFloppy
= TRUE
;
3965 if (InstallOnFloppy
== TRUE
)
3967 return BOOT_LOADER_FLOPPY_PAGE
;
3970 /* Unattended install on hdd? */
3971 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3973 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3976 MUIDisplayPage(BOOT_LOADER_PAGE
);
3977 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3981 CONSOLE_ConInKey(Ir
);
3983 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3984 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3986 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3995 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3997 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3998 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
4000 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4009 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4011 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4012 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4014 if (ConfirmQuit(Ir
) == TRUE
)
4019 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4023 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4025 else if (Line
== 13)
4027 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4029 else if (Line
== 14)
4031 return BOOT_LOADER_FLOPPY_PAGE
;
4033 else if (Line
== 15)
4035 return SUCCESS_PAGE
;
4038 return BOOT_LOADER_PAGE
;
4042 return BOOT_LOADER_PAGE
;
4047 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4051 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4053 // SetStatusText(" Please wait...");
4057 CONSOLE_ConInKey(Ir
);
4059 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4060 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4062 if (ConfirmQuit(Ir
) == TRUE
)
4067 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4069 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
4071 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4072 return BOOT_LOADER_FLOPPY_PAGE
;
4075 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
4076 if (!NT_SUCCESS(Status
))
4078 /* Print error message */
4079 return BOOT_LOADER_FLOPPY_PAGE
;
4082 return SUCCESS_PAGE
;
4086 return BOOT_LOADER_FLOPPY_PAGE
;
4091 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4093 UCHAR PartitionType
;
4096 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
4098 Status
= InstallVBRToPartition(&SystemRootPath
,
4100 &DestinationArcPath
,
4102 if (!NT_SUCCESS(Status
))
4104 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4108 return SUCCESS_PAGE
;
4113 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4115 UCHAR PartitionType
;
4117 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4118 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
4120 /* Step 1: Write the VBR */
4121 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
4123 Status
= InstallVBRToPartition(&SystemRootPath
,
4125 &DestinationArcPath
,
4127 if (!NT_SUCCESS(Status
))
4129 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4133 /* Step 2: Write the MBR */
4134 swprintf(DestinationDevicePathBuffer
,
4135 L
"\\Device\\Harddisk%d\\Partition0",
4136 PartitionList
->BootDisk
->DiskNumber
);
4138 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4139 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4141 DPRINT("Install MBR bootcode: %S ==> %S\n",
4142 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4144 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4145 DestinationDevicePathBuffer
);
4146 if (!NT_SUCCESS (Status
))
4148 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4150 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4154 return SUCCESS_PAGE
;
4159 QuitPage(PINPUT_RECORD Ir
)
4161 MUIDisplayPage(QUIT_PAGE
);
4163 /* Destroy partition list */
4164 if (PartitionList
!= NULL
)
4166 DestroyPartitionList (PartitionList
);
4167 PartitionList
= NULL
;
4170 /* Destroy filesystem list */
4171 if (FileSystemList
!= NULL
)
4173 DestroyFileSystemList (FileSystemList
);
4174 FileSystemList
= NULL
;
4177 /* Destroy computer settings list */
4178 if (ComputerList
!= NULL
)
4180 DestroyGenericList(ComputerList
, TRUE
);
4181 ComputerList
= NULL
;
4184 /* Destroy display settings list */
4185 if (DisplayList
!= NULL
)
4187 DestroyGenericList(DisplayList
, TRUE
);
4191 /* Destroy keyboard settings list */
4192 if (KeyboardList
!= NULL
)
4194 DestroyGenericList(KeyboardList
, TRUE
);
4195 KeyboardList
= NULL
;
4198 /* Destroy keyboard layout list */
4199 if (LayoutList
!= NULL
)
4201 DestroyGenericList(LayoutList
, TRUE
);
4205 if (LanguageList
!= NULL
)
4207 DestroyGenericList(LanguageList
, FALSE
);
4208 LanguageList
= NULL
;
4211 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4215 CONSOLE_ConInKey(Ir
);
4217 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4226 SuccessPage(PINPUT_RECORD Ir
)
4228 MUIDisplayPage(SUCCESS_PAGE
);
4230 if (IsUnattendedSetup
)
4237 CONSOLE_ConInKey(Ir
);
4239 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4248 FlushPage(PINPUT_RECORD Ir
)
4250 MUIDisplayPage(FLUSH_PAGE
);
4256 PnpEventThread(IN LPVOID lpParameter
);
4267 NtQuerySystemTime(&Time
);
4269 Status
= RtlCreateUserThread(NtCurrentProcess(),
4279 if (!NT_SUCCESS(Status
))
4280 hPnpThread
= INVALID_HANDLE_VALUE
;
4282 if (!CONSOLE_Init())
4284 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4285 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4286 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4288 /* Raise a hard error (crash the system/BSOD) */
4289 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4293 /* Initialize global unicode strings */
4294 RtlInitUnicodeString(&SourcePath
, NULL
);
4295 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4296 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4297 RtlInitUnicodeString(&InstallPath
, NULL
);
4298 RtlInitUnicodeString(&DestinationPath
, NULL
);
4299 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4300 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4301 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4303 /* Hide the cursor */
4304 CONSOLE_SetCursorType(TRUE
, FALSE
);
4307 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4309 CONSOLE_ClearScreen();
4312 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4319 Page
= SetupStartPage(&Ir
);
4324 Page
= LanguagePage(&Ir
);
4329 Page
= LicensePage(&Ir
);
4334 Page
= IntroPage(&Ir
);
4338 case INSTALL_INTRO_PAGE
:
4339 Page
= InstallIntroPage(&Ir
);
4343 case SCSI_CONTROLLER_PAGE
:
4344 Page
= ScsiControllerPage(&Ir
);
4349 case OEM_DRIVER_PAGE
:
4350 Page
= OemDriverPage(&Ir
);
4354 case DEVICE_SETTINGS_PAGE
:
4355 Page
= DeviceSettingsPage(&Ir
);
4358 case COMPUTER_SETTINGS_PAGE
:
4359 Page
= ComputerSettingsPage(&Ir
);
4362 case DISPLAY_SETTINGS_PAGE
:
4363 Page
= DisplaySettingsPage(&Ir
);
4366 case KEYBOARD_SETTINGS_PAGE
:
4367 Page
= KeyboardSettingsPage(&Ir
);
4370 case LAYOUT_SETTINGS_PAGE
:
4371 Page
= LayoutSettingsPage(&Ir
);
4374 case SELECT_PARTITION_PAGE
:
4375 Page
= SelectPartitionPage(&Ir
);
4378 case CREATE_PRIMARY_PARTITION_PAGE
:
4379 Page
= CreatePrimaryPartitionPage(&Ir
);
4382 case CREATE_EXTENDED_PARTITION_PAGE
:
4383 Page
= CreateExtendedPartitionPage(&Ir
);
4386 case CREATE_LOGICAL_PARTITION_PAGE
:
4387 Page
= CreateLogicalPartitionPage(&Ir
);
4390 case DELETE_PARTITION_PAGE
:
4391 Page
= DeletePartitionPage(&Ir
);
4394 case SELECT_FILE_SYSTEM_PAGE
:
4395 Page
= SelectFileSystemPage(&Ir
);
4398 case FORMAT_PARTITION_PAGE
:
4399 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4402 case CHECK_FILE_SYSTEM_PAGE
:
4403 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4406 case INSTALL_DIRECTORY_PAGE
:
4407 Page
= InstallDirectoryPage(&Ir
);
4410 case PREPARE_COPY_PAGE
:
4411 Page
= PrepareCopyPage(&Ir
);
4414 case FILE_COPY_PAGE
:
4415 Page
= FileCopyPage(&Ir
);
4419 Page
= RegistryPage(&Ir
);
4422 case BOOT_LOADER_PAGE
:
4423 Page
= BootLoaderPage(&Ir
);
4426 case BOOT_LOADER_FLOPPY_PAGE
:
4427 Page
= BootLoaderFloppyPage(&Ir
);
4430 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4431 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4434 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4435 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4439 case REPAIR_INTRO_PAGE
:
4440 Page
= RepairIntroPage(&Ir
);
4444 Page
= SuccessPage(&Ir
);
4448 Page
= FlushPage(&Ir
);
4452 Page
= QuitPage(&Ir
);
4461 if (Page
== RECOVERY_PAGE
)
4466 /* Avoid bugcheck */
4467 Time
.QuadPart
+= 50000000;
4468 NtDelayExecution(FALSE
, &Time
);
4471 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4472 NtShutdownSystem(ShutdownReboot
);
4473 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4474 NtTerminateProcess(NtCurrentProcess(), 0);
4481 NtProcessStartup(PPEB Peb
)
4483 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4485 ProcessHeap
= Peb
->ProcessHeap
;
4486 InfSetHeap(ProcessHeap
);
4489 #endif /* __REACTOS__ */