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(MUIGetString(STRING_PLEASEWAIT
));
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(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1377 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
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
, MUIGetString(STRING_PARTITIONSIZE
));
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(MUIGetString(STRING_PLEASEWAIT
));
1609 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
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 MUIGetString(STRING_HDINFOPARTCREATE
),
1634 DiskEntry
->DiskNumber
,
1638 &DiskEntry
->DriverName
);
1642 CONSOLE_PrintTextXY(6, 10,
1643 MUIGetString(STRING_HDDINFOUNK1
),
1646 DiskEntry
->DiskNumber
,
1652 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1655 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1656 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1659 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
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_EXT2
)
1773 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1775 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1780 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1782 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1787 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1789 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1794 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1798 if (PartType
== NULL
)
1800 CONSOLE_PrintTextXY(6, 10,
1801 MUIGetString(STRING_HDDINFOUNK2
),
1802 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1803 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1804 PartEntry
->PartInfo
[0].PartitionType
,
1810 CONSOLE_PrintTextXY(6, 10,
1811 " %c%c %s %I64u %s",
1812 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1813 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1820 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1822 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1828 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1836 if (DiskEntry
->DriverName
.Length
> 0)
1838 CONSOLE_PrintTextXY(6, 12,
1839 MUIGetString(STRING_HDINFOPARTDELETE
),
1842 DiskEntry
->DiskNumber
,
1846 &DiskEntry
->DriverName
);
1850 CONSOLE_PrintTextXY(6, 12,
1851 MUIGetString(STRING_HDDINFOUNK3
),
1854 DiskEntry
->DiskNumber
,
1862 CONSOLE_ConInKey(Ir
);
1864 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1865 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1867 if (ConfirmQuit (Ir
) == TRUE
)
1874 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1876 return SELECT_PARTITION_PAGE
;
1878 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1880 DeleteCurrentPartition (PartitionList
);
1882 return SELECT_PARTITION_PAGE
;
1886 return DELETE_PARTITION_PAGE
;
1891 SelectFileSystemPage (PINPUT_RECORD Ir
)
1893 PDISKENTRY DiskEntry
;
1894 PPARTENTRY PartEntry
;
1901 if (PartitionList
== NULL
||
1902 PartitionList
->CurrentDisk
== NULL
||
1903 PartitionList
->CurrentPartition
== NULL
)
1905 /* FIXME: show an error dialog */
1909 DiskEntry
= PartitionList
->CurrentDisk
;
1910 PartEntry
= PartitionList
->CurrentPartition
;
1912 /* adjust disk size */
1913 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1915 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1920 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1924 /* adjust partition size */
1925 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1927 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1932 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1936 /* adjust partition type */
1937 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1938 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1939 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1940 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1944 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1945 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1949 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_EXT2
)
1953 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1955 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1957 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
1959 PartType
= "Unused";
1963 PartType
= "Unknown";
1966 if (PartEntry
->AutoCreate
== TRUE
)
1968 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
1971 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
1972 PartEntry
->PartInfo
[0].PartitionNumber
,
1978 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
1979 DiskEntry
->DiskNumber
,
1985 &DiskEntry
->DriverName
);
1987 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
1990 PartEntry
->AutoCreate
= FALSE
;
1992 else if (PartEntry
->New
== TRUE
)
1994 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
1995 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
1999 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2001 if (PartType
== NULL
)
2003 CONSOLE_PrintTextXY(8, 10,
2004 MUIGetString(STRING_HDDINFOUNK4
),
2005 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2006 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2007 PartEntry
->PartInfo
[0].PartitionType
,
2013 CONSOLE_PrintTextXY(8, 10,
2015 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2016 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2022 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2023 DiskEntry
->DiskNumber
,
2029 &DiskEntry
->DriverName
);
2032 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2034 if (FileSystemList
== NULL
)
2036 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, L
"FAT");
2037 if (FileSystemList
== NULL
)
2039 /* FIXME: show an error dialog */
2043 /* FIXME: Add file systems to list */
2045 DrawFileSystemList (FileSystemList
);
2047 if (RepairUpdateFlag
)
2049 return CHECK_FILE_SYSTEM_PAGE
;
2050 //return SELECT_PARTITION_PAGE;
2053 if (IsUnattendedSetup
)
2055 if (UnattendFormatPartition
)
2057 return FORMAT_PARTITION_PAGE
;
2060 return(CHECK_FILE_SYSTEM_PAGE
);
2065 CONSOLE_ConInKey(Ir
);
2067 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2068 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2070 if (ConfirmQuit (Ir
) == TRUE
)
2077 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2078 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2080 return SELECT_PARTITION_PAGE
;
2082 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2083 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2085 ScrollDownFileSystemList (FileSystemList
);
2087 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2088 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2090 ScrollUpFileSystemList (FileSystemList
);
2092 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2094 if (!FileSystemList
->Selected
->FormatFunc
)
2096 return CHECK_FILE_SYSTEM_PAGE
;
2100 return FORMAT_PARTITION_PAGE
;
2105 return SELECT_FILE_SYSTEM_PAGE
;
2110 FormatPartitionPage (PINPUT_RECORD Ir
)
2112 WCHAR PathBuffer
[MAX_PATH
];
2113 PDISKENTRY DiskEntry
;
2114 PPARTENTRY PartEntry
;
2123 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2125 if (PartitionList
== NULL
||
2126 PartitionList
->CurrentDisk
== NULL
||
2127 PartitionList
->CurrentPartition
== NULL
)
2129 /* FIXME: show an error dialog */
2133 DiskEntry
= PartitionList
->CurrentDisk
;
2134 PartEntry
= PartitionList
->CurrentPartition
;
2138 if (!IsUnattendedSetup
)
2140 CONSOLE_ConInKey(Ir
);
2143 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2144 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2146 if (ConfirmQuit (Ir
) == TRUE
)
2153 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2155 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2157 if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
2159 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2161 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2163 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2164 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_12
;
2166 else if (PartEntry
->PartInfo
[0].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2168 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2170 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2172 /* FAT16 CHS partition (partiton size < 32MB) */
2173 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_16
;
2175 else if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2177 /* FAT16 CHS partition (partition size < 512MB) */
2178 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_HUGE
;
2182 /* FAT32 CHS partition (partition size >= 512MB) */
2183 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32
;
2188 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2190 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2192 /* FAT16 LBA partition (partition size < 512MB) */
2193 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_XINT13
;
2197 /* FAT32 LBA partition (partition size >= 512MB) */
2198 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32_XINT13
;
2202 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2203 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_EXT2
;
2204 else if (!FileSystemList
->Selected
->FormatFunc
)
2208 CheckActiveBootPartition (PartitionList
);
2211 CONSOLE_PrintTextXY(6, 12,
2212 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2213 DiskEntry
->DiskSize
,
2214 DiskEntry
->CylinderSize
,
2215 DiskEntry
->TrackSize
);
2218 DiskEntry
= PartitionList
->CurrentDisk
;
2219 Entry
= DiskEntry
->PartListHead
.Flink
;
2221 while (Entry
!= &DiskEntry
->PartListHead
)
2223 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2225 if (PartEntry
->Unpartitioned
== FALSE
)
2227 for (i
= 0; i
< 4; i
++)
2229 CONSOLE_PrintTextXY(6, Line
,
2230 "%2u: %2u %c %12I64u %12I64u %2u %c",
2232 PartEntry
->PartInfo
[i
].PartitionNumber
,
2233 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2234 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2235 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2236 PartEntry
->PartInfo
[i
].PartitionType
,
2237 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2245 Entry
= Entry
->Flink
;
2248 /* Restore the old entry */
2249 PartEntry
= PartitionList
->CurrentPartition
;
2252 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
2254 DPRINT ("WritePartitionsToDisk() failed\n");
2255 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2259 /* Set DestinationRootPath */
2260 RtlFreeUnicodeString (&DestinationRootPath
);
2261 swprintf (PathBuffer
,
2262 L
"\\Device\\Harddisk%lu\\Partition%lu",
2263 PartitionList
->CurrentDisk
->DiskNumber
,
2264 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2265 RtlCreateUnicodeString (&DestinationRootPath
,
2267 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2270 /* Set SystemRootPath */
2271 RtlFreeUnicodeString (&SystemRootPath
);
2272 swprintf (PathBuffer
,
2273 L
"\\Device\\Harddisk%lu\\Partition%lu",
2274 PartitionList
->ActiveBootDisk
->DiskNumber
,
2275 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2276 RtlCreateUnicodeString (&SystemRootPath
,
2278 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
2281 if (FileSystemList
->Selected
->FormatFunc
)
2283 Status
= FormatPartition(&DestinationRootPath
, FileSystemList
->Selected
);
2284 if (!NT_SUCCESS(Status
))
2286 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2287 /* FIXME: show an error dialog */
2291 PartEntry
->New
= FALSE
;
2293 CheckActiveBootPartition(PartitionList
);
2296 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2298 /* FIXME: Install boot code. This is a hack! */
2299 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
) ||
2300 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
))
2302 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2303 wcscat(PathBuffer
, L
"\\loader\\fat32.bin");
2305 DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
2306 DestinationRootPath
.Buffer
);
2307 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2308 DestinationRootPath
.Buffer
);
2310 if (!NT_SUCCESS(Status
))
2312 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2313 /* FIXME: show an error dialog */
2314 DestroyFileSystemList(FileSystemList
);
2315 FileSystemList
= NULL
;
2321 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2322 wcscat(PathBuffer
, L
"\\loader\\fat.bin");
2324 DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer
,
2325 DestinationRootPath
.Buffer
);
2326 Status
= InstallFat16BootCodeToDisk(PathBuffer
,
2327 DestinationRootPath
.Buffer
);
2329 if (!NT_SUCCESS(Status
))
2331 DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status
);
2332 /* FIXME: show an error dialog */
2333 DestroyFileSystemList(FileSystemList
);
2334 FileSystemList
= NULL
;
2339 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2341 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2342 wcscat(PathBuffer
, L
"\\loader\\ext2.bin");
2344 DPRINT("Install EXT2 bootcode: %S ==> %S\n", PathBuffer
,
2345 DestinationRootPath
.Buffer
);
2346 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2347 DestinationRootPath
.Buffer
);
2349 if (!NT_SUCCESS(Status
))
2351 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2352 /* FIXME: show an error dialog */
2353 DestroyFileSystemList(FileSystemList
);
2354 FileSystemList
= NULL
;
2358 else if (FileSystemList
->Selected
->FormatFunc
)
2360 DestroyFileSystemList(FileSystemList
);
2361 FileSystemList
= NULL
;
2366 CONSOLE_SetStatusText(" Done. Press any key ...");
2367 CONSOLE_ConInKey(Ir
);
2370 DestroyFileSystemList(FileSystemList
);
2371 FileSystemList
= NULL
;
2372 return INSTALL_DIRECTORY_PAGE
;
2376 return FORMAT_PARTITION_PAGE
;
2381 CheckFileSystemPage(PINPUT_RECORD Ir
)
2383 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2384 WCHAR PathBuffer
[MAX_PATH
];
2385 CHAR Buffer
[MAX_PATH
];
2388 /* FIXME: code duplicated in FormatPartitionPage */
2389 /* Set DestinationRootPath */
2390 RtlFreeUnicodeString(&DestinationRootPath
);
2391 swprintf(PathBuffer
,
2392 L
"\\Device\\Harddisk%lu\\Partition%lu",
2393 PartitionList
->CurrentDisk
->DiskNumber
,
2394 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2395 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2396 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2398 /* Set SystemRootPath */
2399 RtlFreeUnicodeString(&SystemRootPath
);
2400 swprintf(PathBuffer
,
2401 L
"\\Device\\Harddisk%lu\\Partition%lu",
2402 PartitionList
->ActiveBootDisk
->DiskNumber
,
2403 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2404 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2405 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2407 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2409 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2411 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2412 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2414 if (!CurrentFileSystem
->ChkdskFunc
)
2417 "Setup is currently unable to check a partition formatted in %S.\n"
2419 " \x07 Press ENTER to continue Setup.\n"
2420 " \x07 Press F3 to quit Setup.",
2421 CurrentFileSystem
->FileSystem
);
2424 MUIGetString(STRING_QUITCONTINUE
),
2425 NULL
, POPUP_WAIT_NONE
);
2429 CONSOLE_ConInKey(Ir
);
2431 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2432 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2434 if (ConfirmQuit(Ir
))
2437 return CHECK_FILE_SYSTEM_PAGE
;
2439 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2441 return INSTALL_DIRECTORY_PAGE
;
2447 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2448 if (!NT_SUCCESS(Status
))
2450 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2451 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2452 "(Status 0x%08lx).\n", Status
);
2455 MUIGetString(STRING_REBOOTCOMPUTER
),
2456 Ir
, POPUP_WAIT_ENTER
);
2461 return INSTALL_DIRECTORY_PAGE
;
2467 InstallDirectoryPage1(PWCHAR InstallDir
, PDISKENTRY DiskEntry
, PPARTENTRY PartEntry
)
2469 WCHAR PathBuffer
[MAX_PATH
];
2471 /* Create 'InstallPath' string */
2472 RtlFreeUnicodeString(&InstallPath
);
2473 RtlCreateUnicodeString(&InstallPath
,
2476 /* Create 'DestinationPath' string */
2477 RtlFreeUnicodeString(&DestinationPath
);
2478 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2480 if (InstallDir
[0] != L
'\\')
2481 wcscat(PathBuffer
, L
"\\");
2483 wcscat(PathBuffer
, InstallDir
);
2484 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2486 /* Create 'DestinationArcPath' */
2487 RtlFreeUnicodeString(&DestinationArcPath
);
2488 swprintf(PathBuffer
,
2489 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2490 DiskEntry
->BiosDiskNumber
,
2491 PartEntry
->PartInfo
[0].PartitionNumber
);
2493 if (InstallDir
[0] != L
'\\')
2494 wcscat(PathBuffer
, L
"\\");
2496 wcscat(PathBuffer
, InstallDir
);
2497 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
2499 return(PREPARE_COPY_PAGE
);
2504 InstallDirectoryPage(PINPUT_RECORD Ir
)
2506 PDISKENTRY DiskEntry
;
2507 PPARTENTRY PartEntry
;
2508 WCHAR InstallDir
[51];
2513 if (PartitionList
== NULL
||
2514 PartitionList
->CurrentDisk
== NULL
||
2515 PartitionList
->CurrentPartition
== NULL
)
2517 /* FIXME: show an error dialog */
2521 DiskEntry
= PartitionList
->CurrentDisk
;
2522 PartEntry
= PartitionList
->CurrentPartition
;
2524 /* Search for 'DefaultPath' in the 'SetupData' section */
2525 if (!SetupFindFirstLineW (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2527 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2531 /* Read the 'DefaultPath' data */
2532 if (INF_GetData (&Context
, NULL
, &DefaultPath
))
2534 wcscpy(InstallDir
, DefaultPath
);
2538 wcscpy(InstallDir
, L
"\\ReactOS");
2541 Length
= wcslen(InstallDir
);
2542 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2543 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2545 if (IsUnattendedSetup
)
2547 return(InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2552 CONSOLE_ConInKey(Ir
);
2554 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2555 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2557 if (ConfirmQuit(Ir
) == TRUE
)
2562 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2564 return (InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2566 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2571 InstallDir
[Length
] = 0;
2572 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2575 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2579 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2581 InstallDir
[Length
] = 0;
2582 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2587 return(INSTALL_DIRECTORY_PAGE
);
2591 AddSectionToCopyQueueCab(HINF InfFile
,
2593 PWCHAR SourceCabinet
,
2594 PCUNICODE_STRING DestinationPath
,
2597 INFCONTEXT FilesContext
;
2598 INFCONTEXT DirContext
;
2600 PWCHAR FileKeyValue
;
2602 PWCHAR TargetFileName
;
2604 /* Search for the SectionName section */
2605 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2608 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2609 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2614 * Enumerate the files in the section
2615 * and add them to the file queue.
2619 /* Get source file name and target directory id */
2620 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2622 /* FIXME: Handle error! */
2623 DPRINT1("INF_GetData() failed\n");
2627 /* Get optional target file name */
2628 if (!INF_GetDataField (&FilesContext
, 2, &TargetFileName
))
2629 TargetFileName
= NULL
;
2631 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2633 /* Lookup target directory */
2634 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2636 /* FIXME: Handle error! */
2637 DPRINT1("SetupFindFirstLine() failed\n");
2641 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2643 /* FIXME: Handle error! */
2644 DPRINT1("INF_GetData() failed\n");
2648 if (!SetupQueueCopy(SetupFileQueue
,
2650 SourceRootPath
.Buffer
,
2651 SourceRootDir
.Buffer
,
2656 /* FIXME: Handle error! */
2657 DPRINT1("SetupQueueCopy() failed\n");
2659 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2665 AddSectionToCopyQueue(HINF InfFile
,
2667 PWCHAR SourceCabinet
,
2668 PCUNICODE_STRING DestinationPath
,
2671 INFCONTEXT FilesContext
;
2672 INFCONTEXT DirContext
;
2674 PWCHAR FileKeyValue
;
2676 PWCHAR TargetFileName
;
2679 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2681 /* Search for the SectionName section */
2682 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2685 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
2686 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
2691 * Enumerate the files in the section
2692 * and add them to the file queue.
2696 /* Get source file name and target directory id */
2697 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2699 /* FIXME: Handle error! */
2700 DPRINT1("INF_GetData() failed\n");
2704 /* Get target directory id */
2705 if (!INF_GetDataField (&FilesContext
, 13, &FileKeyValue
))
2707 /* FIXME: Handle error! */
2708 DPRINT1("INF_GetData() failed\n");
2712 /* Get optional target file name */
2713 if (!INF_GetDataField (&FilesContext
, 11, &TargetFileName
))
2714 TargetFileName
= NULL
;
2715 else if (!*TargetFileName
)
2716 TargetFileName
= NULL
;
2718 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2720 /* Lookup target directory */
2721 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2723 /* FIXME: Handle error! */
2724 DPRINT1("SetupFindFirstLine() failed\n");
2728 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2730 /* FIXME: Handle error! */
2731 DPRINT1("INF_GetData() failed\n");
2735 if (!SetupQueueCopy(SetupFileQueue
,
2737 SourceRootPath
.Buffer
,
2738 SourceRootDir
.Buffer
,
2743 /* FIXME: Handle error! */
2744 DPRINT1("SetupQueueCopy() failed\n");
2746 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2752 PrepareCopyPageInfFile(HINF InfFile
,
2753 PWCHAR SourceCabinet
,
2756 WCHAR PathBuffer
[MAX_PATH
];
2757 INFCONTEXT DirContext
;
2758 PWCHAR AdditionalSectionName
= NULL
;
2763 /* Add common files */
2764 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2767 /* Add specific files depending of computer type */
2768 if (SourceCabinet
== NULL
)
2770 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2773 if (AdditionalSectionName
)
2775 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2780 /* Create directories */
2784 * Install directories like '\reactos\test' are not handled yet.
2787 /* Get destination path */
2788 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2790 /* Remove trailing backslash */
2791 Length
= wcslen(PathBuffer
);
2792 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2794 PathBuffer
[Length
- 1] = 0;
2797 /* Create the install directory */
2798 Status
= SetupCreateDirectory(PathBuffer
);
2799 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2801 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2802 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2806 /* Search for the 'Directories' section */
2807 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2811 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2815 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2821 /* Enumerate the directory values and create the subdirectories */
2824 if (!INF_GetData (&DirContext
, NULL
, &KeyValue
))
2830 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2832 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2834 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2835 wcscat(PathBuffer
, KeyValue
);
2837 DPRINT("FullPath: '%S'\n", PathBuffer
);
2839 else if (KeyValue
[0] != L
'\\')
2841 DPRINT("RelativePath: '%S'\n", KeyValue
);
2842 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2843 wcscat(PathBuffer
, L
"\\");
2844 wcscat(PathBuffer
, KeyValue
);
2846 DPRINT("FullPath: '%S'\n", PathBuffer
);
2848 Status
= SetupCreateDirectory(PathBuffer
);
2849 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2851 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2852 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2856 } while (SetupFindNextLine (&DirContext
, &DirContext
));
2862 PrepareCopyPage(PINPUT_RECORD Ir
)
2865 WCHAR PathBuffer
[MAX_PATH
];
2866 INFCONTEXT CabinetsContext
;
2872 MUIDisplayPage(PREPARE_COPY_PAGE
);
2874 /* Create the file queue */
2875 SetupFileQueue
= SetupOpenFileQueue();
2876 if (SetupFileQueue
== NULL
)
2878 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2882 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2887 /* Search for the 'Cabinets' section */
2888 if (!SetupFindFirstLineW (SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2890 return FILE_COPY_PAGE
;
2894 * Enumerate the directory values in the 'Cabinets'
2895 * section and parse their inf files.
2899 if (!INF_GetData (&CabinetsContext
, NULL
, &KeyValue
))
2902 wcscpy(PathBuffer
, SourcePath
.Buffer
);
2903 wcscat(PathBuffer
, L
"\\");
2904 wcscat(PathBuffer
, KeyValue
);
2907 CabinetInitialize();
2908 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
2909 CabinetSetCabinetName(PathBuffer
);
2911 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
2913 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
2915 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
2916 if (InfFileData
== NULL
)
2918 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
2924 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
2925 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
2929 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
2935 if (InfHandle
== INVALID_HANDLE_VALUE
)
2937 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
2943 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
2948 } while (SetupFindNextLine (&CabinetsContext
, &CabinetsContext
));
2950 return FILE_COPY_PAGE
;
2955 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
2958 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
2960 /* Get the memory information from the system */
2961 NtQuerySystemInformation(SystemPerformanceInformation
,
2966 /* Check if this is initial setup */
2969 /* Set maximum limits to be total RAM pages */
2970 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
2971 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
2972 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
2975 /* Set current values */
2976 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
);
2977 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.NonPagedPoolPages
);
2978 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
2980 /* Check if memory dropped below 40%! */
2981 if (CopyContext
->MemoryBars
[2]->Percent
<= 40)
2983 /* Wait a while until Mm does its thing */
2984 LARGE_INTEGER Interval
;
2985 Interval
.QuadPart
= -1 * 15 * 1000 * 100;
2986 NtDelayExecution(FALSE
, &Interval
);
2990 static UINT CALLBACK
2991 FileCopyCallback(PVOID Context
,
2996 PCOPYCONTEXT CopyContext
;
2998 CopyContext
= (PCOPYCONTEXT
)Context
;
3000 switch (Notification
)
3002 case SPFILENOTIFY_STARTSUBQUEUE
:
3003 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3004 ProgressSetStepCount(CopyContext
->ProgressBar
,
3005 CopyContext
->TotalOperations
);
3006 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3009 case SPFILENOTIFY_STARTCOPY
:
3010 /* Display copy message */
3011 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3012 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3015 case SPFILENOTIFY_ENDCOPY
:
3016 CopyContext
->CompletedOperations
++;
3017 ProgressNextStep(CopyContext
->ProgressBar
);
3018 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3027 FileCopyPage(PINPUT_RECORD Ir
)
3029 COPYCONTEXT CopyContext
;
3031 MUIDisplayPage(FILE_COPY_PAGE
);
3033 /* Create context for the copy process */
3034 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3035 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3036 CopyContext
.TotalOperations
= 0;
3037 CopyContext
.CompletedOperations
= 0;
3039 /* Create the progress bar as well */
3040 CopyContext
.ProgressBar
= CreateProgressBar(13,
3047 MUIGetString(STRING_SETUPCOPYINGFILES
));
3049 /* Create the paged pool progress bar */
3050 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3057 MUIGetString(STRING_PAGEDMEM
));
3059 /* Create the non paged pool progress bar */
3060 CopyContext
.MemoryBars
[1] = CreateProgressBar(28,
3067 MUIGetString(STRING_NONPAGEDMEM
));
3069 /* Create the global memory progress bar */
3070 CopyContext
.MemoryBars
[2] = CreateProgressBar(43,
3077 MUIGetString(STRING_FREEMEM
));
3079 /* Do the file copying */
3080 SetupCommitFileQueueW(NULL
,
3085 /* If we get here, we're done, so cleanup the queue and progress bar */
3086 SetupCloseFileQueue(SetupFileQueue
);
3087 DestroyProgressBar(CopyContext
.ProgressBar
);
3088 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3089 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3090 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3092 /* Go display the next page */
3093 return REGISTRY_PAGE
;
3097 RegistryPage(PINPUT_RECORD Ir
)
3099 INFCONTEXT InfContext
;
3106 MUIDisplayPage(REGISTRY_PAGE
);
3108 if (RepairUpdateFlag
)
3110 return SUCCESS_PAGE
;
3113 if (!SetInstallPathValue(&DestinationPath
))
3115 DPRINT("SetInstallPathValue() failed\n");
3116 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3120 /* Create the default hives */
3122 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3123 if (!NT_SUCCESS(Status
))
3125 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3126 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3130 RegInitializeRegistry();
3133 /* Update registry */
3134 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3136 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3138 DPRINT1("SetupFindFirstLine() failed\n");
3139 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3145 INF_GetDataField (&InfContext
, 0, &Action
);
3146 INF_GetDataField (&InfContext
, 1, &File
);
3147 INF_GetDataField (&InfContext
, 2, &Section
);
3149 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3151 if (!_wcsicmp (Action
, L
"AddReg"))
3155 else if (!_wcsicmp (Action
, L
"DelReg"))
3164 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3166 if (!ImportRegistryFile(File
, Section
, Delete
))
3168 DPRINT("Importing %S failed\n", File
);
3170 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3173 } while (SetupFindNextLine (&InfContext
, &InfContext
));
3175 /* Update display registry settings */
3176 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3177 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3179 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3183 /* Set the locale */
3184 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3185 if (!ProcessLocaleRegistry(LanguageList
))
3187 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3191 /* Update keyboard layout settings */
3192 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3193 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3195 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3199 /* Add codepage information to registry */
3200 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3203 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3207 /* Update the mounted devices list */
3208 SetMountedDeviceValues(PartitionList
);
3210 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3212 return BOOT_LOADER_PAGE
;
3217 BootLoaderPage(PINPUT_RECORD Ir
)
3219 UCHAR PartitionType
;
3220 BOOLEAN InstallOnFloppy
;
3223 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3225 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3227 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3229 DPRINT("Error: active partition invalid (unused)\n");
3230 InstallOnFloppy
= TRUE
;
3232 else if (PartitionType
== 0x0A)
3234 /* OS/2 boot manager partition */
3235 DPRINT("Found OS/2 boot manager partition\n");
3236 InstallOnFloppy
= TRUE
;
3238 else if (PartitionType
== 0x83)
3240 /* Linux ext2 partition */
3241 DPRINT("Found Linux ext2 partition\n");
3242 InstallOnFloppy
= TRUE
;
3244 else if (PartitionType
== PARTITION_IFS
)
3246 /* NTFS partition */
3247 DPRINT("Found NTFS partition\n");
3248 InstallOnFloppy
= TRUE
;
3250 else if ((PartitionType
== PARTITION_FAT_12
) ||
3251 (PartitionType
== PARTITION_FAT_16
) ||
3252 (PartitionType
== PARTITION_HUGE
) ||
3253 (PartitionType
== PARTITION_XINT13
) ||
3254 (PartitionType
== PARTITION_FAT32
) ||
3255 (PartitionType
== PARTITION_FAT32_XINT13
))
3257 DPRINT("Found FAT partition\n");
3258 InstallOnFloppy
= FALSE
;
3262 /* Unknown partition */
3263 DPRINT("Unknown partition found\n");
3264 InstallOnFloppy
= TRUE
;
3267 if (InstallOnFloppy
== TRUE
)
3269 return BOOT_LOADER_FLOPPY_PAGE
;
3272 if (IsUnattendedSetup
)
3274 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3276 return SUCCESS_PAGE
;
3278 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3280 return BOOT_LOADER_FLOPPY_PAGE
;
3282 else if (UnattendMBRInstallType
== 2) /* install on hdd */
3284 return BOOT_LOADER_HARDDISK_PAGE
;
3288 MUIDisplayPage(BOOT_LOADER_PAGE
);
3289 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3293 CONSOLE_ConInKey(Ir
);
3295 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3296 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3298 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3301 if (Line
<12) Line
=14;
3302 if (Line
>14) Line
=12;
3304 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3306 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3307 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3309 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3312 if (Line
<12) Line
=14;
3313 if (Line
>14) Line
=12;
3315 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3317 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3318 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3320 if (ConfirmQuit(Ir
) == TRUE
)
3325 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3329 return BOOT_LOADER_HARDDISK_PAGE
;
3331 else if (Line
== 13)
3333 return BOOT_LOADER_FLOPPY_PAGE
;
3335 else if (Line
== 14)
3337 return SUCCESS_PAGE
;;
3340 return BOOT_LOADER_PAGE
;
3344 return BOOT_LOADER_PAGE
;
3349 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3353 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3355 // SetStatusText(" Please wait...");
3359 CONSOLE_ConInKey(Ir
);
3361 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3362 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3364 if (ConfirmQuit(Ir
) == TRUE
)
3369 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3371 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3373 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3374 return BOOT_LOADER_FLOPPY_PAGE
;
3377 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3378 if (!NT_SUCCESS(Status
))
3380 /* Print error message */
3381 return BOOT_LOADER_FLOPPY_PAGE
;
3384 return SUCCESS_PAGE
;
3388 return BOOT_LOADER_FLOPPY_PAGE
;
3393 BootLoaderHarddiskPage(PINPUT_RECORD Ir
)
3395 UCHAR PartitionType
;
3398 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3399 if ((PartitionType
== PARTITION_FAT_12
) ||
3400 (PartitionType
== PARTITION_FAT_16
) ||
3401 (PartitionType
== PARTITION_HUGE
) ||
3402 (PartitionType
== PARTITION_XINT13
) ||
3403 (PartitionType
== PARTITION_FAT32
) ||
3404 (PartitionType
== PARTITION_FAT32_XINT13
))
3406 Status
= InstallFatBootcodeToPartition(&SystemRootPath
,
3408 &DestinationArcPath
,
3410 if (!NT_SUCCESS(Status
))
3412 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3416 return SUCCESS_PAGE
;
3420 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3424 return BOOT_LOADER_HARDDISK_PAGE
;
3429 QuitPage(PINPUT_RECORD Ir
)
3431 MUIDisplayPage(QUIT_PAGE
);
3433 /* Destroy partition list */
3434 if (PartitionList
!= NULL
)
3436 DestroyPartitionList (PartitionList
);
3437 PartitionList
= NULL
;
3440 /* Destroy filesystem list */
3441 if (FileSystemList
!= NULL
)
3443 DestroyFileSystemList (FileSystemList
);
3444 FileSystemList
= NULL
;
3447 /* Destroy computer settings list */
3448 if (ComputerList
!= NULL
)
3450 DestroyGenericList(ComputerList
, TRUE
);
3451 ComputerList
= NULL
;
3454 /* Destroy display settings list */
3455 if (DisplayList
!= NULL
)
3457 DestroyGenericList(DisplayList
, TRUE
);
3461 /* Destroy keyboard settings list */
3462 if (KeyboardList
!= NULL
)
3464 DestroyGenericList(KeyboardList
, TRUE
);
3465 KeyboardList
= NULL
;
3468 /* Destroy keyboard layout list */
3469 if (LayoutList
!= NULL
)
3471 DestroyGenericList(LayoutList
, TRUE
);
3475 if (LanguageList
!= NULL
)
3477 DestroyGenericList(LanguageList
, FALSE
);
3478 LanguageList
= NULL
;
3481 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
3485 CONSOLE_ConInKey(Ir
);
3487 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3496 SuccessPage(PINPUT_RECORD Ir
)
3498 MUIDisplayPage(SUCCESS_PAGE
);
3500 if (IsUnattendedSetup
)
3507 CONSOLE_ConInKey(Ir
);
3509 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3518 FlushPage(PINPUT_RECORD Ir
)
3520 MUIDisplayPage(FLUSH_PAGE
);
3526 PnpEventThread(IN LPVOID lpParameter
);
3536 NtQuerySystemTime(&Time
);
3538 Status
= RtlCreateUserThread(NtCurrentProcess(), NULL
, TRUE
, 0, 0, 0, PnpEventThread
, &SetupInf
, &hPnpThread
, NULL
);
3539 if (!NT_SUCCESS(Status
))
3540 hPnpThread
= INVALID_HANDLE_VALUE
;
3542 if (!CONSOLE_Init())
3544 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
3545 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
3546 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
3548 /* Raise a hard error (crash the system/BSOD) */
3549 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3553 /* Initialize global unicode strings */
3554 RtlInitUnicodeString(&SourcePath
, NULL
);
3555 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3556 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3557 RtlInitUnicodeString(&InstallPath
, NULL
);
3558 RtlInitUnicodeString(&DestinationPath
, NULL
);
3559 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3560 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3561 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3563 /* Hide the cursor */
3564 CONSOLE_SetCursorType(TRUE
, FALSE
);
3567 while (Page
!= REBOOT_PAGE
)
3569 CONSOLE_ClearScreen();
3572 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3579 Page
= SetupStartPage(&Ir
);
3584 Page
= LanguagePage(&Ir
);
3589 Page
= LicensePage(&Ir
);
3594 Page
= IntroPage(&Ir
);
3598 case INSTALL_INTRO_PAGE
:
3599 Page
= InstallIntroPage(&Ir
);
3603 case SCSI_CONTROLLER_PAGE
:
3604 Page
= ScsiControllerPage(&Ir
);
3609 case OEM_DRIVER_PAGE
:
3610 Page
= OemDriverPage(&Ir
);
3614 case DEVICE_SETTINGS_PAGE
:
3615 Page
= DeviceSettingsPage(&Ir
);
3618 case COMPUTER_SETTINGS_PAGE
:
3619 Page
= ComputerSettingsPage(&Ir
);
3622 case DISPLAY_SETTINGS_PAGE
:
3623 Page
= DisplaySettingsPage(&Ir
);
3626 case KEYBOARD_SETTINGS_PAGE
:
3627 Page
= KeyboardSettingsPage(&Ir
);
3630 case LAYOUT_SETTINGS_PAGE
:
3631 Page
= LayoutSettingsPage(&Ir
);
3634 case SELECT_PARTITION_PAGE
:
3635 Page
= SelectPartitionPage(&Ir
);
3638 case CREATE_PARTITION_PAGE
:
3639 Page
= CreatePartitionPage(&Ir
);
3642 case DELETE_PARTITION_PAGE
:
3643 Page
= DeletePartitionPage(&Ir
);
3646 case SELECT_FILE_SYSTEM_PAGE
:
3647 Page
= SelectFileSystemPage(&Ir
);
3650 case FORMAT_PARTITION_PAGE
:
3651 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3654 case CHECK_FILE_SYSTEM_PAGE
:
3655 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3658 case INSTALL_DIRECTORY_PAGE
:
3659 Page
= InstallDirectoryPage(&Ir
);
3662 case PREPARE_COPY_PAGE
:
3663 Page
= PrepareCopyPage(&Ir
);
3666 case FILE_COPY_PAGE
:
3667 Page
= FileCopyPage(&Ir
);
3671 Page
= RegistryPage(&Ir
);
3674 case BOOT_LOADER_PAGE
:
3675 Page
= BootLoaderPage(&Ir
);
3678 case BOOT_LOADER_FLOPPY_PAGE
:
3679 Page
= BootLoaderFloppyPage(&Ir
);
3682 case BOOT_LOADER_HARDDISK_PAGE
:
3683 Page
= BootLoaderHarddiskPage(&Ir
);
3687 case REPAIR_INTRO_PAGE
:
3688 Page
= RepairIntroPage(&Ir
);
3692 Page
= SuccessPage(&Ir
);
3696 Page
= FlushPage(&Ir
);
3700 Page
= QuitPage(&Ir
);
3708 /// THE FOLLOWING DPRINT IS FOR THE SYSTEM REGRESSION TOOL
3709 /// DO NOT REMOVE!!!
3710 DPRINT1("SYSREG_CHECKPOINT:USETUP_COMPLETE\n");
3714 /* Avoid bugcheck */
3715 Time
.QuadPart
+= 50000000;
3716 NtDelayExecution(FALSE
, &Time
);
3719 NtShutdownSystem(ShutdownReboot
);
3720 NtTerminateProcess(NtCurrentProcess(), 0);
3727 NtProcessStartup(PPEB Peb
)
3729 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3731 ProcessHeap
= Peb
->ProcessHeap
;
3732 INF_SetHeap(ProcessHeap
);
3735 #endif /* __REACTOS__ */