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 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1482 CreateLogicalPartition(PartitionList
,
1483 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1488 CreatePrimaryPartition(PartitionList
,
1489 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1493 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1495 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1496 RequiredPartitionDiskSpace
);
1497 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1500 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1502 return SELECT_FILE_SYSTEM_PAGE
;
1507 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1509 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1510 RequiredPartitionDiskSpace
);
1511 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1514 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1516 return SELECT_FILE_SYSTEM_PAGE
;
1522 /* Update status text */
1523 if (PartitionList
->CurrentPartition
== NULL
)
1525 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1527 else if (PartitionList
->CurrentPartition
->LogicalPartition
)
1529 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1531 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1535 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL
));
1540 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1542 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1544 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1548 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1553 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1557 CONSOLE_ConInKey(Ir
);
1559 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1560 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1562 if (ConfirmQuit(Ir
) == TRUE
)
1564 DestroyPartitionList(PartitionList
);
1565 PartitionList
= NULL
;
1571 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1572 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1574 if (ScrollDownPartitionList(PartitionList
))
1575 DrawPartitionList(PartitionList
);
1577 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1578 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1580 if (ScrollUpPartitionList(PartitionList
))
1581 DrawPartitionList(PartitionList
);
1583 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1585 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1586 continue; //return SELECT_PARTITION_PAGE;
1588 if (PartitionList
->CurrentPartition
== NULL
||
1589 PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1591 if (PartitionList
->CurrentPartition
->LogicalPartition
)
1593 CreateLogicalPartition(PartitionList
,
1599 CreatePrimaryPartition(PartitionList
,
1605 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1607 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1608 RequiredPartitionDiskSpace
);
1609 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1612 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1614 return SELECT_FILE_SYSTEM_PAGE
;
1616 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'P') /* P */
1618 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1620 Error
= PrimaryPartitionCreationChecks(PartitionList
);
1621 if (Error
!= NOT_AN_ERROR
)
1623 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1624 return SELECT_PARTITION_PAGE
;
1627 return CREATE_PRIMARY_PARTITION_PAGE
;
1630 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'E') /* E */
1632 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1634 Error
= ExtendedPartitionCreationChecks(PartitionList
);
1635 if (Error
!= NOT_AN_ERROR
)
1637 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1638 return SELECT_PARTITION_PAGE
;
1641 return CREATE_EXTENDED_PARTITION_PAGE
;
1644 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'L') /* L */
1646 if (PartitionList
->CurrentPartition
->LogicalPartition
== TRUE
)
1648 Error
= LogicalPartitionCreationChecks(PartitionList
);
1649 if (Error
!= NOT_AN_ERROR
)
1651 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1652 return SELECT_PARTITION_PAGE
;
1655 return CREATE_LOGICAL_PARTITION_PAGE
;
1658 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1660 if (PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1662 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1663 return SELECT_PARTITION_PAGE
;
1666 return DELETE_PARTITION_PAGE
;
1670 return SELECT_PARTITION_PAGE
;
1674 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1675 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1676 #define PARTITION_MAXSIZE 999999
1679 ShowPartitionSizeInputBox(SHORT Left
,
1692 WCHAR PartitionSizeBuffer
[100];
1704 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1709 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1710 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1713 WriteConsoleOutputCharacterA(StdOutput
,
1719 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1720 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1722 WriteConsoleOutputCharacterA(StdOutput
,
1728 swprintf(PartitionSizeBuffer
, L
"%lu", MaxSize
);
1729 Index
= wcslen(PartitionSizeBuffer
);
1730 CONSOLE_SetInputTextXY(iLeft
,
1732 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1733 PartitionSizeBuffer
);
1737 CONSOLE_ConInKey(&Ir
);
1739 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1740 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1745 PartitionSizeBuffer
[0] = 0;
1748 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1752 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1757 PartitionSizeBuffer
[0] = 0;
1760 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1764 PartitionSizeBuffer
[Index
] = 0;
1766 CONSOLE_SetInputTextXY(iLeft
,
1768 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1769 PartitionSizeBuffer
);
1771 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1772 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1774 ch
= (WCHAR
)Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1776 if ((ch
>= L
'0') && (ch
<= L
'9'))
1778 PartitionSizeBuffer
[Index
] = ch
;
1780 PartitionSizeBuffer
[Index
] = 0;
1782 CONSOLE_SetInputTextXY(iLeft
,
1784 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1785 PartitionSizeBuffer
);
1790 /* Convert UNICODE --> ANSI the poor man's way */
1791 sprintf(InputBuffer
, "%S", PartitionSizeBuffer
);
1796 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1798 PDISKENTRY DiskEntry
;
1799 PPARTENTRY PartEntry
;
1802 CHAR InputBuffer
[50];
1806 ULONGLONG SectorCount
;
1809 if (PartitionList
== NULL
||
1810 PartitionList
->CurrentDisk
== NULL
||
1811 PartitionList
->CurrentPartition
== NULL
)
1813 /* FIXME: show an error dialog */
1817 DiskEntry
= PartitionList
->CurrentDisk
;
1818 PartEntry
= PartitionList
->CurrentPartition
;
1820 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1822 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1824 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1826 if (DiskSize
>= 10737418240) /* 10 GB */
1828 DiskSize
= DiskSize
/ 1073741824;
1829 Unit
= MUIGetString(STRING_GB
);
1834 DiskSize
= DiskSize
/ 1048576;
1838 Unit
= MUIGetString(STRING_MB
);
1841 if (DiskEntry
->DriverName
.Length
> 0)
1843 CONSOLE_PrintTextXY(6, 10,
1844 MUIGetString(STRING_HDINFOPARTCREATE
),
1847 DiskEntry
->DiskNumber
,
1851 &DiskEntry
->DriverName
);
1855 CONSOLE_PrintTextXY(6, 10,
1856 MUIGetString(STRING_HDDINFOUNK1
),
1859 DiskEntry
->DiskNumber
,
1865 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1868 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1869 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
1872 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1874 PartEntry
= PartitionList
->CurrentPartition
;
1877 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
1879 if (MaxSize
> PARTITION_MAXSIZE
)
1880 MaxSize
= PARTITION_MAXSIZE
;
1882 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1883 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1887 if (ConfirmQuit (Ir
) == TRUE
)
1892 else if (Cancel
== TRUE
)
1894 return SELECT_PARTITION_PAGE
;
1898 PartSize
= atoi(InputBuffer
);
1906 if (PartSize
> MaxSize
)
1912 /* Convert to bytes */
1913 if (PartSize
== MaxSize
)
1915 /* Use all of the unpartitioned disk space */
1916 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1920 /* Calculate the sector count from the size in MB */
1921 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
1923 /* But never get larger than the unpartitioned disk space */
1924 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
1925 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1928 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1930 CreatePrimaryPartition(PartitionList
,
1934 return SELECT_PARTITION_PAGE
;
1938 return CREATE_PRIMARY_PARTITION_PAGE
;
1943 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
1945 PDISKENTRY DiskEntry
;
1946 PPARTENTRY PartEntry
;
1949 CHAR InputBuffer
[50];
1953 ULONGLONG SectorCount
;
1956 if (PartitionList
== NULL
||
1957 PartitionList
->CurrentDisk
== NULL
||
1958 PartitionList
->CurrentPartition
== NULL
)
1960 /* FIXME: show an error dialog */
1964 DiskEntry
= PartitionList
->CurrentDisk
;
1965 PartEntry
= PartitionList
->CurrentPartition
;
1967 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1969 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
1971 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1973 if (DiskSize
>= 10737418240) /* 10 GB */
1975 DiskSize
= DiskSize
/ 1073741824;
1976 Unit
= MUIGetString(STRING_GB
);
1981 DiskSize
= DiskSize
/ 1048576;
1985 Unit
= MUIGetString(STRING_MB
);
1988 if (DiskEntry
->DriverName
.Length
> 0)
1990 CONSOLE_PrintTextXY(6, 10,
1991 MUIGetString(STRING_HDINFOPARTCREATE
),
1994 DiskEntry
->DiskNumber
,
1998 &DiskEntry
->DriverName
);
2002 CONSOLE_PrintTextXY(6, 10,
2003 MUIGetString(STRING_HDDINFOUNK1
),
2006 DiskEntry
->DiskNumber
,
2012 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2015 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2016 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2019 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2021 PartEntry
= PartitionList
->CurrentPartition
;
2024 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2026 if (MaxSize
> PARTITION_MAXSIZE
)
2027 MaxSize
= PARTITION_MAXSIZE
;
2029 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2030 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2034 if (ConfirmQuit (Ir
) == TRUE
)
2039 else if (Cancel
== TRUE
)
2041 return SELECT_PARTITION_PAGE
;
2045 PartSize
= atoi(InputBuffer
);
2053 if (PartSize
> MaxSize
)
2059 /* Convert to bytes */
2060 if (PartSize
== MaxSize
)
2062 /* Use all of the unpartitioned disk space */
2063 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2067 /* Calculate the sector count from the size in MB */
2068 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2070 /* But never get larger than the unpartitioned disk space */
2071 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2072 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2075 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2077 CreateExtendedPartition(PartitionList
,
2080 return SELECT_PARTITION_PAGE
;
2084 return CREATE_EXTENDED_PARTITION_PAGE
;
2089 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2091 PDISKENTRY DiskEntry
;
2092 PPARTENTRY PartEntry
;
2095 CHAR InputBuffer
[50];
2099 ULONGLONG SectorCount
;
2102 if (PartitionList
== NULL
||
2103 PartitionList
->CurrentDisk
== NULL
||
2104 PartitionList
->CurrentPartition
== NULL
)
2106 /* FIXME: show an error dialog */
2110 DiskEntry
= PartitionList
->CurrentDisk
;
2111 PartEntry
= PartitionList
->CurrentPartition
;
2113 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2115 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2117 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2119 if (DiskSize
>= 10737418240) /* 10 GB */
2121 DiskSize
= DiskSize
/ 1073741824;
2122 Unit
= MUIGetString(STRING_GB
);
2127 DiskSize
= DiskSize
/ 1048576;
2131 Unit
= MUIGetString(STRING_MB
);
2134 if (DiskEntry
->DriverName
.Length
> 0)
2136 CONSOLE_PrintTextXY(6, 10,
2137 MUIGetString(STRING_HDINFOPARTCREATE
),
2140 DiskEntry
->DiskNumber
,
2144 &DiskEntry
->DriverName
);
2148 CONSOLE_PrintTextXY(6, 10,
2149 MUIGetString(STRING_HDDINFOUNK1
),
2152 DiskEntry
->DiskNumber
,
2158 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2161 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2162 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2165 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2167 PartEntry
= PartitionList
->CurrentPartition
;
2170 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2172 if (MaxSize
> PARTITION_MAXSIZE
)
2173 MaxSize
= PARTITION_MAXSIZE
;
2175 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2176 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2180 if (ConfirmQuit (Ir
) == TRUE
)
2185 else if (Cancel
== TRUE
)
2187 return SELECT_PARTITION_PAGE
;
2191 PartSize
= atoi(InputBuffer
);
2199 if (PartSize
> MaxSize
)
2205 /* Convert to bytes */
2206 if (PartSize
== MaxSize
)
2208 /* Use all of the unpartitioned disk space */
2209 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2213 /* Calculate the sector count from the size in MB */
2214 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2216 /* But never get larger than the unpartitioned disk space */
2217 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2218 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2221 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2223 CreateLogicalPartition(PartitionList
,
2227 return SELECT_PARTITION_PAGE
;
2231 return CREATE_LOGICAL_PARTITION_PAGE
;
2236 DeletePartitionPage(PINPUT_RECORD Ir
)
2238 PDISKENTRY DiskEntry
;
2239 PPARTENTRY PartEntry
;
2245 if (PartitionList
== NULL
||
2246 PartitionList
->CurrentDisk
== NULL
||
2247 PartitionList
->CurrentPartition
== NULL
)
2249 /* FIXME: show an error dialog */
2253 DiskEntry
= PartitionList
->CurrentDisk
;
2254 PartEntry
= PartitionList
->CurrentPartition
;
2256 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2258 /* Determine partition type */
2260 if (PartEntry
->New
== TRUE
)
2262 PartType
= MUIGetString(STRING_UNFORMATTED
);
2264 else if (PartEntry
->IsPartitioned
== TRUE
)
2266 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2267 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2268 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2269 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2273 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2274 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2278 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2282 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2284 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2286 else if (IsContainerPartition(PartEntry
->PartitionType
))
2288 PartType
= MUIGetString(STRING_EXTENDED_PARTITION
);
2292 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2294 if (PartSize
>= 10737418240) /* 10 GB */
2296 PartSize
= PartSize
/ 1073741824;
2297 Unit
= MUIGetString(STRING_GB
);
2301 if (PartSize
>= 10485760) /* 10 MB */
2303 PartSize
= PartSize
/ 1048576;
2304 Unit
= MUIGetString(STRING_MB
);
2308 PartSize
= PartSize
/ 1024;
2309 Unit
= MUIGetString(STRING_KB
);
2312 if (PartType
== NULL
)
2314 CONSOLE_PrintTextXY(6, 10,
2315 MUIGetString(STRING_HDDINFOUNK2
),
2316 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2317 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2318 PartEntry
->PartitionType
,
2324 CONSOLE_PrintTextXY(6, 10,
2325 " %c%c %s %I64u %s",
2326 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2327 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2333 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2335 if (DiskSize
>= 10737418240) /* 10 GB */
2337 DiskSize
= DiskSize
/ 1073741824;
2338 Unit
= MUIGetString(STRING_GB
);
2343 DiskSize
= DiskSize
/ 1048576;
2347 Unit
= MUIGetString(STRING_MB
);
2350 if (DiskEntry
->DriverName
.Length
> 0)
2352 CONSOLE_PrintTextXY(6, 12,
2353 MUIGetString(STRING_HDINFOPARTDELETE
),
2356 DiskEntry
->DiskNumber
,
2360 &DiskEntry
->DriverName
);
2364 CONSOLE_PrintTextXY(6, 12,
2365 MUIGetString(STRING_HDDINFOUNK3
),
2368 DiskEntry
->DiskNumber
,
2376 CONSOLE_ConInKey(Ir
);
2378 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2379 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2381 if (ConfirmQuit(Ir
) == TRUE
)
2388 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2390 return SELECT_PARTITION_PAGE
;
2392 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2394 DeleteCurrentPartition(PartitionList
);
2396 return SELECT_PARTITION_PAGE
;
2400 return DELETE_PARTITION_PAGE
;
2405 SelectFileSystemPage(PINPUT_RECORD Ir
)
2407 PDISKENTRY DiskEntry
;
2408 PPARTENTRY PartEntry
;
2415 DPRINT("SelectFileSystemPage()\n");
2417 if (PartitionList
== NULL
||
2418 PartitionList
->CurrentDisk
== NULL
||
2419 PartitionList
->CurrentPartition
== NULL
)
2421 /* FIXME: show an error dialog */
2425 /* Find or set the active partition */
2426 CheckActiveBootPartition(PartitionList
);
2428 if (PartitionList
->BootDisk
== NULL
||
2429 PartitionList
->BootPartition
== NULL
)
2431 /* FIXME: show an error dialog */
2435 switch (PartitionList
->FormatState
)
2438 if (PartitionList
->CurrentPartition
!= PartitionList
->BootPartition
)
2440 PartitionList
->TempDisk
= PartitionList
->BootDisk
;
2441 PartitionList
->TempPartition
= PartitionList
->BootPartition
;
2442 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2444 PartitionList
->FormatState
= FormatSystemPartition
;
2445 DPRINT1("FormatState: Start --> FormatSystemPartition\n");
2449 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2450 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2451 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2453 PartitionList
->FormatState
= FormatInstallPartition
;
2454 DPRINT1("FormatState: Start --> FormatInstallPartition\n");
2458 case FormatSystemPartition
:
2459 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2460 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2461 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2463 PartitionList
->FormatState
= FormatInstallPartition
;
2464 DPRINT1("FormatState: FormatSystemPartition --> FormatInstallPartition\n");
2467 case FormatInstallPartition
:
2468 if (GetNextUnformattedPartition(PartitionList
,
2469 &PartitionList
->TempDisk
,
2470 &PartitionList
->TempPartition
))
2472 PartitionList
->FormatState
= FormatOtherPartition
;
2473 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2474 DPRINT1("FormatState: FormatInstallPartition --> FormatOtherPartition\n");
2478 PartitionList
->FormatState
= FormatDone
;
2479 DPRINT1("FormatState: FormatInstallPartition --> FormatDone\n");
2480 return CHECK_FILE_SYSTEM_PAGE
;
2484 case FormatOtherPartition
:
2485 if (GetNextUnformattedPartition(PartitionList
,
2486 &PartitionList
->TempDisk
,
2487 &PartitionList
->TempPartition
))
2489 PartitionList
->FormatState
= FormatOtherPartition
;
2490 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2491 DPRINT1("FormatState: FormatOtherPartition --> FormatOtherPartition\n");
2495 PartitionList
->FormatState
= FormatDone
;
2496 DPRINT1("FormatState: FormatOtherPartition --> FormatDone\n");
2497 return CHECK_FILE_SYSTEM_PAGE
;
2502 DPRINT1("FormatState: Invalid value %ld\n", PartitionList
->FormatState
);
2503 /* FIXME: show an error dialog */
2507 DiskEntry
= PartitionList
->TempDisk
;
2508 PartEntry
= PartitionList
->TempPartition
;
2510 /* adjust disk size */
2511 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2512 if (DiskSize
>= 10737418240) /* 10 GB */
2514 DiskSize
= DiskSize
/ 1073741824;
2515 DiskUnit
= MUIGetString(STRING_GB
);
2519 DiskSize
= DiskSize
/ 1048576;
2520 DiskUnit
= MUIGetString(STRING_MB
);
2523 /* adjust partition size */
2524 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2525 if (PartSize
>= 10737418240) /* 10 GB */
2527 PartSize
= PartSize
/ 1073741824;
2528 PartUnit
= MUIGetString(STRING_GB
);
2532 PartSize
= PartSize
/ 1048576;
2533 PartUnit
= MUIGetString(STRING_MB
);
2536 /* adjust partition type */
2537 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2538 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2539 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2540 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2544 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2545 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2549 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2553 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2555 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2557 else if (PartEntry
->PartitionType
== PARTITION_ENTRY_UNUSED
)
2559 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2563 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2566 if (PartEntry
->AutoCreate
== TRUE
)
2568 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2571 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2572 PartEntry
->PartitionNumber
,
2578 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2579 DiskEntry
->DiskNumber
,
2585 &DiskEntry
->DriverName
);
2587 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2590 PartEntry
->AutoCreate
= FALSE
;
2592 else if (PartEntry
->New
== TRUE
)
2594 switch (PartitionList
->FormatState
)
2596 case FormatSystemPartition
:
2597 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2600 case FormatInstallPartition
:
2601 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2604 case FormatOtherPartition
:
2605 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2612 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2616 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2618 if (PartType
== NULL
)
2620 CONSOLE_PrintTextXY(8, 10,
2621 MUIGetString(STRING_HDDINFOUNK4
),
2622 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2623 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2624 PartEntry
->PartitionType
,
2630 CONSOLE_PrintTextXY(8, 10,
2632 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2633 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2639 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2640 DiskEntry
->DiskNumber
,
2646 &DiskEntry
->DriverName
);
2649 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2651 if (FileSystemList
== NULL
)
2653 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2654 if (FileSystemList
== NULL
)
2656 /* FIXME: show an error dialog */
2660 /* FIXME: Add file systems to list */
2663 DrawFileSystemList(FileSystemList
);
2665 if (RepairUpdateFlag
)
2667 return CHECK_FILE_SYSTEM_PAGE
;
2668 //return SELECT_PARTITION_PAGE;
2671 if (IsUnattendedSetup
)
2673 if (UnattendFormatPartition
)
2675 PartEntry
->FileSystem
= GetFileSystemByName(FileSystemList
,
2677 return FORMAT_PARTITION_PAGE
;
2680 return CHECK_FILE_SYSTEM_PAGE
;
2685 CONSOLE_ConInKey(Ir
);
2687 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2688 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2690 if (ConfirmQuit(Ir
) == TRUE
)
2697 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2698 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2700 return SELECT_PARTITION_PAGE
;
2702 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2703 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2705 ScrollDownFileSystemList(FileSystemList
);
2707 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2708 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2710 ScrollUpFileSystemList(FileSystemList
);
2712 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2714 if (!FileSystemList
->Selected
->FormatFunc
)
2716 return SELECT_FILE_SYSTEM_PAGE
;
2720 PartEntry
->FileSystem
= FileSystemList
->Selected
;
2721 return FORMAT_PARTITION_PAGE
;
2726 return SELECT_FILE_SYSTEM_PAGE
;
2731 FormatPartitionPage(PINPUT_RECORD Ir
)
2733 UNICODE_STRING PartitionRootPath
;
2734 WCHAR PathBuffer
[MAX_PATH
];
2735 PDISKENTRY DiskEntry
;
2736 PPARTENTRY PartEntry
;
2745 DPRINT("FormatPartitionPage()\n");
2747 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2749 if (PartitionList
== NULL
||
2750 PartitionList
->TempDisk
== NULL
||
2751 PartitionList
->TempPartition
== NULL
)
2753 /* FIXME: show an error dialog */
2757 DiskEntry
= PartitionList
->TempDisk
;
2758 PartEntry
= PartitionList
->TempPartition
;
2762 if (!IsUnattendedSetup
)
2764 CONSOLE_ConInKey(Ir
);
2767 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2768 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2770 if (ConfirmQuit(Ir
) == TRUE
)
2777 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2779 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2781 if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"FAT") == 0)
2783 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2785 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2786 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2788 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2790 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2792 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2794 /* FAT16 CHS partition (partiton size < 32MB) */
2795 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2797 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2799 /* FAT16 CHS partition (partition size < 512MB) */
2800 PartEntry
->PartitionType
= PARTITION_HUGE
;
2804 /* FAT32 CHS partition (partition size >= 512MB) */
2805 PartEntry
->PartitionType
= PARTITION_FAT32
;
2810 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2812 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2814 /* FAT16 LBA partition (partition size < 512MB) */
2815 PartEntry
->PartitionType
= PARTITION_XINT13
;
2819 /* FAT32 LBA partition (partition size >= 512MB) */
2820 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2824 DiskEntry
->Dirty
= TRUE
;
2825 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2826 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2829 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"EXT2") == 0)
2831 PartEntry
->PartitionType
= PARTITION_EXT2
;
2833 DiskEntry
->Dirty
= TRUE
;
2834 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2835 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2838 else if (!PartEntry
->FileSystem
->FormatFunc
)
2844 CONSOLE_PrintTextXY(6, 12,
2845 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2846 DiskEntry
->DiskSize
,
2847 DiskEntry
->CylinderSize
,
2848 DiskEntry
->TrackSize
);
2851 DiskEntry
= PartitionList
->TempDisk
;
2852 Entry
= DiskEntry
->PartListHead
.Flink
;
2854 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2856 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2858 if (PartEntry
->IsPartitioned
== TRUE
)
2860 CONSOLE_PrintTextXY(6, Line
,
2861 "%2u: %2u %c %12I64u %12I64u %2u %c",
2863 PartEntry
->PartitionNumber
,
2864 PartEntry
->BootIndicator
? 'A' : '-',
2865 PartEntry
->StartSector
.QuadPart
,
2866 PartEntry
->SectorCount
.QuadPart
,
2867 PartEntry
->PartitionType
,
2868 PartEntry
->Dirty
? '*' : ' ');
2872 Entry
= Entry
->Flink
;
2875 /* Restore the old entry */
2876 PartEntry
= PartitionList
->TempPartition
;
2879 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2881 DPRINT("WritePartitionsToDisk() failed\n");
2882 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2886 /* Set PartitionRootPath */
2887 swprintf(PathBuffer
,
2888 L
"\\Device\\Harddisk%lu\\Partition%lu",
2889 DiskEntry
->DiskNumber
,
2890 PartEntry
->PartitionNumber
);
2891 RtlInitUnicodeString(&PartitionRootPath
,
2893 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
2895 if (PartEntry
->FileSystem
->FormatFunc
)
2897 Status
= FormatPartition(&PartitionRootPath
,
2898 PartEntry
->FileSystem
);
2899 if (!NT_SUCCESS(Status
))
2901 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2902 MUIDisplayError(ERROR_FORMATTING_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
, PathBuffer
);
2906 PartEntry
->New
= FALSE
;
2910 CONSOLE_SetStatusText(" Done. Press any key ...");
2911 CONSOLE_ConInKey(Ir
);
2914 return SELECT_FILE_SYSTEM_PAGE
;
2918 return FORMAT_PARTITION_PAGE
;
2923 CheckFileSystemPage(PINPUT_RECORD Ir
)
2925 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2926 UNICODE_STRING PartitionRootPath
;
2927 WCHAR PathBuffer
[MAX_PATH
];
2928 CHAR Buffer
[MAX_PATH
];
2929 LPWSTR FileSystemName
= NULL
;
2930 PDISKENTRY DiskEntry
;
2931 PPARTENTRY PartEntry
;
2934 if (PartitionList
== NULL
)
2936 /* FIXME: show an error dialog */
2940 if (!GetNextUncheckedPartition(PartitionList
,
2944 return INSTALL_DIRECTORY_PAGE
;
2947 /* Set PartitionRootPath */
2948 swprintf(PathBuffer
,
2949 L
"\\Device\\Harddisk%lu\\Partition%lu",
2950 DiskEntry
->DiskNumber
,
2951 PartEntry
->PartitionNumber
);
2952 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
2953 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
2955 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2957 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2959 CurrentFileSystem
= PartEntry
->FileSystem
;
2960 if (CurrentFileSystem
== NULL
|| CurrentFileSystem
->FileSystemName
== NULL
)
2962 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2963 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2964 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2965 (PartEntry
->PartitionType
== PARTITION_XINT13
) ||
2966 (PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2967 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2969 FileSystemName
= L
"FAT";
2971 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2973 FileSystemName
= L
"EXT2";
2975 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2977 FileSystemName
= L
"NTFS"; /* FIXME: Not quite correct! */
2980 DPRINT("FileSystemName: %S\n", FileSystemName
);
2982 if (FileSystemName
!= NULL
)
2983 CurrentFileSystem
= GetFileSystemByName(FileSystemList
,
2987 /* HACK: Do not try to check a partition with an unknown filesytem */
2988 if (CurrentFileSystem
== NULL
)
2990 PartEntry
->NeedsCheck
= FALSE
;
2991 return CHECK_FILE_SYSTEM_PAGE
;
2994 if (CurrentFileSystem
->ChkdskFunc
== NULL
)
2997 "Setup is currently unable to check a partition formatted in %S.\n"
2999 " \x07 Press ENTER to continue Setup.\n"
3000 " \x07 Press F3 to quit Setup.",
3001 CurrentFileSystem
->FileSystemName
);
3004 MUIGetString(STRING_QUITCONTINUE
),
3005 NULL
, POPUP_WAIT_NONE
);
3009 CONSOLE_ConInKey(Ir
);
3011 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3012 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3014 if (ConfirmQuit(Ir
))
3017 return CHECK_FILE_SYSTEM_PAGE
;
3019 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3021 PartEntry
->NeedsCheck
= FALSE
;
3022 return CHECK_FILE_SYSTEM_PAGE
;
3028 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3029 if (!NT_SUCCESS(Status
))
3031 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3032 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
3033 "(Status 0x%08lx).\n", Status
);
3036 MUIGetString(STRING_REBOOTCOMPUTER
),
3037 Ir
, POPUP_WAIT_ENTER
);
3042 PartEntry
->NeedsCheck
= FALSE
;
3043 return CHECK_FILE_SYSTEM_PAGE
;
3049 InstallDirectoryPage1(PWCHAR InstallDir
,
3050 PDISKENTRY DiskEntry
,
3051 PPARTENTRY PartEntry
)
3053 WCHAR PathBuffer
[MAX_PATH
];
3055 /* Create 'InstallPath' string */
3056 RtlFreeUnicodeString(&InstallPath
);
3057 RtlCreateUnicodeString(&InstallPath
,
3060 /* Create 'DestinationRootPath' string */
3061 RtlFreeUnicodeString(&DestinationRootPath
);
3062 swprintf(PathBuffer
,
3063 L
"\\Device\\Harddisk%lu\\Partition%lu",
3064 DiskEntry
->DiskNumber
,
3065 PartEntry
->PartitionNumber
);
3066 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
3067 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
3069 /* Create 'DestinationPath' string */
3070 RtlFreeUnicodeString(&DestinationPath
);
3071 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3073 if (InstallDir
[0] != L
'\\')
3074 wcscat(PathBuffer
, L
"\\");
3076 wcscat(PathBuffer
, InstallDir
);
3077 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
3079 /* Create 'DestinationArcPath' */
3080 RtlFreeUnicodeString(&DestinationArcPath
);
3081 swprintf(PathBuffer
,
3082 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
3083 DiskEntry
->BiosDiskNumber
,
3084 PartEntry
->PartitionNumber
);
3086 if (InstallDir
[0] != L
'\\')
3087 wcscat(PathBuffer
, L
"\\");
3089 wcscat(PathBuffer
, InstallDir
);
3090 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3092 return PREPARE_COPY_PAGE
;
3097 InstallDirectoryPage(PINPUT_RECORD Ir
)
3099 PDISKENTRY DiskEntry
;
3100 PPARTENTRY PartEntry
;
3101 WCHAR InstallDir
[51];
3105 /* We do not need the filsystem list any more */
3106 DestroyFileSystemList(FileSystemList
);
3107 FileSystemList
= NULL
;
3109 if (PartitionList
== NULL
||
3110 PartitionList
->CurrentDisk
== NULL
||
3111 PartitionList
->CurrentPartition
== NULL
)
3113 /* FIXME: show an error dialog */
3117 DiskEntry
= PartitionList
->CurrentDisk
;
3118 PartEntry
= PartitionList
->CurrentPartition
;
3120 if (IsUnattendedSetup
)
3121 wcscpy(InstallDir
, UnattendInstallationDirectory
);
3123 wcscpy(InstallDir
, L
"\\ReactOS");
3125 Length
= wcslen(InstallDir
);
3126 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3127 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3129 // FIXME: Check the validity of the InstallDir; however what to do
3130 // if it is invalid but we are in unattended setup? (case of somebody
3131 // specified an invalid installation directory in the unattended file).
3133 if (IsUnattendedSetup
)
3135 return InstallDirectoryPage1(InstallDir
,
3142 CONSOLE_ConInKey(Ir
);
3144 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3145 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3147 if (ConfirmQuit(Ir
) == TRUE
)
3152 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3155 * Check for the validity of the installation directory and pop up
3156 * an error if it is not the case. Then the user can fix its input.
3158 if (!IsValidPath(InstallDir
, Length
))
3160 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3161 return INSTALL_DIRECTORY_PAGE
;
3163 return InstallDirectoryPage1(InstallDir
,
3167 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3172 InstallDir
[Length
] = 0;
3173 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3176 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3180 c
= (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3181 if (iswalpha(c
) || iswdigit(c
) || c
== '.' || c
== '\\' || c
== '-' || c
== '_')
3183 InstallDir
[Length
] = c
;
3185 InstallDir
[Length
] = 0;
3186 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3192 return INSTALL_DIRECTORY_PAGE
;
3197 AddSectionToCopyQueueCab(HINF InfFile
,
3199 PWCHAR SourceCabinet
,
3200 PCUNICODE_STRING DestinationPath
,
3203 INFCONTEXT FilesContext
;
3204 INFCONTEXT DirContext
;
3206 PWCHAR FileKeyValue
;
3208 PWCHAR TargetFileName
;
3210 /* Search for the SectionName section */
3211 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3214 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3215 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3220 * Enumerate the files in the section
3221 * and add them to the file queue.
3225 /* Get source file name and target directory id */
3226 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3228 /* FIXME: Handle error! */
3229 DPRINT1("INF_GetData() failed\n");
3233 /* Get optional target file name */
3234 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3235 TargetFileName
= NULL
;
3237 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3239 /* Lookup target directory */
3240 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3242 /* FIXME: Handle error! */
3243 DPRINT1("SetupFindFirstLine() failed\n");
3247 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3249 /* FIXME: Handle error! */
3250 DPRINT1("INF_GetData() failed\n");
3254 if (!SetupQueueCopy(SetupFileQueue
,
3256 SourceRootPath
.Buffer
,
3257 SourceRootDir
.Buffer
,
3262 /* FIXME: Handle error! */
3263 DPRINT1("SetupQueueCopy() failed\n");
3265 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3272 AddSectionToCopyQueue(HINF InfFile
,
3274 PWCHAR SourceCabinet
,
3275 PCUNICODE_STRING DestinationPath
,
3278 INFCONTEXT FilesContext
;
3279 INFCONTEXT DirContext
;
3281 PWCHAR FileKeyValue
;
3283 PWCHAR TargetFileName
;
3285 WCHAR CompleteOrigDirName
[512];
3288 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3290 /* Search for the SectionName section */
3291 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3294 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3295 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3300 * Enumerate the files in the section
3301 * and add them to the file queue.
3305 /* Get source file name and target directory id */
3306 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3308 /* FIXME: Handle error! */
3309 DPRINT1("INF_GetData() failed\n");
3313 /* Get target directory id */
3314 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3316 /* FIXME: Handle error! */
3317 DPRINT1("INF_GetData() failed\n");
3321 /* Get optional target file name */
3322 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3323 TargetFileName
= NULL
;
3324 else if (!*TargetFileName
)
3325 TargetFileName
= NULL
;
3327 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3329 /* Lookup target directory */
3330 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3332 /* FIXME: Handle error! */
3333 DPRINT1("SetupFindFirstLine() failed\n");
3337 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3339 /* FIXME: Handle error! */
3340 DPRINT1("INF_GetData() failed\n");
3344 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3346 /* Installation path */
3347 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3349 else if (DirKeyValue
[0] == L
'\\')
3352 wcscpy(CompleteOrigDirName
, DirKeyValue
);
3354 else // if (DirKeyValue[0] != L'\\')
3356 /* Path relative to the installation path */
3357 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3358 wcscat(CompleteOrigDirName
, L
"\\");
3359 wcscat(CompleteOrigDirName
, DirKeyValue
);
3362 /* Remove trailing backslash */
3363 Length
= wcslen(CompleteOrigDirName
);
3364 if ((Length
> 0) && (CompleteOrigDirName
[Length
- 1] == L
'\\'))
3366 CompleteOrigDirName
[Length
- 1] = 0;
3369 if (!SetupQueueCopy(SetupFileQueue
,
3371 SourceRootPath
.Buffer
,
3372 CompleteOrigDirName
,
3377 /* FIXME: Handle error! */
3378 DPRINT1("SetupQueueCopy() failed\n");
3380 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3387 PrepareCopyPageInfFile(HINF InfFile
,
3388 PWCHAR SourceCabinet
,
3391 WCHAR PathBuffer
[MAX_PATH
];
3392 INFCONTEXT DirContext
;
3393 PWCHAR AdditionalSectionName
= NULL
;
3398 /* Add common files */
3399 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3402 /* Add specific files depending of computer type */
3403 if (SourceCabinet
== NULL
)
3405 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3408 if (AdditionalSectionName
)
3410 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3415 /* Create directories */
3419 * - Install directories like '\reactos\test' are not handled yet.
3420 * - Copying files to DestinationRootPath should be done from within
3421 * the SystemPartitionFiles section.
3422 * At the moment we check whether we specify paths like '\foo' or '\\' for that.
3423 * For installing to DestinationPath specify just '\' .
3426 /* Get destination path */
3427 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3429 /* Remove trailing backslash */
3430 Length
= wcslen(PathBuffer
);
3431 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3433 PathBuffer
[Length
- 1] = 0;
3436 /* Create the install directory */
3437 Status
= SetupCreateDirectory(PathBuffer
);
3438 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3440 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3441 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3445 /* Search for the 'Directories' section */
3446 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3450 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3454 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3460 /* Enumerate the directory values and create the subdirectories */
3463 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3469 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3471 /* Installation path */
3472 DPRINT("InstallationPath: '%S'\n", DirKeyValue
);
3474 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3476 DPRINT("FullPath: '%S'\n", PathBuffer
);
3478 else if (DirKeyValue
[0] == L
'\\')
3481 DPRINT("Absolute Path: '%S'\n", DirKeyValue
);
3483 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3484 wcscat(PathBuffer
, DirKeyValue
);
3486 /* Remove trailing backslash */
3487 Length
= wcslen(PathBuffer
);
3488 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3490 PathBuffer
[Length
- 1] = 0;
3493 DPRINT("FullPath: '%S'\n", PathBuffer
);
3495 Status
= SetupCreateDirectory(PathBuffer
);
3496 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3498 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3499 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3503 else // if (DirKeyValue[0] != L'\\')
3505 /* Path relative to the installation path */
3506 DPRINT("RelativePath: '%S'\n", DirKeyValue
);
3508 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3509 wcscat(PathBuffer
, L
"\\");
3510 wcscat(PathBuffer
, DirKeyValue
);
3512 /* Remove trailing backslash */
3513 Length
= wcslen(PathBuffer
);
3514 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3516 PathBuffer
[Length
- 1] = 0;
3519 DPRINT("FullPath: '%S'\n", PathBuffer
);
3521 Status
= SetupCreateDirectory(PathBuffer
);
3522 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3524 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3525 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3529 } while (SetupFindNextLine(&DirContext
, &DirContext
));
3536 PrepareCopyPage(PINPUT_RECORD Ir
)
3539 WCHAR PathBuffer
[MAX_PATH
];
3540 INFCONTEXT CabinetsContext
;
3546 MUIDisplayPage(PREPARE_COPY_PAGE
);
3548 /* Create the file queue */
3549 SetupFileQueue
= SetupOpenFileQueue();
3550 if (SetupFileQueue
== NULL
)
3552 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3556 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3561 /* Search for the 'Cabinets' section */
3562 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3564 return FILE_COPY_PAGE
;
3568 * Enumerate the directory values in the 'Cabinets'
3569 * section and parse their inf files.
3573 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3576 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3577 wcscat(PathBuffer
, L
"\\");
3578 wcscat(PathBuffer
, KeyValue
);
3581 CabinetInitialize();
3582 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3583 CabinetSetCabinetName(PathBuffer
);
3585 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3587 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3589 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3590 if (InfFileData
== NULL
)
3592 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3598 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3599 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3603 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3610 if (InfHandle
== INVALID_HANDLE_VALUE
)
3612 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3618 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3623 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3625 return FILE_COPY_PAGE
;
3631 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3634 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3636 /* Get the memory information from the system */
3637 NtQuerySystemInformation(SystemPerformanceInformation
,
3642 /* Check if this is initial setup */
3645 /* Set maximum limits to be total RAM pages */
3646 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3647 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3648 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3651 /* Set current values */
3652 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3653 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3654 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3660 FileCopyCallback(PVOID Context
,
3665 PCOPYCONTEXT CopyContext
;
3667 CopyContext
= (PCOPYCONTEXT
)Context
;
3669 switch (Notification
)
3671 case SPFILENOTIFY_STARTSUBQUEUE
:
3672 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3673 ProgressSetStepCount(CopyContext
->ProgressBar
,
3674 CopyContext
->TotalOperations
);
3675 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3678 case SPFILENOTIFY_STARTCOPY
:
3679 /* Display copy message */
3680 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3681 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3684 case SPFILENOTIFY_ENDCOPY
:
3685 CopyContext
->CompletedOperations
++;
3687 /* SYSREG checkpoint */
3688 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3689 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3691 ProgressNextStep(CopyContext
->ProgressBar
);
3692 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3702 FileCopyPage(PINPUT_RECORD Ir
)
3704 COPYCONTEXT CopyContext
;
3705 unsigned int mem_bar_width
;
3707 MUIDisplayPage(FILE_COPY_PAGE
);
3709 /* Create context for the copy process */
3710 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3711 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3712 CopyContext
.TotalOperations
= 0;
3713 CopyContext
.CompletedOperations
= 0;
3715 /* Create the progress bar as well */
3716 CopyContext
.ProgressBar
= CreateProgressBar(13,
3723 MUIGetString(STRING_SETUPCOPYINGFILES
));
3725 // fit memory bars to screen width, distribute them uniform
3726 mem_bar_width
= (xScreen
- 26) / 5;
3727 mem_bar_width
-= mem_bar_width
% 2; // make even
3728 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3729 /* Create the paged pool progress bar */
3730 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3739 /* Create the non paged pool progress bar */
3740 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3742 (xScreen
/ 2) + (mem_bar_width
/ 2),
3744 (xScreen
/ 2)- (mem_bar_width
/ 2),
3749 /* Create the global memory progress bar */
3750 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3754 xScreen
- 13 - mem_bar_width
,
3759 /* Do the file copying */
3760 SetupCommitFileQueueW(NULL
,
3765 /* If we get here, we're done, so cleanup the queue and progress bar */
3766 SetupCloseFileQueue(SetupFileQueue
);
3767 DestroyProgressBar(CopyContext
.ProgressBar
);
3768 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3769 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3770 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3772 /* Go display the next page */
3773 return REGISTRY_PAGE
;
3778 RegistryPage(PINPUT_RECORD Ir
)
3780 INFCONTEXT InfContext
;
3787 MUIDisplayPage(REGISTRY_PAGE
);
3789 if (RepairUpdateFlag
)
3791 return SUCCESS_PAGE
;
3794 if (!SetInstallPathValue(&DestinationPath
))
3796 DPRINT1("SetInstallPathValue() failed\n");
3797 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3801 /* Create the default hives */
3803 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3804 if (!NT_SUCCESS(Status
))
3806 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3807 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3811 RegInitializeRegistry();
3814 /* Update registry */
3815 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3817 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3819 DPRINT1("SetupFindFirstLine() failed\n");
3820 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3826 INF_GetDataField (&InfContext
, 0, &Action
);
3827 INF_GetDataField (&InfContext
, 1, &File
);
3828 INF_GetDataField (&InfContext
, 2, &Section
);
3830 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3835 if (!_wcsicmp (Action
, L
"AddReg"))
3839 else if (!_wcsicmp (Action
, L
"DelReg"))
3848 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3850 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3852 DPRINT1("Importing %S failed\n", File
);
3854 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3857 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3859 /* Update display registry settings */
3860 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3861 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3863 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3867 /* Set the locale */
3868 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3869 if (!ProcessLocaleRegistry(LanguageList
))
3871 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3875 /* Add keyboard layouts */
3876 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3877 if (!AddKeyboardLayouts())
3879 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3885 if (!SetGeoID(MUIGetGeoID()))
3887 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3891 if (!IsUnattendedSetup
)
3893 /* Update keyboard layout settings */
3894 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3895 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3897 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3902 /* Add codepage information to registry */
3903 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3906 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3910 /* Set the default pagefile entry */
3911 SetDefaultPagefile(DestinationDriveLetter
);
3913 /* Update the mounted devices list */
3914 SetMountedDeviceValues(PartitionList
);
3916 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3918 return BOOT_LOADER_PAGE
;
3923 BootLoaderPage(PINPUT_RECORD Ir
)
3925 UCHAR PartitionType
;
3926 BOOLEAN InstallOnFloppy
;
3928 WCHAR PathBuffer
[MAX_PATH
];
3930 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3932 RtlFreeUnicodeString(&SystemRootPath
);
3933 swprintf(PathBuffer
,
3934 L
"\\Device\\Harddisk%lu\\Partition%lu",
3935 PartitionList
->BootDisk
->DiskNumber
,
3936 PartitionList
->BootPartition
->PartitionNumber
);
3937 RtlCreateUnicodeString(&SystemRootPath
,
3939 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3941 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
3943 if (IsUnattendedSetup
)
3945 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3947 return SUCCESS_PAGE
;
3949 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3951 return BOOT_LOADER_FLOPPY_PAGE
;
3955 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3957 DPRINT("Error: active partition invalid (unused)\n");
3958 InstallOnFloppy
= TRUE
;
3960 else if (PartitionType
== 0x0A)
3962 /* OS/2 boot manager partition */
3963 DPRINT("Found OS/2 boot manager partition\n");
3964 InstallOnFloppy
= TRUE
;
3966 else if (PartitionType
== 0x83)
3968 /* Linux ext2 partition */
3969 DPRINT("Found Linux ext2 partition\n");
3970 InstallOnFloppy
= TRUE
;
3972 else if (PartitionType
== PARTITION_IFS
)
3974 /* NTFS partition */
3975 DPRINT("Found NTFS partition\n");
3976 InstallOnFloppy
= TRUE
;
3978 else if ((PartitionType
== PARTITION_FAT_12
) ||
3979 (PartitionType
== PARTITION_FAT_16
) ||
3980 (PartitionType
== PARTITION_HUGE
) ||
3981 (PartitionType
== PARTITION_XINT13
) ||
3982 (PartitionType
== PARTITION_FAT32
) ||
3983 (PartitionType
== PARTITION_FAT32_XINT13
))
3985 DPRINT("Found FAT partition\n");
3986 InstallOnFloppy
= FALSE
;
3990 /* Unknown partition */
3991 DPRINT("Unknown partition found\n");
3992 InstallOnFloppy
= TRUE
;
3995 if (InstallOnFloppy
== TRUE
)
3997 return BOOT_LOADER_FLOPPY_PAGE
;
4000 /* Unattended install on hdd? */
4001 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
4003 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4006 MUIDisplayPage(BOOT_LOADER_PAGE
);
4007 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4011 CONSOLE_ConInKey(Ir
);
4013 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4014 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
4016 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4025 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4027 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4028 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
4030 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4039 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4041 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4042 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4044 if (ConfirmQuit(Ir
) == TRUE
)
4049 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4053 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4055 else if (Line
== 13)
4057 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4059 else if (Line
== 14)
4061 return BOOT_LOADER_FLOPPY_PAGE
;
4063 else if (Line
== 15)
4065 return SUCCESS_PAGE
;
4068 return BOOT_LOADER_PAGE
;
4072 return BOOT_LOADER_PAGE
;
4077 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4081 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4083 // SetStatusText(" Please wait...");
4087 CONSOLE_ConInKey(Ir
);
4089 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4090 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4092 if (ConfirmQuit(Ir
) == TRUE
)
4097 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4099 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
4101 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4102 return BOOT_LOADER_FLOPPY_PAGE
;
4105 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
4106 if (!NT_SUCCESS(Status
))
4108 /* Print error message */
4109 return BOOT_LOADER_FLOPPY_PAGE
;
4112 return SUCCESS_PAGE
;
4116 return BOOT_LOADER_FLOPPY_PAGE
;
4121 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4123 UCHAR PartitionType
;
4126 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
4128 Status
= InstallVBRToPartition(&SystemRootPath
,
4130 &DestinationArcPath
,
4132 if (!NT_SUCCESS(Status
))
4134 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4138 return SUCCESS_PAGE
;
4143 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4145 UCHAR PartitionType
;
4147 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4148 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
4150 /* Step 1: Write the VBR */
4151 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
4153 Status
= InstallVBRToPartition(&SystemRootPath
,
4155 &DestinationArcPath
,
4157 if (!NT_SUCCESS(Status
))
4159 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4163 /* Step 2: Write the MBR */
4164 swprintf(DestinationDevicePathBuffer
,
4165 L
"\\Device\\Harddisk%d\\Partition0",
4166 PartitionList
->BootDisk
->DiskNumber
);
4168 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4169 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4171 DPRINT("Install MBR bootcode: %S ==> %S\n",
4172 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4174 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4175 DestinationDevicePathBuffer
);
4176 if (!NT_SUCCESS (Status
))
4178 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4180 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4184 return SUCCESS_PAGE
;
4189 QuitPage(PINPUT_RECORD Ir
)
4191 MUIDisplayPage(QUIT_PAGE
);
4193 /* Destroy partition list */
4194 if (PartitionList
!= NULL
)
4196 DestroyPartitionList (PartitionList
);
4197 PartitionList
= NULL
;
4200 /* Destroy filesystem list */
4201 if (FileSystemList
!= NULL
)
4203 DestroyFileSystemList (FileSystemList
);
4204 FileSystemList
= NULL
;
4207 /* Destroy computer settings list */
4208 if (ComputerList
!= NULL
)
4210 DestroyGenericList(ComputerList
, TRUE
);
4211 ComputerList
= NULL
;
4214 /* Destroy display settings list */
4215 if (DisplayList
!= NULL
)
4217 DestroyGenericList(DisplayList
, TRUE
);
4221 /* Destroy keyboard settings list */
4222 if (KeyboardList
!= NULL
)
4224 DestroyGenericList(KeyboardList
, TRUE
);
4225 KeyboardList
= NULL
;
4228 /* Destroy keyboard layout list */
4229 if (LayoutList
!= NULL
)
4231 DestroyGenericList(LayoutList
, TRUE
);
4235 if (LanguageList
!= NULL
)
4237 DestroyGenericList(LanguageList
, FALSE
);
4238 LanguageList
= NULL
;
4241 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4245 CONSOLE_ConInKey(Ir
);
4247 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4256 SuccessPage(PINPUT_RECORD Ir
)
4258 MUIDisplayPage(SUCCESS_PAGE
);
4260 if (IsUnattendedSetup
)
4267 CONSOLE_ConInKey(Ir
);
4269 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4278 FlushPage(PINPUT_RECORD Ir
)
4280 MUIDisplayPage(FLUSH_PAGE
);
4286 PnpEventThread(IN LPVOID lpParameter
);
4297 NtQuerySystemTime(&Time
);
4299 Status
= RtlCreateUserThread(NtCurrentProcess(),
4309 if (!NT_SUCCESS(Status
))
4310 hPnpThread
= INVALID_HANDLE_VALUE
;
4312 if (!CONSOLE_Init())
4314 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4315 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4316 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4318 /* Raise a hard error (crash the system/BSOD) */
4319 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4323 /* Initialize global unicode strings */
4324 RtlInitUnicodeString(&SourcePath
, NULL
);
4325 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4326 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4327 RtlInitUnicodeString(&InstallPath
, NULL
);
4328 RtlInitUnicodeString(&DestinationPath
, NULL
);
4329 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4330 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4331 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4333 /* Hide the cursor */
4334 CONSOLE_SetCursorType(TRUE
, FALSE
);
4337 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4339 CONSOLE_ClearScreen();
4342 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4349 Page
= SetupStartPage(&Ir
);
4354 Page
= LanguagePage(&Ir
);
4359 Page
= LicensePage(&Ir
);
4364 Page
= IntroPage(&Ir
);
4368 case INSTALL_INTRO_PAGE
:
4369 Page
= InstallIntroPage(&Ir
);
4373 case SCSI_CONTROLLER_PAGE
:
4374 Page
= ScsiControllerPage(&Ir
);
4379 case OEM_DRIVER_PAGE
:
4380 Page
= OemDriverPage(&Ir
);
4384 case DEVICE_SETTINGS_PAGE
:
4385 Page
= DeviceSettingsPage(&Ir
);
4388 case COMPUTER_SETTINGS_PAGE
:
4389 Page
= ComputerSettingsPage(&Ir
);
4392 case DISPLAY_SETTINGS_PAGE
:
4393 Page
= DisplaySettingsPage(&Ir
);
4396 case KEYBOARD_SETTINGS_PAGE
:
4397 Page
= KeyboardSettingsPage(&Ir
);
4400 case LAYOUT_SETTINGS_PAGE
:
4401 Page
= LayoutSettingsPage(&Ir
);
4404 case SELECT_PARTITION_PAGE
:
4405 Page
= SelectPartitionPage(&Ir
);
4408 case CREATE_PRIMARY_PARTITION_PAGE
:
4409 Page
= CreatePrimaryPartitionPage(&Ir
);
4412 case CREATE_EXTENDED_PARTITION_PAGE
:
4413 Page
= CreateExtendedPartitionPage(&Ir
);
4416 case CREATE_LOGICAL_PARTITION_PAGE
:
4417 Page
= CreateLogicalPartitionPage(&Ir
);
4420 case DELETE_PARTITION_PAGE
:
4421 Page
= DeletePartitionPage(&Ir
);
4424 case SELECT_FILE_SYSTEM_PAGE
:
4425 Page
= SelectFileSystemPage(&Ir
);
4428 case FORMAT_PARTITION_PAGE
:
4429 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4432 case CHECK_FILE_SYSTEM_PAGE
:
4433 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4436 case INSTALL_DIRECTORY_PAGE
:
4437 Page
= InstallDirectoryPage(&Ir
);
4440 case PREPARE_COPY_PAGE
:
4441 Page
= PrepareCopyPage(&Ir
);
4444 case FILE_COPY_PAGE
:
4445 Page
= FileCopyPage(&Ir
);
4449 Page
= RegistryPage(&Ir
);
4452 case BOOT_LOADER_PAGE
:
4453 Page
= BootLoaderPage(&Ir
);
4456 case BOOT_LOADER_FLOPPY_PAGE
:
4457 Page
= BootLoaderFloppyPage(&Ir
);
4460 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4461 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4464 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4465 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4469 case REPAIR_INTRO_PAGE
:
4470 Page
= RepairIntroPage(&Ir
);
4474 Page
= SuccessPage(&Ir
);
4478 Page
= FlushPage(&Ir
);
4482 Page
= QuitPage(&Ir
);
4491 if (Page
== RECOVERY_PAGE
)
4496 /* Avoid bugcheck */
4497 Time
.QuadPart
+= 50000000;
4498 NtDelayExecution(FALSE
, &Time
);
4501 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4502 NtShutdownSystem(ShutdownReboot
);
4503 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4504 NtTerminateProcess(NtCurrentProcess(), 0);
4511 NtProcessStartup(PPEB Peb
)
4513 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4515 ProcessHeap
= Peb
->ProcessHeap
;
4516 InfSetHeap(ProcessHeap
);
4519 #endif /* __REACTOS__ */