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 if (PartitionList
->CurrentPartition
->BootIndicator
)
1667 return CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
;
1669 return DELETE_PARTITION_PAGE
;
1673 return SELECT_PARTITION_PAGE
;
1677 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1678 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1679 #define PARTITION_MAXSIZE 999999
1682 ShowPartitionSizeInputBox(SHORT Left
,
1695 WCHAR PartitionSizeBuffer
[100];
1707 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1712 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1713 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1716 WriteConsoleOutputCharacterA(StdOutput
,
1722 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1723 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1725 WriteConsoleOutputCharacterA(StdOutput
,
1731 swprintf(PartitionSizeBuffer
, L
"%lu", MaxSize
);
1732 Index
= wcslen(PartitionSizeBuffer
);
1733 CONSOLE_SetInputTextXY(iLeft
,
1735 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1736 PartitionSizeBuffer
);
1740 CONSOLE_ConInKey(&Ir
);
1742 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1743 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1748 PartitionSizeBuffer
[0] = 0;
1751 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1755 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1760 PartitionSizeBuffer
[0] = 0;
1763 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1767 PartitionSizeBuffer
[Index
] = 0;
1769 CONSOLE_SetInputTextXY(iLeft
,
1771 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1772 PartitionSizeBuffer
);
1774 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1775 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1777 ch
= (WCHAR
)Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1779 if ((ch
>= L
'0') && (ch
<= L
'9'))
1781 PartitionSizeBuffer
[Index
] = ch
;
1783 PartitionSizeBuffer
[Index
] = 0;
1785 CONSOLE_SetInputTextXY(iLeft
,
1787 PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1788 PartitionSizeBuffer
);
1793 /* Convert UNICODE --> ANSI the poor man's way */
1794 sprintf(InputBuffer
, "%S", PartitionSizeBuffer
);
1799 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1801 PDISKENTRY DiskEntry
;
1802 PPARTENTRY PartEntry
;
1805 CHAR InputBuffer
[50];
1809 ULONGLONG SectorCount
;
1812 if (PartitionList
== NULL
||
1813 PartitionList
->CurrentDisk
== NULL
||
1814 PartitionList
->CurrentPartition
== NULL
)
1816 /* FIXME: show an error dialog */
1820 DiskEntry
= PartitionList
->CurrentDisk
;
1821 PartEntry
= PartitionList
->CurrentPartition
;
1823 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1825 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1827 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1829 if (DiskSize
>= 10737418240) /* 10 GB */
1831 DiskSize
= DiskSize
/ 1073741824;
1832 Unit
= MUIGetString(STRING_GB
);
1837 DiskSize
= DiskSize
/ 1048576;
1841 Unit
= MUIGetString(STRING_MB
);
1844 if (DiskEntry
->DriverName
.Length
> 0)
1846 CONSOLE_PrintTextXY(6, 10,
1847 MUIGetString(STRING_HDINFOPARTCREATE
),
1850 DiskEntry
->DiskNumber
,
1854 &DiskEntry
->DriverName
);
1858 CONSOLE_PrintTextXY(6, 10,
1859 MUIGetString(STRING_HDDINFOUNK1
),
1862 DiskEntry
->DiskNumber
,
1868 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1871 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1872 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
1875 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1877 PartEntry
= PartitionList
->CurrentPartition
;
1880 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
1882 if (MaxSize
> PARTITION_MAXSIZE
)
1883 MaxSize
= PARTITION_MAXSIZE
;
1885 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1886 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1890 if (ConfirmQuit (Ir
) == TRUE
)
1895 else if (Cancel
== TRUE
)
1897 return SELECT_PARTITION_PAGE
;
1901 PartSize
= atoi(InputBuffer
);
1909 if (PartSize
> MaxSize
)
1915 /* Convert to bytes */
1916 if (PartSize
== MaxSize
)
1918 /* Use all of the unpartitioned disk space */
1919 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1923 /* Calculate the sector count from the size in MB */
1924 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
1926 /* But never get larger than the unpartitioned disk space */
1927 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
1928 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1931 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1933 CreatePrimaryPartition(PartitionList
,
1937 return SELECT_PARTITION_PAGE
;
1941 return CREATE_PRIMARY_PARTITION_PAGE
;
1946 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
1948 PDISKENTRY DiskEntry
;
1949 PPARTENTRY PartEntry
;
1952 CHAR InputBuffer
[50];
1956 ULONGLONG SectorCount
;
1959 if (PartitionList
== NULL
||
1960 PartitionList
->CurrentDisk
== NULL
||
1961 PartitionList
->CurrentPartition
== NULL
)
1963 /* FIXME: show an error dialog */
1967 DiskEntry
= PartitionList
->CurrentDisk
;
1968 PartEntry
= PartitionList
->CurrentPartition
;
1970 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1972 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
1974 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1976 if (DiskSize
>= 10737418240) /* 10 GB */
1978 DiskSize
= DiskSize
/ 1073741824;
1979 Unit
= MUIGetString(STRING_GB
);
1984 DiskSize
= DiskSize
/ 1048576;
1988 Unit
= MUIGetString(STRING_MB
);
1991 if (DiskEntry
->DriverName
.Length
> 0)
1993 CONSOLE_PrintTextXY(6, 10,
1994 MUIGetString(STRING_HDINFOPARTCREATE
),
1997 DiskEntry
->DiskNumber
,
2001 &DiskEntry
->DriverName
);
2005 CONSOLE_PrintTextXY(6, 10,
2006 MUIGetString(STRING_HDDINFOUNK1
),
2009 DiskEntry
->DiskNumber
,
2015 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2018 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2019 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2022 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2024 PartEntry
= PartitionList
->CurrentPartition
;
2027 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2029 if (MaxSize
> PARTITION_MAXSIZE
)
2030 MaxSize
= PARTITION_MAXSIZE
;
2032 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2033 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2037 if (ConfirmQuit (Ir
) == TRUE
)
2042 else if (Cancel
== TRUE
)
2044 return SELECT_PARTITION_PAGE
;
2048 PartSize
= atoi(InputBuffer
);
2056 if (PartSize
> MaxSize
)
2062 /* Convert to bytes */
2063 if (PartSize
== MaxSize
)
2065 /* Use all of the unpartitioned disk space */
2066 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2070 /* Calculate the sector count from the size in MB */
2071 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2073 /* But never get larger than the unpartitioned disk space */
2074 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2075 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2078 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2080 CreateExtendedPartition(PartitionList
,
2083 return SELECT_PARTITION_PAGE
;
2087 return CREATE_EXTENDED_PARTITION_PAGE
;
2092 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2094 PDISKENTRY DiskEntry
;
2095 PPARTENTRY PartEntry
;
2098 CHAR InputBuffer
[50];
2102 ULONGLONG SectorCount
;
2105 if (PartitionList
== NULL
||
2106 PartitionList
->CurrentDisk
== NULL
||
2107 PartitionList
->CurrentPartition
== NULL
)
2109 /* FIXME: show an error dialog */
2113 DiskEntry
= PartitionList
->CurrentDisk
;
2114 PartEntry
= PartitionList
->CurrentPartition
;
2116 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2118 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2120 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2122 if (DiskSize
>= 10737418240) /* 10 GB */
2124 DiskSize
= DiskSize
/ 1073741824;
2125 Unit
= MUIGetString(STRING_GB
);
2130 DiskSize
= DiskSize
/ 1048576;
2134 Unit
= MUIGetString(STRING_MB
);
2137 if (DiskEntry
->DriverName
.Length
> 0)
2139 CONSOLE_PrintTextXY(6, 10,
2140 MUIGetString(STRING_HDINFOPARTCREATE
),
2143 DiskEntry
->DiskNumber
,
2147 &DiskEntry
->DriverName
);
2151 CONSOLE_PrintTextXY(6, 10,
2152 MUIGetString(STRING_HDDINFOUNK1
),
2155 DiskEntry
->DiskNumber
,
2161 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2164 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2165 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2168 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2170 PartEntry
= PartitionList
->CurrentPartition
;
2173 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2175 if (MaxSize
> PARTITION_MAXSIZE
)
2176 MaxSize
= PARTITION_MAXSIZE
;
2178 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2179 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2183 if (ConfirmQuit (Ir
) == TRUE
)
2188 else if (Cancel
== TRUE
)
2190 return SELECT_PARTITION_PAGE
;
2194 PartSize
= atoi(InputBuffer
);
2202 if (PartSize
> MaxSize
)
2208 /* Convert to bytes */
2209 if (PartSize
== MaxSize
)
2211 /* Use all of the unpartitioned disk space */
2212 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2216 /* Calculate the sector count from the size in MB */
2217 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2219 /* But never get larger than the unpartitioned disk space */
2220 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2221 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2224 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2226 CreateLogicalPartition(PartitionList
,
2230 return SELECT_PARTITION_PAGE
;
2234 return CREATE_LOGICAL_PARTITION_PAGE
;
2239 ConfirmDeleteSystemPartitionPage(PINPUT_RECORD Ir
)
2241 MUIDisplayPage(CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
);
2245 CONSOLE_ConInKey(Ir
);
2247 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2248 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2250 if (ConfirmQuit(Ir
) == TRUE
)
2257 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2259 return DELETE_PARTITION_PAGE
;
2261 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2263 return SELECT_PARTITION_PAGE
;
2267 return SELECT_PARTITION_PAGE
;
2272 DeletePartitionPage(PINPUT_RECORD Ir
)
2274 PDISKENTRY DiskEntry
;
2275 PPARTENTRY PartEntry
;
2281 if (PartitionList
== NULL
||
2282 PartitionList
->CurrentDisk
== NULL
||
2283 PartitionList
->CurrentPartition
== NULL
)
2285 /* FIXME: show an error dialog */
2289 DiskEntry
= PartitionList
->CurrentDisk
;
2290 PartEntry
= PartitionList
->CurrentPartition
;
2292 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2294 /* Determine partition type */
2296 if (PartEntry
->New
== TRUE
)
2298 PartType
= MUIGetString(STRING_UNFORMATTED
);
2300 else if (PartEntry
->IsPartitioned
== TRUE
)
2302 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2303 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2304 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2305 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2309 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2310 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2314 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2318 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2320 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2322 else if (IsContainerPartition(PartEntry
->PartitionType
))
2324 PartType
= MUIGetString(STRING_EXTENDED_PARTITION
);
2328 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2330 if (PartSize
>= 10737418240) /* 10 GB */
2332 PartSize
= PartSize
/ 1073741824;
2333 Unit
= MUIGetString(STRING_GB
);
2337 if (PartSize
>= 10485760) /* 10 MB */
2339 PartSize
= PartSize
/ 1048576;
2340 Unit
= MUIGetString(STRING_MB
);
2344 PartSize
= PartSize
/ 1024;
2345 Unit
= MUIGetString(STRING_KB
);
2348 if (PartType
== NULL
)
2350 CONSOLE_PrintTextXY(6, 10,
2351 MUIGetString(STRING_HDDINFOUNK2
),
2352 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2353 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2354 PartEntry
->PartitionType
,
2360 CONSOLE_PrintTextXY(6, 10,
2361 " %c%c %s %I64u %s",
2362 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2363 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2369 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2371 if (DiskSize
>= 10737418240) /* 10 GB */
2373 DiskSize
= DiskSize
/ 1073741824;
2374 Unit
= MUIGetString(STRING_GB
);
2379 DiskSize
= DiskSize
/ 1048576;
2383 Unit
= MUIGetString(STRING_MB
);
2386 if (DiskEntry
->DriverName
.Length
> 0)
2388 CONSOLE_PrintTextXY(6, 12,
2389 MUIGetString(STRING_HDINFOPARTDELETE
),
2392 DiskEntry
->DiskNumber
,
2396 &DiskEntry
->DriverName
);
2400 CONSOLE_PrintTextXY(6, 12,
2401 MUIGetString(STRING_HDDINFOUNK3
),
2404 DiskEntry
->DiskNumber
,
2412 CONSOLE_ConInKey(Ir
);
2414 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2415 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2417 if (ConfirmQuit(Ir
) == TRUE
)
2424 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2426 return SELECT_PARTITION_PAGE
;
2428 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2430 DeleteCurrentPartition(PartitionList
);
2432 return SELECT_PARTITION_PAGE
;
2436 return DELETE_PARTITION_PAGE
;
2441 SelectFileSystemPage(PINPUT_RECORD Ir
)
2443 PDISKENTRY DiskEntry
;
2444 PPARTENTRY PartEntry
;
2451 DPRINT("SelectFileSystemPage()\n");
2453 if (PartitionList
== NULL
||
2454 PartitionList
->CurrentDisk
== NULL
||
2455 PartitionList
->CurrentPartition
== NULL
)
2457 /* FIXME: show an error dialog */
2461 /* Find or set the active partition */
2462 CheckActiveBootPartition(PartitionList
);
2464 if (PartitionList
->BootDisk
== NULL
||
2465 PartitionList
->BootPartition
== NULL
)
2467 /* FIXME: show an error dialog */
2471 switch (PartitionList
->FormatState
)
2474 if (PartitionList
->CurrentPartition
!= PartitionList
->BootPartition
)
2476 PartitionList
->TempDisk
= PartitionList
->BootDisk
;
2477 PartitionList
->TempPartition
= PartitionList
->BootPartition
;
2478 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2480 PartitionList
->FormatState
= FormatSystemPartition
;
2481 DPRINT1("FormatState: Start --> FormatSystemPartition\n");
2485 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2486 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2487 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2489 PartitionList
->FormatState
= FormatInstallPartition
;
2490 DPRINT1("FormatState: Start --> FormatInstallPartition\n");
2494 case FormatSystemPartition
:
2495 PartitionList
->TempDisk
= PartitionList
->CurrentDisk
;
2496 PartitionList
->TempPartition
= PartitionList
->CurrentPartition
;
2497 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2499 PartitionList
->FormatState
= FormatInstallPartition
;
2500 DPRINT1("FormatState: FormatSystemPartition --> FormatInstallPartition\n");
2503 case FormatInstallPartition
:
2504 if (GetNextUnformattedPartition(PartitionList
,
2505 &PartitionList
->TempDisk
,
2506 &PartitionList
->TempPartition
))
2508 PartitionList
->FormatState
= FormatOtherPartition
;
2509 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2510 DPRINT1("FormatState: FormatInstallPartition --> FormatOtherPartition\n");
2514 PartitionList
->FormatState
= FormatDone
;
2515 DPRINT1("FormatState: FormatInstallPartition --> FormatDone\n");
2516 return CHECK_FILE_SYSTEM_PAGE
;
2520 case FormatOtherPartition
:
2521 if (GetNextUnformattedPartition(PartitionList
,
2522 &PartitionList
->TempDisk
,
2523 &PartitionList
->TempPartition
))
2525 PartitionList
->FormatState
= FormatOtherPartition
;
2526 PartitionList
->TempPartition
->NeedsCheck
= TRUE
;
2527 DPRINT1("FormatState: FormatOtherPartition --> FormatOtherPartition\n");
2531 PartitionList
->FormatState
= FormatDone
;
2532 DPRINT1("FormatState: FormatOtherPartition --> FormatDone\n");
2533 return CHECK_FILE_SYSTEM_PAGE
;
2538 DPRINT1("FormatState: Invalid value %ld\n", PartitionList
->FormatState
);
2539 /* FIXME: show an error dialog */
2543 DiskEntry
= PartitionList
->TempDisk
;
2544 PartEntry
= PartitionList
->TempPartition
;
2546 /* adjust disk size */
2547 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2548 if (DiskSize
>= 10737418240) /* 10 GB */
2550 DiskSize
= DiskSize
/ 1073741824;
2551 DiskUnit
= MUIGetString(STRING_GB
);
2555 DiskSize
= DiskSize
/ 1048576;
2556 DiskUnit
= MUIGetString(STRING_MB
);
2559 /* adjust partition size */
2560 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2561 if (PartSize
>= 10737418240) /* 10 GB */
2563 PartSize
= PartSize
/ 1073741824;
2564 PartUnit
= MUIGetString(STRING_GB
);
2568 PartSize
= PartSize
/ 1048576;
2569 PartUnit
= MUIGetString(STRING_MB
);
2572 /* adjust partition type */
2573 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2574 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2575 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2576 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2580 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2581 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2585 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2589 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2591 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2593 else if (PartEntry
->PartitionType
== PARTITION_ENTRY_UNUSED
)
2595 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2599 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2602 if (PartEntry
->AutoCreate
== TRUE
)
2604 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2607 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2608 PartEntry
->PartitionNumber
,
2614 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2615 DiskEntry
->DiskNumber
,
2621 &DiskEntry
->DriverName
);
2623 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2626 PartEntry
->AutoCreate
= FALSE
;
2628 else if (PartEntry
->New
== TRUE
)
2630 switch (PartitionList
->FormatState
)
2632 case FormatSystemPartition
:
2633 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART
));
2636 case FormatInstallPartition
:
2637 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2640 case FormatOtherPartition
:
2641 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDOTHERPART
));
2648 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2652 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2654 if (PartType
== NULL
)
2656 CONSOLE_PrintTextXY(8, 10,
2657 MUIGetString(STRING_HDDINFOUNK4
),
2658 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2659 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2660 PartEntry
->PartitionType
,
2666 CONSOLE_PrintTextXY(8, 10,
2668 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2669 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2675 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2676 DiskEntry
->DiskNumber
,
2682 &DiskEntry
->DriverName
);
2685 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2687 if (FileSystemList
== NULL
)
2689 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2690 if (FileSystemList
== NULL
)
2692 /* FIXME: show an error dialog */
2696 /* FIXME: Add file systems to list */
2699 DrawFileSystemList(FileSystemList
);
2701 if (RepairUpdateFlag
)
2703 return CHECK_FILE_SYSTEM_PAGE
;
2704 //return SELECT_PARTITION_PAGE;
2707 if (IsUnattendedSetup
)
2709 if (UnattendFormatPartition
)
2711 PartEntry
->FileSystem
= GetFileSystemByName(FileSystemList
,
2713 return FORMAT_PARTITION_PAGE
;
2716 return CHECK_FILE_SYSTEM_PAGE
;
2721 CONSOLE_ConInKey(Ir
);
2723 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2724 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2726 if (ConfirmQuit(Ir
) == TRUE
)
2733 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2734 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2736 return SELECT_PARTITION_PAGE
;
2738 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2739 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2741 ScrollDownFileSystemList(FileSystemList
);
2743 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2744 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2746 ScrollUpFileSystemList(FileSystemList
);
2748 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2750 if (!FileSystemList
->Selected
->FormatFunc
)
2752 return SELECT_FILE_SYSTEM_PAGE
;
2756 PartEntry
->FileSystem
= FileSystemList
->Selected
;
2757 return FORMAT_PARTITION_PAGE
;
2762 return SELECT_FILE_SYSTEM_PAGE
;
2767 FormatPartitionPage(PINPUT_RECORD Ir
)
2769 UNICODE_STRING PartitionRootPath
;
2770 WCHAR PathBuffer
[MAX_PATH
];
2771 PDISKENTRY DiskEntry
;
2772 PPARTENTRY PartEntry
;
2781 DPRINT("FormatPartitionPage()\n");
2783 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2785 if (PartitionList
== NULL
||
2786 PartitionList
->TempDisk
== NULL
||
2787 PartitionList
->TempPartition
== NULL
)
2789 /* FIXME: show an error dialog */
2793 DiskEntry
= PartitionList
->TempDisk
;
2794 PartEntry
= PartitionList
->TempPartition
;
2798 if (!IsUnattendedSetup
)
2800 CONSOLE_ConInKey(Ir
);
2803 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2804 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2806 if (ConfirmQuit(Ir
) == TRUE
)
2813 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2815 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2817 if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"FAT") == 0)
2819 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2821 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2822 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2824 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2826 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2828 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2830 /* FAT16 CHS partition (partiton size < 32MB) */
2831 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2833 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2835 /* FAT16 CHS partition (partition size < 512MB) */
2836 PartEntry
->PartitionType
= PARTITION_HUGE
;
2840 /* FAT32 CHS partition (partition size >= 512MB) */
2841 PartEntry
->PartitionType
= PARTITION_FAT32
;
2846 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2848 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2850 /* FAT16 LBA partition (partition size < 512MB) */
2851 PartEntry
->PartitionType
= PARTITION_XINT13
;
2855 /* FAT32 LBA partition (partition size >= 512MB) */
2856 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2860 DiskEntry
->Dirty
= TRUE
;
2861 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2862 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2865 else if (wcscmp(PartEntry
->FileSystem
->FileSystemName
, L
"EXT2") == 0)
2867 PartEntry
->PartitionType
= PARTITION_EXT2
;
2869 DiskEntry
->Dirty
= TRUE
;
2870 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2871 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].RewritePartition
= TRUE
;
2874 else if (!PartEntry
->FileSystem
->FormatFunc
)
2880 CONSOLE_PrintTextXY(6, 12,
2881 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2882 DiskEntry
->DiskSize
,
2883 DiskEntry
->CylinderSize
,
2884 DiskEntry
->TrackSize
);
2887 DiskEntry
= PartitionList
->TempDisk
;
2888 Entry
= DiskEntry
->PartListHead
.Flink
;
2890 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2892 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2894 if (PartEntry
->IsPartitioned
== TRUE
)
2896 CONSOLE_PrintTextXY(6, Line
,
2897 "%2u: %2u %c %12I64u %12I64u %2u %c",
2899 PartEntry
->PartitionNumber
,
2900 PartEntry
->BootIndicator
? 'A' : '-',
2901 PartEntry
->StartSector
.QuadPart
,
2902 PartEntry
->SectorCount
.QuadPart
,
2903 PartEntry
->PartitionType
,
2904 PartEntry
->Dirty
? '*' : ' ');
2908 Entry
= Entry
->Flink
;
2911 /* Restore the old entry */
2912 PartEntry
= PartitionList
->TempPartition
;
2915 if (WritePartitionsToDisk(PartitionList
) == FALSE
)
2917 DPRINT("WritePartitionsToDisk() failed\n");
2918 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2922 /* Set PartitionRootPath */
2923 swprintf(PathBuffer
,
2924 L
"\\Device\\Harddisk%lu\\Partition%lu",
2925 DiskEntry
->DiskNumber
,
2926 PartEntry
->PartitionNumber
);
2927 RtlInitUnicodeString(&PartitionRootPath
,
2929 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
2931 if (PartEntry
->FileSystem
->FormatFunc
)
2933 Status
= FormatPartition(&PartitionRootPath
,
2934 PartEntry
->FileSystem
);
2935 if (!NT_SUCCESS(Status
))
2937 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2938 MUIDisplayError(ERROR_FORMATTING_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
, PathBuffer
);
2942 PartEntry
->New
= FALSE
;
2946 CONSOLE_SetStatusText(" Done. Press any key ...");
2947 CONSOLE_ConInKey(Ir
);
2950 return SELECT_FILE_SYSTEM_PAGE
;
2954 return FORMAT_PARTITION_PAGE
;
2959 CheckFileSystemPage(PINPUT_RECORD Ir
)
2961 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2962 UNICODE_STRING PartitionRootPath
;
2963 WCHAR PathBuffer
[MAX_PATH
];
2964 CHAR Buffer
[MAX_PATH
];
2965 LPWSTR FileSystemName
= NULL
;
2966 PDISKENTRY DiskEntry
;
2967 PPARTENTRY PartEntry
;
2970 if (PartitionList
== NULL
)
2972 /* FIXME: show an error dialog */
2976 if (!GetNextUncheckedPartition(PartitionList
,
2980 return INSTALL_DIRECTORY_PAGE
;
2983 /* Set PartitionRootPath */
2984 swprintf(PathBuffer
,
2985 L
"\\Device\\Harddisk%lu\\Partition%lu",
2986 DiskEntry
->DiskNumber
,
2987 PartEntry
->PartitionNumber
);
2988 RtlInitUnicodeString(&PartitionRootPath
, PathBuffer
);
2989 DPRINT("PartitionRootPath: %wZ\n", &PartitionRootPath
);
2991 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2993 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2995 CurrentFileSystem
= PartEntry
->FileSystem
;
2996 if (CurrentFileSystem
== NULL
|| CurrentFileSystem
->FileSystemName
== NULL
)
2998 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2999 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
3000 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
3001 (PartEntry
->PartitionType
== PARTITION_XINT13
) ||
3002 (PartEntry
->PartitionType
== PARTITION_FAT32
) ||
3003 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
3005 FileSystemName
= L
"FAT";
3007 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
3009 FileSystemName
= L
"EXT2";
3011 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
3013 FileSystemName
= L
"NTFS"; /* FIXME: Not quite correct! */
3016 DPRINT("FileSystemName: %S\n", FileSystemName
);
3018 if (FileSystemName
!= NULL
)
3019 CurrentFileSystem
= GetFileSystemByName(FileSystemList
,
3023 /* HACK: Do not try to check a partition with an unknown filesytem */
3024 if (CurrentFileSystem
== NULL
)
3026 PartEntry
->NeedsCheck
= FALSE
;
3027 return CHECK_FILE_SYSTEM_PAGE
;
3030 if (CurrentFileSystem
->ChkdskFunc
== NULL
)
3033 "Setup is currently unable to check a partition formatted in %S.\n"
3035 " \x07 Press ENTER to continue Setup.\n"
3036 " \x07 Press F3 to quit Setup.",
3037 CurrentFileSystem
->FileSystemName
);
3040 MUIGetString(STRING_QUITCONTINUE
),
3041 NULL
, POPUP_WAIT_NONE
);
3045 CONSOLE_ConInKey(Ir
);
3047 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
3048 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
3050 if (ConfirmQuit(Ir
))
3053 return CHECK_FILE_SYSTEM_PAGE
;
3055 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
3057 PartEntry
->NeedsCheck
= FALSE
;
3058 return CHECK_FILE_SYSTEM_PAGE
;
3064 Status
= ChkdskPartition(&PartitionRootPath
, CurrentFileSystem
);
3065 if (!NT_SUCCESS(Status
))
3067 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
3068 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
3069 "(Status 0x%08lx).\n", Status
);
3072 MUIGetString(STRING_REBOOTCOMPUTER
),
3073 Ir
, POPUP_WAIT_ENTER
);
3078 PartEntry
->NeedsCheck
= FALSE
;
3079 return CHECK_FILE_SYSTEM_PAGE
;
3085 InstallDirectoryPage1(PWCHAR InstallDir
,
3086 PDISKENTRY DiskEntry
,
3087 PPARTENTRY PartEntry
)
3089 WCHAR PathBuffer
[MAX_PATH
];
3091 /* Create 'InstallPath' string */
3092 RtlFreeUnicodeString(&InstallPath
);
3093 RtlCreateUnicodeString(&InstallPath
,
3096 /* Create 'DestinationRootPath' string */
3097 RtlFreeUnicodeString(&DestinationRootPath
);
3098 swprintf(PathBuffer
,
3099 L
"\\Device\\Harddisk%lu\\Partition%lu",
3100 DiskEntry
->DiskNumber
,
3101 PartEntry
->PartitionNumber
);
3102 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
3103 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
3105 /* Create 'DestinationPath' string */
3106 RtlFreeUnicodeString(&DestinationPath
);
3107 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3109 if (InstallDir
[0] != L
'\\')
3110 wcscat(PathBuffer
, L
"\\");
3112 wcscat(PathBuffer
, InstallDir
);
3113 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
3115 /* Create 'DestinationArcPath' */
3116 RtlFreeUnicodeString(&DestinationArcPath
);
3117 swprintf(PathBuffer
,
3118 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
3119 DiskEntry
->BiosDiskNumber
,
3120 PartEntry
->PartitionNumber
);
3122 if (InstallDir
[0] != L
'\\')
3123 wcscat(PathBuffer
, L
"\\");
3125 wcscat(PathBuffer
, InstallDir
);
3126 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3128 return PREPARE_COPY_PAGE
;
3133 InstallDirectoryPage(PINPUT_RECORD Ir
)
3135 PDISKENTRY DiskEntry
;
3136 PPARTENTRY PartEntry
;
3137 WCHAR InstallDir
[51];
3141 /* We do not need the filsystem list any more */
3142 DestroyFileSystemList(FileSystemList
);
3143 FileSystemList
= NULL
;
3145 if (PartitionList
== NULL
||
3146 PartitionList
->CurrentDisk
== NULL
||
3147 PartitionList
->CurrentPartition
== NULL
)
3149 /* FIXME: show an error dialog */
3153 DiskEntry
= PartitionList
->CurrentDisk
;
3154 PartEntry
= PartitionList
->CurrentPartition
;
3156 if (IsUnattendedSetup
)
3157 wcscpy(InstallDir
, UnattendInstallationDirectory
);
3159 wcscpy(InstallDir
, L
"\\ReactOS");
3161 Length
= wcslen(InstallDir
);
3162 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3163 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3165 // FIXME: Check the validity of the InstallDir; however what to do
3166 // if it is invalid but we are in unattended setup? (case of somebody
3167 // specified an invalid installation directory in the unattended file).
3169 if (IsUnattendedSetup
)
3171 return InstallDirectoryPage1(InstallDir
,
3178 CONSOLE_ConInKey(Ir
);
3180 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3181 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3183 if (ConfirmQuit(Ir
) == TRUE
)
3188 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3191 * Check for the validity of the installation directory and pop up
3192 * an error if it is not the case. Then the user can fix its input.
3194 if (!IsValidPath(InstallDir
, Length
))
3196 MUIDisplayError(ERROR_DIRECTORY_NAME
, Ir
, POPUP_WAIT_ENTER
);
3197 return INSTALL_DIRECTORY_PAGE
;
3199 return InstallDirectoryPage1(InstallDir
,
3203 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3208 InstallDir
[Length
] = 0;
3209 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3212 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3216 c
= (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3217 if (iswalpha(c
) || iswdigit(c
) || c
== '.' || c
== '\\' || c
== '-' || c
== '_')
3219 InstallDir
[Length
] = c
;
3221 InstallDir
[Length
] = 0;
3222 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3228 return INSTALL_DIRECTORY_PAGE
;
3233 AddSectionToCopyQueueCab(HINF InfFile
,
3235 PWCHAR SourceCabinet
,
3236 PCUNICODE_STRING DestinationPath
,
3239 INFCONTEXT FilesContext
;
3240 INFCONTEXT DirContext
;
3242 PWCHAR FileKeyValue
;
3244 PWCHAR TargetFileName
;
3246 /* Search for the SectionName section */
3247 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3250 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3251 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3256 * Enumerate the files in the section
3257 * and add them to the file queue.
3261 /* Get source file name and target directory id */
3262 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3264 /* FIXME: Handle error! */
3265 DPRINT1("INF_GetData() failed\n");
3269 /* Get optional target file name */
3270 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3271 TargetFileName
= NULL
;
3273 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3275 /* Lookup target directory */
3276 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3278 /* FIXME: Handle error! */
3279 DPRINT1("SetupFindFirstLine() failed\n");
3283 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3285 /* FIXME: Handle error! */
3286 DPRINT1("INF_GetData() failed\n");
3290 if (!SetupQueueCopy(SetupFileQueue
,
3292 SourceRootPath
.Buffer
,
3293 SourceRootDir
.Buffer
,
3298 /* FIXME: Handle error! */
3299 DPRINT1("SetupQueueCopy() failed\n");
3301 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3308 AddSectionToCopyQueue(HINF InfFile
,
3310 PWCHAR SourceCabinet
,
3311 PCUNICODE_STRING DestinationPath
,
3314 INFCONTEXT FilesContext
;
3315 INFCONTEXT DirContext
;
3317 PWCHAR FileKeyValue
;
3319 PWCHAR TargetFileName
;
3321 WCHAR CompleteOrigDirName
[512];
3324 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3326 /* Search for the SectionName section */
3327 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3330 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3331 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3336 * Enumerate the files in the section
3337 * and add them to the file queue.
3341 /* Get source file name and target directory id */
3342 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3344 /* FIXME: Handle error! */
3345 DPRINT1("INF_GetData() failed\n");
3349 /* Get target directory id */
3350 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3352 /* FIXME: Handle error! */
3353 DPRINT1("INF_GetData() failed\n");
3357 /* Get optional target file name */
3358 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3359 TargetFileName
= NULL
;
3360 else if (!*TargetFileName
)
3361 TargetFileName
= NULL
;
3363 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3365 /* Lookup target directory */
3366 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3368 /* FIXME: Handle error! */
3369 DPRINT1("SetupFindFirstLine() failed\n");
3373 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3375 /* FIXME: Handle error! */
3376 DPRINT1("INF_GetData() failed\n");
3380 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3382 /* Installation path */
3383 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3385 else if (DirKeyValue
[0] == L
'\\')
3388 wcscpy(CompleteOrigDirName
, DirKeyValue
);
3390 else // if (DirKeyValue[0] != L'\\')
3392 /* Path relative to the installation path */
3393 wcscpy(CompleteOrigDirName
, SourceRootDir
.Buffer
);
3394 wcscat(CompleteOrigDirName
, L
"\\");
3395 wcscat(CompleteOrigDirName
, DirKeyValue
);
3398 /* Remove trailing backslash */
3399 Length
= wcslen(CompleteOrigDirName
);
3400 if ((Length
> 0) && (CompleteOrigDirName
[Length
- 1] == L
'\\'))
3402 CompleteOrigDirName
[Length
- 1] = 0;
3405 if (!SetupQueueCopy(SetupFileQueue
,
3407 SourceRootPath
.Buffer
,
3408 CompleteOrigDirName
,
3413 /* FIXME: Handle error! */
3414 DPRINT1("SetupQueueCopy() failed\n");
3416 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3423 PrepareCopyPageInfFile(HINF InfFile
,
3424 PWCHAR SourceCabinet
,
3427 WCHAR PathBuffer
[MAX_PATH
];
3428 INFCONTEXT DirContext
;
3429 PWCHAR AdditionalSectionName
= NULL
;
3434 /* Add common files */
3435 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3438 /* Add specific files depending of computer type */
3439 if (SourceCabinet
== NULL
)
3441 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3444 if (AdditionalSectionName
)
3446 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3451 /* Create directories */
3455 * - Install directories like '\reactos\test' are not handled yet.
3456 * - Copying files to DestinationRootPath should be done from within
3457 * the SystemPartitionFiles section.
3458 * At the moment we check whether we specify paths like '\foo' or '\\' for that.
3459 * For installing to DestinationPath specify just '\' .
3462 /* Get destination path */
3463 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3465 /* Remove trailing backslash */
3466 Length
= wcslen(PathBuffer
);
3467 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3469 PathBuffer
[Length
- 1] = 0;
3472 /* Create the install directory */
3473 Status
= SetupCreateDirectory(PathBuffer
);
3474 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3476 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3477 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3481 /* Search for the 'Directories' section */
3482 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3486 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3490 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3496 /* Enumerate the directory values and create the subdirectories */
3499 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3505 if ((DirKeyValue
[0] == 0) || (DirKeyValue
[0] == L
'\\' && DirKeyValue
[1] == 0))
3507 /* Installation path */
3508 DPRINT("InstallationPath: '%S'\n", DirKeyValue
);
3510 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3512 DPRINT("FullPath: '%S'\n", PathBuffer
);
3514 else if (DirKeyValue
[0] == L
'\\')
3517 DPRINT("Absolute Path: '%S'\n", DirKeyValue
);
3519 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3520 wcscat(PathBuffer
, DirKeyValue
);
3522 /* Remove trailing backslash */
3523 Length
= wcslen(PathBuffer
);
3524 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3526 PathBuffer
[Length
- 1] = 0;
3529 DPRINT("FullPath: '%S'\n", PathBuffer
);
3531 Status
= SetupCreateDirectory(PathBuffer
);
3532 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3534 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3535 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3539 else // if (DirKeyValue[0] != L'\\')
3541 /* Path relative to the installation path */
3542 DPRINT("RelativePath: '%S'\n", DirKeyValue
);
3544 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3545 wcscat(PathBuffer
, L
"\\");
3546 wcscat(PathBuffer
, DirKeyValue
);
3548 /* Remove trailing backslash */
3549 Length
= wcslen(PathBuffer
);
3550 if ((Length
> 0) && (PathBuffer
[Length
- 1] == L
'\\'))
3552 PathBuffer
[Length
- 1] = 0;
3555 DPRINT("FullPath: '%S'\n", PathBuffer
);
3557 Status
= SetupCreateDirectory(PathBuffer
);
3558 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3560 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3561 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3565 } while (SetupFindNextLine(&DirContext
, &DirContext
));
3572 PrepareCopyPage(PINPUT_RECORD Ir
)
3575 WCHAR PathBuffer
[MAX_PATH
];
3576 INFCONTEXT CabinetsContext
;
3582 MUIDisplayPage(PREPARE_COPY_PAGE
);
3584 /* Create the file queue */
3585 SetupFileQueue
= SetupOpenFileQueue();
3586 if (SetupFileQueue
== NULL
)
3588 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3592 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3597 /* Search for the 'Cabinets' section */
3598 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3600 return FILE_COPY_PAGE
;
3604 * Enumerate the directory values in the 'Cabinets'
3605 * section and parse their inf files.
3609 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3612 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3613 wcscat(PathBuffer
, L
"\\");
3614 wcscat(PathBuffer
, KeyValue
);
3617 CabinetInitialize();
3618 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3619 CabinetSetCabinetName(PathBuffer
);
3621 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3623 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3625 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3626 if (InfFileData
== NULL
)
3628 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3634 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3635 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3639 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3646 if (InfHandle
== INVALID_HANDLE_VALUE
)
3648 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3654 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3659 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3661 return FILE_COPY_PAGE
;
3667 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3670 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3672 /* Get the memory information from the system */
3673 NtQuerySystemInformation(SystemPerformanceInformation
,
3678 /* Check if this is initial setup */
3681 /* Set maximum limits to be total RAM pages */
3682 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3683 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3684 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3687 /* Set current values */
3688 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3689 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3690 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3696 FileCopyCallback(PVOID Context
,
3701 PCOPYCONTEXT CopyContext
;
3703 CopyContext
= (PCOPYCONTEXT
)Context
;
3705 switch (Notification
)
3707 case SPFILENOTIFY_STARTSUBQUEUE
:
3708 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3709 ProgressSetStepCount(CopyContext
->ProgressBar
,
3710 CopyContext
->TotalOperations
);
3711 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3714 case SPFILENOTIFY_STARTCOPY
:
3715 /* Display copy message */
3716 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3717 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3720 case SPFILENOTIFY_ENDCOPY
:
3721 CopyContext
->CompletedOperations
++;
3723 /* SYSREG checkpoint */
3724 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3725 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3727 ProgressNextStep(CopyContext
->ProgressBar
);
3728 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3738 FileCopyPage(PINPUT_RECORD Ir
)
3740 COPYCONTEXT CopyContext
;
3741 unsigned int mem_bar_width
;
3743 MUIDisplayPage(FILE_COPY_PAGE
);
3745 /* Create context for the copy process */
3746 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3747 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3748 CopyContext
.TotalOperations
= 0;
3749 CopyContext
.CompletedOperations
= 0;
3751 /* Create the progress bar as well */
3752 CopyContext
.ProgressBar
= CreateProgressBar(13,
3759 MUIGetString(STRING_SETUPCOPYINGFILES
));
3761 // fit memory bars to screen width, distribute them uniform
3762 mem_bar_width
= (xScreen
- 26) / 5;
3763 mem_bar_width
-= mem_bar_width
% 2; // make even
3764 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3765 /* Create the paged pool progress bar */
3766 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3775 /* Create the non paged pool progress bar */
3776 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3778 (xScreen
/ 2) + (mem_bar_width
/ 2),
3780 (xScreen
/ 2)- (mem_bar_width
/ 2),
3785 /* Create the global memory progress bar */
3786 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3790 xScreen
- 13 - mem_bar_width
,
3795 /* Do the file copying */
3796 SetupCommitFileQueueW(NULL
,
3801 /* If we get here, we're done, so cleanup the queue and progress bar */
3802 SetupCloseFileQueue(SetupFileQueue
);
3803 DestroyProgressBar(CopyContext
.ProgressBar
);
3804 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3805 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3806 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3808 /* Go display the next page */
3809 return REGISTRY_PAGE
;
3814 RegistryPage(PINPUT_RECORD Ir
)
3816 INFCONTEXT InfContext
;
3823 MUIDisplayPage(REGISTRY_PAGE
);
3825 if (RepairUpdateFlag
)
3827 return SUCCESS_PAGE
;
3830 if (!SetInstallPathValue(&DestinationPath
))
3832 DPRINT1("SetInstallPathValue() failed\n");
3833 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3837 /* Create the default hives */
3839 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3840 if (!NT_SUCCESS(Status
))
3842 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3843 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3847 RegInitializeRegistry();
3850 /* Update registry */
3851 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3853 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3855 DPRINT1("SetupFindFirstLine() failed\n");
3856 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3862 INF_GetDataField (&InfContext
, 0, &Action
);
3863 INF_GetDataField (&InfContext
, 1, &File
);
3864 INF_GetDataField (&InfContext
, 2, &Section
);
3866 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3871 if (!_wcsicmp (Action
, L
"AddReg"))
3875 else if (!_wcsicmp (Action
, L
"DelReg"))
3884 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3886 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3888 DPRINT1("Importing %S failed\n", File
);
3890 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3893 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3895 /* Update display registry settings */
3896 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3897 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3899 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3903 /* Set the locale */
3904 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3905 if (!ProcessLocaleRegistry(LanguageList
))
3907 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3911 /* Add keyboard layouts */
3912 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3913 if (!AddKeyboardLayouts())
3915 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3921 if (!SetGeoID(MUIGetGeoID()))
3923 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3927 if (!IsUnattendedSetup
)
3929 /* Update keyboard layout settings */
3930 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3931 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3933 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3938 /* Add codepage information to registry */
3939 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3942 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3946 /* Set the default pagefile entry */
3947 SetDefaultPagefile(DestinationDriveLetter
);
3949 /* Update the mounted devices list */
3950 SetMountedDeviceValues(PartitionList
);
3952 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3954 return BOOT_LOADER_PAGE
;
3959 BootLoaderPage(PINPUT_RECORD Ir
)
3961 UCHAR PartitionType
;
3962 BOOLEAN InstallOnFloppy
;
3964 WCHAR PathBuffer
[MAX_PATH
];
3966 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3968 RtlFreeUnicodeString(&SystemRootPath
);
3969 swprintf(PathBuffer
,
3970 L
"\\Device\\Harddisk%lu\\Partition%lu",
3971 PartitionList
->BootDisk
->DiskNumber
,
3972 PartitionList
->BootPartition
->PartitionNumber
);
3973 RtlCreateUnicodeString(&SystemRootPath
,
3975 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3977 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
3979 if (IsUnattendedSetup
)
3981 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3983 return SUCCESS_PAGE
;
3985 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3987 return BOOT_LOADER_FLOPPY_PAGE
;
3991 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3993 DPRINT("Error: active partition invalid (unused)\n");
3994 InstallOnFloppy
= TRUE
;
3996 else if (PartitionType
== 0x0A)
3998 /* OS/2 boot manager partition */
3999 DPRINT("Found OS/2 boot manager partition\n");
4000 InstallOnFloppy
= TRUE
;
4002 else if (PartitionType
== 0x83)
4004 /* Linux ext2 partition */
4005 DPRINT("Found Linux ext2 partition\n");
4006 InstallOnFloppy
= TRUE
;
4008 else if (PartitionType
== PARTITION_IFS
)
4010 /* NTFS partition */
4011 DPRINT("Found NTFS partition\n");
4012 InstallOnFloppy
= TRUE
;
4014 else if ((PartitionType
== PARTITION_FAT_12
) ||
4015 (PartitionType
== PARTITION_FAT_16
) ||
4016 (PartitionType
== PARTITION_HUGE
) ||
4017 (PartitionType
== PARTITION_XINT13
) ||
4018 (PartitionType
== PARTITION_FAT32
) ||
4019 (PartitionType
== PARTITION_FAT32_XINT13
))
4021 DPRINT("Found FAT partition\n");
4022 InstallOnFloppy
= FALSE
;
4026 /* Unknown partition */
4027 DPRINT("Unknown partition found\n");
4028 InstallOnFloppy
= TRUE
;
4031 if (InstallOnFloppy
== TRUE
)
4033 return BOOT_LOADER_FLOPPY_PAGE
;
4036 /* Unattended install on hdd? */
4037 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
4039 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4042 MUIDisplayPage(BOOT_LOADER_PAGE
);
4043 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4047 CONSOLE_ConInKey(Ir
);
4049 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4050 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
4052 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4061 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4063 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4064 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
4066 CONSOLE_NormalTextXY(8, Line
, 60, 1);
4075 CONSOLE_InvertTextXY(8, Line
, 60, 1);
4077 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4078 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4080 if (ConfirmQuit(Ir
) == TRUE
)
4085 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4089 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
4091 else if (Line
== 13)
4093 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
4095 else if (Line
== 14)
4097 return BOOT_LOADER_FLOPPY_PAGE
;
4099 else if (Line
== 15)
4101 return SUCCESS_PAGE
;
4104 return BOOT_LOADER_PAGE
;
4108 return BOOT_LOADER_PAGE
;
4113 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
4117 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
4119 // SetStatusText(" Please wait...");
4123 CONSOLE_ConInKey(Ir
);
4125 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
4126 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
4128 if (ConfirmQuit(Ir
) == TRUE
)
4133 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4135 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
4137 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
4138 return BOOT_LOADER_FLOPPY_PAGE
;
4141 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
4142 if (!NT_SUCCESS(Status
))
4144 /* Print error message */
4145 return BOOT_LOADER_FLOPPY_PAGE
;
4148 return SUCCESS_PAGE
;
4152 return BOOT_LOADER_FLOPPY_PAGE
;
4157 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
4159 UCHAR PartitionType
;
4162 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
4164 Status
= InstallVBRToPartition(&SystemRootPath
,
4166 &DestinationArcPath
,
4168 if (!NT_SUCCESS(Status
))
4170 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4174 return SUCCESS_PAGE
;
4179 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
4181 UCHAR PartitionType
;
4183 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
4184 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
4186 /* Step 1: Write the VBR */
4187 PartitionType
= PartitionList
->BootPartition
->PartitionType
;
4189 Status
= InstallVBRToPartition(&SystemRootPath
,
4191 &DestinationArcPath
,
4193 if (!NT_SUCCESS(Status
))
4195 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4199 /* Step 2: Write the MBR */
4200 swprintf(DestinationDevicePathBuffer
,
4201 L
"\\Device\\Harddisk%d\\Partition0",
4202 PartitionList
->BootDisk
->DiskNumber
);
4204 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4205 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4207 DPRINT("Install MBR bootcode: %S ==> %S\n",
4208 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4210 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4211 DestinationDevicePathBuffer
);
4212 if (!NT_SUCCESS (Status
))
4214 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4216 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4220 return SUCCESS_PAGE
;
4225 QuitPage(PINPUT_RECORD Ir
)
4227 MUIDisplayPage(QUIT_PAGE
);
4229 /* Destroy partition list */
4230 if (PartitionList
!= NULL
)
4232 DestroyPartitionList (PartitionList
);
4233 PartitionList
= NULL
;
4236 /* Destroy filesystem list */
4237 if (FileSystemList
!= NULL
)
4239 DestroyFileSystemList (FileSystemList
);
4240 FileSystemList
= NULL
;
4243 /* Destroy computer settings list */
4244 if (ComputerList
!= NULL
)
4246 DestroyGenericList(ComputerList
, TRUE
);
4247 ComputerList
= NULL
;
4250 /* Destroy display settings list */
4251 if (DisplayList
!= NULL
)
4253 DestroyGenericList(DisplayList
, TRUE
);
4257 /* Destroy keyboard settings list */
4258 if (KeyboardList
!= NULL
)
4260 DestroyGenericList(KeyboardList
, TRUE
);
4261 KeyboardList
= NULL
;
4264 /* Destroy keyboard layout list */
4265 if (LayoutList
!= NULL
)
4267 DestroyGenericList(LayoutList
, TRUE
);
4271 if (LanguageList
!= NULL
)
4273 DestroyGenericList(LanguageList
, FALSE
);
4274 LanguageList
= NULL
;
4277 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4281 CONSOLE_ConInKey(Ir
);
4283 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4292 SuccessPage(PINPUT_RECORD Ir
)
4294 MUIDisplayPage(SUCCESS_PAGE
);
4296 if (IsUnattendedSetup
)
4303 CONSOLE_ConInKey(Ir
);
4305 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4314 FlushPage(PINPUT_RECORD Ir
)
4316 MUIDisplayPage(FLUSH_PAGE
);
4322 PnpEventThread(IN LPVOID lpParameter
);
4333 NtQuerySystemTime(&Time
);
4335 Status
= RtlCreateUserThread(NtCurrentProcess(),
4345 if (!NT_SUCCESS(Status
))
4346 hPnpThread
= INVALID_HANDLE_VALUE
;
4348 if (!CONSOLE_Init())
4350 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4351 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4352 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4354 /* Raise a hard error (crash the system/BSOD) */
4355 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4359 /* Initialize global unicode strings */
4360 RtlInitUnicodeString(&SourcePath
, NULL
);
4361 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4362 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4363 RtlInitUnicodeString(&InstallPath
, NULL
);
4364 RtlInitUnicodeString(&DestinationPath
, NULL
);
4365 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4366 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4367 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4369 /* Hide the cursor */
4370 CONSOLE_SetCursorType(TRUE
, FALSE
);
4373 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4375 CONSOLE_ClearScreen();
4378 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4385 Page
= SetupStartPage(&Ir
);
4390 Page
= LanguagePage(&Ir
);
4395 Page
= LicensePage(&Ir
);
4400 Page
= IntroPage(&Ir
);
4404 case INSTALL_INTRO_PAGE
:
4405 Page
= InstallIntroPage(&Ir
);
4409 case SCSI_CONTROLLER_PAGE
:
4410 Page
= ScsiControllerPage(&Ir
);
4415 case OEM_DRIVER_PAGE
:
4416 Page
= OemDriverPage(&Ir
);
4420 case DEVICE_SETTINGS_PAGE
:
4421 Page
= DeviceSettingsPage(&Ir
);
4424 case COMPUTER_SETTINGS_PAGE
:
4425 Page
= ComputerSettingsPage(&Ir
);
4428 case DISPLAY_SETTINGS_PAGE
:
4429 Page
= DisplaySettingsPage(&Ir
);
4432 case KEYBOARD_SETTINGS_PAGE
:
4433 Page
= KeyboardSettingsPage(&Ir
);
4436 case LAYOUT_SETTINGS_PAGE
:
4437 Page
= LayoutSettingsPage(&Ir
);
4440 case SELECT_PARTITION_PAGE
:
4441 Page
= SelectPartitionPage(&Ir
);
4444 case CREATE_PRIMARY_PARTITION_PAGE
:
4445 Page
= CreatePrimaryPartitionPage(&Ir
);
4448 case CREATE_EXTENDED_PARTITION_PAGE
:
4449 Page
= CreateExtendedPartitionPage(&Ir
);
4452 case CREATE_LOGICAL_PARTITION_PAGE
:
4453 Page
= CreateLogicalPartitionPage(&Ir
);
4456 case CONFIRM_DELETE_SYSTEM_PARTITION_PAGE
:
4457 Page
= ConfirmDeleteSystemPartitionPage(&Ir
);
4460 case DELETE_PARTITION_PAGE
:
4461 Page
= DeletePartitionPage(&Ir
);
4464 case SELECT_FILE_SYSTEM_PAGE
:
4465 Page
= SelectFileSystemPage(&Ir
);
4468 case FORMAT_PARTITION_PAGE
:
4469 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4472 case CHECK_FILE_SYSTEM_PAGE
:
4473 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4476 case INSTALL_DIRECTORY_PAGE
:
4477 Page
= InstallDirectoryPage(&Ir
);
4480 case PREPARE_COPY_PAGE
:
4481 Page
= PrepareCopyPage(&Ir
);
4484 case FILE_COPY_PAGE
:
4485 Page
= FileCopyPage(&Ir
);
4489 Page
= RegistryPage(&Ir
);
4492 case BOOT_LOADER_PAGE
:
4493 Page
= BootLoaderPage(&Ir
);
4496 case BOOT_LOADER_FLOPPY_PAGE
:
4497 Page
= BootLoaderFloppyPage(&Ir
);
4500 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4501 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4504 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4505 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4509 case REPAIR_INTRO_PAGE
:
4510 Page
= RepairIntroPage(&Ir
);
4514 Page
= SuccessPage(&Ir
);
4518 Page
= FlushPage(&Ir
);
4522 Page
= QuitPage(&Ir
);
4531 if (Page
== RECOVERY_PAGE
)
4536 /* Avoid bugcheck */
4537 Time
.QuadPart
+= 50000000;
4538 NtDelayExecution(FALSE
, &Time
);
4541 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4542 NtShutdownSystem(ShutdownReboot
);
4543 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4544 NtTerminateProcess(NtCurrentProcess(), 0);
4551 NtProcessStartup(PPEB Peb
)
4553 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4555 ProcessHeap
= Peb
->ProcessHeap
;
4556 InfSetHeap(ProcessHeap
);
4559 #endif /* __REACTOS__ */