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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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)
34 /* GLOBALS ******************************************************************/
37 UNICODE_STRING SourceRootPath
;
38 UNICODE_STRING SourceRootDir
;
39 UNICODE_STRING SourcePath
;
40 BOOLEAN IsUnattendedSetup
= FALSE
;
41 LONG UnattendDestinationDiskNumber
;
42 LONG UnattendDestinationPartitionNumber
;
43 LONG UnattendMBRInstallType
= -1;
44 LONG UnattendFormatPartition
= 0;
45 LONG AutoPartition
= 0;
46 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
47 PWCHAR SelectedLanguageId
;
48 WCHAR DefaultLanguage
[20];
49 WCHAR DefaultKBLayout
[20];
50 BOOLEAN RepairUpdateFlag
= FALSE
;
51 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
53 /* LOCALS *******************************************************************/
55 static PPARTLIST PartitionList
= NULL
;
57 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
59 static UNICODE_STRING InstallPath
;
61 /* Path to the install directory */
62 static UNICODE_STRING DestinationPath
;
63 static UNICODE_STRING DestinationArcPath
;
64 static UNICODE_STRING DestinationRootPath
;
66 /* Path to the active partition (boot manager) */
67 static UNICODE_STRING SystemRootPath
;
71 static HSPFILEQ SetupFileQueue
= NULL
;
73 static BOOLEAN WarnLinuxPartitions
= TRUE
;
75 static PGENERIC_LIST ComputerList
= NULL
;
76 static PGENERIC_LIST DisplayList
= NULL
;
77 static PGENERIC_LIST KeyboardList
= NULL
;
78 static PGENERIC_LIST LayoutList
= NULL
;
79 static PGENERIC_LIST LanguageList
= NULL
;
81 /* FUNCTIONS ****************************************************************/
84 PrintString(char* fmt
,...)
88 UNICODE_STRING UnicodeString
;
89 ANSI_STRING AnsiString
;
92 vsprintf(buffer
, fmt
, ap
);
95 RtlInitAnsiString(&AnsiString
, buffer
);
96 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
97 NtDisplayString(&UnicodeString
);
98 RtlFreeUnicodeString(&UnicodeString
);
112 /* draw upper left corner */
115 FillConsoleOutputCharacterA(
122 /* draw upper edge */
125 FillConsoleOutputCharacterA(
132 /* draw upper right corner */
133 coPos
.X
= xLeft
+ Width
- 1;
135 FillConsoleOutputCharacterA(
142 /* Draw right edge, inner space and left edge */
143 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
146 FillConsoleOutputCharacterA(
154 FillConsoleOutputCharacterA(
161 coPos
.X
= xLeft
+ Width
- 1;
162 FillConsoleOutputCharacterA(
170 /* draw lower left corner */
172 coPos
.Y
= yTop
+ Height
- 1;
173 FillConsoleOutputCharacterA(
180 /* draw lower edge */
182 coPos
.Y
= yTop
+ Height
- 1;
183 FillConsoleOutputCharacterA(
190 /* draw lower right corner */
191 coPos
.X
= xLeft
+ Width
- 1;
192 coPos
.Y
= yTop
+ Height
- 1;
193 FillConsoleOutputCharacterA(
202 PopupError(PCCH Text
,
220 /* Count text lines and longest line */
227 p
= strchr(pnext
, '\n');
231 Length
= strlen(pnext
);
236 Length
= (ULONG
)(p
- pnext
);
242 if (Length
> MaxLength
)
245 if (LastLine
== TRUE
)
251 /* Check length of status line */
254 Length
= strlen(Status
);
256 if (Length
> MaxLength
)
260 Width
= MaxLength
+ 4;
266 yTop
= (yScreen
- Height
) / 2;
267 xLeft
= (xScreen
- Width
) / 2;
270 /* Set screen attributes */
272 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
274 FillConsoleOutputAttribute(StdOutput
,
275 FOREGROUND_RED
| BACKGROUND_WHITE
,
281 DrawBox(xLeft
, yTop
, Width
, Height
);
283 /* Print message text */
288 p
= strchr(pnext
, '\n');
292 Length
= strlen(pnext
);
297 Length
= (ULONG
)(p
- pnext
);
304 WriteConsoleOutputCharacterA(StdOutput
,
311 if (LastLine
== TRUE
)
318 /* Print separator line and status text */
321 coPos
.Y
= yTop
+ Height
- 3;
323 FillConsoleOutputCharacterA(StdOutput
,
330 FillConsoleOutputCharacterA(StdOutput
,
336 coPos
.X
= xLeft
+ Width
- 1;
337 FillConsoleOutputCharacterA(StdOutput
,
345 WriteConsoleOutputCharacterA(StdOutput
,
347 min(strlen(Status
), (SIZE_T
)Width
- 4),
352 if (WaitEvent
== POPUP_WAIT_NONE
)
357 CONSOLE_ConInKey(Ir
);
359 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
360 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
372 * FALSE: Don't quit setup.
375 ConfirmQuit(PINPUT_RECORD Ir
)
378 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
382 CONSOLE_ConInKey(Ir
);
384 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
385 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
390 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
402 CheckUnattendedSetup(VOID
)
404 WCHAR UnattendInfPath
[MAX_PATH
];
411 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
413 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
417 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
418 wcscat(UnattendInfPath
, L
"\\unattend.inf");
420 /* Load 'unattend.inf' from install media. */
421 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
426 if (UnattendInf
== INVALID_HANDLE_VALUE
)
428 DPRINT("SetupOpenInfFileW() failed\n");
432 /* Open 'Unattend' section */
433 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
435 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
436 SetupCloseInfFile(UnattendInf
);
440 /* Get pointer 'Signature' key */
441 if (!INF_GetData(&Context
, NULL
, &Value
))
443 DPRINT("INF_GetData() failed for key 'Signature'\n");
444 SetupCloseInfFile(UnattendInf
);
448 /* Check 'Signature' string */
449 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
451 DPRINT("Signature not $ReactOS$\n");
452 SetupCloseInfFile(UnattendInf
);
456 /* Check if Unattend setup is enabled */
457 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
459 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
460 SetupCloseInfFile(UnattendInf
);
464 if (!INF_GetData(&Context
, NULL
, &Value
))
466 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
467 SetupCloseInfFile(UnattendInf
);
471 if (_wcsicmp(Value
, L
"yes") != 0)
473 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
474 SetupCloseInfFile(UnattendInf
);
478 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
479 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
481 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
482 SetupCloseInfFile(UnattendInf
);
486 if (!SetupGetIntField(&Context
, 1, &IntValue
))
488 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
489 SetupCloseInfFile(UnattendInf
);
493 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
495 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
496 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
498 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
499 SetupCloseInfFile(UnattendInf
);
503 if (!SetupGetIntField(&Context
, 1, &IntValue
))
505 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
506 SetupCloseInfFile(UnattendInf
);
510 UnattendDestinationPartitionNumber
= IntValue
;
512 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
513 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
515 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
516 SetupCloseInfFile(UnattendInf
);
520 /* Get pointer 'InstallationDirectory' key */
521 if (!INF_GetData(&Context
, NULL
, &Value
))
523 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
524 SetupCloseInfFile(UnattendInf
);
528 wcscpy(UnattendInstallationDirectory
, Value
);
530 IsUnattendedSetup
= TRUE
;
532 /* Search for 'MBRInstallType' in the 'Unattend' section */
533 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
535 if (SetupGetIntField(&Context
, 1, &IntValue
))
537 UnattendMBRInstallType
= IntValue
;
541 /* Search for 'FormatPartition' in the 'Unattend' section */
542 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
544 if (SetupGetIntField(&Context
, 1, &IntValue
))
546 UnattendFormatPartition
= IntValue
;
550 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
552 if (SetupGetIntField(&Context
, 1, &IntValue
))
554 AutoPartition
= IntValue
;
558 SetupCloseInfFile(UnattendInf
);
560 DPRINT("Running unattended setup\n");
567 PGENERIC_LIST_ENTRY ListEntry
;
568 LPCWSTR pszNewLayout
;
570 pszNewLayout
= MUIDefaultKeyboardLayout();
572 if (LayoutList
== NULL
)
574 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
577 Entry
= LayoutList
->ListHead
.Flink
;
579 /* Search for default layout (if provided) */
580 if (pszNewLayout
!= NULL
)
582 while (Entry
!= &LayoutList
->ListHead
)
584 ListEntry
= CONTAINING_RECORD (Entry
, GENERIC_LIST_ENTRY
, Entry
);
586 if (!wcscmp(pszNewLayout
, ListEntry
->UserData
))
588 LayoutList
->CurrentEntry
= ListEntry
;
592 Entry
= Entry
->Flink
;
598 LanguagePage(PINPUT_RECORD Ir
)
600 /* Initialize the computer settings list */
601 if (LanguageList
== NULL
)
603 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
605 if (LanguageList
== NULL
)
607 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
612 DrawGenericList(LanguageList
,
618 MUIDisplayPage(LANGUAGE_PAGE
);
622 CONSOLE_ConInKey(Ir
);
624 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
625 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
627 #if 0 //Dynamically update user interface
628 SelectedLanguageId
= (PWCHAR
)LanguageList
->CurrentEntry
->UserData
;
629 MUIDisplayPage(LANGUAGE_PAGE
);
631 ScrollDownGenericList (LanguageList
);
633 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
634 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
637 SelectedLanguageId
= (PWCHAR
)LanguageList
->CurrentEntry
->UserData
;
638 MUIDisplayPage(LANGUAGE_PAGE
);
640 ScrollUpGenericList (LanguageList
);
642 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
643 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
645 if (ConfirmQuit(Ir
) == TRUE
)
648 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
650 SelectedLanguageId
= (PWCHAR
)LanguageList
->CurrentEntry
->UserData
;
652 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
658 SetConsoleCodePage();
662 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
665 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
676 * Number of the next page.
679 SetupStartPage(PINPUT_RECORD Ir
)
681 SYSTEM_DEVICE_INFORMATION Sdi
;
683 WCHAR FileNameBuffer
[MAX_PATH
];
689 CONSOLE_SetStatusText(" Please wait...");
692 /* Check whether a harddisk is available */
693 Status
= NtQuerySystemInformation (SystemDeviceInformation
,
695 sizeof(SYSTEM_DEVICE_INFORMATION
),
698 if (!NT_SUCCESS (Status
))
700 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
701 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
705 if (Sdi
.NumberOfDisks
== 0)
707 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
711 /* Get the source path and source root path */
712 Status
= GetSourcePaths(&SourcePath
,
716 if (!NT_SUCCESS(Status
))
718 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
719 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
725 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
726 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
727 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
731 /* Load txtsetup.sif from install media. */
732 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
733 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
735 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
740 if (SetupInf
== INVALID_HANDLE_VALUE
)
742 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
746 /* Open 'Version' section */
747 if (!SetupFindFirstLineW (SetupInf
, L
"Version", L
"Signature", &Context
))
749 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
753 /* Get pointer 'Signature' key */
754 if (!INF_GetData (&Context
, NULL
, &Value
))
756 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
760 /* Check 'Signature' string */
761 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
763 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
767 /* Start PnP thread */
768 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
770 NtResumeThread(hPnpThread
, NULL
);
771 hPnpThread
= INVALID_HANDLE_VALUE
;
774 CheckUnattendedSetup();
776 if (IsUnattendedSetup
)
779 //read options from inf
780 ComputerList
= CreateComputerTypeList(SetupInf
);
781 DisplayList
= CreateDisplayDriverList(SetupInf
);
782 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
783 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
784 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
786 return INSTALL_INTRO_PAGE
;
789 return LANGUAGE_PAGE
;
799 IntroPage(PINPUT_RECORD Ir
)
801 MUIDisplayPage(START_PAGE
);
805 CONSOLE_ConInKey(Ir
);
807 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
808 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
810 if (ConfirmQuit(Ir
) == TRUE
)
815 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
817 return INSTALL_INTRO_PAGE
;
820 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
822 return REPAIR_INTRO_PAGE
;
825 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
838 * Back to main setup page.
841 LicensePage(PINPUT_RECORD Ir
)
843 MUIDisplayPage(LICENSE_PAGE
);
847 CONSOLE_ConInKey(Ir
);
849 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
860 RepairIntroPage(PINPUT_RECORD Ir
)
862 MUIDisplayPage(REPAIR_INTRO_PAGE
);
866 CONSOLE_ConInKey(Ir
);
868 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
872 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
874 RepairUpdateFlag
= TRUE
;
875 return INSTALL_INTRO_PAGE
;
877 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
881 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
882 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
888 return REPAIR_INTRO_PAGE
;
893 InstallIntroPage(PINPUT_RECORD Ir
)
895 MUIDisplayPage(INSTALL_INTRO_PAGE
);
897 if (RepairUpdateFlag
)
899 //return SELECT_PARTITION_PAGE;
900 return DEVICE_SETTINGS_PAGE
;
903 if (IsUnattendedSetup
)
905 return SELECT_PARTITION_PAGE
;
910 CONSOLE_ConInKey(Ir
);
912 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
913 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
915 if (ConfirmQuit(Ir
) == TRUE
)
920 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
922 return DEVICE_SETTINGS_PAGE
;
923 // return SCSI_CONTROLLER_PAGE;
927 return INSTALL_INTRO_PAGE
;
933 ScsiControllerPage(PINPUT_RECORD Ir
)
935 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
937 /* FIXME: print loaded mass storage driver descriptions */
939 SetTextXY(8, 10, "TEST device");
943 SetStatusText(" ENTER = Continue F3 = Quit");
949 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
950 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
952 if (ConfirmQuit(Ir
) == TRUE
)
957 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
959 return DEVICE_SETTINGS_PAGE
;
963 return SCSI_CONTROLLER_PAGE
;
969 DeviceSettingsPage(PINPUT_RECORD Ir
)
971 static ULONG Line
= 16;
972 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
974 /* Initialize the computer settings list */
975 if (ComputerList
== NULL
)
977 ComputerList
= CreateComputerTypeList(SetupInf
);
978 if (ComputerList
== NULL
)
980 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
985 /* Initialize the display settings list */
986 if (DisplayList
== NULL
)
988 DisplayList
= CreateDisplayDriverList(SetupInf
);
989 if (DisplayList
== NULL
)
991 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
996 /* Initialize the keyboard settings list */
997 if (KeyboardList
== NULL
)
999 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1000 if (KeyboardList
== NULL
)
1002 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1007 /* Initialize the keyboard layout list */
1008 if (LayoutList
== NULL
)
1010 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1011 if (LayoutList
== NULL
)
1013 /* FIXME: report error */
1014 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1019 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1022 CONSOLE_SetTextXY(25, 11, GetGenericListEntry(ComputerList
)->Text
);
1023 CONSOLE_SetTextXY(25, 12, GetGenericListEntry(DisplayList
)->Text
);
1024 CONSOLE_SetTextXY(25, 13, GetGenericListEntry(KeyboardList
)->Text
);
1025 CONSOLE_SetTextXY(25, 14, GetGenericListEntry(LayoutList
)->Text
);
1027 CONSOLE_InvertTextXY (24, Line
, 48, 1);
1029 if (RepairUpdateFlag
)
1031 return SELECT_PARTITION_PAGE
;
1036 CONSOLE_ConInKey(Ir
);
1038 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1039 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1041 CONSOLE_NormalTextXY (24, Line
, 48, 1);
1045 else if (Line
== 16)
1050 CONSOLE_InvertTextXY (24, Line
, 48, 1);
1052 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1053 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1055 CONSOLE_NormalTextXY (24, Line
, 48, 1);
1059 else if (Line
== 16)
1064 CONSOLE_InvertTextXY (24, Line
, 48, 1);
1066 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1067 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1069 if (ConfirmQuit(Ir
) == TRUE
)
1074 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1077 return COMPUTER_SETTINGS_PAGE
;
1078 else if (Line
== 12)
1079 return DISPLAY_SETTINGS_PAGE
;
1080 else if (Line
== 13)
1081 return KEYBOARD_SETTINGS_PAGE
;
1082 else if (Line
== 14)
1083 return LAYOUT_SETTINGS_PAGE
;
1084 else if (Line
== 16)
1085 return SELECT_PARTITION_PAGE
;
1089 return DEVICE_SETTINGS_PAGE
;
1094 ComputerSettingsPage(PINPUT_RECORD Ir
)
1096 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1098 DrawGenericList(ComputerList
,
1104 SaveGenericListState(ComputerList
);
1108 CONSOLE_ConInKey(Ir
);
1110 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1111 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1113 ScrollDownGenericList (ComputerList
);
1115 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1116 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1118 ScrollUpGenericList (ComputerList
);
1120 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1121 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1123 if (ConfirmQuit(Ir
) == TRUE
)
1128 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1129 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1131 RestoreGenericListState(ComputerList
);
1132 return DEVICE_SETTINGS_PAGE
;
1134 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1136 return DEVICE_SETTINGS_PAGE
;
1140 return COMPUTER_SETTINGS_PAGE
;
1145 DisplaySettingsPage(PINPUT_RECORD Ir
)
1147 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1149 DrawGenericList(DisplayList
,
1155 SaveGenericListState(DisplayList
);
1159 CONSOLE_ConInKey(Ir
);
1161 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1162 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1164 ScrollDownGenericList (DisplayList
);
1166 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1167 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1169 ScrollUpGenericList (DisplayList
);
1171 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1172 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1174 if (ConfirmQuit(Ir
) == TRUE
)
1181 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1182 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1184 RestoreGenericListState(DisplayList
);
1185 return DEVICE_SETTINGS_PAGE
;
1187 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1189 return DEVICE_SETTINGS_PAGE
;
1193 return DISPLAY_SETTINGS_PAGE
;
1198 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1200 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1202 DrawGenericList(KeyboardList
,
1208 SaveGenericListState(KeyboardList
);
1212 CONSOLE_ConInKey(Ir
);
1214 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1215 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1217 ScrollDownGenericList (KeyboardList
);
1219 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1220 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1222 ScrollUpGenericList (KeyboardList
);
1224 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1225 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1227 if (ConfirmQuit(Ir
) == TRUE
)
1232 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1233 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1235 RestoreGenericListState(KeyboardList
);
1236 return DEVICE_SETTINGS_PAGE
;
1238 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1240 return DEVICE_SETTINGS_PAGE
;
1244 return DISPLAY_SETTINGS_PAGE
;
1249 LayoutSettingsPage(PINPUT_RECORD Ir
)
1251 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1253 DrawGenericList(LayoutList
,
1259 SaveGenericListState(LayoutList
);
1263 CONSOLE_ConInKey(Ir
);
1265 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1266 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1268 ScrollDownGenericList (LayoutList
);
1270 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1271 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1273 ScrollUpGenericList (LayoutList
);
1275 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1276 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1278 if (ConfirmQuit(Ir
) == TRUE
)
1283 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1284 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1286 RestoreGenericListState(LayoutList
);
1287 return DEVICE_SETTINGS_PAGE
;
1289 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1291 return DEVICE_SETTINGS_PAGE
;
1295 return DISPLAY_SETTINGS_PAGE
;
1300 SelectPartitionPage(PINPUT_RECORD Ir
)
1302 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1304 if (PartitionList
== NULL
)
1306 PartitionList
= CreatePartitionList (2,
1311 if (PartitionList
== NULL
)
1313 /* FIXME: show an error dialog */
1318 CheckActiveBootPartition (PartitionList
);
1320 DrawPartitionList (PartitionList
);
1322 /* Warn about partitions created by Linux Fdisk */
1323 if (WarnLinuxPartitions
== TRUE
&&
1324 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1326 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1330 CONSOLE_ConInKey (Ir
);
1332 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1333 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1337 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1339 WarnLinuxPartitions
= FALSE
;
1340 return SELECT_PARTITION_PAGE
;
1345 if (IsUnattendedSetup
)
1347 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1351 PPARTENTRY PartEntry
= PartEntry
= PartitionList
->CurrentPartition
;
1352 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1354 CreateNewPartition(PartitionList
,
1358 return (SELECT_FILE_SYSTEM_PAGE
);
1363 return(SELECT_FILE_SYSTEM_PAGE
);
1369 /* Update status text */
1370 if (PartitionList
->CurrentPartition
== NULL
||
1371 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1373 CONSOLE_SetStatusText (" ENTER = Install C = Create Partition F3 = Quit");
1377 CONSOLE_SetStatusText (" ENTER = Install D = Delete Partition F3 = Quit");
1380 CONSOLE_ConInKey(Ir
);
1382 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1383 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1385 if (ConfirmQuit(Ir
) == TRUE
)
1387 DestroyPartitionList (PartitionList
);
1388 PartitionList
= NULL
;
1394 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1395 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1397 ScrollDownPartitionList (PartitionList
);
1399 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1400 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1402 ScrollUpPartitionList (PartitionList
);
1404 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1406 if (PartitionList
->CurrentPartition
== NULL
||
1407 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1409 CreateNewPartition (PartitionList
,
1414 return SELECT_FILE_SYSTEM_PAGE
;
1416 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1418 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1420 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1421 return SELECT_PARTITION_PAGE
;
1424 return CREATE_PARTITION_PAGE
;
1426 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1428 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1430 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1431 return SELECT_PARTITION_PAGE
;
1434 return DELETE_PARTITION_PAGE
;
1438 return SELECT_PARTITION_PAGE
;
1443 DrawInputField(ULONG FieldLength
,
1454 memset(buf
, '_', sizeof(buf
));
1455 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1456 strcat(buf
, FieldContent
);
1458 WriteConsoleOutputCharacterA (StdOutput
,
1466 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1469 ShowPartitionSizeInputBox(SHORT Left
,
1493 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1498 strcpy (Buffer
, "Size of new partition:");
1499 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
1502 WriteConsoleOutputCharacterA(StdOutput
,
1508 sprintf (Buffer
, "MB (max. %lu MB)", MaxSize
);
1509 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1511 WriteConsoleOutputCharacterA(StdOutput
,
1517 sprintf(Buffer
, "%lu", MaxSize
);
1518 Index
= strlen(Buffer
);
1519 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1526 CONSOLE_ConInKey (&Ir
);
1528 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1529 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1537 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1541 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1549 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1555 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1560 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1561 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1563 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1565 if ((ch
>= '0') && (ch
<= '9'))
1571 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1579 strcpy (InputBuffer
, Buffer
);
1584 CreatePartitionPage (PINPUT_RECORD Ir
)
1586 PDISKENTRY DiskEntry
;
1587 PPARTENTRY PartEntry
;
1590 CHAR InputBuffer
[50];
1596 if (PartitionList
== NULL
||
1597 PartitionList
->CurrentDisk
== NULL
||
1598 PartitionList
->CurrentPartition
== NULL
)
1600 /* FIXME: show an error dialog */
1604 DiskEntry
= PartitionList
->CurrentDisk
;
1605 PartEntry
= PartitionList
->CurrentPartition
;
1607 CONSOLE_SetStatusText (" Please wait...");
1609 CONSOLE_SetTextXY (6, 8, "You have chosen to create a new partition on");
1612 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1614 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1620 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1628 if (DiskEntry
->DriverName
.Length
> 0)
1630 CONSOLE_PrintTextXY (6, 10,
1631 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1634 DiskEntry
->DiskNumber
,
1638 &DiskEntry
->DriverName
);
1642 CONSOLE_PrintTextXY (6, 10,
1643 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1646 DiskEntry
->DiskNumber
,
1652 CONSOLE_SetTextXY (6, 12, "Please enter the size of the new partition in megabytes.");
1655 CONSOLE_PrintTextXY (8, 10, "Maximum size of the new partition is %I64u MB",
1656 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1659 CONSOLE_SetStatusText (" ENTER = Create Partition ESC = Cancel F3 = Quit");
1661 PartEntry
= PartitionList
->CurrentPartition
;
1664 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1665 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1666 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1670 if (ConfirmQuit (Ir
) == TRUE
)
1675 else if (Cancel
== TRUE
)
1677 return SELECT_PARTITION_PAGE
;
1681 PartSize
= atoi(InputBuffer
);
1689 if (PartSize
> MaxSize
)
1695 /* Convert to bytes */
1696 if (PartSize
== MaxSize
)
1698 /* Use all of the unpartitioned disk space */
1699 PartSize
= PartEntry
->UnpartitionedLength
;
1703 /* Round-up by cylinder size */
1704 PartSize
= ROUND_UP (PartSize
* 1024 * 1024,
1705 DiskEntry
->CylinderSize
);
1707 /* But never get larger than the unpartitioned disk space */
1708 if (PartSize
> PartEntry
->UnpartitionedLength
)
1709 PartSize
= PartEntry
->UnpartitionedLength
;
1712 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1714 CreateNewPartition (PartitionList
,
1718 return SELECT_PARTITION_PAGE
;
1722 return CREATE_PARTITION_PAGE
;
1727 DeletePartitionPage (PINPUT_RECORD Ir
)
1729 PDISKENTRY DiskEntry
;
1730 PPARTENTRY PartEntry
;
1736 if (PartitionList
== NULL
||
1737 PartitionList
->CurrentDisk
== NULL
||
1738 PartitionList
->CurrentPartition
== NULL
)
1740 /* FIXME: show an error dialog */
1744 DiskEntry
= PartitionList
->CurrentDisk
;
1745 PartEntry
= PartitionList
->CurrentPartition
;
1747 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1749 /* Determine partition type */
1751 if (PartEntry
->New
== TRUE
)
1753 PartType
= "New (Unformatted)";
1755 else if (PartEntry
->Unpartitioned
== FALSE
)
1757 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1758 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1759 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1760 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1764 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1765 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1769 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1771 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1776 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1778 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1783 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1785 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1790 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1794 if (PartType
== NULL
)
1796 CONSOLE_PrintTextXY (6, 10,
1797 " %c%c Type %lu %I64u %s",
1798 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1799 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1800 PartEntry
->PartInfo
[0].PartitionType
,
1806 CONSOLE_PrintTextXY (6, 10,
1807 " %c%c %s %I64u %s",
1808 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1809 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1816 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1818 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1824 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1832 if (DiskEntry
->DriverName
.Length
> 0)
1834 CONSOLE_PrintTextXY (6, 12,
1835 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1838 DiskEntry
->DiskNumber
,
1842 &DiskEntry
->DriverName
);
1846 CONSOLE_PrintTextXY (6, 12,
1847 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1850 DiskEntry
->DiskNumber
,
1858 CONSOLE_ConInKey (Ir
);
1860 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1861 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1863 if (ConfirmQuit (Ir
) == TRUE
)
1870 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1872 return SELECT_PARTITION_PAGE
;
1874 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1876 DeleteCurrentPartition (PartitionList
);
1878 return SELECT_PARTITION_PAGE
;
1882 return DELETE_PARTITION_PAGE
;
1887 SelectFileSystemPage (PINPUT_RECORD Ir
)
1889 PDISKENTRY DiskEntry
;
1890 PPARTENTRY PartEntry
;
1897 if (PartitionList
== NULL
||
1898 PartitionList
->CurrentDisk
== NULL
||
1899 PartitionList
->CurrentPartition
== NULL
)
1901 /* FIXME: show an error dialog */
1905 DiskEntry
= PartitionList
->CurrentDisk
;
1906 PartEntry
= PartitionList
->CurrentPartition
;
1908 /* adjust disk size */
1909 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1911 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1916 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1920 /* adjust partition size */
1921 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1923 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1928 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1932 /* adjust partition type */
1933 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1934 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1935 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1936 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1940 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1941 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1945 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1947 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1949 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
1951 PartType
= "Unused";
1955 PartType
= "Unknown";
1958 if (PartEntry
->AutoCreate
== TRUE
)
1960 CONSOLE_SetTextXY(6, 8, "Setup created a new partition on");
1963 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
1964 PartEntry
->PartInfo
[0].PartitionNumber
,
1970 CONSOLE_PrintTextXY(8, 10, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
1971 DiskEntry
->DiskNumber
,
1977 &DiskEntry
->DriverName
);
1979 CONSOLE_SetTextXY(6, 12, "This Partition will be formatted next.");
1982 PartEntry
->AutoCreate
= FALSE
;
1984 else if (PartEntry
->New
== TRUE
)
1986 CONSOLE_SetTextXY(6, 8, "You chose to install ReactOS on a new or unformatted Partition.");
1987 CONSOLE_SetTextXY(6, 10, "This Partition will be formatted next.");
1991 CONSOLE_SetTextXY(6, 8, "Setup install ReactOS onto Partition");
1993 if (PartType
== NULL
)
1995 CONSOLE_PrintTextXY (8, 10,
1996 "%c%c Type %lu %I64u %s",
1997 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1998 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1999 PartEntry
->PartInfo
[0].PartitionType
,
2005 CONSOLE_PrintTextXY (8, 10,
2007 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2008 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2014 CONSOLE_PrintTextXY(6, 12, "on Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
2015 DiskEntry
->DiskNumber
,
2021 &DiskEntry
->DriverName
);
2024 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2026 if (FileSystemList
== NULL
)
2028 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, L
"FAT");
2029 if (FileSystemList
== NULL
)
2031 /* FIXME: show an error dialog */
2035 /* FIXME: Add file systems to list */
2037 DrawFileSystemList (FileSystemList
);
2039 if (RepairUpdateFlag
)
2041 return CHECK_FILE_SYSTEM_PAGE
;
2042 //return SELECT_PARTITION_PAGE;
2045 if (IsUnattendedSetup
)
2047 if (UnattendFormatPartition
)
2049 return FORMAT_PARTITION_PAGE
;
2052 return(CHECK_FILE_SYSTEM_PAGE
);
2057 CONSOLE_ConInKey (Ir
);
2059 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2060 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2062 if (ConfirmQuit (Ir
) == TRUE
)
2069 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2070 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2072 return SELECT_PARTITION_PAGE
;
2074 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2075 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2077 ScrollDownFileSystemList (FileSystemList
);
2079 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2080 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2082 ScrollUpFileSystemList (FileSystemList
);
2084 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2086 if (!FileSystemList
->Selected
->FormatFunc
)
2088 return CHECK_FILE_SYSTEM_PAGE
;
2092 return FORMAT_PARTITION_PAGE
;
2097 return SELECT_FILE_SYSTEM_PAGE
;
2102 FormatPartitionPage (PINPUT_RECORD Ir
)
2104 WCHAR PathBuffer
[MAX_PATH
];
2105 PDISKENTRY DiskEntry
;
2106 PPARTENTRY PartEntry
;
2115 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2117 if (PartitionList
== NULL
||
2118 PartitionList
->CurrentDisk
== NULL
||
2119 PartitionList
->CurrentPartition
== NULL
)
2121 /* FIXME: show an error dialog */
2125 DiskEntry
= PartitionList
->CurrentDisk
;
2126 PartEntry
= PartitionList
->CurrentPartition
;
2130 if (!IsUnattendedSetup
)
2132 CONSOLE_ConInKey(Ir
);
2135 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2136 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2138 if (ConfirmQuit (Ir
) == TRUE
)
2145 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2147 CONSOLE_SetStatusText (" Please wait ...");
2149 if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
2151 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2153 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2155 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2156 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_12
;
2158 else if (PartEntry
->PartInfo
[0].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2160 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2162 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2164 /* FAT16 CHS partition (partiton size < 32MB) */
2165 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_16
;
2167 else if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2169 /* FAT16 CHS partition (partition size < 512MB) */
2170 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_HUGE
;
2174 /* FAT32 CHS partition (partition size >= 512MB) */
2175 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32
;
2180 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2182 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2184 /* FAT16 LBA partition (partition size < 512MB) */
2185 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_XINT13
;
2189 /* FAT32 LBA partition (partition size >= 512MB) */
2190 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32_XINT13
;
2194 else if (!FileSystemList
->Selected
->FormatFunc
)
2198 CheckActiveBootPartition (PartitionList
);
2201 CONSOLE_PrintTextXY (6, 12,
2202 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2203 DiskEntry
->DiskSize
,
2204 DiskEntry
->CylinderSize
,
2205 DiskEntry
->TrackSize
);
2208 DiskEntry
= PartitionList
->CurrentDisk
;
2209 Entry
= DiskEntry
->PartListHead
.Flink
;
2211 while (Entry
!= &DiskEntry
->PartListHead
)
2213 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2215 if (PartEntry
->Unpartitioned
== FALSE
)
2217 for (i
= 0; i
< 4; i
++)
2219 CONSOLE_PrintTextXY (6, Line
,
2220 "%2u: %2u %c %12I64u %12I64u %2u %c",
2222 PartEntry
->PartInfo
[i
].PartitionNumber
,
2223 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2224 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2225 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2226 PartEntry
->PartInfo
[i
].PartitionType
,
2227 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2235 Entry
= Entry
->Flink
;
2238 /* Restore the old entry */
2239 PartEntry
= PartitionList
->CurrentPartition
;
2242 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
2244 DPRINT ("WritePartitionsToDisk() failed\n");
2245 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2249 /* Set DestinationRootPath */
2250 RtlFreeUnicodeString (&DestinationRootPath
);
2251 swprintf (PathBuffer
,
2252 L
"\\Device\\Harddisk%lu\\Partition%lu",
2253 PartitionList
->CurrentDisk
->DiskNumber
,
2254 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2255 RtlCreateUnicodeString (&DestinationRootPath
,
2257 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2260 /* Set SystemRootPath */
2261 RtlFreeUnicodeString (&SystemRootPath
);
2262 swprintf (PathBuffer
,
2263 L
"\\Device\\Harddisk%lu\\Partition%lu",
2264 PartitionList
->ActiveBootDisk
->DiskNumber
,
2265 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2266 RtlCreateUnicodeString (&SystemRootPath
,
2268 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
2271 if (FileSystemList
->Selected
->FormatFunc
)
2273 Status
= FormatPartition(&DestinationRootPath
, FileSystemList
->Selected
);
2274 if (!NT_SUCCESS(Status
))
2276 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2277 /* FIXME: show an error dialog */
2281 PartEntry
->New
= FALSE
;
2283 CheckActiveBootPartition(PartitionList
);
2286 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2288 /* FIXME: Install boot code. This is a hack! */
2289 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
) ||
2290 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
))
2292 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2293 wcscat(PathBuffer
, L
"\\loader\\fat32.bin");
2295 DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
2296 DestinationRootPath
.Buffer
);
2297 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2298 DestinationRootPath
.Buffer
);
2300 if (!NT_SUCCESS(Status
))
2302 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2303 /* FIXME: show an error dialog */
2304 DestroyFileSystemList(FileSystemList
);
2305 FileSystemList
= NULL
;
2311 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2312 wcscat(PathBuffer
, L
"\\loader\\fat.bin");
2314 DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer
,
2315 DestinationRootPath
.Buffer
);
2316 Status
= InstallFat16BootCodeToDisk(PathBuffer
,
2317 DestinationRootPath
.Buffer
);
2319 if (!NT_SUCCESS(Status
))
2321 DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status
);
2322 /* FIXME: show an error dialog */
2323 DestroyFileSystemList(FileSystemList
);
2324 FileSystemList
= NULL
;
2329 else if (FileSystemList
->Selected
->FormatFunc
)
2331 DestroyFileSystemList(FileSystemList
);
2332 FileSystemList
= NULL
;
2337 CONSOLE_SetStatusText (" Done. Press any key ...");
2338 CONSOLE_ConInKey(Ir
);
2341 DestroyFileSystemList(FileSystemList
);
2342 FileSystemList
= NULL
;
2343 return INSTALL_DIRECTORY_PAGE
;
2347 return FORMAT_PARTITION_PAGE
;
2352 CheckFileSystemPage(PINPUT_RECORD Ir
)
2354 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2355 WCHAR PathBuffer
[MAX_PATH
];
2356 CHAR Buffer
[MAX_PATH
];
2359 /* FIXME: code duplicated in FormatPartitionPage */
2360 /* Set DestinationRootPath */
2361 RtlFreeUnicodeString(&DestinationRootPath
);
2362 swprintf(PathBuffer
,
2363 L
"\\Device\\Harddisk%lu\\Partition%lu",
2364 PartitionList
->CurrentDisk
->DiskNumber
,
2365 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2366 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2367 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2369 /* Set SystemRootPath */
2370 RtlFreeUnicodeString(&SystemRootPath
);
2371 swprintf(PathBuffer
,
2372 L
"\\Device\\Harddisk%lu\\Partition%lu",
2373 PartitionList
->ActiveBootDisk
->DiskNumber
,
2374 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2375 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2376 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2378 CONSOLE_SetTextXY(6, 8, "Setup is now checking the selected partition.");
2380 CONSOLE_SetStatusText(" Please wait...");
2382 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2383 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2385 if (!CurrentFileSystem
->ChkdskFunc
)
2388 "Setup is currently unable to check a partition formatted in %S.\n"
2390 " \x07 Press ENTER to continue Setup.\n"
2391 " \x07 Press F3 to quit Setup.",
2392 CurrentFileSystem
->FileSystem
);
2395 "F3= Quit ENTER = Continue",
2396 NULL
, POPUP_WAIT_NONE
);
2400 CONSOLE_ConInKey(Ir
);
2402 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2403 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2405 if (ConfirmQuit(Ir
))
2408 return CHECK_FILE_SYSTEM_PAGE
;
2410 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2412 return INSTALL_DIRECTORY_PAGE
;
2418 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2419 if (!NT_SUCCESS(Status
))
2421 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2422 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2423 "(Status 0x%08lx).\n", Status
);
2426 "ENTER = Reboot computer",
2427 Ir
, POPUP_WAIT_ENTER
);
2432 return INSTALL_DIRECTORY_PAGE
;
2438 InstallDirectoryPage1(PWCHAR InstallDir
, PDISKENTRY DiskEntry
, PPARTENTRY PartEntry
)
2440 WCHAR PathBuffer
[MAX_PATH
];
2442 /* Create 'InstallPath' string */
2443 RtlFreeUnicodeString(&InstallPath
);
2444 RtlCreateUnicodeString(&InstallPath
,
2447 /* Create 'DestinationPath' string */
2448 RtlFreeUnicodeString(&DestinationPath
);
2449 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2451 if (InstallDir
[0] != L
'\\')
2452 wcscat(PathBuffer
, L
"\\");
2454 wcscat(PathBuffer
, InstallDir
);
2455 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2457 /* Create 'DestinationArcPath' */
2458 RtlFreeUnicodeString(&DestinationArcPath
);
2459 swprintf(PathBuffer
,
2460 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2461 DiskEntry
->BiosDiskNumber
,
2462 PartEntry
->PartInfo
[0].PartitionNumber
);
2464 if (InstallDir
[0] != L
'\\')
2465 wcscat(PathBuffer
, L
"\\");
2467 wcscat(PathBuffer
, InstallDir
);
2468 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2470 return(PREPARE_COPY_PAGE
);
2475 InstallDirectoryPage(PINPUT_RECORD Ir
)
2477 PDISKENTRY DiskEntry
;
2478 PPARTENTRY PartEntry
;
2479 WCHAR InstallDir
[51];
2484 if (PartitionList
== NULL
||
2485 PartitionList
->CurrentDisk
== NULL
||
2486 PartitionList
->CurrentPartition
== NULL
)
2488 /* FIXME: show an error dialog */
2492 DiskEntry
= PartitionList
->CurrentDisk
;
2493 PartEntry
= PartitionList
->CurrentPartition
;
2495 /* Search for 'DefaultPath' in the 'SetupData' section */
2496 if (!SetupFindFirstLineW (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2498 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2502 /* Read the 'DefaultPath' data */
2503 if (INF_GetData (&Context
, NULL
, &DefaultPath
))
2505 wcscpy(InstallDir
, DefaultPath
);
2509 wcscpy(InstallDir
, L
"\\ReactOS");
2512 Length
= wcslen(InstallDir
);
2513 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2514 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2516 if (IsUnattendedSetup
)
2518 return(InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2523 CONSOLE_ConInKey(Ir
);
2525 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2526 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2528 if (ConfirmQuit(Ir
) == TRUE
)
2533 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2535 return (InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2537 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2542 InstallDir
[Length
] = 0;
2543 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2546 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2550 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2552 InstallDir
[Length
] = 0;
2553 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2558 return(INSTALL_DIRECTORY_PAGE
);
2562 AddSectionToCopyQueueCab(HINF InfFile
,
2564 PWCHAR SourceCabinet
,
2565 PCUNICODE_STRING DestinationPath
,
2568 INFCONTEXT FilesContext
;
2569 INFCONTEXT DirContext
;
2571 PWCHAR FileKeyValue
;
2573 PWCHAR TargetFileName
;
2575 /* Search for the SectionName section */
2576 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2579 sprintf(Buffer
, "Setup failed to find the '%S' section\nin TXTSETUP.SIF.\n", SectionName
);
2580 PopupError(Buffer
, "ENTER = Reboot computer", Ir
, POPUP_WAIT_ENTER
);
2585 * Enumerate the files in the section
2586 * and add them to the file queue.
2590 /* Get source file name and target directory id */
2591 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2593 /* FIXME: Handle error! */
2594 DPRINT1("INF_GetData() failed\n");
2598 /* Get optional target file name */
2599 if (!INF_GetDataField (&FilesContext
, 2, &TargetFileName
))
2600 TargetFileName
= NULL
;
2602 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2604 /* Lookup target directory */
2605 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2607 /* FIXME: Handle error! */
2608 DPRINT1("SetupFindFirstLine() failed\n");
2612 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2614 /* FIXME: Handle error! */
2615 DPRINT1("INF_GetData() failed\n");
2619 if (!SetupQueueCopy(SetupFileQueue
,
2621 SourceRootPath
.Buffer
,
2622 SourceRootDir
.Buffer
,
2627 /* FIXME: Handle error! */
2628 DPRINT1("SetupQueueCopy() failed\n");
2630 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2636 AddSectionToCopyQueue(HINF InfFile
,
2638 PWCHAR SourceCabinet
,
2639 PCUNICODE_STRING DestinationPath
,
2642 INFCONTEXT FilesContext
;
2643 INFCONTEXT DirContext
;
2645 PWCHAR FileKeyValue
;
2647 PWCHAR TargetFileName
;
2650 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2652 /* Search for the SectionName section */
2653 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2656 sprintf(Buffer
, "Setup failed to find the '%S' section\nin TXTSETUP.SIF.\n", SectionName
);
2657 PopupError(Buffer
, "ENTER = Reboot computer", Ir
, POPUP_WAIT_ENTER
);
2662 * Enumerate the files in the section
2663 * and add them to the file queue.
2667 /* Get source file name and target directory id */
2668 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2670 /* FIXME: Handle error! */
2671 DPRINT1("INF_GetData() failed\n");
2675 /* Get target directory id */
2676 if (!INF_GetDataField (&FilesContext
, 13, &FileKeyValue
))
2678 /* FIXME: Handle error! */
2679 DPRINT1("INF_GetData() failed\n");
2683 /* Get optional target file name */
2684 if (!INF_GetDataField (&FilesContext
, 11, &TargetFileName
))
2685 TargetFileName
= NULL
;
2686 else if (!*TargetFileName
)
2687 TargetFileName
= NULL
;
2689 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2691 /* Lookup target directory */
2692 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2694 /* FIXME: Handle error! */
2695 DPRINT1("SetupFindFirstLine() failed\n");
2699 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2701 /* FIXME: Handle error! */
2702 DPRINT1("INF_GetData() failed\n");
2706 if (!SetupQueueCopy(SetupFileQueue
,
2708 SourceRootPath
.Buffer
,
2709 SourceRootDir
.Buffer
,
2714 /* FIXME: Handle error! */
2715 DPRINT1("SetupQueueCopy() failed\n");
2717 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2723 PrepareCopyPageInfFile(HINF InfFile
,
2724 PWCHAR SourceCabinet
,
2727 WCHAR PathBuffer
[MAX_PATH
];
2728 INFCONTEXT DirContext
;
2729 PWCHAR AdditionalSectionName
= NULL
;
2734 /* Add common files */
2735 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2738 /* Add specific files depending of computer type */
2739 if (SourceCabinet
== NULL
)
2741 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2744 if (AdditionalSectionName
)
2746 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2751 /* Create directories */
2755 * Install directories like '\reactos\test' are not handled yet.
2758 /* Get destination path */
2759 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2761 /* Remove trailing backslash */
2762 Length
= wcslen(PathBuffer
);
2763 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2765 PathBuffer
[Length
- 1] = 0;
2768 /* Create the install directory */
2769 Status
= SetupCreateDirectory(PathBuffer
);
2770 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2772 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2773 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2777 /* Search for the 'Directories' section */
2778 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2782 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2786 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2792 /* Enumerate the directory values and create the subdirectories */
2795 if (!INF_GetData (&DirContext
, NULL
, &KeyValue
))
2801 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2803 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2805 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2806 wcscat(PathBuffer
, KeyValue
);
2808 DPRINT("FullPath: '%S'\n", PathBuffer
);
2810 else if (KeyValue
[0] != L
'\\')
2812 DPRINT("RelativePath: '%S'\n", KeyValue
);
2813 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2814 wcscat(PathBuffer
, L
"\\");
2815 wcscat(PathBuffer
, KeyValue
);
2817 DPRINT("FullPath: '%S'\n", PathBuffer
);
2819 Status
= SetupCreateDirectory(PathBuffer
);
2820 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2822 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2823 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2827 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2833 PrepareCopyPage(PINPUT_RECORD Ir
)
2836 WCHAR PathBuffer
[MAX_PATH
];
2837 INFCONTEXT CabinetsContext
;
2843 MUIDisplayPage(PREPARE_COPY_PAGE
);
2845 /* Create the file queue */
2846 SetupFileQueue
= SetupOpenFileQueue();
2847 if (SetupFileQueue
== NULL
)
2849 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2853 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2858 /* Search for the 'Cabinets' section */
2859 if (!SetupFindFirstLineW (SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2861 return FILE_COPY_PAGE
;
2865 * Enumerate the directory values in the 'Cabinets'
2866 * section and parse their inf files.
2870 if (!INF_GetData (&CabinetsContext
, NULL
, &KeyValue
))
2873 wcscpy(PathBuffer
, SourcePath
.Buffer
);
2874 wcscat(PathBuffer
, L
"\\");
2875 wcscat(PathBuffer
, KeyValue
);
2878 CabinetInitialize();
2879 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
2880 CabinetSetCabinetName(PathBuffer
);
2882 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
2884 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
2886 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
2887 if (InfFileData
== NULL
)
2889 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
2895 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
2896 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
2900 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
2906 if (InfHandle
== INVALID_HANDLE_VALUE
)
2908 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
2914 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
2919 } while (SetupFindNextLine (&CabinetsContext
, &CabinetsContext
));
2921 return FILE_COPY_PAGE
;
2926 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
2929 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
2931 /* Get the memory information from the system */
2932 NtQuerySystemInformation(SystemPerformanceInformation
,
2937 /* Check if this is initial setup */
2940 /* Set maximum limits to be total RAM pages */
2941 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
2942 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
2943 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
2946 /* Set current values */
2947 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
);
2948 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.NonPagedPoolPages
);
2949 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
2951 /* Check if memory dropped below 40%! */
2952 if (CopyContext
->MemoryBars
[2]->Percent
<= 40)
2954 /* Wait a while until Mm does its thing */
2955 LARGE_INTEGER Interval
;
2956 Interval
.QuadPart
= -1 * 15 * 1000 * 100;
2957 NtDelayExecution(FALSE
, &Interval
);
2961 static UINT CALLBACK
2962 FileCopyCallback(PVOID Context
,
2967 PCOPYCONTEXT CopyContext
;
2969 CopyContext
= (PCOPYCONTEXT
)Context
;
2971 switch (Notification
)
2973 case SPFILENOTIFY_STARTSUBQUEUE
:
2974 CopyContext
->TotalOperations
= (ULONG
)Param2
;
2975 ProgressSetStepCount(CopyContext
->ProgressBar
,
2976 CopyContext
->TotalOperations
);
2977 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
2980 case SPFILENOTIFY_STARTCOPY
:
2981 /* Display copy message */
2982 CONSOLE_SetStatusText(" \xB3 Copying file: %S", (PWSTR
)Param1
);
2983 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
2986 case SPFILENOTIFY_ENDCOPY
:
2987 CopyContext
->CompletedOperations
++;
2988 ProgressNextStep(CopyContext
->ProgressBar
);
2989 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
2998 FileCopyPage(PINPUT_RECORD Ir
)
3000 COPYCONTEXT CopyContext
;
3002 MUIDisplayPage(FILE_COPY_PAGE
);
3004 /* Create context for the copy process */
3005 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3006 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3007 CopyContext
.TotalOperations
= 0;
3008 CopyContext
.CompletedOperations
= 0;
3010 /* Create the progress bar as well */
3011 CopyContext
.ProgressBar
= CreateProgressBar(13,
3018 "Setup is copying files...");
3020 /* Create the paged pool progress bar */
3021 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3030 /* Create the non paged pool progress bar */
3031 CopyContext
.MemoryBars
[1] = CreateProgressBar(28,
3040 /* Create the global memory progress bar */
3041 CopyContext
.MemoryBars
[2] = CreateProgressBar(43,
3050 /* Do the file copying */
3051 SetupCommitFileQueueW(NULL
,
3056 /* If we get here, we're done, so cleanup the queue and progress bar */
3057 SetupCloseFileQueue(SetupFileQueue
);
3058 DestroyProgressBar(CopyContext
.ProgressBar
);
3059 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3060 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3061 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3063 /* Go display the next page */
3064 return REGISTRY_PAGE
;
3068 RegistryPage(PINPUT_RECORD Ir
)
3070 INFCONTEXT InfContext
;
3077 MUIDisplayPage(REGISTRY_PAGE
);
3079 if (RepairUpdateFlag
)
3081 return SUCCESS_PAGE
;
3084 if (!SetInstallPathValue(&DestinationPath
))
3086 DPRINT("SetInstallPathValue() failed\n");
3087 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3091 /* Create the default hives */
3093 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3094 if (!NT_SUCCESS(Status
))
3096 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3097 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3101 RegInitializeRegistry();
3104 /* Update registry */
3105 CONSOLE_SetStatusText(" Updating registry hives...");
3107 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3109 DPRINT1("SetupFindFirstLine() failed\n");
3110 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3116 INF_GetDataField (&InfContext
, 0, &Action
);
3117 INF_GetDataField (&InfContext
, 1, &File
);
3118 INF_GetDataField (&InfContext
, 2, &Section
);
3120 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3122 if (!_wcsicmp (Action
, L
"AddReg"))
3126 else if (!_wcsicmp (Action
, L
"DelReg"))
3135 CONSOLE_SetStatusText(" Importing %S...", File
);
3137 if (!ImportRegistryFile(File
, Section
, Delete
))
3139 DPRINT("Importing %S failed\n", File
);
3141 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3144 } while (SetupFindNextLine (&InfContext
, &InfContext
));
3146 /* Update display registry settings */
3147 CONSOLE_SetStatusText(" Updating display registry settings...");
3148 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3150 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3154 /* Set the locale */
3155 CONSOLE_SetStatusText(" Updating locale settings...");
3156 if (!ProcessLocaleRegistry(LanguageList
))
3158 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3162 /* Update keyboard layout settings */
3163 CONSOLE_SetStatusText(" Updating keyboard layout settings...");
3164 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3166 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3170 /* Add codepage information to registry */
3171 CONSOLE_SetStatusText(" Adding codepage information to registry...");
3174 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3178 /* Update the mounted devices list */
3179 SetMountedDeviceValues(PartitionList
);
3181 CONSOLE_SetStatusText(" Done...");
3183 return BOOT_LOADER_PAGE
;
3188 BootLoaderPage(PINPUT_RECORD Ir
)
3190 UCHAR PartitionType
;
3191 BOOLEAN InstallOnFloppy
;
3194 CONSOLE_SetStatusText(" Please wait...");
3196 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3198 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3200 DPRINT("Error: active partition invalid (unused)\n");
3201 InstallOnFloppy
= TRUE
;
3203 else if (PartitionType
== 0x0A)
3205 /* OS/2 boot manager partition */
3206 DPRINT("Found OS/2 boot manager partition\n");
3207 InstallOnFloppy
= TRUE
;
3209 else if (PartitionType
== 0x83)
3211 /* Linux ext2 partition */
3212 DPRINT("Found Linux ext2 partition\n");
3213 InstallOnFloppy
= TRUE
;
3215 else if (PartitionType
== PARTITION_IFS
)
3217 /* NTFS partition */
3218 DPRINT("Found NTFS partition\n");
3219 InstallOnFloppy
= TRUE
;
3221 else if ((PartitionType
== PARTITION_FAT_12
) ||
3222 (PartitionType
== PARTITION_FAT_16
) ||
3223 (PartitionType
== PARTITION_HUGE
) ||
3224 (PartitionType
== PARTITION_XINT13
) ||
3225 (PartitionType
== PARTITION_FAT32
) ||
3226 (PartitionType
== PARTITION_FAT32_XINT13
))
3228 DPRINT("Found FAT partition\n");
3229 InstallOnFloppy
= FALSE
;
3233 /* Unknown partition */
3234 DPRINT("Unknown partition found\n");
3235 InstallOnFloppy
= TRUE
;
3238 if (InstallOnFloppy
== TRUE
)
3240 return BOOT_LOADER_FLOPPY_PAGE
;
3243 if (IsUnattendedSetup
)
3245 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3247 return SUCCESS_PAGE
;
3249 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3251 return BOOT_LOADER_FLOPPY_PAGE
;
3253 else if (UnattendMBRInstallType
== 2) /* install on hdd */
3255 return BOOT_LOADER_HARDDISK_PAGE
;
3259 MUIDisplayPage(BOOT_LOADER_PAGE
);
3260 CONSOLE_InvertTextXY (8, Line
, 60, 1);
3264 CONSOLE_ConInKey(Ir
);
3266 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3267 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3269 CONSOLE_NormalTextXY (8, Line
, 60, 1);
3272 if (Line
<12) Line
=14;
3273 if (Line
>14) Line
=12;
3275 CONSOLE_InvertTextXY (8, Line
, 60, 1);
3277 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3278 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3280 CONSOLE_NormalTextXY (8, Line
, 60, 1);
3283 if (Line
<12) Line
=14;
3284 if (Line
>14) Line
=12;
3286 CONSOLE_InvertTextXY (8, Line
, 60, 1);
3288 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3289 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3291 if (ConfirmQuit(Ir
) == TRUE
)
3296 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3300 return BOOT_LOADER_HARDDISK_PAGE
;
3302 else if (Line
== 13)
3304 return BOOT_LOADER_FLOPPY_PAGE
;
3306 else if (Line
== 14)
3308 return SUCCESS_PAGE
;;
3311 return BOOT_LOADER_PAGE
;
3315 return BOOT_LOADER_PAGE
;
3320 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3324 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3326 // SetStatusText(" Please wait...");
3330 CONSOLE_ConInKey(Ir
);
3332 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3333 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3335 if (ConfirmQuit(Ir
) == TRUE
)
3340 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3342 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3344 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3345 return BOOT_LOADER_FLOPPY_PAGE
;
3348 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3349 if (!NT_SUCCESS(Status
))
3351 /* Print error message */
3352 return BOOT_LOADER_FLOPPY_PAGE
;
3355 return SUCCESS_PAGE
;
3359 return BOOT_LOADER_FLOPPY_PAGE
;
3364 BootLoaderHarddiskPage(PINPUT_RECORD Ir
)
3366 UCHAR PartitionType
;
3369 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3370 if ((PartitionType
== PARTITION_FAT_12
) ||
3371 (PartitionType
== PARTITION_FAT_16
) ||
3372 (PartitionType
== PARTITION_HUGE
) ||
3373 (PartitionType
== PARTITION_XINT13
) ||
3374 (PartitionType
== PARTITION_FAT32
) ||
3375 (PartitionType
== PARTITION_FAT32_XINT13
))
3377 Status
= InstallFatBootcodeToPartition(&SystemRootPath
,
3379 &DestinationArcPath
,
3381 if (!NT_SUCCESS(Status
))
3383 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3387 return SUCCESS_PAGE
;
3391 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3395 return BOOT_LOADER_HARDDISK_PAGE
;
3400 QuitPage(PINPUT_RECORD Ir
)
3402 MUIDisplayPage(QUIT_PAGE
);
3404 /* Destroy partition list */
3405 if (PartitionList
!= NULL
)
3407 DestroyPartitionList (PartitionList
);
3408 PartitionList
= NULL
;
3411 /* Destroy filesystem list */
3412 if (FileSystemList
!= NULL
)
3414 DestroyFileSystemList (FileSystemList
);
3415 FileSystemList
= NULL
;
3418 /* Destroy computer settings list */
3419 if (ComputerList
!= NULL
)
3421 DestroyGenericList(ComputerList
, TRUE
);
3422 ComputerList
= NULL
;
3425 /* Destroy display settings list */
3426 if (DisplayList
!= NULL
)
3428 DestroyGenericList(DisplayList
, TRUE
);
3432 /* Destroy keyboard settings list */
3433 if (KeyboardList
!= NULL
)
3435 DestroyGenericList(KeyboardList
, TRUE
);
3436 KeyboardList
= NULL
;
3439 /* Destroy keyboard layout list */
3440 if (LayoutList
!= NULL
)
3442 DestroyGenericList(LayoutList
, TRUE
);
3446 if (LanguageList
!= NULL
)
3448 DestroyGenericList(LanguageList
, FALSE
);
3449 LanguageList
= NULL
;
3452 CONSOLE_SetStatusText(" ENTER = Reboot computer");
3456 CONSOLE_ConInKey(Ir
);
3458 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3467 SuccessPage(PINPUT_RECORD Ir
)
3469 MUIDisplayPage(SUCCESS_PAGE
);
3471 if (IsUnattendedSetup
)
3478 CONSOLE_ConInKey(Ir
);
3480 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3489 FlushPage(PINPUT_RECORD Ir
)
3491 MUIDisplayPage(FLUSH_PAGE
);
3497 PnpEventThread(IN LPVOID lpParameter
);
3507 NtQuerySystemTime(&Time
);
3509 Status
= RtlCreateUserThread(NtCurrentProcess(), NULL
, TRUE
, 0, 0, 0, PnpEventThread
, &SetupInf
, &hPnpThread
, NULL
);
3510 if (!NT_SUCCESS(Status
))
3511 hPnpThread
= INVALID_HANDLE_VALUE
;
3513 if (!CONSOLE_Init())
3515 PrintString("Unable to open the console\n\n");
3516 PrintString("The most common cause of this is using an USB keyboard\n");
3517 PrintString("USB keyboards are not fully supported yet\n");
3519 /* Raise a hard error (crash the system/BSOD) */
3520 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3524 /* Initialize global unicode strings */
3525 RtlInitUnicodeString(&SourcePath
, NULL
);
3526 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3527 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3528 RtlInitUnicodeString(&InstallPath
, NULL
);
3529 RtlInitUnicodeString(&DestinationPath
, NULL
);
3530 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3531 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3532 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3534 /* Hide the cursor */
3535 CONSOLE_SetCursorType(TRUE
, FALSE
);
3538 while (Page
!= REBOOT_PAGE
)
3540 CONSOLE_ClearScreen();
3543 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3550 Page
= SetupStartPage(&Ir
);
3555 Page
= LanguagePage(&Ir
);
3560 Page
= LicensePage(&Ir
);
3565 Page
= IntroPage(&Ir
);
3569 case INSTALL_INTRO_PAGE
:
3570 Page
= InstallIntroPage(&Ir
);
3574 case SCSI_CONTROLLER_PAGE
:
3575 Page
= ScsiControllerPage(&Ir
);
3580 case OEM_DRIVER_PAGE
:
3581 Page
= OemDriverPage(&Ir
);
3585 case DEVICE_SETTINGS_PAGE
:
3586 Page
= DeviceSettingsPage(&Ir
);
3589 case COMPUTER_SETTINGS_PAGE
:
3590 Page
= ComputerSettingsPage(&Ir
);
3593 case DISPLAY_SETTINGS_PAGE
:
3594 Page
= DisplaySettingsPage(&Ir
);
3597 case KEYBOARD_SETTINGS_PAGE
:
3598 Page
= KeyboardSettingsPage(&Ir
);
3601 case LAYOUT_SETTINGS_PAGE
:
3602 Page
= LayoutSettingsPage(&Ir
);
3605 case SELECT_PARTITION_PAGE
:
3606 Page
= SelectPartitionPage(&Ir
);
3609 case CREATE_PARTITION_PAGE
:
3610 Page
= CreatePartitionPage(&Ir
);
3613 case DELETE_PARTITION_PAGE
:
3614 Page
= DeletePartitionPage(&Ir
);
3617 case SELECT_FILE_SYSTEM_PAGE
:
3618 Page
= SelectFileSystemPage(&Ir
);
3621 case FORMAT_PARTITION_PAGE
:
3622 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3625 case CHECK_FILE_SYSTEM_PAGE
:
3626 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3629 case INSTALL_DIRECTORY_PAGE
:
3630 Page
= InstallDirectoryPage(&Ir
);
3633 case PREPARE_COPY_PAGE
:
3634 Page
= PrepareCopyPage(&Ir
);
3637 case FILE_COPY_PAGE
:
3638 Page
= FileCopyPage(&Ir
);
3642 Page
= RegistryPage(&Ir
);
3645 case BOOT_LOADER_PAGE
:
3646 Page
= BootLoaderPage(&Ir
);
3649 case BOOT_LOADER_FLOPPY_PAGE
:
3650 Page
= BootLoaderFloppyPage(&Ir
);
3653 case BOOT_LOADER_HARDDISK_PAGE
:
3654 Page
= BootLoaderHarddiskPage(&Ir
);
3658 case REPAIR_INTRO_PAGE
:
3659 Page
= RepairIntroPage(&Ir
);
3663 Page
= SuccessPage(&Ir
);
3667 Page
= FlushPage(&Ir
);
3671 Page
= QuitPage(&Ir
);
3679 /// THE FOLLOWING DPRINT IS FOR THE SYSTEM REGRESSION TOOL
3680 /// DO NOT REMOVE!!!
3681 DPRINT1("SYSREG_CHECKPOINT:USETUP_COMPLETE\n");
3685 /* Avoid bugcheck */
3686 Time
.QuadPart
+= 50000000;
3687 NtDelayExecution(FALSE
, &Time
);
3690 NtShutdownSystem(ShutdownReboot
);
3691 NtTerminateProcess(NtCurrentProcess(), 0);
3698 NtProcessStartup(PPEB Peb
)
3700 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3702 ProcessHeap
= Peb
->ProcessHeap
;
3703 INF_SetHeap(ProcessHeap
);
3706 #endif /* __REACTOS__ */