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
,
99 NtDisplayString(&UnicodeString
);
100 RtlFreeUnicodeString(&UnicodeString
);
114 /* draw upper left corner */
117 FillConsoleOutputCharacterA(
124 /* draw upper edge */
127 FillConsoleOutputCharacterA(
134 /* draw upper right corner */
135 coPos
.X
= xLeft
+ Width
- 1;
137 FillConsoleOutputCharacterA(
144 /* Draw right edge, inner space and left edge */
145 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
148 FillConsoleOutputCharacterA(
156 FillConsoleOutputCharacterA(
163 coPos
.X
= xLeft
+ Width
- 1;
164 FillConsoleOutputCharacterA(
172 /* draw lower left corner */
174 coPos
.Y
= yTop
+ Height
- 1;
175 FillConsoleOutputCharacterA(
182 /* draw lower edge */
184 coPos
.Y
= yTop
+ Height
- 1;
185 FillConsoleOutputCharacterA(
192 /* draw lower right corner */
193 coPos
.X
= xLeft
+ Width
- 1;
194 coPos
.Y
= yTop
+ Height
- 1;
195 FillConsoleOutputCharacterA(
204 PopupError(PCHAR Text
,
222 /* Count text lines and longest line */
228 p
= strchr(pnext
, '\n');
231 Length
= strlen(pnext
);
236 Length
= (ULONG
)(p
- pnext
);
241 if (Length
> MaxLength
)
244 if (LastLine
== TRUE
)
250 /* Check length of status line */
253 Length
= strlen(Status
);
254 if (Length
> MaxLength
)
258 Width
= MaxLength
+ 4;
263 yTop
= (yScreen
- Height
) / 2;
264 xLeft
= (xScreen
- Width
) / 2;
267 /* Set screen attributes */
269 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
271 FillConsoleOutputAttribute(StdOutput
,
272 FOREGROUND_RED
| BACKGROUND_WHITE
,
278 DrawBox(xLeft
, yTop
, Width
, Height
);
280 /* Print message text */
285 p
= strchr(pnext
, '\n');
288 Length
= strlen(pnext
);
293 Length
= (ULONG
)(p
- pnext
);
300 WriteConsoleOutputCharacterA(StdOutput
,
307 if (LastLine
== TRUE
)
314 /* Print separator line and status text */
317 coPos
.Y
= yTop
+ Height
- 3;
319 FillConsoleOutputCharacterA(StdOutput
,
326 FillConsoleOutputCharacterA(StdOutput
,
332 coPos
.X
= xLeft
+ Width
- 1;
333 FillConsoleOutputCharacterA(StdOutput
,
341 WriteConsoleOutputCharacterA(StdOutput
,
343 min(strlen(Status
), (SIZE_T
)Width
- 4),
348 if (WaitEvent
== POPUP_WAIT_NONE
)
353 CONSOLE_ConInKey(Ir
);
355 if (WaitEvent
== POPUP_WAIT_ANY_KEY
356 || Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
368 * FALSE: Don't quit setup.
371 ConfirmQuit(PINPUT_RECORD Ir
)
374 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
378 CONSOLE_ConInKey(Ir
);
380 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
381 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
386 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
398 CheckUnattendedSetup(VOID
)
400 WCHAR UnattendInfPath
[MAX_PATH
];
407 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
409 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
413 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
414 wcscat(UnattendInfPath
, L
"\\unattend.inf");
416 /* Load 'unattend.inf' from install media. */
417 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
421 if (UnattendInf
== INVALID_HANDLE_VALUE
)
423 DPRINT("SetupOpenInfFileW() failed\n");
427 /* Open 'Unattend' section */
428 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
430 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
431 SetupCloseInfFile(UnattendInf
);
435 /* Get pointer 'Signature' key */
436 if (!INF_GetData(&Context
, NULL
, &Value
))
438 DPRINT("INF_GetData() failed for key 'Signature'\n");
439 SetupCloseInfFile(UnattendInf
);
443 /* Check 'Signature' string */
444 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
446 DPRINT("Signature not $ReactOS$\n");
447 SetupCloseInfFile(UnattendInf
);
451 /* Check if Unattend setup is enabled */
452 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
454 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
455 SetupCloseInfFile(UnattendInf
);
458 if (!INF_GetData(&Context
, NULL
, &Value
))
460 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
461 SetupCloseInfFile(UnattendInf
);
464 if (_wcsicmp(Value
, L
"yes") != 0)
466 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
467 SetupCloseInfFile(UnattendInf
);
471 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
472 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
474 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
475 SetupCloseInfFile(UnattendInf
);
478 if (!SetupGetIntField(&Context
, 1, &IntValue
))
480 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
481 SetupCloseInfFile(UnattendInf
);
484 UnattendDestinationDiskNumber
= (LONG
)IntValue
;
486 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
487 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
489 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
490 SetupCloseInfFile(UnattendInf
);
493 if (!SetupGetIntField(&Context
, 1, &IntValue
))
495 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
496 SetupCloseInfFile(UnattendInf
);
499 UnattendDestinationPartitionNumber
= IntValue
;
501 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
502 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationPartitionNumber", &Context
))
504 DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
505 SetupCloseInfFile(UnattendInf
);
509 /* Get pointer 'InstallationDirectory' key */
510 if (!INF_GetData(&Context
, NULL
, &Value
))
512 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
513 SetupCloseInfFile(UnattendInf
);
516 wcscpy(UnattendInstallationDirectory
, Value
);
518 IsUnattendedSetup
= TRUE
;
520 /* Search for 'MBRInstallType' in the 'Unattend' section */
521 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
523 if (SetupGetIntField(&Context
, 1, &IntValue
))
525 UnattendMBRInstallType
= IntValue
;
528 /* Search for 'FormatPartition' in the 'Unattend' section */
529 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
531 if (SetupGetIntField(&Context
, 1, &IntValue
))
533 UnattendFormatPartition
= IntValue
;
536 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
538 if (SetupGetIntField(&Context
, 1, &IntValue
))
540 AutoPartition
= IntValue
;
543 SetupCloseInfFile(UnattendInf
);
545 DPRINT("Running unattended setup\n");
552 PGENERIC_LIST_ENTRY ListEntry
;
553 WCHAR szNewLayout
[20];
555 MUIDefaultKeyboardLayout(szNewLayout
);
557 if (LayoutList
== NULL
)
559 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
561 Entry
= LayoutList
->ListHead
.Flink
;
562 while (Entry
!= &LayoutList
->ListHead
)
564 ListEntry
= CONTAINING_RECORD (Entry
, GENERIC_LIST_ENTRY
, Entry
);
565 if (!wcscmp(szNewLayout
, ListEntry
->UserData
))
567 LayoutList
->CurrentEntry
= ListEntry
;
570 Entry
= Entry
->Flink
;
575 LanguagePage(PINPUT_RECORD Ir
)
577 /* Initialize the computer settings list */
578 if (LanguageList
== NULL
)
580 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
581 if (LanguageList
== NULL
)
583 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
588 DrawGenericList(LanguageList
,
594 MUIDisplayPage(LANGUAGE_PAGE
);
598 CONSOLE_ConInKey(Ir
);
600 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
601 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
603 #if 0 //Dynamically update user interface
604 SelectedLanguageId
= (PWCHAR
)LanguageList
->CurrentEntry
->UserData
;
605 MUIDisplayPage(LANGUAGE_PAGE
);
607 ScrollDownGenericList (LanguageList
);
609 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
610 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
613 SelectedLanguageId
= (PWCHAR
)LanguageList
->CurrentEntry
->UserData
;
614 MUIDisplayPage(LANGUAGE_PAGE
);
616 ScrollUpGenericList (LanguageList
);
618 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
619 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
621 if (ConfirmQuit(Ir
) == TRUE
)
624 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
626 SelectedLanguageId
= (PWCHAR
)LanguageList
->CurrentEntry
->UserData
;
627 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
642 * Number of the next page.
645 SetupStartPage(PINPUT_RECORD Ir
)
647 SYSTEM_DEVICE_INFORMATION Sdi
;
649 WCHAR FileNameBuffer
[MAX_PATH
];
655 CONSOLE_SetStatusText(" Please wait...");
658 /* Check whether a harddisk is available */
659 Status
= NtQuerySystemInformation (SystemDeviceInformation
,
661 sizeof(SYSTEM_DEVICE_INFORMATION
),
663 if (!NT_SUCCESS (Status
))
665 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
666 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
670 if (Sdi
.NumberOfDisks
== 0)
672 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
676 /* Get the source path and source root path */
677 Status
= GetSourcePaths(&SourcePath
,
680 if (!NT_SUCCESS(Status
))
682 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
683 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
689 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
690 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
691 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
695 /* Load txtsetup.sif from install media. */
696 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
697 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
699 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
703 if (SetupInf
== INVALID_HANDLE_VALUE
)
705 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
709 /* Open 'Version' section */
710 if (!SetupFindFirstLineW (SetupInf
, L
"Version", L
"Signature", &Context
))
712 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
717 /* Get pointer 'Signature' key */
718 if (!INF_GetData (&Context
, NULL
, &Value
))
720 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
724 /* Check 'Signature' string */
725 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
727 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
731 /* Start PnP thread */
732 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
734 //HACK: Commented out till the problem with CM is solved
735 //NtResumeThread(hPnpThread, NULL);
736 hPnpThread
= INVALID_HANDLE_VALUE
;
739 CheckUnattendedSetup();
741 if (IsUnattendedSetup
)
744 //read options from inf
745 ComputerList
= CreateComputerTypeList(SetupInf
);
746 DisplayList
= CreateDisplayDriverList(SetupInf
);
747 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
748 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
749 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
751 return INSTALL_INTRO_PAGE
;
754 return LANGUAGE_PAGE
;
764 IntroPage(PINPUT_RECORD Ir
)
766 MUIDisplayPage(START_PAGE
);
770 CONSOLE_ConInKey(Ir
);
772 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
773 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
775 if (ConfirmQuit(Ir
) == TRUE
)
779 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
781 return INSTALL_INTRO_PAGE
;
784 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
786 return REPAIR_INTRO_PAGE
;
789 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
802 * Back to main setup page.
805 LicensePage(PINPUT_RECORD Ir
)
807 MUIDisplayPage(LICENSE_PAGE
);
811 CONSOLE_ConInKey(Ir
);
813 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
824 RepairIntroPage(PINPUT_RECORD Ir
)
826 MUIDisplayPage(REPAIR_INTRO_PAGE
);
830 CONSOLE_ConInKey(Ir
);
832 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
836 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
838 RepairUpdateFlag
= TRUE
;
839 return INSTALL_INTRO_PAGE
;
841 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
845 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
846 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
852 return REPAIR_INTRO_PAGE
;
857 InstallIntroPage(PINPUT_RECORD Ir
)
859 MUIDisplayPage(INSTALL_INTRO_PAGE
);
861 if (RepairUpdateFlag
)
863 //return SELECT_PARTITION_PAGE;
864 return DEVICE_SETTINGS_PAGE
;
867 if (IsUnattendedSetup
)
869 return SELECT_PARTITION_PAGE
;
874 CONSOLE_ConInKey(Ir
);
876 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
877 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
879 if (ConfirmQuit(Ir
) == TRUE
)
883 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
885 return DEVICE_SETTINGS_PAGE
;
886 // return SCSI_CONTROLLER_PAGE;
890 return INSTALL_INTRO_PAGE
;
896 ScsiControllerPage(PINPUT_RECORD Ir
)
898 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
900 /* FIXME: print loaded mass storage driver descriptions */
902 SetTextXY(8, 10, "TEST device");
906 SetStatusText(" ENTER = Continue F3 = Quit");
912 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
913 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
915 if (ConfirmQuit(Ir
) == TRUE
)
919 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
921 return DEVICE_SETTINGS_PAGE
;
925 return SCSI_CONTROLLER_PAGE
;
931 DeviceSettingsPage(PINPUT_RECORD Ir
)
933 static ULONG Line
= 16;
934 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
936 /* Initialize the computer settings list */
937 if (ComputerList
== NULL
)
939 ComputerList
= CreateComputerTypeList(SetupInf
);
940 if (ComputerList
== NULL
)
942 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
947 /* Initialize the display settings list */
948 if (DisplayList
== NULL
)
950 DisplayList
= CreateDisplayDriverList(SetupInf
);
951 if (DisplayList
== NULL
)
953 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
958 /* Initialize the keyboard settings list */
959 if (KeyboardList
== NULL
)
961 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
962 if (KeyboardList
== NULL
)
964 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
969 /* Initialize the keyboard layout list */
970 if (LayoutList
== NULL
)
972 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
973 if (LayoutList
== NULL
)
975 /* FIXME: report error */
976 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
981 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
984 CONSOLE_SetTextXY(25, 11, GetGenericListEntry(ComputerList
)->Text
);
985 CONSOLE_SetTextXY(25, 12, GetGenericListEntry(DisplayList
)->Text
);
986 CONSOLE_SetTextXY(25, 13, GetGenericListEntry(KeyboardList
)->Text
);
987 CONSOLE_SetTextXY(25, 14, GetGenericListEntry(LayoutList
)->Text
);
989 CONSOLE_InvertTextXY (24, Line
, 48, 1);
991 if (RepairUpdateFlag
)
993 return SELECT_PARTITION_PAGE
;
998 CONSOLE_ConInKey(Ir
);
1000 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1001 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1003 CONSOLE_NormalTextXY (24, Line
, 48, 1);
1006 else if (Line
== 16)
1010 CONSOLE_InvertTextXY (24, Line
, 48, 1);
1012 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1013 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1015 CONSOLE_NormalTextXY (24, Line
, 48, 1);
1018 else if (Line
== 16)
1022 CONSOLE_InvertTextXY (24, Line
, 48, 1);
1024 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1025 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1027 if (ConfirmQuit(Ir
) == TRUE
)
1031 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1034 return COMPUTER_SETTINGS_PAGE
;
1035 else if (Line
== 12)
1036 return DISPLAY_SETTINGS_PAGE
;
1037 else if (Line
== 13)
1038 return KEYBOARD_SETTINGS_PAGE
;
1039 else if (Line
== 14)
1040 return LAYOUT_SETTINGS_PAGE
;
1041 else if (Line
== 16)
1042 return SELECT_PARTITION_PAGE
;
1046 return DEVICE_SETTINGS_PAGE
;
1051 ComputerSettingsPage(PINPUT_RECORD Ir
)
1053 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1055 DrawGenericList(ComputerList
,
1061 SaveGenericListState(ComputerList
);
1065 CONSOLE_ConInKey(Ir
);
1067 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1068 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1070 ScrollDownGenericList (ComputerList
);
1072 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1073 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1075 ScrollUpGenericList (ComputerList
);
1077 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1078 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1080 if (ConfirmQuit(Ir
) == TRUE
)
1084 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1085 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1087 RestoreGenericListState(ComputerList
);
1088 return DEVICE_SETTINGS_PAGE
;
1090 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1092 return DEVICE_SETTINGS_PAGE
;
1096 return COMPUTER_SETTINGS_PAGE
;
1101 DisplaySettingsPage(PINPUT_RECORD Ir
)
1103 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1105 DrawGenericList(DisplayList
,
1111 SaveGenericListState(DisplayList
);
1115 CONSOLE_ConInKey(Ir
);
1117 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1118 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1120 ScrollDownGenericList (DisplayList
);
1122 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1123 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1125 ScrollUpGenericList (DisplayList
);
1127 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1128 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1130 if (ConfirmQuit(Ir
) == TRUE
)
1136 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1137 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1139 RestoreGenericListState(DisplayList
);
1140 return DEVICE_SETTINGS_PAGE
;
1142 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1144 return DEVICE_SETTINGS_PAGE
;
1148 return DISPLAY_SETTINGS_PAGE
;
1153 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1155 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1157 DrawGenericList(KeyboardList
,
1165 SaveGenericListState(KeyboardList
);
1169 CONSOLE_ConInKey(Ir
);
1171 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1172 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1174 ScrollDownGenericList (KeyboardList
);
1176 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1177 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1179 ScrollUpGenericList (KeyboardList
);
1181 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1182 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1184 if (ConfirmQuit(Ir
) == TRUE
)
1188 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1189 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1191 RestoreGenericListState(KeyboardList
);
1192 return DEVICE_SETTINGS_PAGE
;
1194 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1196 return DEVICE_SETTINGS_PAGE
;
1200 return DISPLAY_SETTINGS_PAGE
;
1205 LayoutSettingsPage(PINPUT_RECORD Ir
)
1207 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1209 DrawGenericList(LayoutList
,
1215 SaveGenericListState(LayoutList
);
1219 CONSOLE_ConInKey(Ir
);
1221 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1222 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1224 ScrollDownGenericList (LayoutList
);
1226 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1227 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1229 ScrollUpGenericList (LayoutList
);
1231 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1232 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1234 if (ConfirmQuit(Ir
) == TRUE
)
1238 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1239 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1241 RestoreGenericListState(LayoutList
);
1242 return DEVICE_SETTINGS_PAGE
;
1244 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1246 return DEVICE_SETTINGS_PAGE
;
1250 return DISPLAY_SETTINGS_PAGE
;
1255 SelectPartitionPage(PINPUT_RECORD Ir
)
1257 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1259 if (PartitionList
== NULL
)
1261 PartitionList
= CreatePartitionList (2,
1265 if (PartitionList
== NULL
)
1267 /* FIXME: show an error dialog */
1272 CheckActiveBootPartition (PartitionList
);
1274 DrawPartitionList (PartitionList
);
1276 /* Warn about partitions created by Linux Fdisk */
1277 if (WarnLinuxPartitions
== TRUE
&&
1278 CheckForLinuxFdiskPartitions (PartitionList
) == TRUE
)
1280 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1283 CONSOLE_ConInKey (Ir
);
1285 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1286 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1290 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1292 WarnLinuxPartitions
= FALSE
;
1293 return SELECT_PARTITION_PAGE
;
1298 if (IsUnattendedSetup
)
1300 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1304 PPARTENTRY PartEntry
= PartEntry
= PartitionList
->CurrentPartition
;
1305 ULONG MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1306 CreateNewPartition (PartitionList
,
1309 return (SELECT_FILE_SYSTEM_PAGE
);
1314 return(SELECT_FILE_SYSTEM_PAGE
);
1320 /* Update status text */
1321 if (PartitionList
->CurrentPartition
== NULL
||
1322 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1324 CONSOLE_SetStatusText (" ENTER = Install C = Create Partition F3 = Quit");
1328 CONSOLE_SetStatusText (" ENTER = Install D = Delete Partition F3 = Quit");
1331 CONSOLE_ConInKey(Ir
);
1333 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1334 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1336 if (ConfirmQuit(Ir
) == TRUE
)
1338 DestroyPartitionList (PartitionList
);
1339 PartitionList
= NULL
;
1344 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1345 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1347 ScrollDownPartitionList (PartitionList
);
1349 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1350 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1352 ScrollUpPartitionList (PartitionList
);
1354 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1356 if (PartitionList
->CurrentPartition
== NULL
||
1357 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1359 CreateNewPartition (PartitionList
,
1364 return SELECT_FILE_SYSTEM_PAGE
;
1366 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'C') /* C */
1368 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
1370 MUIDisplayError(ERROR_NEW_PARTITION
, Ir
, POPUP_WAIT_ANY_KEY
);
1371 return SELECT_PARTITION_PAGE
;
1374 return CREATE_PARTITION_PAGE
;
1376 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1378 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
1380 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1381 return SELECT_PARTITION_PAGE
;
1384 return DELETE_PARTITION_PAGE
;
1388 return SELECT_PARTITION_PAGE
;
1393 DrawInputField(ULONG FieldLength
,
1404 memset(buf
, '_', sizeof(buf
));
1405 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1406 strcat(buf
, FieldContent
);
1408 WriteConsoleOutputCharacterA (StdOutput
,
1416 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1419 ShowPartitionSizeInputBox(SHORT Left
,
1443 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1448 strcpy (Buffer
, "Size of new partition:");
1449 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
1451 WriteConsoleOutputCharacterA (StdOutput
,
1457 sprintf (Buffer
, "MB (max. %lu MB)", MaxSize
);
1458 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1460 WriteConsoleOutputCharacterA (StdOutput
,
1466 sprintf(Buffer
, "%lu", MaxSize
);
1467 Index
= strlen(Buffer
);
1468 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1475 CONSOLE_ConInKey (&Ir
);
1477 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1478 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1485 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1489 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1496 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1501 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1506 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1507 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1509 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1510 if ((ch
>= '0') && (ch
<= '9'))
1515 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1523 strcpy (InputBuffer
,
1529 CreatePartitionPage (PINPUT_RECORD Ir
)
1531 PDISKENTRY DiskEntry
;
1532 PPARTENTRY PartEntry
;
1535 CHAR InputBuffer
[50];
1541 if (PartitionList
== NULL
||
1542 PartitionList
->CurrentDisk
== NULL
||
1543 PartitionList
->CurrentPartition
== NULL
)
1545 /* FIXME: show an error dialog */
1549 DiskEntry
= PartitionList
->CurrentDisk
;
1550 PartEntry
= PartitionList
->CurrentPartition
;
1552 CONSOLE_SetStatusText (" Please wait...");
1554 CONSOLE_SetTextXY (6, 8, "You have chosen to create a new partition on");
1557 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1559 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1565 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1571 if (DiskEntry
->DriverName
.Length
> 0)
1573 CONSOLE_PrintTextXY (6, 10,
1574 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1577 DiskEntry
->DiskNumber
,
1581 &DiskEntry
->DriverName
);
1585 CONSOLE_PrintTextXY (6, 10,
1586 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1589 DiskEntry
->DiskNumber
,
1596 CONSOLE_SetTextXY (6, 12, "Please enter the size of the new partition in megabytes.");
1599 CONSOLE_PrintTextXY (8, 10, "Maximum size of the new partition is %I64u MB",
1600 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1603 CONSOLE_SetStatusText (" ENTER = Create Partition ESC = Cancel F3 = Quit");
1605 PartEntry
= PartitionList
->CurrentPartition
;
1608 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1609 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1610 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1613 if (ConfirmQuit (Ir
) == TRUE
)
1618 else if (Cancel
== TRUE
)
1620 return SELECT_PARTITION_PAGE
;
1624 PartSize
= atoi (InputBuffer
);
1631 if (PartSize
> MaxSize
)
1637 /* Convert to bytes */
1638 if (PartSize
== MaxSize
)
1640 /* Use all of the unpartitioned disk space */
1641 PartSize
= PartEntry
->UnpartitionedLength
;
1645 /* Round-up by cylinder size */
1646 PartSize
= ROUND_UP (PartSize
* 1024 * 1024,
1647 DiskEntry
->CylinderSize
);
1649 /* But never get larger than the unpartitioned disk space */
1650 if (PartSize
> PartEntry
->UnpartitionedLength
)
1651 PartSize
= PartEntry
->UnpartitionedLength
;
1654 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1656 CreateNewPartition (PartitionList
,
1660 return SELECT_PARTITION_PAGE
;
1664 return CREATE_PARTITION_PAGE
;
1669 DeletePartitionPage (PINPUT_RECORD Ir
)
1671 PDISKENTRY DiskEntry
;
1672 PPARTENTRY PartEntry
;
1678 if (PartitionList
== NULL
||
1679 PartitionList
->CurrentDisk
== NULL
||
1680 PartitionList
->CurrentPartition
== NULL
)
1682 /* FIXME: show an error dialog */
1686 DiskEntry
= PartitionList
->CurrentDisk
;
1687 PartEntry
= PartitionList
->CurrentPartition
;
1689 MUIDisplayPage(DELETE_PARTITION_PAGE
);
1691 /* Determine partition type */
1693 if (PartEntry
->New
== TRUE
)
1695 PartType
= "New (Unformatted)";
1697 else if (PartEntry
->Unpartitioned
== FALSE
)
1699 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1700 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1701 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1702 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1706 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1707 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1711 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1713 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1718 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1720 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1725 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0xA00000LL
) /* 10 MB */
1727 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1732 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1736 if (PartType
== NULL
)
1738 CONSOLE_PrintTextXY (6, 10,
1739 " %c%c Type %lu %I64u %s",
1740 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1741 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1742 PartEntry
->PartInfo
[0].PartitionType
,
1748 CONSOLE_PrintTextXY (6, 10,
1749 " %c%c %s %I64u %s",
1750 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1751 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1758 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1760 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1766 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1772 if (DiskEntry
->DriverName
.Length
> 0)
1774 CONSOLE_PrintTextXY (6, 12,
1775 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1778 DiskEntry
->DiskNumber
,
1782 &DiskEntry
->DriverName
);
1786 CONSOLE_PrintTextXY (6, 12,
1787 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1790 DiskEntry
->DiskNumber
,
1798 CONSOLE_ConInKey (Ir
);
1800 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1801 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1803 if (ConfirmQuit (Ir
) == TRUE
)
1809 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1811 return SELECT_PARTITION_PAGE
;
1813 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1815 DeleteCurrentPartition (PartitionList
);
1817 return SELECT_PARTITION_PAGE
;
1821 return DELETE_PARTITION_PAGE
;
1826 SelectFileSystemPage (PINPUT_RECORD Ir
)
1828 PDISKENTRY DiskEntry
;
1829 PPARTENTRY PartEntry
;
1836 if (PartitionList
== NULL
||
1837 PartitionList
->CurrentDisk
== NULL
||
1838 PartitionList
->CurrentPartition
== NULL
)
1840 /* FIXME: show an error dialog */
1844 DiskEntry
= PartitionList
->CurrentDisk
;
1845 PartEntry
= PartitionList
->CurrentPartition
;
1847 /* adjust disk size */
1848 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1850 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1855 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1859 /* adjust partition size */
1860 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000LL
) /* 10 GB */
1862 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1867 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1871 /* adjust partition type */
1872 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1873 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1874 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1875 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1879 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1880 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1884 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1886 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1888 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
1890 PartType
= "Unused";
1894 PartType
= "Unknown";
1897 if (PartEntry
->AutoCreate
== TRUE
)
1899 CONSOLE_SetTextXY(6, 8, "Setup created a new partition on");
1902 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
1903 PartEntry
->PartInfo
[0].PartitionNumber
,
1909 CONSOLE_PrintTextXY(8, 10, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
1910 DiskEntry
->DiskNumber
,
1916 &DiskEntry
->DriverName
);
1918 CONSOLE_SetTextXY(6, 12, "This Partition will be formatted next.");
1921 PartEntry
->AutoCreate
= FALSE
;
1923 else if (PartEntry
->New
== TRUE
)
1925 CONSOLE_SetTextXY(6, 8, "You chose to install ReactOS on a new or unformatted Partition.");
1926 CONSOLE_SetTextXY(6, 10, "This Partition will be formatted next.");
1930 CONSOLE_SetTextXY(6, 8, "Setup install ReactOS onto Partition");
1932 if (PartType
== NULL
)
1934 CONSOLE_PrintTextXY (8, 10,
1935 "%c%c Type %lu %I64u %s",
1936 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1937 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1938 PartEntry
->PartInfo
[0].PartitionType
,
1944 CONSOLE_PrintTextXY (8, 10,
1946 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1947 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1953 CONSOLE_PrintTextXY(6, 12, "on Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
1954 DiskEntry
->DiskNumber
,
1960 &DiskEntry
->DriverName
);
1963 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
1965 if (FileSystemList
== NULL
)
1967 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, L
"FAT");
1968 if (FileSystemList
== NULL
)
1970 /* FIXME: show an error dialog */
1974 /* FIXME: Add file systems to list */
1976 DrawFileSystemList (FileSystemList
);
1978 if (RepairUpdateFlag
)
1980 return (CHECK_FILE_SYSTEM_PAGE
);
1981 //return SELECT_PARTITION_PAGE;
1984 if (IsUnattendedSetup
)
1986 if (UnattendFormatPartition
)
1988 return FORMAT_PARTITION_PAGE
;
1990 return(CHECK_FILE_SYSTEM_PAGE
);
1995 CONSOLE_ConInKey (Ir
);
1997 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1998 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2000 if (ConfirmQuit (Ir
) == TRUE
)
2006 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2007 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2009 return SELECT_PARTITION_PAGE
;
2011 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2012 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2014 ScrollDownFileSystemList (FileSystemList
);
2016 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2017 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2019 ScrollUpFileSystemList (FileSystemList
);
2021 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2023 if (!FileSystemList
->Selected
->FormatFunc
)
2025 return CHECK_FILE_SYSTEM_PAGE
;
2029 return FORMAT_PARTITION_PAGE
;
2034 return SELECT_FILE_SYSTEM_PAGE
;
2039 FormatPartitionPage (PINPUT_RECORD Ir
)
2041 WCHAR PathBuffer
[MAX_PATH
];
2042 PDISKENTRY DiskEntry
;
2043 PPARTENTRY PartEntry
;
2052 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2054 if (PartitionList
== NULL
||
2055 PartitionList
->CurrentDisk
== NULL
||
2056 PartitionList
->CurrentPartition
== NULL
)
2058 /* FIXME: show an error dialog */
2062 DiskEntry
= PartitionList
->CurrentDisk
;
2063 PartEntry
= PartitionList
->CurrentPartition
;
2067 if (!IsUnattendedSetup
)
2069 CONSOLE_ConInKey(Ir
);
2072 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2073 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2075 if (ConfirmQuit (Ir
) == TRUE
)
2081 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2083 CONSOLE_SetStatusText (" Please wait ...");
2085 if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
2087 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2089 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (4200LL * 1024LL))
2091 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2092 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_12
;
2094 else if (PartEntry
->PartInfo
[0].StartingOffset
.QuadPart
< (1024LL * 255LL * 63LL * 512LL))
2096 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2098 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (32LL * 1024LL * 1024LL))
2100 /* FAT16 CHS partition (partiton size < 32MB) */
2101 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_16
;
2103 else if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2105 /* FAT16 CHS partition (partition size < 512MB) */
2106 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_HUGE
;
2110 /* FAT32 CHS partition (partition size >= 512MB) */
2111 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32
;
2116 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2118 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (512LL * 1024LL * 1024LL))
2120 /* FAT16 LBA partition (partition size < 512MB) */
2121 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_XINT13
;
2125 /* FAT32 LBA partition (partition size >= 512MB) */
2126 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32_XINT13
;
2130 else if (!FileSystemList
->Selected
->FormatFunc
)
2134 CheckActiveBootPartition (PartitionList
);
2137 CONSOLE_PrintTextXY (6, 12,
2138 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2139 DiskEntry
->DiskSize
,
2140 DiskEntry
->CylinderSize
,
2141 DiskEntry
->TrackSize
);
2144 DiskEntry
= PartitionList
->CurrentDisk
;
2145 Entry
= DiskEntry
->PartListHead
.Flink
;
2146 while (Entry
!= &DiskEntry
->PartListHead
)
2148 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2150 if (PartEntry
->Unpartitioned
== FALSE
)
2153 for (i
= 0; i
< 4; i
++)
2155 CONSOLE_PrintTextXY (6, Line
,
2156 "%2u: %2u %c %12I64u %12I64u %2u %c",
2158 PartEntry
->PartInfo
[i
].PartitionNumber
,
2159 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
2160 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
2161 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
2162 PartEntry
->PartInfo
[i
].PartitionType
,
2163 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
2171 Entry
= Entry
->Flink
;
2174 /* Restore the old entry */
2175 PartEntry
= PartitionList
->CurrentPartition
;
2178 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
2180 DPRINT ("WritePartitionsToDisk() failed\n");
2181 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2185 /* Set DestinationRootPath */
2186 RtlFreeUnicodeString (&DestinationRootPath
);
2187 swprintf (PathBuffer
,
2188 L
"\\Device\\Harddisk%lu\\Partition%lu",
2189 PartitionList
->CurrentDisk
->DiskNumber
,
2190 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2191 RtlCreateUnicodeString (&DestinationRootPath
,
2193 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2196 /* Set SystemRootPath */
2197 RtlFreeUnicodeString (&SystemRootPath
);
2198 swprintf (PathBuffer
,
2199 L
"\\Device\\Harddisk%lu\\Partition%lu",
2200 PartitionList
->ActiveBootDisk
->DiskNumber
,
2201 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2202 RtlCreateUnicodeString (&SystemRootPath
,
2204 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
2207 if (FileSystemList
->Selected
->FormatFunc
)
2209 Status
= FormatPartition(&DestinationRootPath
, FileSystemList
->Selected
);
2210 if (!NT_SUCCESS(Status
))
2212 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2213 /* FIXME: show an error dialog */
2217 PartEntry
->New
= FALSE
;
2219 CheckActiveBootPartition(PartitionList
);
2222 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2224 /* FIXME: Install boot code. This is a hack! */
2225 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
)
2226 || (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
))
2228 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2229 wcscat(PathBuffer
, L
"\\loader\\fat32.bin");
2231 DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
2232 DestinationRootPath
.Buffer
);
2233 Status
= InstallFat32BootCodeToDisk(PathBuffer
,
2234 DestinationRootPath
.Buffer
);
2235 if (!NT_SUCCESS(Status
))
2237 DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status
);
2238 /* FIXME: show an error dialog */
2239 DestroyFileSystemList(FileSystemList
);
2240 FileSystemList
= NULL
;
2246 wcscpy(PathBuffer
, SourceRootPath
.Buffer
);
2247 wcscat(PathBuffer
, L
"\\loader\\fat.bin");
2249 DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer
,
2250 DestinationRootPath
.Buffer
);
2251 Status
= InstallFat16BootCodeToDisk(PathBuffer
,
2252 DestinationRootPath
.Buffer
);
2253 if (!NT_SUCCESS(Status
))
2255 DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status
);
2256 /* FIXME: show an error dialog */
2257 DestroyFileSystemList(FileSystemList
);
2258 FileSystemList
= NULL
;
2263 else if (FileSystemList
->Selected
->FormatFunc
)
2265 DestroyFileSystemList(FileSystemList
);
2266 FileSystemList
= NULL
;
2271 CONSOLE_SetStatusText (" Done. Press any key ...");
2272 CONSOLE_ConInKey(Ir
);
2275 DestroyFileSystemList(FileSystemList
);
2276 FileSystemList
= NULL
;
2277 return INSTALL_DIRECTORY_PAGE
;
2281 return FORMAT_PARTITION_PAGE
;
2286 CheckFileSystemPage(PINPUT_RECORD Ir
)
2288 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2289 WCHAR PathBuffer
[MAX_PATH
];
2290 CHAR Buffer
[MAX_PATH
];
2293 /* FIXME: code duplicated in FormatPartitionPage */
2294 /* Set DestinationRootPath */
2295 RtlFreeUnicodeString(&DestinationRootPath
);
2296 swprintf(PathBuffer
,
2297 L
"\\Device\\Harddisk%lu\\Partition%lu",
2298 PartitionList
->CurrentDisk
->DiskNumber
,
2299 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
2300 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2301 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2303 /* Set SystemRootPath */
2304 RtlFreeUnicodeString(&SystemRootPath
);
2305 swprintf(PathBuffer
,
2306 L
"\\Device\\Harddisk%lu\\Partition%lu",
2307 PartitionList
->ActiveBootDisk
->DiskNumber
,
2308 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
2309 RtlCreateUnicodeString(&SystemRootPath
, PathBuffer
);
2310 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
2312 CONSOLE_SetTextXY(6, 8, "Setup is now checking the selected partition.");
2314 CONSOLE_SetStatusText(" Please wait...");
2316 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2317 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2319 if (!CurrentFileSystem
->ChkdskFunc
)
2322 "Setup is currently unable to check a partition formatted in %S.\n"
2324 " \x07 Press ENTER to continue Setup.\n"
2325 " \x07 Press F3 to quit Setup.",
2326 CurrentFileSystem
->FileSystem
);
2329 "F3= Quit ENTER = Continue",
2330 NULL
, POPUP_WAIT_NONE
);
2334 CONSOLE_ConInKey(Ir
);
2336 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00
2337 && Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2339 if (ConfirmQuit(Ir
))
2342 return CHECK_FILE_SYSTEM_PAGE
;
2344 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2346 return INSTALL_DIRECTORY_PAGE
;
2352 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2353 if (!NT_SUCCESS(Status
))
2355 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2356 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2357 "(Status 0x%08lx).\n", Status
);
2359 "ENTER = Reboot computer",
2360 Ir
, POPUP_WAIT_ENTER
);
2364 return INSTALL_DIRECTORY_PAGE
;
2370 InstallDirectoryPage1(PWCHAR InstallDir
, PDISKENTRY DiskEntry
, PPARTENTRY PartEntry
)
2372 WCHAR PathBuffer
[MAX_PATH
];
2374 /* Create 'InstallPath' string */
2375 RtlFreeUnicodeString(&InstallPath
);
2376 RtlCreateUnicodeString(&InstallPath
,
2379 /* Create 'DestinationPath' string */
2380 RtlFreeUnicodeString(&DestinationPath
);
2382 DestinationRootPath
.Buffer
);
2383 if (InstallDir
[0] != L
'\\')
2386 wcscat(PathBuffer
, InstallDir
);
2387 RtlCreateUnicodeString(&DestinationPath
,
2390 /* Create 'DestinationArcPath' */
2391 RtlFreeUnicodeString(&DestinationArcPath
);
2392 swprintf(PathBuffer
,
2393 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2394 DiskEntry
->BiosDiskNumber
,
2395 PartEntry
->PartInfo
[0].PartitionNumber
);
2396 if (InstallDir
[0] != L
'\\')
2399 wcscat(PathBuffer
, InstallDir
);
2400 RtlCreateUnicodeString(&DestinationArcPath
,
2403 return(PREPARE_COPY_PAGE
);
2408 InstallDirectoryPage(PINPUT_RECORD Ir
)
2410 PDISKENTRY DiskEntry
;
2411 PPARTENTRY PartEntry
;
2412 WCHAR InstallDir
[51];
2417 if (PartitionList
== NULL
||
2418 PartitionList
->CurrentDisk
== NULL
||
2419 PartitionList
->CurrentPartition
== NULL
)
2421 /* FIXME: show an error dialog */
2425 DiskEntry
= PartitionList
->CurrentDisk
;
2426 PartEntry
= PartitionList
->CurrentPartition
;
2428 /* Search for 'DefaultPath' in the 'SetupData' section */
2429 if (!SetupFindFirstLineW (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
2431 MUIDisplayError(ERROR_FIND_SETUPDATA
, Ir
, POPUP_WAIT_ENTER
);
2435 /* Read the 'DefaultPath' data */
2436 if (INF_GetData (&Context
, NULL
, &DefaultPath
))
2438 wcscpy(InstallDir
, DefaultPath
);
2442 wcscpy(InstallDir
, L
"\\ReactOS");
2444 Length
= wcslen(InstallDir
);
2445 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2446 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
2448 if (IsUnattendedSetup
)
2450 return(InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2455 CONSOLE_ConInKey(Ir
);
2457 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2458 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2460 if (ConfirmQuit(Ir
) == TRUE
)
2464 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2466 return (InstallDirectoryPage1 (InstallDir
, DiskEntry
, PartEntry
));
2468 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
2473 InstallDir
[Length
] = 0;
2474 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2477 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
2481 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
2483 InstallDir
[Length
] = 0;
2484 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
2489 return(INSTALL_DIRECTORY_PAGE
);
2493 AddSectionToCopyQueueCab(HINF InfFile
,
2495 PWCHAR SourceCabinet
,
2496 PCUNICODE_STRING DestinationPath
,
2499 INFCONTEXT FilesContext
;
2500 INFCONTEXT DirContext
;
2502 PWCHAR FileKeyValue
;
2504 PWCHAR TargetFileName
;
2506 /* Search for the SectionName section */
2507 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2510 sprintf(Buffer
, "Setup failed to find the '%S' section\nin TXTSETUP.SIF.\n", SectionName
);
2511 PopupError(Buffer
, "ENTER = Reboot computer", Ir
, POPUP_WAIT_ENTER
);
2516 * Enumerate the files in the section
2517 * and add them to the file queue.
2521 /* Get source file name and target directory id */
2522 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2524 /* FIXME: Handle error! */
2525 DPRINT1("INF_GetData() failed\n");
2529 /* Get optional target file name */
2530 if (!INF_GetDataField (&FilesContext
, 2, &TargetFileName
))
2531 TargetFileName
= NULL
;
2533 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2535 /* Lookup target directory */
2536 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2538 /* FIXME: Handle error! */
2539 DPRINT1("SetupFindFirstLine() failed\n");
2543 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2545 /* FIXME: Handle error! */
2546 DPRINT1("INF_GetData() failed\n");
2550 if (!SetupQueueCopy(SetupFileQueue
,
2552 SourceRootPath
.Buffer
,
2553 SourceRootDir
.Buffer
,
2558 /* FIXME: Handle error! */
2559 DPRINT1("SetupQueueCopy() failed\n");
2562 while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2568 AddSectionToCopyQueue(HINF InfFile
,
2570 PWCHAR SourceCabinet
,
2571 PCUNICODE_STRING DestinationPath
,
2574 INFCONTEXT FilesContext
;
2575 INFCONTEXT DirContext
;
2577 PWCHAR FileKeyValue
;
2579 PWCHAR TargetFileName
;
2582 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
2584 /* Search for the SectionName section */
2585 if (!SetupFindFirstLineW (InfFile
, SectionName
, NULL
, &FilesContext
))
2588 sprintf(Buffer
, "Setup failed to find the '%S' section\nin TXTSETUP.SIF.\n", SectionName
);
2589 PopupError(Buffer
, "ENTER = Reboot computer", Ir
, POPUP_WAIT_ENTER
);
2594 * Enumerate the files in the section
2595 * and add them to the file queue.
2599 /* Get source file name and target directory id */
2600 if (!INF_GetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2602 /* FIXME: Handle error! */
2603 DPRINT1("INF_GetData() failed\n");
2607 /* Get target directory id */
2608 if (!INF_GetDataField (&FilesContext
, 13, &FileKeyValue
))
2610 /* FIXME: Handle error! */
2611 DPRINT1("INF_GetData() failed\n");
2615 /* Get optional target file name */
2616 if (!INF_GetDataField (&FilesContext
, 11, &TargetFileName
))
2617 TargetFileName
= NULL
;
2618 else if (!*TargetFileName
)
2619 TargetFileName
= NULL
;
2621 DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2623 /* Lookup target directory */
2624 if (!SetupFindFirstLineW (InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
2626 /* FIXME: Handle error! */
2627 DPRINT1("SetupFindFirstLine() failed\n");
2631 if (!INF_GetData (&DirContext
, NULL
, &DirKeyValue
))
2633 /* FIXME: Handle error! */
2634 DPRINT1("INF_GetData() failed\n");
2638 if (!SetupQueueCopy(SetupFileQueue
,
2640 SourceRootPath
.Buffer
,
2641 SourceRootDir
.Buffer
,
2646 /* FIXME: Handle error! */
2647 DPRINT1("SetupQueueCopy() failed\n");
2650 while (SetupFindNextLine(&FilesContext
, &FilesContext
));
2656 PrepareCopyPageInfFile(HINF InfFile
,
2657 PWCHAR SourceCabinet
,
2660 WCHAR PathBuffer
[MAX_PATH
];
2661 INFCONTEXT DirContext
;
2662 PWCHAR AdditionalSectionName
= NULL
;
2667 /* Add common files */
2668 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
2671 /* Add specific files depending of computer type */
2672 if (SourceCabinet
== NULL
)
2674 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
2676 if (AdditionalSectionName
)
2678 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
2683 /* Create directories */
2687 * Install directories like '\reactos\test' are not handled yet.
2690 /* Get destination path */
2691 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2693 /* Remove trailing backslash */
2694 Length
= wcslen(PathBuffer
);
2695 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2697 PathBuffer
[Length
- 1] = 0;
2700 /* Create the install directory */
2701 Status
= SetupCreateDirectory(PathBuffer
);
2702 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2704 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2705 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
2710 /* Search for the 'Directories' section */
2711 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
2715 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2719 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
2724 /* Enumerate the directory values and create the subdirectories */
2727 if (!INF_GetData (&DirContext
, NULL
, &KeyValue
))
2733 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2735 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2737 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2738 wcscat(PathBuffer
, KeyValue
);
2740 DPRINT("FullPath: '%S'\n", PathBuffer
);
2742 else if (KeyValue
[0] != L
'\\')
2744 DPRINT("RelativePath: '%S'\n", KeyValue
);
2745 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2746 wcscat(PathBuffer
, L
"\\");
2747 wcscat(PathBuffer
, KeyValue
);
2749 DPRINT("FullPath: '%S'\n", PathBuffer
);
2751 Status
= SetupCreateDirectory(PathBuffer
);
2752 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2754 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2755 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
2760 while (SetupFindNextLine (&DirContext
, &DirContext
));
2766 PrepareCopyPage(PINPUT_RECORD Ir
)
2769 WCHAR PathBuffer
[MAX_PATH
];
2770 INFCONTEXT CabinetsContext
;
2776 MUIDisplayPage(PREPARE_COPY_PAGE
);
2778 /* Create the file queue */
2779 SetupFileQueue
= SetupOpenFileQueue();
2780 if (SetupFileQueue
== NULL
)
2782 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
2786 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
2791 /* Search for the 'Cabinets' section */
2792 if (!SetupFindFirstLineW (SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
2794 return FILE_COPY_PAGE
;
2798 * Enumerate the directory values in the 'Cabinets'
2799 * section and parse their inf files.
2803 if (!INF_GetData (&CabinetsContext
, NULL
, &KeyValue
))
2806 wcscpy(PathBuffer
, SourcePath
.Buffer
);
2807 wcscat(PathBuffer
, L
"\\");
2808 wcscat(PathBuffer
, KeyValue
);
2811 CabinetInitialize();
2812 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
2813 CabinetSetCabinetName(PathBuffer
);
2815 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
2817 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
2819 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
2820 if (InfFileData
== NULL
)
2822 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
2828 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
2829 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
2833 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
2838 if (InfHandle
== INVALID_HANDLE_VALUE
)
2840 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
2846 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
2852 while (SetupFindNextLine (&CabinetsContext
, &CabinetsContext
));
2854 return FILE_COPY_PAGE
;
2859 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
2862 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
2864 /* Get the memory information from the system */
2865 NtQuerySystemInformation(SystemPerformanceInformation
,
2870 /* Check if this is initial setup */
2873 /* Set maximum limits to be total RAM pages */
2874 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
2875 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
2876 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
2879 /* Set current values */
2880 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
);
2881 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.NonPagedPoolPages
);
2882 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
2884 /* Check if memory dropped below 40%! */
2885 if (CopyContext
->MemoryBars
[2]->Percent
<= 40)
2887 /* Wait a while until Mm does its thing */
2888 LARGE_INTEGER Interval
;
2889 Interval
.QuadPart
= -1 * 15 * 1000 * 100;
2890 NtDelayExecution(FALSE
, &Interval
);
2894 static UINT CALLBACK
2895 FileCopyCallback(PVOID Context
,
2900 PCOPYCONTEXT CopyContext
;
2902 CopyContext
= (PCOPYCONTEXT
)Context
;
2904 switch (Notification
)
2906 case SPFILENOTIFY_STARTSUBQUEUE
:
2907 CopyContext
->TotalOperations
= (ULONG
)Param2
;
2908 ProgressSetStepCount(CopyContext
->ProgressBar
,
2909 CopyContext
->TotalOperations
);
2910 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
2913 case SPFILENOTIFY_STARTCOPY
:
2914 /* Display copy message */
2915 CONSOLE_SetStatusText(" \xB3 Copying file: %S", (PWSTR
)Param1
);
2916 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
2919 case SPFILENOTIFY_ENDCOPY
:
2920 CopyContext
->CompletedOperations
++;
2921 ProgressNextStep(CopyContext
->ProgressBar
);
2922 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
2931 FileCopyPage(PINPUT_RECORD Ir
)
2933 COPYCONTEXT CopyContext
;
2935 MUIDisplayPage(FILE_COPY_PAGE
);
2937 /* Create context for the copy process */
2938 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
2939 CopyContext
.InstallPath
= InstallPath
.Buffer
;
2940 CopyContext
.TotalOperations
= 0;
2941 CopyContext
.CompletedOperations
= 0;
2943 /* Create the progress bar as well */
2944 CopyContext
.ProgressBar
= CreateProgressBar(13,
2951 "Setup is copying files...");
2953 /* Create the paged pool progress bar */
2954 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
2963 /* Create the non paged pool progress bar */
2964 CopyContext
.MemoryBars
[1] = CreateProgressBar(28,
2973 /* Create the global memory progress bar */
2974 CopyContext
.MemoryBars
[2] = CreateProgressBar(43,
2983 /* Do the file copying */
2984 SetupCommitFileQueueW(NULL
,
2989 /* If we get here, we're done, so cleanup the queue and progress bar */
2990 SetupCloseFileQueue(SetupFileQueue
);
2991 DestroyProgressBar(CopyContext
.ProgressBar
);
2992 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
2993 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
2994 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
2996 /* Go display the next page */
2997 return REGISTRY_PAGE
;
3001 RegistryPage(PINPUT_RECORD Ir
)
3003 INFCONTEXT InfContext
;
3010 MUIDisplayPage(REGISTRY_PAGE
);
3012 if (RepairUpdateFlag
)
3014 return SUCCESS_PAGE
;
3017 if (!SetInstallPathValue(&DestinationPath
))
3019 DPRINT("SetInstallPathValue() failed\n");
3020 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3024 /* Create the default hives */
3026 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3027 if (!NT_SUCCESS(Status
))
3029 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3030 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3034 RegInitializeRegistry();
3037 /* Update registry */
3038 CONSOLE_SetStatusText(" Updating registry hives...");
3040 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3042 DPRINT1("SetupFindFirstLine() failed\n");
3043 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3049 INF_GetDataField (&InfContext
, 0, &Action
);
3050 INF_GetDataField (&InfContext
, 1, &File
);
3051 INF_GetDataField (&InfContext
, 2, &Section
);
3053 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3055 if (!_wcsicmp (Action
, L
"AddReg"))
3059 else if (!_wcsicmp (Action
, L
"DelReg"))
3068 CONSOLE_SetStatusText(" Importing %S...", File
);
3070 if (!ImportRegistryFile(File
, Section
, Delete
))
3072 DPRINT("Importing %S failed\n", File
);
3074 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3078 while (SetupFindNextLine (&InfContext
, &InfContext
));
3080 /* Update display registry settings */
3081 CONSOLE_SetStatusText(" Updating display registry settings...");
3082 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3084 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3088 /* Update keyboard layout settings */
3089 CONSOLE_SetStatusText(" Updating keyboard layout settings...");
3090 if (!ProcessKeyboardLayoutRegistry(LanguageList
))
3092 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3096 /* Add codepage information to registry */
3097 CONSOLE_SetStatusText(" Adding codepage information to registry...");
3100 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3104 /* Update the mounted devices list */
3105 SetMountedDeviceValues(PartitionList
);
3107 CONSOLE_SetStatusText(" Done...");
3109 return BOOT_LOADER_PAGE
;
3114 BootLoaderPage(PINPUT_RECORD Ir
)
3116 UCHAR PartitionType
;
3117 BOOLEAN InstallOnFloppy
;
3120 CONSOLE_SetStatusText(" Please wait...");
3122 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3124 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3126 DPRINT("Error: active partition invalid (unused)\n");
3127 InstallOnFloppy
= TRUE
;
3129 else if (PartitionType
== 0x0A)
3131 /* OS/2 boot manager partition */
3132 DPRINT("Found OS/2 boot manager partition\n");
3133 InstallOnFloppy
= TRUE
;
3135 else if (PartitionType
== 0x83)
3137 /* Linux ext2 partition */
3138 DPRINT("Found Linux ext2 partition\n");
3139 InstallOnFloppy
= TRUE
;
3141 else if (PartitionType
== PARTITION_IFS
)
3143 /* NTFS partition */
3144 DPRINT("Found NTFS partition\n");
3145 InstallOnFloppy
= TRUE
;
3147 else if ((PartitionType
== PARTITION_FAT_12
) ||
3148 (PartitionType
== PARTITION_FAT_16
) ||
3149 (PartitionType
== PARTITION_HUGE
) ||
3150 (PartitionType
== PARTITION_XINT13
) ||
3151 (PartitionType
== PARTITION_FAT32
) ||
3152 (PartitionType
== PARTITION_FAT32_XINT13
))
3154 DPRINT("Found FAT partition\n");
3155 InstallOnFloppy
= FALSE
;
3159 /* Unknown partition */
3160 DPRINT("Unknown partition found\n");
3161 InstallOnFloppy
= TRUE
;
3164 if (InstallOnFloppy
== TRUE
)
3166 return BOOT_LOADER_FLOPPY_PAGE
;
3169 if (IsUnattendedSetup
)
3171 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3173 return SUCCESS_PAGE
;
3175 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3177 return BOOT_LOADER_FLOPPY_PAGE
;
3179 else if (UnattendMBRInstallType
== 2) /* install on hdd */
3181 return BOOT_LOADER_HARDDISK_PAGE
;
3185 MUIDisplayPage(BOOT_LOADER_PAGE
);
3186 CONSOLE_InvertTextXY (8, Line
, 60, 1);
3190 CONSOLE_ConInKey(Ir
);
3192 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3193 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3195 CONSOLE_NormalTextXY (8, Line
, 60, 1);
3198 if (Line
<12) Line
=14;
3199 if (Line
>14) Line
=12;
3203 CONSOLE_InvertTextXY (8, Line
, 60, 1);
3205 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3206 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3208 CONSOLE_NormalTextXY (8, Line
, 48, 1);
3211 if (Line
<12) Line
=14;
3212 if (Line
>14) Line
=12;
3215 CONSOLE_InvertTextXY (8, Line
, 48, 1);
3217 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3218 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3220 if (ConfirmQuit(Ir
) == TRUE
)
3224 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3228 return BOOT_LOADER_HARDDISK_PAGE
;
3230 else if (Line
== 13)
3232 return BOOT_LOADER_FLOPPY_PAGE
;
3234 else if (Line
== 14)
3236 return SUCCESS_PAGE
;;
3239 return BOOT_LOADER_PAGE
;
3244 return BOOT_LOADER_PAGE
;
3249 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3253 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3255 // SetStatusText(" Please wait...");
3259 CONSOLE_ConInKey(Ir
);
3261 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3262 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3264 if (ConfirmQuit(Ir
) == TRUE
)
3268 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3270 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3272 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3273 return BOOT_LOADER_FLOPPY_PAGE
;
3276 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
,
3277 &DestinationArcPath
);
3278 if (!NT_SUCCESS(Status
))
3280 /* Print error message */
3281 return BOOT_LOADER_FLOPPY_PAGE
;
3284 return SUCCESS_PAGE
;
3288 return BOOT_LOADER_FLOPPY_PAGE
;
3293 BootLoaderHarddiskPage(PINPUT_RECORD Ir
)
3295 UCHAR PartitionType
;
3298 PartitionType
= PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
;
3299 if ((PartitionType
== PARTITION_FAT_12
) ||
3300 (PartitionType
== PARTITION_FAT_16
) ||
3301 (PartitionType
== PARTITION_HUGE
) ||
3302 (PartitionType
== PARTITION_XINT13
) ||
3303 (PartitionType
== PARTITION_FAT32
) ||
3304 (PartitionType
== PARTITION_FAT32_XINT13
))
3306 Status
= InstallFatBootcodeToPartition(&SystemRootPath
,
3308 &DestinationArcPath
,
3310 if (!NT_SUCCESS(Status
))
3312 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
3316 return SUCCESS_PAGE
;
3320 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3324 return BOOT_LOADER_HARDDISK_PAGE
;
3329 QuitPage(PINPUT_RECORD Ir
)
3331 MUIDisplayPage(QUIT_PAGE
);
3333 /* Destroy partition list */
3334 if (PartitionList
!= NULL
)
3336 DestroyPartitionList (PartitionList
);
3337 PartitionList
= NULL
;
3340 /* Destroy filesystem list */
3341 if (FileSystemList
!= NULL
)
3343 DestroyFileSystemList (FileSystemList
);
3344 FileSystemList
= NULL
;
3347 /* Destroy computer settings list */
3348 if (ComputerList
!= NULL
)
3350 DestroyGenericList(ComputerList
, TRUE
);
3351 ComputerList
= NULL
;
3354 /* Destroy display settings list */
3355 if (DisplayList
!= NULL
)
3357 DestroyGenericList(DisplayList
, TRUE
);
3361 /* Destroy keyboard settings list */
3362 if (KeyboardList
!= NULL
)
3364 DestroyGenericList(KeyboardList
, TRUE
);
3365 KeyboardList
= NULL
;
3368 /* Destroy keyboard layout list */
3369 if (LayoutList
!= NULL
)
3371 DestroyGenericList(LayoutList
, TRUE
);
3375 if (LanguageList
!= NULL
)
3377 DestroyGenericList(LanguageList
, FALSE
);
3378 LanguageList
= NULL
;
3381 CONSOLE_SetStatusText(" ENTER = Reboot computer");
3385 CONSOLE_ConInKey(Ir
);
3387 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3396 SuccessPage(PINPUT_RECORD Ir
)
3398 MUIDisplayPage(SUCCESS_PAGE
);
3400 if (IsUnattendedSetup
)
3407 CONSOLE_ConInKey(Ir
);
3409 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3418 FlushPage(PINPUT_RECORD Ir
)
3420 MUIDisplayPage(FLUSH_PAGE
);
3426 PnpEventThread(IN LPVOID lpParameter
);
3436 NtQuerySystemTime(&Time
);
3438 Status
= RtlCreateUserThread(NtCurrentProcess(), NULL
, TRUE
, 0, 0, 0, PnpEventThread
, &SetupInf
, &hPnpThread
, NULL
);
3439 if (!NT_SUCCESS(Status
))
3440 hPnpThread
= INVALID_HANDLE_VALUE
;
3441 if (!CONSOLE_Init())
3443 PrintString("Unable to open the console\n\n");
3444 PrintString("The most common cause of this is using an USB keyboard\n");
3445 PrintString("USB keyboards are not fully supported yet\n");
3447 /* Raise a hard error (crash the system/BSOD) */
3448 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3452 /* Initialize global unicode strings */
3453 RtlInitUnicodeString(&SourcePath
, NULL
);
3454 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3455 RtlInitUnicodeString(&SourceRootDir
, NULL
);
3456 RtlInitUnicodeString(&InstallPath
, NULL
);
3457 RtlInitUnicodeString(&DestinationPath
, NULL
);
3458 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3459 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3460 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3462 /* Hide the cursor */
3463 CONSOLE_SetCursorType(TRUE
, FALSE
);
3466 while (Page
!= REBOOT_PAGE
)
3468 CONSOLE_ClearScreen();
3471 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
3478 Page
= SetupStartPage(&Ir
);
3482 Page
= LanguagePage(&Ir
);
3486 Page
= LicensePage(&Ir
);
3491 Page
= IntroPage(&Ir
);
3495 case INSTALL_INTRO_PAGE
:
3496 Page
= InstallIntroPage(&Ir
);
3500 case SCSI_CONTROLLER_PAGE
:
3501 Page
= ScsiControllerPage(&Ir
);
3506 case OEM_DRIVER_PAGE
:
3507 Page
= OemDriverPage(&Ir
);
3511 case DEVICE_SETTINGS_PAGE
:
3512 Page
= DeviceSettingsPage(&Ir
);
3515 case COMPUTER_SETTINGS_PAGE
:
3516 Page
= ComputerSettingsPage(&Ir
);
3519 case DISPLAY_SETTINGS_PAGE
:
3520 Page
= DisplaySettingsPage(&Ir
);
3523 case KEYBOARD_SETTINGS_PAGE
:
3524 Page
= KeyboardSettingsPage(&Ir
);
3527 case LAYOUT_SETTINGS_PAGE
:
3528 Page
= LayoutSettingsPage(&Ir
);
3531 case SELECT_PARTITION_PAGE
:
3532 Page
= SelectPartitionPage(&Ir
);
3535 case CREATE_PARTITION_PAGE
:
3536 Page
= CreatePartitionPage(&Ir
);
3539 case DELETE_PARTITION_PAGE
:
3540 Page
= DeletePartitionPage(&Ir
);
3543 case SELECT_FILE_SYSTEM_PAGE
:
3544 Page
= SelectFileSystemPage(&Ir
);
3547 case FORMAT_PARTITION_PAGE
:
3548 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
3551 case CHECK_FILE_SYSTEM_PAGE
:
3552 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
3555 case INSTALL_DIRECTORY_PAGE
:
3556 Page
= InstallDirectoryPage(&Ir
);
3559 case PREPARE_COPY_PAGE
:
3560 Page
= PrepareCopyPage(&Ir
);
3563 case FILE_COPY_PAGE
:
3564 Page
= FileCopyPage(&Ir
);
3568 Page
= RegistryPage(&Ir
);
3571 case BOOT_LOADER_PAGE
:
3572 Page
= BootLoaderPage(&Ir
);
3575 case BOOT_LOADER_FLOPPY_PAGE
:
3576 Page
= BootLoaderFloppyPage(&Ir
);
3579 case BOOT_LOADER_HARDDISK_PAGE
:
3580 Page
= BootLoaderHarddiskPage(&Ir
);
3584 case REPAIR_INTRO_PAGE
:
3585 Page
= RepairIntroPage(&Ir
);
3589 Page
= SuccessPage(&Ir
);
3593 Page
= FlushPage(&Ir
);
3597 Page
= QuitPage(&Ir
);
3605 /// THE FOLLOWING DPRINT IS FOR THE SYSTEM REGRESSION TOOL
3606 /// DO NOT REMOVE!!!
3607 DPRINT1("SYSREG_CHECKPOINT:USETUP_COMPLETE\n");
3611 /* Avoid bugcheck */
3612 Time
.QuadPart
+= 50000000;
3613 NtDelayExecution(FALSE
, &Time
);
3616 NtShutdownSystem(ShutdownReboot
);
3617 NtTerminateProcess(NtCurrentProcess(), 0);
3624 NtProcessStartup(PPEB Peb
)
3626 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3628 ProcessHeap
= Peb
->ProcessHeap
;
3629 INF_SetHeap(ProcessHeap
);
3632 #endif /* __REACTOS__ */