3 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/usetup.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMER: Eric Kohl
25 * Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * Hervé Poussineau (hpoussin@reactos.org)
42 /* GLOBALS ******************************************************************/
45 UNICODE_STRING SourceRootPath
;
46 UNICODE_STRING SourceRootDir
;
47 UNICODE_STRING SourcePath
;
48 BOOLEAN IsUnattendedSetup
= FALSE
;
49 LONG UnattendDestinationDiskNumber
;
50 LONG UnattendDestinationPartitionNumber
;
51 LONG UnattendMBRInstallType
= -1;
52 LONG UnattendFormatPartition
= 0;
53 LONG AutoPartition
= 0;
54 WCHAR UnattendInstallationDirectory
[MAX_PATH
];
55 PWCHAR SelectedLanguageId
;
57 WCHAR DefaultLanguage
[20];
58 WCHAR DefaultKBLayout
[20];
59 BOOLEAN RepairUpdateFlag
= FALSE
;
60 HANDLE hPnpThread
= INVALID_HANDLE_VALUE
;
61 PPARTLIST PartitionList
= NULL
;
63 /* LOCALS *******************************************************************/
65 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
67 static UNICODE_STRING InstallPath
;
69 /* Path to the install directory */
70 static UNICODE_STRING DestinationPath
;
71 static UNICODE_STRING DestinationArcPath
;
72 static UNICODE_STRING DestinationRootPath
;
74 static WCHAR DestinationDriveLetter
;
76 /* Path to the active partition (boot manager) */
77 static UNICODE_STRING SystemRootPath
;
81 static HSPFILEQ SetupFileQueue
= NULL
;
83 static BOOLEAN WarnLinuxPartitions
= TRUE
;
85 static PGENERIC_LIST ComputerList
= NULL
;
86 static PGENERIC_LIST DisplayList
= NULL
;
87 static PGENERIC_LIST KeyboardList
= NULL
;
88 static PGENERIC_LIST LayoutList
= NULL
;
89 static PGENERIC_LIST LanguageList
= NULL
;
91 static LANGID LanguageId
= 0;
93 static ULONG RequiredPartitionDiskSpace
= ~0;
95 /* FUNCTIONS ****************************************************************/
98 PrintString(char* fmt
,...)
102 UNICODE_STRING UnicodeString
;
103 ANSI_STRING AnsiString
;
106 vsprintf(buffer
, fmt
, ap
);
109 RtlInitAnsiString(&AnsiString
, buffer
);
110 RtlAnsiStringToUnicodeString(&UnicodeString
, &AnsiString
, TRUE
);
111 NtDisplayString(&UnicodeString
);
112 RtlFreeUnicodeString(&UnicodeString
);
117 DrawBox(IN SHORT xLeft
,
125 /* draw upper left corner */
128 FillConsoleOutputCharacterA(StdOutput
,
134 /* draw upper edge */
137 FillConsoleOutputCharacterA(StdOutput
,
143 /* draw upper right corner */
144 coPos
.X
= xLeft
+ Width
- 1;
146 FillConsoleOutputCharacterA(StdOutput
,
152 /* Draw right edge, inner space and left edge */
153 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
156 FillConsoleOutputCharacterA(StdOutput
,
163 FillConsoleOutputCharacterA(StdOutput
,
169 coPos
.X
= xLeft
+ Width
- 1;
170 FillConsoleOutputCharacterA(StdOutput
,
177 /* draw lower left corner */
179 coPos
.Y
= yTop
+ Height
- 1;
180 FillConsoleOutputCharacterA(StdOutput
,
186 /* draw lower edge */
188 coPos
.Y
= yTop
+ Height
- 1;
189 FillConsoleOutputCharacterA(StdOutput
,
195 /* draw lower right corner */
196 coPos
.X
= xLeft
+ Width
- 1;
197 coPos
.Y
= yTop
+ Height
- 1;
198 FillConsoleOutputCharacterA(StdOutput
,
207 PopupError(PCCH Text
,
225 /* Count text lines and longest line */
232 p
= strchr(pnext
, '\n');
236 Length
= strlen(pnext
);
241 Length
= (ULONG
)(p
- pnext
);
247 if (Length
> MaxLength
)
250 if (LastLine
== TRUE
)
256 /* Check length of status line */
259 Length
= strlen(Status
);
261 if (Length
> MaxLength
)
265 Width
= MaxLength
+ 4;
271 yTop
= (yScreen
- Height
) / 2;
272 xLeft
= (xScreen
- Width
) / 2;
275 /* Set screen attributes */
277 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
279 FillConsoleOutputAttribute(StdOutput
,
280 FOREGROUND_RED
| BACKGROUND_WHITE
,
286 DrawBox(xLeft
, yTop
, Width
, Height
);
288 /* Print message text */
293 p
= strchr(pnext
, '\n');
297 Length
= strlen(pnext
);
302 Length
= (ULONG
)(p
- pnext
);
309 WriteConsoleOutputCharacterA(StdOutput
,
316 if (LastLine
== TRUE
)
323 /* Print separator line and status text */
326 coPos
.Y
= yTop
+ Height
- 3;
328 FillConsoleOutputCharacterA(StdOutput
,
335 FillConsoleOutputCharacterA(StdOutput
,
341 coPos
.X
= xLeft
+ Width
- 1;
342 FillConsoleOutputCharacterA(StdOutput
,
350 WriteConsoleOutputCharacterA(StdOutput
,
352 min(strlen(Status
), (SIZE_T
)Width
- 4),
357 if (WaitEvent
== POPUP_WAIT_NONE
)
362 CONSOLE_ConInKey(Ir
);
364 if (WaitEvent
== POPUP_WAIT_ANY_KEY
||
365 Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D)
377 * FALSE: Don't quit setup.
380 ConfirmQuit(PINPUT_RECORD Ir
)
383 MUIDisplayError(ERROR_NOT_INSTALLED
, NULL
, POPUP_WAIT_NONE
);
387 CONSOLE_ConInKey(Ir
);
389 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
390 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
395 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
407 CheckUnattendedSetup(VOID
)
409 WCHAR UnattendInfPath
[MAX_PATH
];
416 if (DoesFileExist(SourcePath
.Buffer
, L
"unattend.inf") == FALSE
)
418 DPRINT("Does not exist: %S\\%S\n", SourcePath
.Buffer
, L
"unattend.inf");
422 wcscpy(UnattendInfPath
, SourcePath
.Buffer
);
423 wcscat(UnattendInfPath
, L
"\\unattend.inf");
425 /* Load 'unattend.inf' from install media. */
426 UnattendInf
= SetupOpenInfFileW(UnattendInfPath
,
432 if (UnattendInf
== INVALID_HANDLE_VALUE
)
434 DPRINT("SetupOpenInfFileW() failed\n");
438 /* Open 'Unattend' section */
439 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"Signature", &Context
))
441 DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
442 SetupCloseInfFile(UnattendInf
);
446 /* Get pointer 'Signature' key */
447 if (!INF_GetData(&Context
, NULL
, &Value
))
449 DPRINT("INF_GetData() failed for key 'Signature'\n");
450 SetupCloseInfFile(UnattendInf
);
454 /* Check 'Signature' string */
455 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
457 DPRINT("Signature not $ReactOS$\n");
458 SetupCloseInfFile(UnattendInf
);
462 /* Check if Unattend setup is enabled */
463 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"UnattendSetupEnabled", &Context
))
465 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
466 SetupCloseInfFile(UnattendInf
);
470 if (!INF_GetData(&Context
, NULL
, &Value
))
472 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
473 SetupCloseInfFile(UnattendInf
);
477 if (_wcsicmp(Value
, L
"yes") != 0)
479 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
480 SetupCloseInfFile(UnattendInf
);
484 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
485 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"DestinationDiskNumber", &Context
))
487 DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
488 SetupCloseInfFile(UnattendInf
);
492 if (!SetupGetIntField(&Context
, 1, &IntValue
))
494 DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
495 SetupCloseInfFile(UnattendInf
);
499 UnattendDestinationDiskNumber
= (LONG
)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 if (!SetupGetIntField(&Context
, 1, &IntValue
))
511 DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
512 SetupCloseInfFile(UnattendInf
);
516 UnattendDestinationPartitionNumber
= IntValue
;
518 /* Search for 'InstallationDirectory' in the 'Unattend' section */
519 if (!SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"InstallationDirectory", &Context
))
521 DPRINT("SetupFindFirstLine() failed for key 'InstallationDirectory'\n");
522 SetupCloseInfFile(UnattendInf
);
526 /* Get pointer 'InstallationDirectory' key */
527 if (!INF_GetData(&Context
, NULL
, &Value
))
529 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
530 SetupCloseInfFile(UnattendInf
);
534 wcscpy(UnattendInstallationDirectory
, Value
);
536 IsUnattendedSetup
= TRUE
;
538 /* Search for 'MBRInstallType' in the 'Unattend' section */
539 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"MBRInstallType", &Context
))
541 if (SetupGetIntField(&Context
, 1, &IntValue
))
543 UnattendMBRInstallType
= IntValue
;
547 /* Search for 'FormatPartition' in the 'Unattend' section */
548 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"FormatPartition", &Context
))
550 if (SetupGetIntField(&Context
, 1, &IntValue
))
552 UnattendFormatPartition
= IntValue
;
556 if (SetupFindFirstLineW(UnattendInf
, L
"Unattend", L
"AutoPartition", &Context
))
558 if (SetupGetIntField(&Context
, 1, &IntValue
))
560 AutoPartition
= IntValue
;
564 /* search for LocaleID in the 'Unattend' section*/
565 if (SetupFindFirstLineW (UnattendInf
, L
"Unattend", L
"LocaleID", &Context
))
567 if (INF_GetData (&Context
, NULL
, &Value
))
569 LONG Id
= wcstol(Value
, NULL
, 16);
570 swprintf(LocaleID
,L
"%08lx", Id
);
574 SetupCloseInfFile(UnattendInf
);
576 DPRINT("Running unattended setup\n");
583 PGENERIC_LIST_ENTRY ListEntry
;
584 LPCWSTR pszNewLayout
;
586 pszNewLayout
= MUIDefaultKeyboardLayout();
588 if (LayoutList
== NULL
)
590 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
591 if (LayoutList
== NULL
)
593 /* FIXME: Handle error! */
598 ListEntry
= GetFirstListEntry(LayoutList
);
600 /* Search for default layout (if provided) */
601 if (pszNewLayout
!= NULL
)
603 while (ListEntry
!= NULL
)
605 if (!wcscmp(pszNewLayout
, GetListEntryUserData(ListEntry
)))
607 SetCurrentListEntry(LayoutList
, ListEntry
);
611 ListEntry
= GetNextListEntry(ListEntry
);
618 LanguagePage(PINPUT_RECORD Ir
)
620 PWCHAR NewLanguageId
;
621 BOOL RefreshPage
= FALSE
;
623 /* Initialize the computer settings list */
624 if (LanguageList
== NULL
)
626 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
628 if (LanguageList
== NULL
)
630 PopupError("Setup failed to initialize available translations", NULL
, NULL
, POPUP_WAIT_NONE
);
636 SelectedLanguageId
= DefaultLanguage
;
637 SetConsoleCodePage();
639 DrawGenericList(LanguageList
,
645 ScrollToPositionGenericList (LanguageList
, GetDefaultLanguageIndex());
647 MUIDisplayPage(LANGUAGE_PAGE
);
651 CONSOLE_ConInKey(Ir
);
653 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
654 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
656 ScrollDownGenericList (LanguageList
);
659 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
660 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
662 ScrollUpGenericList(LanguageList
);
665 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
666 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
668 ScrollPageDownGenericList(LanguageList
);
671 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
672 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
674 ScrollPageUpGenericList(LanguageList
);
677 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
678 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
680 if (ConfirmQuit(Ir
) == TRUE
)
683 RedrawGenericList(LanguageList
);
685 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
687 SelectedLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
689 LanguageId
= (LANGID
)(wcstol(SelectedLanguageId
, NULL
, 16) & 0xFFFF);
691 if (wcscmp(SelectedLanguageId
, DefaultLanguage
))
697 SetConsoleCodePage();
701 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
704 GenericListKeyPress (LanguageList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
710 NewLanguageId
= (PWCHAR
)GetListEntryUserData(GetCurrentListEntry(LanguageList
));
712 if (SelectedLanguageId
!= NewLanguageId
)
714 /* Clear the language page */
715 MUIClearPage(LANGUAGE_PAGE
);
717 SelectedLanguageId
= NewLanguageId
;
720 SetConsoleCodePage();
722 /* Redraw language selection page in native language */
723 MUIDisplayPage(LANGUAGE_PAGE
);
737 * Number of the next page.
740 SetupStartPage(PINPUT_RECORD Ir
)
742 //SYSTEM_DEVICE_INFORMATION Sdi;
744 WCHAR FileNameBuffer
[MAX_PATH
];
749 PGENERIC_LIST_ENTRY ListEntry
;
752 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
755 /* Check whether a harddisk is available */
756 Status
= NtQuerySystemInformation(SystemDeviceInformation
,
758 sizeof(SYSTEM_DEVICE_INFORMATION
),
761 if (!NT_SUCCESS(Status
))
763 CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status
);
764 MUIDisplayError(ERROR_DRIVE_INFORMATION
, Ir
, POPUP_WAIT_ENTER
);
768 if (Sdi
.NumberOfDisks
== 0)
770 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
775 /* Get the source path and source root path */
776 Status
= GetSourcePaths(&SourcePath
,
780 if (!NT_SUCCESS(Status
))
782 CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status
);
783 MUIDisplayError(ERROR_NO_SOURCE_DRIVE
, Ir
, POPUP_WAIT_ENTER
);
789 CONSOLE_PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
790 CONSOLE_PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
791 CONSOLE_PrintTextXY(6, 17, "SourceRootDir: '%wZ'", &SourceRootDir
);
795 /* Load txtsetup.sif from install media. */
796 wcscpy(FileNameBuffer
, SourcePath
.Buffer
);
797 wcscat(FileNameBuffer
, L
"\\txtsetup.sif");
799 SetupInf
= SetupOpenInfFileW(FileNameBuffer
,
805 if (SetupInf
== INVALID_HANDLE_VALUE
)
807 MUIDisplayError(ERROR_LOAD_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
811 /* Open 'Version' section */
812 if (!SetupFindFirstLineW(SetupInf
, L
"Version", L
"Signature", &Context
))
814 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
818 /* Get pointer 'Signature' key */
819 if (!INF_GetData(&Context
, NULL
, &Value
))
821 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
825 /* Check 'Signature' string */
826 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
828 MUIDisplayError(ERROR_SIGNATURE_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
832 /* Open 'DiskSpaceRequirements' section */
833 if (!SetupFindFirstLineW(SetupInf
, L
"DiskSpaceRequirements", L
"FreeSysPartDiskSpace", &Context
))
835 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
839 /* Get the 'FreeSysPartDiskSpace' value */
840 if (!SetupGetIntField(&Context
, 1, &IntValue
))
842 MUIDisplayError(ERROR_CORRUPT_TXTSETUPSIF
, Ir
, POPUP_WAIT_ENTER
);
846 RequiredPartitionDiskSpace
= (ULONG
)IntValue
;
848 /* Start PnP thread */
849 if (hPnpThread
!= INVALID_HANDLE_VALUE
)
851 NtResumeThread(hPnpThread
, NULL
);
852 hPnpThread
= INVALID_HANDLE_VALUE
;
855 CheckUnattendedSetup();
857 if (IsUnattendedSetup
)
860 //read options from inf
861 ComputerList
= CreateComputerTypeList(SetupInf
);
862 DisplayList
= CreateDisplayDriverList(SetupInf
);
863 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
864 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
865 LanguageList
= CreateLanguageList(SetupInf
, DefaultLanguage
);
868 wcscpy(SelectedLanguageId
,LocaleID
);
870 /* first we hack LanguageList */
871 ListEntry
= GetFirstListEntry(LanguageList
);
873 while (ListEntry
!= NULL
)
875 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
877 DPRINT("found %S in LanguageList\n",GetListEntryUserData(ListEntry
));
878 SetCurrentListEntry(LanguageList
, ListEntry
);
882 ListEntry
= GetNextListEntry(ListEntry
);
886 ListEntry
= GetFirstListEntry(LayoutList
);
888 while (ListEntry
!= NULL
)
890 if (!wcsicmp(LocaleID
, GetListEntryUserData(ListEntry
)))
892 DPRINT("found %S in LayoutList\n",GetListEntryUserData(ListEntry
));
893 SetCurrentListEntry(LayoutList
, ListEntry
);
897 ListEntry
= GetNextListEntry(ListEntry
);
900 SetConsoleCodePage();
902 return INSTALL_INTRO_PAGE
;
905 return LANGUAGE_PAGE
;
915 IntroPage(PINPUT_RECORD Ir
)
917 MUIDisplayPage(START_PAGE
);
921 CONSOLE_ConInKey(Ir
);
923 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
924 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
926 if (ConfirmQuit(Ir
) == TRUE
)
931 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
933 return INSTALL_INTRO_PAGE
;
935 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
937 return REPAIR_INTRO_PAGE
;
939 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'L') /* R */
952 * Back to main setup page.
955 LicensePage(PINPUT_RECORD Ir
)
957 MUIDisplayPage(LICENSE_PAGE
);
961 CONSOLE_ConInKey(Ir
);
963 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
974 RepairIntroPage(PINPUT_RECORD Ir
)
976 MUIDisplayPage(REPAIR_INTRO_PAGE
);
980 CONSOLE_ConInKey(Ir
);
982 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
986 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'U') /* U */
988 RepairUpdateFlag
= TRUE
;
989 return INSTALL_INTRO_PAGE
;
991 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
993 return RECOVERY_PAGE
;
995 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
996 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1002 return REPAIR_INTRO_PAGE
;
1007 InstallIntroPage(PINPUT_RECORD Ir
)
1009 MUIDisplayPage(INSTALL_INTRO_PAGE
);
1011 if (RepairUpdateFlag
)
1013 //return SELECT_PARTITION_PAGE;
1014 return DEVICE_SETTINGS_PAGE
;
1017 if (IsUnattendedSetup
)
1019 return SELECT_PARTITION_PAGE
;
1024 CONSOLE_ConInKey(Ir
);
1026 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1027 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1029 if (ConfirmQuit(Ir
) == TRUE
)
1034 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1036 return DEVICE_SETTINGS_PAGE
;
1037 // return SCSI_CONTROLLER_PAGE;
1041 return INSTALL_INTRO_PAGE
;
1047 ScsiControllerPage(PINPUT_RECORD Ir
)
1049 SetTextXY(6, 8, "Setup detected the following mass storage devices:");
1051 /* FIXME: print loaded mass storage driver descriptions */
1053 SetTextXY(8, 10, "TEST device");
1057 SetStatusText(" ENTER = Continue F3 = Quit");
1063 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1064 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1066 if (ConfirmQuit(Ir
) == TRUE
)
1071 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1073 return DEVICE_SETTINGS_PAGE
;
1077 return SCSI_CONTROLLER_PAGE
;
1083 DeviceSettingsPage(PINPUT_RECORD Ir
)
1085 static ULONG Line
= 16;
1086 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1088 /* Initialize the computer settings list */
1089 if (ComputerList
== NULL
)
1091 ComputerList
= CreateComputerTypeList(SetupInf
);
1092 if (ComputerList
== NULL
)
1094 MUIDisplayError(ERROR_LOAD_COMPUTER
, Ir
, POPUP_WAIT_ENTER
);
1099 /* Initialize the display settings list */
1100 if (DisplayList
== NULL
)
1102 DisplayList
= CreateDisplayDriverList(SetupInf
);
1103 if (DisplayList
== NULL
)
1105 MUIDisplayError(ERROR_LOAD_DISPLAY
, Ir
, POPUP_WAIT_ENTER
);
1110 /* Initialize the keyboard settings list */
1111 if (KeyboardList
== NULL
)
1113 KeyboardList
= CreateKeyboardDriverList(SetupInf
);
1114 if (KeyboardList
== NULL
)
1116 MUIDisplayError(ERROR_LOAD_KEYBOARD
, Ir
, POPUP_WAIT_ENTER
);
1121 /* Initialize the keyboard layout list */
1122 if (LayoutList
== NULL
)
1124 LayoutList
= CreateKeyboardLayoutList(SetupInf
, DefaultKBLayout
);
1125 if (LayoutList
== NULL
)
1127 /* FIXME: report error */
1128 MUIDisplayError(ERROR_LOAD_KBLAYOUT
, Ir
, POPUP_WAIT_ENTER
);
1133 MUIDisplayPage(DEVICE_SETTINGS_PAGE
);
1136 CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList
))));
1137 CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList
))));
1138 CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList
))));
1139 CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList
))));
1141 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1143 if (RepairUpdateFlag
)
1145 return SELECT_PARTITION_PAGE
;
1150 CONSOLE_ConInKey(Ir
);
1152 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1153 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1155 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1159 else if (Line
== 16)
1164 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1166 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1167 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1169 CONSOLE_NormalTextXY(24, Line
, 48, 1);
1173 else if (Line
== 16)
1178 CONSOLE_InvertTextXY(24, Line
, 48, 1);
1180 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1181 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1183 if (ConfirmQuit(Ir
) == TRUE
)
1188 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1191 return COMPUTER_SETTINGS_PAGE
;
1192 else if (Line
== 12)
1193 return DISPLAY_SETTINGS_PAGE
;
1194 else if (Line
== 13)
1195 return KEYBOARD_SETTINGS_PAGE
;
1196 else if (Line
== 14)
1197 return LAYOUT_SETTINGS_PAGE
;
1198 else if (Line
== 16)
1199 return SELECT_PARTITION_PAGE
;
1203 return DEVICE_SETTINGS_PAGE
;
1208 ComputerSettingsPage(PINPUT_RECORD Ir
)
1210 MUIDisplayPage(COMPUTER_SETTINGS_PAGE
);
1212 DrawGenericList(ComputerList
,
1218 SaveGenericListState(ComputerList
);
1222 CONSOLE_ConInKey(Ir
);
1224 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1225 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1227 ScrollDownGenericList(ComputerList
);
1229 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1230 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1232 ScrollUpGenericList(ComputerList
);
1234 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1235 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1237 if (ConfirmQuit(Ir
) == TRUE
)
1242 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1243 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1245 RestoreGenericListState(ComputerList
);
1246 return DEVICE_SETTINGS_PAGE
;
1248 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1250 return DEVICE_SETTINGS_PAGE
;
1254 return COMPUTER_SETTINGS_PAGE
;
1259 DisplaySettingsPage(PINPUT_RECORD Ir
)
1261 MUIDisplayPage(DISPLAY_SETTINGS_PAGE
);
1263 DrawGenericList(DisplayList
,
1269 SaveGenericListState(DisplayList
);
1273 CONSOLE_ConInKey(Ir
);
1275 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1276 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1278 ScrollDownGenericList(DisplayList
);
1280 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1281 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1283 ScrollUpGenericList(DisplayList
);
1285 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1286 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1288 if (ConfirmQuit(Ir
) == TRUE
)
1295 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1296 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1298 RestoreGenericListState(DisplayList
);
1299 return DEVICE_SETTINGS_PAGE
;
1301 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1303 return DEVICE_SETTINGS_PAGE
;
1307 return DISPLAY_SETTINGS_PAGE
;
1312 KeyboardSettingsPage(PINPUT_RECORD Ir
)
1314 MUIDisplayPage(KEYBOARD_SETTINGS_PAGE
);
1316 DrawGenericList(KeyboardList
,
1322 SaveGenericListState(KeyboardList
);
1326 CONSOLE_ConInKey(Ir
);
1328 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1329 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1331 ScrollDownGenericList(KeyboardList
);
1333 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1334 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1336 ScrollUpGenericList(KeyboardList
);
1338 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1339 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1341 if (ConfirmQuit(Ir
) == TRUE
)
1346 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1347 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1349 RestoreGenericListState(KeyboardList
);
1350 return DEVICE_SETTINGS_PAGE
;
1352 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1354 return DEVICE_SETTINGS_PAGE
;
1358 return KEYBOARD_SETTINGS_PAGE
;
1363 LayoutSettingsPage(PINPUT_RECORD Ir
)
1365 MUIDisplayPage(LAYOUT_SETTINGS_PAGE
);
1367 DrawGenericList(LayoutList
,
1373 SaveGenericListState(LayoutList
);
1377 CONSOLE_ConInKey(Ir
);
1379 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1380 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1382 ScrollDownGenericList(LayoutList
);
1384 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1385 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1387 ScrollUpGenericList(LayoutList
);
1389 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1390 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_NEXT
)) /* PAGE DOWN */
1392 ScrollPageDownGenericList(LayoutList
);
1394 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1395 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_PRIOR
)) /* PAGE UP */
1397 ScrollPageUpGenericList(LayoutList
);
1399 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1400 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1402 if (ConfirmQuit(Ir
) == TRUE
)
1407 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1408 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1410 RestoreGenericListState(LayoutList
);
1411 return DEVICE_SETTINGS_PAGE
;
1413 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1415 return DEVICE_SETTINGS_PAGE
;
1417 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
> 0x60) && (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
< 0x7b))
1420 GenericListKeyPress(LayoutList
, Ir
->Event
.KeyEvent
.uChar
.AsciiChar
);
1424 return LAYOUT_SETTINGS_PAGE
;
1429 IsDiskSizeValid(PPARTENTRY PartEntry
)
1433 size
= PartEntry
->SectorCount
.QuadPart
* PartEntry
->DiskEntry
->BytesPerSector
;
1434 size
= (size
+ 524288) / 1048576; /* in MBytes */
1436 if (size
< RequiredPartitionDiskSpace
)
1438 /* partition is too small so ask for another partion */
1439 DPRINT1("Partition is too small (size: %I64u MB), required disk space is %lu MB\n", size
, RequiredPartitionDiskSpace
);
1450 SelectPartitionPage(PINPUT_RECORD Ir
)
1454 MUIDisplayPage(SELECT_PARTITION_PAGE
);
1456 if (PartitionList
== NULL
)
1458 PartitionList
= CreatePartitionList(2,
1462 if (PartitionList
== NULL
)
1464 /* FIXME: show an error dialog */
1467 else if (IsListEmpty (&PartitionList
->DiskListHead
))
1469 MUIDisplayError(ERROR_NO_HDD
, Ir
, POPUP_WAIT_ENTER
);
1474 DrawPartitionList(PartitionList
);
1476 /* Warn about partitions created by Linux Fdisk */
1477 if (WarnLinuxPartitions
== TRUE
&&
1478 CheckForLinuxFdiskPartitions(PartitionList
) == TRUE
)
1480 MUIDisplayError(ERROR_WARN_PARTITION
, NULL
, POPUP_WAIT_NONE
);
1484 CONSOLE_ConInKey(Ir
);
1486 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1487 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1491 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1493 WarnLinuxPartitions
= FALSE
;
1494 return SELECT_PARTITION_PAGE
;
1499 if (IsUnattendedSetup
)
1501 if (!SelectPartition(PartitionList
, UnattendDestinationDiskNumber
, UnattendDestinationPartitionNumber
))
1505 CreatePrimaryPartition(PartitionList
,
1506 PartitionList
->CurrentPartition
->SectorCount
.QuadPart
,
1509 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1511 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1512 RequiredPartitionDiskSpace
);
1513 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1516 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1518 return SELECT_FILE_SYSTEM_PAGE
;
1523 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1525 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1526 RequiredPartitionDiskSpace
);
1527 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1530 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1532 return SELECT_FILE_SYSTEM_PAGE
;
1538 /* Update status text */
1539 if (PartitionList
->CurrentPartition
== NULL
)
1541 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1543 else if (PartitionList
->CurrentPartition
->LogicalPartition
)
1545 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1547 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1551 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATELOGICAL
));
1556 if (PartitionList
->CurrentPartition
->IsPartitioned
)
1558 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1560 CONSOLE_SetStatusText(MUIGetString(STRING_DELETEPARTITION
));
1564 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLDELETEPARTITION
));
1569 CONSOLE_SetStatusText(MUIGetString(STRING_INSTALLCREATEPARTITION
));
1573 CONSOLE_ConInKey(Ir
);
1575 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1576 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1578 if (ConfirmQuit(Ir
) == TRUE
)
1580 DestroyPartitionList(PartitionList
);
1581 PartitionList
= NULL
;
1587 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1588 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1590 if (ScrollDownPartitionList(PartitionList
))
1591 DrawPartitionList(PartitionList
);
1593 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1594 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1596 if (ScrollUpPartitionList(PartitionList
))
1597 DrawPartitionList(PartitionList
);
1599 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1601 if (IsContainerPartition(PartitionList
->CurrentPartition
->PartitionType
))
1602 continue; //return SELECT_PARTITION_PAGE;
1604 if (PartitionList
->CurrentPartition
== NULL
||
1605 PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1607 CreatePrimaryPartition(PartitionList
,
1612 if (!IsDiskSizeValid(PartitionList
->CurrentPartition
))
1614 MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE
, Ir
, POPUP_WAIT_ANY_KEY
,
1615 RequiredPartitionDiskSpace
);
1616 return SELECT_PARTITION_PAGE
; /* let the user select another partition */
1619 DestinationDriveLetter
= (WCHAR
)PartitionList
->CurrentPartition
->DriveLetter
;
1621 return INSTALL_DIRECTORY_PAGE
;
1623 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'P') /* P */
1625 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1627 Error
= PrimaryPartitionCreationChecks(PartitionList
);
1628 if (Error
!= NOT_AN_ERROR
)
1630 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1631 return SELECT_PARTITION_PAGE
;
1634 return CREATE_PRIMARY_PARTITION_PAGE
;
1637 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'E') /* E */
1639 if (PartitionList
->CurrentPartition
->LogicalPartition
== FALSE
)
1641 Error
= ExtendedPartitionCreationChecks(PartitionList
);
1642 if (Error
!= NOT_AN_ERROR
)
1644 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1645 return SELECT_PARTITION_PAGE
;
1648 return CREATE_EXTENDED_PARTITION_PAGE
;
1651 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'L') /* L */
1653 if (PartitionList
->CurrentPartition
->LogicalPartition
== TRUE
)
1655 Error
= LogicalPartitionCreationChecks(PartitionList
);
1656 if (Error
!= NOT_AN_ERROR
)
1658 MUIDisplayError(Error
, Ir
, POPUP_WAIT_ANY_KEY
);
1659 return SELECT_PARTITION_PAGE
;
1662 return CREATE_LOGICAL_PARTITION_PAGE
;
1665 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
1667 if (PartitionList
->CurrentPartition
->IsPartitioned
== FALSE
)
1669 MUIDisplayError(ERROR_DELETE_SPACE
, Ir
, POPUP_WAIT_ANY_KEY
);
1670 return SELECT_PARTITION_PAGE
;
1673 return DELETE_PARTITION_PAGE
;
1677 return SELECT_PARTITION_PAGE
;
1682 DrawInputField(ULONG FieldLength
,
1693 memset(buf
, '_', sizeof(buf
));
1694 buf
[FieldLength
- strlen(FieldContent
)] = 0;
1695 strcat(buf
, FieldContent
);
1697 WriteConsoleOutputCharacterA(StdOutput
,
1705 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
1706 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
1707 #define PARTITION_MAXSIZE 999999
1710 ShowPartitionSizeInputBox(SHORT Left
,
1734 DrawBox(Left
, Top
, Right
- Left
+ 1, Bottom
- Top
+ 1);
1739 strcpy(Buffer
, MUIGetString(STRING_PARTITIONSIZE
));
1740 iLeft
= coPos
.X
+ strlen(Buffer
) + 1;
1743 WriteConsoleOutputCharacterA(StdOutput
,
1749 sprintf(Buffer
, MUIGetString(STRING_MAXSIZE
), MaxSize
);
1750 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
1752 WriteConsoleOutputCharacterA(StdOutput
,
1758 sprintf(Buffer
, "%lu", MaxSize
);
1759 Index
= strlen(Buffer
);
1760 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1767 CONSOLE_ConInKey(&Ir
);
1769 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1770 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1778 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1782 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1790 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1796 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1801 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1802 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1804 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1806 if ((ch
>= '0') && (ch
<= '9'))
1812 DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1820 strcpy(InputBuffer
, Buffer
);
1825 CreatePrimaryPartitionPage(PINPUT_RECORD Ir
)
1827 PDISKENTRY DiskEntry
;
1828 PPARTENTRY PartEntry
;
1831 CHAR InputBuffer
[50];
1835 ULONGLONG SectorCount
;
1839 if (PartitionList
== NULL
||
1840 PartitionList
->CurrentDisk
== NULL
||
1841 PartitionList
->CurrentPartition
== NULL
)
1843 /* FIXME: show an error dialog */
1847 DiskEntry
= PartitionList
->CurrentDisk
;
1848 PartEntry
= PartitionList
->CurrentPartition
;
1850 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
1852 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSENEWPARTITION
));
1854 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
1856 if (DiskSize
>= 10737418240) /* 10 GB */
1858 DiskSize
= DiskSize
/ 1073741824;
1859 Unit
= MUIGetString(STRING_GB
);
1864 DiskSize
= DiskSize
/ 1048576;
1868 Unit
= MUIGetString(STRING_MB
);
1871 if (DiskEntry
->DriverName
.Length
> 0)
1873 CONSOLE_PrintTextXY(6, 10,
1874 MUIGetString(STRING_HDINFOPARTCREATE
),
1877 DiskEntry
->DiskNumber
,
1881 &DiskEntry
->DriverName
);
1885 CONSOLE_PrintTextXY(6, 10,
1886 MUIGetString(STRING_HDDINFOUNK1
),
1889 DiskEntry
->DiskNumber
,
1895 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
1898 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
1899 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
1902 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
1904 PartEntry
= PartitionList
->CurrentPartition
;
1907 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
1909 if (MaxSize
> PARTITION_MAXSIZE
)
1910 MaxSize
= PARTITION_MAXSIZE
;
1912 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1913 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1917 if (ConfirmQuit (Ir
) == TRUE
)
1922 else if (Cancel
== TRUE
)
1924 return SELECT_PARTITION_PAGE
;
1928 PartSize
= atoi(InputBuffer
);
1936 if (PartSize
> MaxSize
)
1942 /* Convert to bytes */
1943 if (PartSize
== MaxSize
)
1945 /* Use all of the unpartitioned disk space */
1946 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1950 /* Calculate the sector count from the size in MB */
1951 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
1953 /* But never get larger than the unpartitioned disk space */
1954 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
1955 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
1958 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1960 CreatePrimaryPartition(PartitionList
,
1964 Status
= WriteDirtyPartitions(PartitionList
);
1965 if (!NT_SUCCESS(Status
))
1967 DPRINT("WriteDirtyPartitions() failed\n");
1968 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
1972 return SELECT_FILE_SYSTEM_PAGE
;
1976 return CREATE_PRIMARY_PARTITION_PAGE
;
1981 CreateExtendedPartitionPage(PINPUT_RECORD Ir
)
1983 PDISKENTRY DiskEntry
;
1984 PPARTENTRY PartEntry
;
1987 CHAR InputBuffer
[50];
1991 ULONGLONG SectorCount
;
1995 if (PartitionList
== NULL
||
1996 PartitionList
->CurrentDisk
== NULL
||
1997 PartitionList
->CurrentPartition
== NULL
)
1999 /* FIXME: show an error dialog */
2003 DiskEntry
= PartitionList
->CurrentDisk
;
2004 PartEntry
= PartitionList
->CurrentPartition
;
2006 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2008 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_EXTENDED_PARTITION
));
2010 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2012 if (DiskSize
>= 10737418240) /* 10 GB */
2014 DiskSize
= DiskSize
/ 1073741824;
2015 Unit
= MUIGetString(STRING_GB
);
2020 DiskSize
= DiskSize
/ 1048576;
2024 Unit
= MUIGetString(STRING_MB
);
2027 if (DiskEntry
->DriverName
.Length
> 0)
2029 CONSOLE_PrintTextXY(6, 10,
2030 MUIGetString(STRING_HDINFOPARTCREATE
),
2033 DiskEntry
->DiskNumber
,
2037 &DiskEntry
->DriverName
);
2041 CONSOLE_PrintTextXY(6, 10,
2042 MUIGetString(STRING_HDDINFOUNK1
),
2045 DiskEntry
->DiskNumber
,
2051 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2054 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2055 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2058 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2060 PartEntry
= PartitionList
->CurrentPartition
;
2063 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2065 if (MaxSize
> PARTITION_MAXSIZE
)
2066 MaxSize
= PARTITION_MAXSIZE
;
2068 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2069 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2073 if (ConfirmQuit (Ir
) == TRUE
)
2078 else if (Cancel
== TRUE
)
2080 return SELECT_PARTITION_PAGE
;
2084 PartSize
= atoi(InputBuffer
);
2092 if (PartSize
> MaxSize
)
2098 /* Convert to bytes */
2099 if (PartSize
== MaxSize
)
2101 /* Use all of the unpartitioned disk space */
2102 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2106 /* Calculate the sector count from the size in MB */
2107 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2109 /* But never get larger than the unpartitioned disk space */
2110 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2111 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2114 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
2116 CreateExtendedPartition(PartitionList
,
2119 Status
= WriteDirtyPartitions(PartitionList
);
2120 if (!NT_SUCCESS(Status
))
2122 DPRINT("WriteDirtyPartitions() failed\n");
2123 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2127 return SELECT_PARTITION_PAGE
;
2131 return CREATE_EXTENDED_PARTITION_PAGE
;
2136 CreateLogicalPartitionPage(PINPUT_RECORD Ir
)
2138 PDISKENTRY DiskEntry
;
2139 PPARTENTRY PartEntry
;
2142 CHAR InputBuffer
[50];
2146 ULONGLONG SectorCount
;
2150 if (PartitionList
== NULL
||
2151 PartitionList
->CurrentDisk
== NULL
||
2152 PartitionList
->CurrentPartition
== NULL
)
2154 /* FIXME: show an error dialog */
2158 DiskEntry
= PartitionList
->CurrentDisk
;
2159 PartEntry
= PartitionList
->CurrentPartition
;
2161 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2163 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHOOSE_NEW_LOGICAL_PARTITION
));
2165 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2167 if (DiskSize
>= 10737418240) /* 10 GB */
2169 DiskSize
= DiskSize
/ 1073741824;
2170 Unit
= MUIGetString(STRING_GB
);
2175 DiskSize
= DiskSize
/ 1048576;
2179 Unit
= MUIGetString(STRING_MB
);
2182 if (DiskEntry
->DriverName
.Length
> 0)
2184 CONSOLE_PrintTextXY(6, 10,
2185 MUIGetString(STRING_HDINFOPARTCREATE
),
2188 DiskEntry
->DiskNumber
,
2192 &DiskEntry
->DriverName
);
2196 CONSOLE_PrintTextXY(6, 10,
2197 MUIGetString(STRING_HDDINFOUNK1
),
2200 DiskEntry
->DiskNumber
,
2206 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_HDDSIZE
));
2209 CONSOLE_PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
2210 PartitionList
->CurrentPartition
->SectorCount
* DiskEntry
->BytesPerSector
/ 1048576);
2213 CONSOLE_SetStatusText(MUIGetString(STRING_CREATEPARTITION
));
2215 PartEntry
= PartitionList
->CurrentPartition
;
2218 MaxSize
= (PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
) / 1048576; /* in MBytes (rounded) */
2220 if (MaxSize
> PARTITION_MAXSIZE
)
2221 MaxSize
= PARTITION_MAXSIZE
;
2223 ShowPartitionSizeInputBox(12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
2224 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
2228 if (ConfirmQuit (Ir
) == TRUE
)
2233 else if (Cancel
== TRUE
)
2235 return SELECT_PARTITION_PAGE
;
2239 PartSize
= atoi(InputBuffer
);
2247 if (PartSize
> MaxSize
)
2253 /* Convert to bytes */
2254 if (PartSize
== MaxSize
)
2256 /* Use all of the unpartitioned disk space */
2257 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2261 /* Calculate the sector count from the size in MB */
2262 SectorCount
= PartSize
* 1048576 / DiskEntry
->BytesPerSector
;
2264 /* But never get larger than the unpartitioned disk space */
2265 if (SectorCount
> PartEntry
->SectorCount
.QuadPart
)
2266 SectorCount
= PartEntry
->SectorCount
.QuadPart
;
2269 DPRINT("Partition size: %I64u bytes\n", PartSize
);
2271 CreateLogicalPartition(PartitionList
,
2274 Status
= WriteDirtyPartitions(PartitionList
);
2275 if (!NT_SUCCESS(Status
))
2277 DPRINT("WriteDirtyPartitions() failed\n");
2278 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2282 return SELECT_FILE_SYSTEM_PAGE
;
2286 return CREATE_LOGICAL_PARTITION_PAGE
;
2291 DeletePartitionPage(PINPUT_RECORD Ir
)
2293 PDISKENTRY DiskEntry
;
2294 PPARTENTRY PartEntry
;
2301 if (PartitionList
== NULL
||
2302 PartitionList
->CurrentDisk
== NULL
||
2303 PartitionList
->CurrentPartition
== NULL
)
2305 /* FIXME: show an error dialog */
2309 DiskEntry
= PartitionList
->CurrentDisk
;
2310 PartEntry
= PartitionList
->CurrentPartition
;
2312 MUIDisplayPage(DELETE_PARTITION_PAGE
);
2314 /* Determine partition type */
2316 if (PartEntry
->New
== TRUE
)
2318 PartType
= MUIGetString(STRING_UNFORMATTED
);
2320 else if (PartEntry
->IsPartitioned
== TRUE
)
2322 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2323 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2324 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2325 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2329 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2330 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2334 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2338 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2340 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2342 else if (IsContainerPartition(PartEntry
->PartitionType
))
2344 PartType
= MUIGetString(STRING_EXTENDED_PARTITION
);
2348 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2350 if (PartSize
>= 10737418240) /* 10 GB */
2352 PartSize
= PartSize
/ 1073741824;
2353 Unit
= MUIGetString(STRING_GB
);
2357 if (PartSize
>= 10485760) /* 10 MB */
2359 PartSize
= PartSize
/ 1048576;
2360 Unit
= MUIGetString(STRING_MB
);
2364 PartSize
= PartSize
/ 1024;
2365 Unit
= MUIGetString(STRING_KB
);
2368 if (PartType
== NULL
)
2370 CONSOLE_PrintTextXY(6, 10,
2371 MUIGetString(STRING_HDDINFOUNK2
),
2372 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2373 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2374 PartEntry
->PartitionType
,
2380 CONSOLE_PrintTextXY(6, 10,
2381 " %c%c %s %I64u %s",
2382 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2383 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2389 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2391 if (DiskSize
>= 10737418240) /* 10 GB */
2393 DiskSize
= DiskSize
/ 1073741824;
2394 Unit
= MUIGetString(STRING_GB
);
2399 DiskSize
= DiskSize
/ 1048576;
2403 Unit
= MUIGetString(STRING_MB
);
2406 if (DiskEntry
->DriverName
.Length
> 0)
2408 CONSOLE_PrintTextXY(6, 12,
2409 MUIGetString(STRING_HDINFOPARTDELETE
),
2412 DiskEntry
->DiskNumber
,
2416 &DiskEntry
->DriverName
);
2420 CONSOLE_PrintTextXY(6, 12,
2421 MUIGetString(STRING_HDDINFOUNK3
),
2424 DiskEntry
->DiskNumber
,
2432 CONSOLE_ConInKey(Ir
);
2434 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2435 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2437 if (ConfirmQuit(Ir
) == TRUE
)
2444 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
2446 return SELECT_PARTITION_PAGE
;
2448 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== 'D') /* D */
2450 DeleteCurrentPartition(PartitionList
);
2452 Status
= WriteDirtyPartitions(PartitionList
);
2453 if (!NT_SUCCESS(Status
))
2455 DPRINT("WriteDirtyPartitions() failed\n");
2456 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2460 return SELECT_PARTITION_PAGE
;
2464 return DELETE_PARTITION_PAGE
;
2469 SelectFileSystemPage(PINPUT_RECORD Ir
)
2471 PDISKENTRY DiskEntry
;
2472 PPARTENTRY PartEntry
;
2479 if (PartitionList
== NULL
||
2480 PartitionList
->CurrentDisk
== NULL
||
2481 PartitionList
->CurrentPartition
== NULL
)
2483 /* FIXME: show an error dialog */
2487 DiskEntry
= PartitionList
->CurrentDisk
;
2488 PartEntry
= PartitionList
->CurrentPartition
;
2490 /* adjust disk size */
2491 DiskSize
= DiskEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2492 if (DiskSize
>= 10737418240) /* 10 GB */
2494 DiskSize
= DiskSize
/ 1073741824;
2495 DiskUnit
= MUIGetString(STRING_GB
);
2499 DiskSize
= DiskSize
/ 1048576;
2500 DiskUnit
= MUIGetString(STRING_MB
);
2503 /* adjust partition size */
2504 PartSize
= PartEntry
->SectorCount
.QuadPart
* DiskEntry
->BytesPerSector
;
2505 if (PartSize
>= 10737418240) /* 10 GB */
2507 PartSize
= PartSize
/ 1073741824;
2508 PartUnit
= MUIGetString(STRING_GB
);
2512 PartSize
= PartSize
/ 1048576;
2513 PartUnit
= MUIGetString(STRING_MB
);
2516 /* adjust partition type */
2517 if ((PartEntry
->PartitionType
== PARTITION_FAT_12
) ||
2518 (PartEntry
->PartitionType
== PARTITION_FAT_16
) ||
2519 (PartEntry
->PartitionType
== PARTITION_HUGE
) ||
2520 (PartEntry
->PartitionType
== PARTITION_XINT13
))
2524 else if ((PartEntry
->PartitionType
== PARTITION_FAT32
) ||
2525 (PartEntry
->PartitionType
== PARTITION_FAT32_XINT13
))
2529 else if (PartEntry
->PartitionType
== PARTITION_EXT2
)
2533 else if (PartEntry
->PartitionType
== PARTITION_IFS
)
2535 PartType
= "NTFS"; /* FIXME: Not quite correct! */
2537 else if (PartEntry
->PartitionType
== PARTITION_ENTRY_UNUSED
)
2539 PartType
= MUIGetString(STRING_FORMATUNUSED
);
2543 PartType
= MUIGetString(STRING_FORMATUNKNOWN
);
2546 if (PartEntry
->AutoCreate
== TRUE
)
2548 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NEWPARTITION
));
2551 CONSOLE_PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
2552 PartEntry
->PartitionNumber
,
2558 CONSOLE_PrintTextXY(8, 10, MUIGetString(STRING_HDINFOPARTZEROED
),
2559 DiskEntry
->DiskNumber
,
2565 &DiskEntry
->DriverName
);
2567 CONSOLE_SetTextXY(6, 12, MUIGetString(STRING_PARTFORMAT
));
2570 PartEntry
->AutoCreate
= FALSE
;
2572 else if (PartEntry
->New
== TRUE
)
2574 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDPART
));
2575 CONSOLE_SetTextXY(6, 10, MUIGetString(STRING_PARTFORMAT
));
2579 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_INSTALLONPART
));
2581 if (PartType
== NULL
)
2583 CONSOLE_PrintTextXY(8, 10,
2584 MUIGetString(STRING_HDDINFOUNK4
),
2585 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2586 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2587 PartEntry
->PartitionType
,
2593 CONSOLE_PrintTextXY(8, 10,
2595 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
2596 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
2602 CONSOLE_PrintTextXY(6, 12, MUIGetString(STRING_HDINFOPARTEXISTS
),
2603 DiskEntry
->DiskNumber
,
2609 &DiskEntry
->DriverName
);
2612 MUIDisplayPage(SELECT_FILE_SYSTEM_PAGE
);
2614 if (FileSystemList
== NULL
)
2616 FileSystemList
= CreateFileSystemList(6, 26, PartEntry
->New
, L
"FAT");
2617 if (FileSystemList
== NULL
)
2619 /* FIXME: show an error dialog */
2623 /* FIXME: Add file systems to list */
2626 DrawFileSystemList(FileSystemList
);
2628 if (RepairUpdateFlag
)
2630 return CHECK_FILE_SYSTEM_PAGE
;
2631 //return SELECT_PARTITION_PAGE;
2634 if (IsUnattendedSetup
)
2636 if (UnattendFormatPartition
)
2638 return FORMAT_PARTITION_PAGE
;
2641 return CHECK_FILE_SYSTEM_PAGE
;
2646 CONSOLE_ConInKey(Ir
);
2648 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2649 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2651 if (ConfirmQuit(Ir
) == TRUE
)
2658 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2659 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
2661 return SELECT_PARTITION_PAGE
;
2663 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2664 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
2666 ScrollDownFileSystemList(FileSystemList
);
2668 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2669 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
2671 ScrollUpFileSystemList(FileSystemList
);
2673 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
2675 if (!FileSystemList
->Selected
->FormatFunc
)
2677 return CHECK_FILE_SYSTEM_PAGE
;
2681 return FORMAT_PARTITION_PAGE
;
2686 return SELECT_FILE_SYSTEM_PAGE
;
2691 FormatPartitionPage(PINPUT_RECORD Ir
)
2693 WCHAR PathBuffer
[MAX_PATH
];
2694 PDISKENTRY DiskEntry
;
2695 PPARTENTRY PartEntry
;
2704 MUIDisplayPage(FORMAT_PARTITION_PAGE
);
2706 if (PartitionList
== NULL
||
2707 PartitionList
->CurrentDisk
== NULL
||
2708 PartitionList
->CurrentPartition
== NULL
)
2710 /* FIXME: show an error dialog */
2714 DiskEntry
= PartitionList
->CurrentDisk
;
2715 PartEntry
= PartitionList
->CurrentPartition
;
2719 if (!IsUnattendedSetup
)
2721 CONSOLE_ConInKey(Ir
);
2724 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
2725 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
2727 if (ConfirmQuit(Ir
) == TRUE
)
2734 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
|| IsUnattendedSetup
) /* ENTER */
2736 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2738 if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"FAT") == 0)
2740 if (PartEntry
->SectorCount
.QuadPart
< 8192)
2742 /* FAT12 CHS partition (disk is smaller than 4.1MB) */
2743 PartEntry
->PartitionType
= PARTITION_FAT_12
;
2745 else if (PartEntry
->StartSector
.QuadPart
< 1450560)
2747 /* Partition starts below the 8.4GB boundary ==> CHS partition */
2749 if (PartEntry
->SectorCount
.QuadPart
< 65536)
2751 /* FAT16 CHS partition (partiton size < 32MB) */
2752 PartEntry
->PartitionType
= PARTITION_FAT_16
;
2754 else if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2756 /* FAT16 CHS partition (partition size < 512MB) */
2757 PartEntry
->PartitionType
= PARTITION_HUGE
;
2761 /* FAT32 CHS partition (partition size >= 512MB) */
2762 PartEntry
->PartitionType
= PARTITION_FAT32
;
2767 /* Partition starts above the 8.4GB boundary ==> LBA partition */
2769 if (PartEntry
->SectorCount
.QuadPart
< 1048576)
2771 /* FAT16 LBA partition (partition size < 512MB) */
2772 PartEntry
->PartitionType
= PARTITION_XINT13
;
2776 /* FAT32 LBA partition (partition size >= 512MB) */
2777 PartEntry
->PartitionType
= PARTITION_FAT32_XINT13
;
2781 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2784 else if (wcscmp(FileSystemList
->Selected
->FileSystem
, L
"EXT2") == 0)
2786 PartEntry
->PartitionType
= PARTITION_EXT2
;
2787 DiskEntry
->LayoutBuffer
->PartitionEntry
[PartEntry
->PartitionIndex
].PartitionType
= PartEntry
->PartitionType
;
2790 else if (!FileSystemList
->Selected
->FormatFunc
)
2794 CONSOLE_PrintTextXY(6, 12,
2795 "Disk: %I64u Cylinder: %I64u Track: %I64u",
2796 DiskEntry
->DiskSize
,
2797 DiskEntry
->CylinderSize
,
2798 DiskEntry
->TrackSize
);
2801 DiskEntry
= PartitionList
->CurrentDisk
;
2802 Entry
= DiskEntry
->PartListHead
.Flink
;
2804 while (Entry
!= &DiskEntry
->PrimaryPartListHead
)
2806 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
2808 if (PartEntry
->IsPartitioned
== TRUE
)
2810 CONSOLE_PrintTextXY(6, Line
,
2811 "%2u: %2u %c %12I64u %12I64u %2u %c",
2813 PartEntry
->PartitionNumber
,
2814 PartEntry
->BootIndicator
? 'A' : '-',
2815 PartEntry
->StartSector
.QuadPart
,
2816 PartEntry
->SectorCount
.QuadPart
,
2817 PartEntry
->PartitionType
,
2818 PartEntry
->Dirty
? '*' : ' ');
2822 Entry
= Entry
->Flink
;
2825 /* Restore the old entry */
2826 PartEntry
= PartitionList
->CurrentPartition
;
2829 CheckActiveBootPartition(PartitionList
);
2831 Status
= WriteDirtyPartitions(PartitionList
);
2832 if (!NT_SUCCESS(Status
))
2834 DPRINT("WriteDirtyPartitions() failed\n");
2835 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
2839 /* Set DestinationRootPath */
2840 RtlFreeUnicodeString(&DestinationRootPath
);
2841 swprintf(PathBuffer
,
2842 L
"\\Device\\Harddisk%lu\\Partition%lu",
2843 PartitionList
->CurrentDisk
->DiskNumber
,
2844 PartitionList
->CurrentPartition
->PartitionNumber
);
2845 RtlCreateUnicodeString(&DestinationRootPath
,
2847 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2849 if (FileSystemList
->Selected
->FormatFunc
)
2851 Status
= FormatPartition(&DestinationRootPath
,
2852 FileSystemList
->Selected
);
2853 if (!NT_SUCCESS(Status
))
2855 DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status
);
2856 /* FIXME: show an error dialog */
2860 PartEntry
->New
= FALSE
;
2865 CONSOLE_SetStatusText(" Done. Press any key ...");
2866 CONSOLE_ConInKey(Ir
);
2869 DestroyFileSystemList(FileSystemList
);
2870 FileSystemList
= NULL
;
2872 if (IsUnattendedSetup
)
2873 return INSTALL_DIRECTORY_PAGE
;
2875 return SELECT_PARTITION_PAGE
;
2879 return FORMAT_PARTITION_PAGE
;
2884 CheckFileSystemPage(PINPUT_RECORD Ir
)
2886 PFILE_SYSTEM_ITEM CurrentFileSystem
;
2887 WCHAR PathBuffer
[MAX_PATH
];
2888 CHAR Buffer
[MAX_PATH
];
2891 /* FIXME: code duplicated in FormatPartitionPage */
2892 /* Set DestinationRootPath */
2893 RtlFreeUnicodeString(&DestinationRootPath
);
2894 swprintf(PathBuffer
,
2895 L
"\\Device\\Harddisk%lu\\Partition%lu",
2896 PartitionList
->CurrentDisk
->DiskNumber
,
2897 PartitionList
->CurrentPartition
->PartitionNumber
);
2898 RtlCreateUnicodeString(&DestinationRootPath
, PathBuffer
);
2899 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2901 CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_CHECKINGPART
));
2903 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
2905 /* WRONG: first filesystem is not necesseraly the one of the current partition! */
2906 CurrentFileSystem
= CONTAINING_RECORD(FileSystemList
->ListHead
.Flink
, FILE_SYSTEM_ITEM
, ListEntry
);
2908 if (!CurrentFileSystem
->ChkdskFunc
)
2911 "Setup is currently unable to check a partition formatted in %S.\n"
2913 " \x07 Press ENTER to continue Setup.\n"
2914 " \x07 Press F3 to quit Setup.",
2915 CurrentFileSystem
->FileSystem
);
2918 MUIGetString(STRING_QUITCONTINUE
),
2919 NULL
, POPUP_WAIT_NONE
);
2923 CONSOLE_ConInKey(Ir
);
2925 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00 &&
2926 Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
) /* F3 */
2928 if (ConfirmQuit(Ir
))
2931 return CHECK_FILE_SYSTEM_PAGE
;
2933 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== VK_RETURN
) /* ENTER */
2935 return INSTALL_DIRECTORY_PAGE
;
2941 Status
= ChkdskPartition(&DestinationRootPath
, CurrentFileSystem
);
2942 if (!NT_SUCCESS(Status
))
2944 DPRINT("ChkdskPartition() failed with status 0x%08lx\n", Status
);
2945 sprintf(Buffer
, "Setup failed to verify the selected partition.\n"
2946 "(Status 0x%08lx).\n", Status
);
2949 MUIGetString(STRING_REBOOTCOMPUTER
),
2950 Ir
, POPUP_WAIT_ENTER
);
2955 return INSTALL_DIRECTORY_PAGE
;
2961 InstallDirectoryPage1(PWCHAR InstallDir
,
2962 PDISKENTRY DiskEntry
,
2963 PPARTENTRY PartEntry
)
2965 WCHAR PathBuffer
[MAX_PATH
];
2967 /* Create 'InstallPath' string */
2968 RtlFreeUnicodeString(&InstallPath
);
2969 RtlCreateUnicodeString(&InstallPath
,
2972 /* Set DestinationRootPath */
2973 RtlFreeUnicodeString(&DestinationRootPath
);
2974 swprintf(PathBuffer
,
2975 L
"\\Device\\Harddisk%lu\\Partition%lu",
2976 DiskEntry
->DiskNumber
,
2977 PartEntry
->PartitionNumber
);
2978 RtlCreateUnicodeString(&DestinationRootPath
,
2980 DPRINT("DestinationRootPath: %wZ\n", &DestinationRootPath
);
2982 /* Create 'DestinationPath' string */
2983 RtlFreeUnicodeString(&DestinationPath
);
2984 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2986 if (InstallDir
[0] != L
'\\')
2987 wcscat(PathBuffer
, L
"\\");
2989 wcscat(PathBuffer
, InstallDir
);
2990 RtlCreateUnicodeString(&DestinationPath
, PathBuffer
);
2992 /* Create 'DestinationArcPath' */
2993 RtlFreeUnicodeString(&DestinationArcPath
);
2994 swprintf(PathBuffer
,
2995 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
2996 DiskEntry
->BiosDiskNumber
,
2997 PartEntry
->PartitionNumber
);
2999 if (InstallDir
[0] != L
'\\')
3000 wcscat(PathBuffer
, L
"\\");
3002 wcscat(PathBuffer
, InstallDir
);
3003 RtlCreateUnicodeString(&DestinationArcPath
, PathBuffer
);
3005 return PREPARE_COPY_PAGE
;
3010 InstallDirectoryPage(PINPUT_RECORD Ir
)
3012 PDISKENTRY DiskEntry
;
3013 PPARTENTRY PartEntry
;
3014 WCHAR InstallDir
[51];
3017 if (PartitionList
== NULL
||
3018 PartitionList
->CurrentDisk
== NULL
||
3019 PartitionList
->CurrentPartition
== NULL
)
3021 /* FIXME: show an error dialog */
3025 DiskEntry
= PartitionList
->CurrentDisk
;
3026 PartEntry
= PartitionList
->CurrentPartition
;
3028 if (IsUnattendedSetup
)
3029 wcscpy(InstallDir
, UnattendInstallationDirectory
);
3031 wcscpy(InstallDir
, L
"\\ReactOS");
3033 Length
= wcslen(InstallDir
);
3034 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3035 MUIDisplayPage(INSTALL_DIRECTORY_PAGE
);
3037 if (IsUnattendedSetup
)
3039 return InstallDirectoryPage1(InstallDir
,
3046 CONSOLE_ConInKey(Ir
);
3048 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3049 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3051 if (ConfirmQuit(Ir
) == TRUE
)
3056 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3058 return InstallDirectoryPage1(InstallDir
,
3062 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
3067 InstallDir
[Length
] = 0;
3068 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3071 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
3075 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
3077 InstallDir
[Length
] = 0;
3078 CONSOLE_SetInputTextXY(8, 11, 51, InstallDir
);
3083 return INSTALL_DIRECTORY_PAGE
;
3088 AddSectionToCopyQueueCab(HINF InfFile
,
3090 PWCHAR SourceCabinet
,
3091 PCUNICODE_STRING DestinationPath
,
3094 INFCONTEXT FilesContext
;
3095 INFCONTEXT DirContext
;
3097 PWCHAR FileKeyValue
;
3099 PWCHAR TargetFileName
;
3101 /* Search for the SectionName section */
3102 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3105 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3106 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3111 * Enumerate the files in the section
3112 * and add them to the file queue.
3116 /* Get source file name and target directory id */
3117 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3119 /* FIXME: Handle error! */
3120 DPRINT1("INF_GetData() failed\n");
3124 /* Get optional target file name */
3125 if (!INF_GetDataField(&FilesContext
, 2, &TargetFileName
))
3126 TargetFileName
= NULL
;
3128 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3130 /* Lookup target directory */
3131 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3133 /* FIXME: Handle error! */
3134 DPRINT1("SetupFindFirstLine() failed\n");
3138 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3140 /* FIXME: Handle error! */
3141 DPRINT1("INF_GetData() failed\n");
3145 if (!SetupQueueCopy(SetupFileQueue
,
3147 SourceRootPath
.Buffer
,
3148 SourceRootDir
.Buffer
,
3153 /* FIXME: Handle error! */
3154 DPRINT1("SetupQueueCopy() failed\n");
3156 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3163 AddSectionToCopyQueue(HINF InfFile
,
3165 PWCHAR SourceCabinet
,
3166 PCUNICODE_STRING DestinationPath
,
3169 INFCONTEXT FilesContext
;
3170 INFCONTEXT DirContext
;
3172 PWCHAR FileKeyValue
;
3174 PWCHAR TargetFileName
;
3175 WCHAR CompleteOrigFileName
[512];
3178 return AddSectionToCopyQueueCab(InfFile
, L
"SourceFiles", SourceCabinet
, DestinationPath
, Ir
);
3180 /* Search for the SectionName section */
3181 if (!SetupFindFirstLineW(InfFile
, SectionName
, NULL
, &FilesContext
))
3184 sprintf(Buffer
, MUIGetString(STRING_TXTSETUPFAILED
), SectionName
);
3185 PopupError(Buffer
, MUIGetString(STRING_REBOOTCOMPUTER
), Ir
, POPUP_WAIT_ENTER
);
3190 * Enumerate the files in the section
3191 * and add them to the file queue.
3195 /* Get source file name and target directory id */
3196 if (!INF_GetData(&FilesContext
, &FileKeyName
, &FileKeyValue
))
3198 /* FIXME: Handle error! */
3199 DPRINT1("INF_GetData() failed\n");
3203 /* Get target directory id */
3204 if (!INF_GetDataField(&FilesContext
, 13, &FileKeyValue
))
3206 /* FIXME: Handle error! */
3207 DPRINT1("INF_GetData() failed\n");
3211 /* Get optional target file name */
3212 if (!INF_GetDataField(&FilesContext
, 11, &TargetFileName
))
3213 TargetFileName
= NULL
;
3214 else if (!*TargetFileName
)
3215 TargetFileName
= NULL
;
3217 DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
3219 /* Lookup target directory */
3220 if (!SetupFindFirstLineW(InfFile
, L
"Directories", FileKeyValue
, &DirContext
))
3222 /* FIXME: Handle error! */
3223 DPRINT1("SetupFindFirstLine() failed\n");
3227 if (!INF_GetData(&DirContext
, NULL
, &DirKeyValue
))
3229 /* FIXME: Handle error! */
3230 DPRINT1("INF_GetData() failed\n");
3234 wcscpy(CompleteOrigFileName
, SourceRootDir
.Buffer
);
3235 wcscat(CompleteOrigFileName
, L
"\\");
3236 wcscat(CompleteOrigFileName
, DirKeyValue
);
3238 if (!SetupQueueCopy(SetupFileQueue
,
3240 SourceRootPath
.Buffer
,
3241 CompleteOrigFileName
,
3246 /* FIXME: Handle error! */
3247 DPRINT1("SetupQueueCopy() failed\n");
3249 } while (SetupFindNextLine(&FilesContext
, &FilesContext
));
3256 PrepareCopyPageInfFile(HINF InfFile
,
3257 PWCHAR SourceCabinet
,
3260 WCHAR PathBuffer
[MAX_PATH
];
3261 INFCONTEXT DirContext
;
3262 PWCHAR AdditionalSectionName
= NULL
;
3267 /* Add common files */
3268 if (!AddSectionToCopyQueue(InfFile
, L
"SourceDisksFiles", SourceCabinet
, &DestinationPath
, Ir
))
3271 /* Add specific files depending of computer type */
3272 if (SourceCabinet
== NULL
)
3274 if (!ProcessComputerFiles(InfFile
, ComputerList
, &AdditionalSectionName
))
3277 if (AdditionalSectionName
)
3279 if (!AddSectionToCopyQueue(InfFile
, AdditionalSectionName
, SourceCabinet
, &DestinationPath
, Ir
))
3284 /* Create directories */
3288 * Install directories like '\reactos\test' are not handled yet.
3291 /* Get destination path */
3292 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3294 /* Remove trailing backslash */
3295 Length
= wcslen(PathBuffer
);
3296 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
3298 PathBuffer
[Length
- 1] = 0;
3301 /* Create the install directory */
3302 Status
= SetupCreateDirectory(PathBuffer
);
3303 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3305 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3306 MUIDisplayError(ERROR_CREATE_INSTALL_DIR
, Ir
, POPUP_WAIT_ENTER
);
3310 /* Search for the 'Directories' section */
3311 if (!SetupFindFirstLineW(InfFile
, L
"Directories", NULL
, &DirContext
))
3315 MUIDisplayError(ERROR_CABINET_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3319 MUIDisplayError(ERROR_TXTSETUP_SECTION
, Ir
, POPUP_WAIT_ENTER
);
3325 /* Enumerate the directory values and create the subdirectories */
3328 if (!INF_GetData(&DirContext
, NULL
, &KeyValue
))
3334 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
3336 DPRINT("Absolute Path: '%S'\n", KeyValue
);
3338 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
3339 wcscat(PathBuffer
, KeyValue
);
3341 DPRINT("FullPath: '%S'\n", PathBuffer
);
3343 else if (KeyValue
[0] != L
'\\')
3345 DPRINT("RelativePath: '%S'\n", KeyValue
);
3346 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
3347 wcscat(PathBuffer
, L
"\\");
3348 wcscat(PathBuffer
, KeyValue
);
3350 DPRINT("FullPath: '%S'\n", PathBuffer
);
3352 Status
= SetupCreateDirectory(PathBuffer
);
3353 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
3355 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
3356 MUIDisplayError(ERROR_CREATE_DIR
, Ir
, POPUP_WAIT_ENTER
);
3360 } while (SetupFindNextLine (&DirContext
, &DirContext
));
3367 PrepareCopyPage(PINPUT_RECORD Ir
)
3370 WCHAR PathBuffer
[MAX_PATH
];
3371 INFCONTEXT CabinetsContext
;
3377 MUIDisplayPage(PREPARE_COPY_PAGE
);
3379 /* Create the file queue */
3380 SetupFileQueue
= SetupOpenFileQueue();
3381 if (SetupFileQueue
== NULL
)
3383 MUIDisplayError(ERROR_COPY_QUEUE
, Ir
, POPUP_WAIT_ENTER
);
3387 if (!PrepareCopyPageInfFile(SetupInf
, NULL
, Ir
))
3392 /* Search for the 'Cabinets' section */
3393 if (!SetupFindFirstLineW(SetupInf
, L
"Cabinets", NULL
, &CabinetsContext
))
3395 return FILE_COPY_PAGE
;
3399 * Enumerate the directory values in the 'Cabinets'
3400 * section and parse their inf files.
3404 if (!INF_GetData(&CabinetsContext
, NULL
, &KeyValue
))
3407 wcscpy(PathBuffer
, SourcePath
.Buffer
);
3408 wcscat(PathBuffer
, L
"\\");
3409 wcscat(PathBuffer
, KeyValue
);
3412 CabinetInitialize();
3413 CabinetSetEventHandlers(NULL
, NULL
, NULL
);
3414 CabinetSetCabinetName(PathBuffer
);
3416 if (CabinetOpen() == CAB_STATUS_SUCCESS
)
3418 DPRINT("Cabinet %S\n", CabinetGetCabinetName());
3420 InfFileData
= CabinetGetCabinetReservedArea(&InfFileSize
);
3421 if (InfFileData
== NULL
)
3423 MUIDisplayError(ERROR_CABINET_SCRIPT
, Ir
, POPUP_WAIT_ENTER
);
3429 DPRINT("Cannot open cabinet: %S.\n", CabinetGetCabinetName());
3430 MUIDisplayError(ERROR_CABINET_MISSING
, Ir
, POPUP_WAIT_ENTER
);
3434 InfHandle
= INF_OpenBufferedFileA((CHAR
*) InfFileData
,
3441 if (InfHandle
== INVALID_HANDLE_VALUE
)
3443 MUIDisplayError(ERROR_INVALID_CABINET_INF
, Ir
, POPUP_WAIT_ENTER
);
3449 if (!PrepareCopyPageInfFile(InfHandle
, KeyValue
, Ir
))
3454 } while (SetupFindNextLine(&CabinetsContext
, &CabinetsContext
));
3456 return FILE_COPY_PAGE
;
3462 SetupUpdateMemoryInfo(IN PCOPYCONTEXT CopyContext
,
3465 SYSTEM_PERFORMANCE_INFORMATION PerfInfo
;
3467 /* Get the memory information from the system */
3468 NtQuerySystemInformation(SystemPerformanceInformation
,
3473 /* Check if this is initial setup */
3476 /* Set maximum limits to be total RAM pages */
3477 ProgressSetStepCount(CopyContext
->MemoryBars
[0], PerfInfo
.CommitLimit
);
3478 ProgressSetStepCount(CopyContext
->MemoryBars
[1], PerfInfo
.CommitLimit
);
3479 ProgressSetStepCount(CopyContext
->MemoryBars
[2], PerfInfo
.CommitLimit
);
3482 /* Set current values */
3483 ProgressSetStep(CopyContext
->MemoryBars
[0], PerfInfo
.PagedPoolPages
+ PerfInfo
.NonPagedPoolPages
);
3484 ProgressSetStep(CopyContext
->MemoryBars
[1], PerfInfo
.ResidentSystemCachePage
);
3485 ProgressSetStep(CopyContext
->MemoryBars
[2], PerfInfo
.AvailablePages
);
3491 FileCopyCallback(PVOID Context
,
3496 PCOPYCONTEXT CopyContext
;
3498 CopyContext
= (PCOPYCONTEXT
)Context
;
3500 switch (Notification
)
3502 case SPFILENOTIFY_STARTSUBQUEUE
:
3503 CopyContext
->TotalOperations
= (ULONG
)Param2
;
3504 ProgressSetStepCount(CopyContext
->ProgressBar
,
3505 CopyContext
->TotalOperations
);
3506 SetupUpdateMemoryInfo(CopyContext
, TRUE
);
3509 case SPFILENOTIFY_STARTCOPY
:
3510 /* Display copy message */
3511 CONSOLE_SetStatusText(MUIGetString(STRING_COPYING
), (PWSTR
)Param1
);
3512 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3515 case SPFILENOTIFY_ENDCOPY
:
3516 CopyContext
->CompletedOperations
++;
3518 /* SYSREG checkpoint */
3519 if (CopyContext
->TotalOperations
>> 1 == CopyContext
->CompletedOperations
)
3520 DPRINT1("CHECKPOINT:HALF_COPIED\n");
3522 ProgressNextStep(CopyContext
->ProgressBar
);
3523 SetupUpdateMemoryInfo(CopyContext
, FALSE
);
3533 FileCopyPage(PINPUT_RECORD Ir
)
3535 COPYCONTEXT CopyContext
;
3536 unsigned int mem_bar_width
;
3538 MUIDisplayPage(FILE_COPY_PAGE
);
3540 /* Create context for the copy process */
3541 CopyContext
.DestinationRootPath
= DestinationRootPath
.Buffer
;
3542 CopyContext
.InstallPath
= InstallPath
.Buffer
;
3543 CopyContext
.TotalOperations
= 0;
3544 CopyContext
.CompletedOperations
= 0;
3546 /* Create the progress bar as well */
3547 CopyContext
.ProgressBar
= CreateProgressBar(13,
3554 MUIGetString(STRING_SETUPCOPYINGFILES
));
3556 // fit memory bars to screen width, distribute them uniform
3557 mem_bar_width
= (xScreen
- 26) / 5;
3558 mem_bar_width
-= mem_bar_width
% 2; // make even
3559 /* ATTENTION: The following progress bars are debug stuff, which should not be translated!! */
3560 /* Create the paged pool progress bar */
3561 CopyContext
.MemoryBars
[0] = CreateProgressBar(13,
3570 /* Create the non paged pool progress bar */
3571 CopyContext
.MemoryBars
[1] = CreateProgressBar((xScreen
/ 2)- (mem_bar_width
/ 2),
3573 (xScreen
/ 2) + (mem_bar_width
/ 2),
3575 (xScreen
/ 2)- (mem_bar_width
/ 2),
3580 /* Create the global memory progress bar */
3581 CopyContext
.MemoryBars
[2] = CreateProgressBar(xScreen
- 13 - mem_bar_width
,
3585 xScreen
- 13 - mem_bar_width
,
3590 /* Do the file copying */
3591 SetupCommitFileQueueW(NULL
,
3596 /* If we get here, we're done, so cleanup the queue and progress bar */
3597 SetupCloseFileQueue(SetupFileQueue
);
3598 DestroyProgressBar(CopyContext
.ProgressBar
);
3599 DestroyProgressBar(CopyContext
.MemoryBars
[0]);
3600 DestroyProgressBar(CopyContext
.MemoryBars
[1]);
3601 DestroyProgressBar(CopyContext
.MemoryBars
[2]);
3603 /* Go display the next page */
3604 return REGISTRY_PAGE
;
3609 RegistryPage(PINPUT_RECORD Ir
)
3611 INFCONTEXT InfContext
;
3618 MUIDisplayPage(REGISTRY_PAGE
);
3620 if (RepairUpdateFlag
)
3622 return SUCCESS_PAGE
;
3625 if (!SetInstallPathValue(&DestinationPath
))
3627 DPRINT("SetInstallPathValue() failed\n");
3628 MUIDisplayError(ERROR_INITIALIZE_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3632 /* Create the default hives */
3634 Status
= NtInitializeRegistry(CM_BOOT_FLAG_SETUP
);
3635 if (!NT_SUCCESS(Status
))
3637 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
3638 MUIDisplayError(ERROR_CREATE_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3642 RegInitializeRegistry();
3645 /* Update registry */
3646 CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE
));
3648 if (!SetupFindFirstLineW(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
3650 DPRINT1("SetupFindFirstLine() failed\n");
3651 MUIDisplayError(ERROR_FIND_REGISTRY
, Ir
, POPUP_WAIT_ENTER
);
3657 INF_GetDataField (&InfContext
, 0, &Action
);
3658 INF_GetDataField (&InfContext
, 1, &File
);
3659 INF_GetDataField (&InfContext
, 2, &Section
);
3661 DPRINT("Action: %S File: %S Section %S\n", Action
, File
, Section
);
3666 if (!_wcsicmp (Action
, L
"AddReg"))
3670 else if (!_wcsicmp (Action
, L
"DelReg"))
3679 CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE
), File
);
3681 if (!ImportRegistryFile(File
, Section
, LanguageId
, Delete
))
3683 DPRINT("Importing %S failed\n", File
);
3685 MUIDisplayError(ERROR_IMPORT_HIVE
, Ir
, POPUP_WAIT_ENTER
);
3688 } while (SetupFindNextLine(&InfContext
, &InfContext
));
3690 /* Update display registry settings */
3691 CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE
));
3692 if (!ProcessDisplayRegistry(SetupInf
, DisplayList
))
3694 MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3698 /* Set the locale */
3699 CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE
));
3700 if (!ProcessLocaleRegistry(LanguageList
))
3702 MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3706 /* Add keyboard layouts */
3707 CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS
));
3708 if (!AddKeyboardLayouts())
3710 MUIDisplayError(ERROR_ADDING_KBLAYOUTS
, Ir
, POPUP_WAIT_ENTER
);
3716 if (!SetGeoID(MUIGetGeoID()))
3718 MUIDisplayError(ERROR_UPDATE_GEOID
, Ir
, POPUP_WAIT_ENTER
);
3722 if (!IsUnattendedSetup
)
3724 /* Update keyboard layout settings */
3725 CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE
));
3726 if (!ProcessKeyboardLayoutRegistry(LayoutList
))
3728 MUIDisplayError(ERROR_UPDATE_KBSETTINGS
, Ir
, POPUP_WAIT_ENTER
);
3733 /* Add codepage information to registry */
3734 CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE
));
3737 MUIDisplayError(ERROR_ADDING_CODEPAGE
, Ir
, POPUP_WAIT_ENTER
);
3741 /* Set the default pagefile entry */
3742 SetDefaultPagefile(DestinationDriveLetter
);
3744 /* Update the mounted devices list */
3745 SetMountedDeviceValues(PartitionList
);
3747 CONSOLE_SetStatusText(MUIGetString(STRING_DONE
));
3749 return BOOT_LOADER_PAGE
;
3754 BootLoaderPage(PINPUT_RECORD Ir
)
3756 UCHAR PartitionType
;
3757 BOOLEAN InstallOnFloppy
;
3759 WCHAR PathBuffer
[MAX_PATH
];
3762 CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT
));
3764 /* Find or set the active partition */
3765 CheckActiveBootPartition(PartitionList
);
3767 /* Update the partition table because we may have changed the active partition */
3768 Status
= WriteDirtyPartitions(PartitionList
);
3769 if (!NT_SUCCESS(Status
))
3771 DPRINT("WriteDirtyPartitions() failed\n");
3772 MUIDisplayError(ERROR_WRITE_PTABLE
, Ir
, POPUP_WAIT_ENTER
);
3776 RtlFreeUnicodeString(&SystemRootPath
);
3777 swprintf(PathBuffer
,
3778 L
"\\Device\\Harddisk%lu\\Partition%lu",
3779 PartitionList
->ActiveBootDisk
->DiskNumber
,
3780 PartitionList
->ActiveBootPartition
->PartitionNumber
);
3781 RtlCreateUnicodeString(&SystemRootPath
,
3783 DPRINT("SystemRootPath: %wZ\n", &SystemRootPath
);
3785 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3787 if (IsUnattendedSetup
)
3789 if (UnattendMBRInstallType
== 0) /* skip MBR installation */
3791 return SUCCESS_PAGE
;
3793 else if (UnattendMBRInstallType
== 1) /* install on floppy */
3795 return BOOT_LOADER_FLOPPY_PAGE
;
3799 if (PartitionType
== PARTITION_ENTRY_UNUSED
)
3801 DPRINT("Error: active partition invalid (unused)\n");
3802 InstallOnFloppy
= TRUE
;
3804 else if (PartitionType
== 0x0A)
3806 /* OS/2 boot manager partition */
3807 DPRINT("Found OS/2 boot manager partition\n");
3808 InstallOnFloppy
= TRUE
;
3810 else if (PartitionType
== 0x83)
3812 /* Linux ext2 partition */
3813 DPRINT("Found Linux ext2 partition\n");
3814 InstallOnFloppy
= TRUE
;
3816 else if (PartitionType
== PARTITION_IFS
)
3818 /* NTFS partition */
3819 DPRINT("Found NTFS partition\n");
3820 InstallOnFloppy
= TRUE
;
3822 else if ((PartitionType
== PARTITION_FAT_12
) ||
3823 (PartitionType
== PARTITION_FAT_16
) ||
3824 (PartitionType
== PARTITION_HUGE
) ||
3825 (PartitionType
== PARTITION_XINT13
) ||
3826 (PartitionType
== PARTITION_FAT32
) ||
3827 (PartitionType
== PARTITION_FAT32_XINT13
))
3829 DPRINT("Found FAT partition\n");
3830 InstallOnFloppy
= FALSE
;
3834 /* Unknown partition */
3835 DPRINT("Unknown partition found\n");
3836 InstallOnFloppy
= TRUE
;
3839 if (InstallOnFloppy
== TRUE
)
3841 return BOOT_LOADER_FLOPPY_PAGE
;
3844 /* Unattended install on hdd? */
3845 if (IsUnattendedSetup
&& UnattendMBRInstallType
== 2)
3847 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3850 MUIDisplayPage(BOOT_LOADER_PAGE
);
3851 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3855 CONSOLE_ConInKey(Ir
);
3857 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3858 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
3860 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3869 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3871 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3872 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
3874 CONSOLE_NormalTextXY(8, Line
, 60, 1);
3883 CONSOLE_InvertTextXY(8, Line
, 60, 1);
3885 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3886 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3888 if (ConfirmQuit(Ir
) == TRUE
)
3893 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3897 return BOOT_LOADER_HARDDISK_MBR_PAGE
;
3899 else if (Line
== 13)
3901 return BOOT_LOADER_HARDDISK_VBR_PAGE
;
3903 else if (Line
== 14)
3905 return BOOT_LOADER_FLOPPY_PAGE
;
3907 else if (Line
== 15)
3909 return SUCCESS_PAGE
;
3912 return BOOT_LOADER_PAGE
;
3916 return BOOT_LOADER_PAGE
;
3921 BootLoaderFloppyPage(PINPUT_RECORD Ir
)
3925 MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE
);
3927 // SetStatusText(" Please wait...");
3931 CONSOLE_ConInKey(Ir
);
3933 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
3934 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
3936 if (ConfirmQuit(Ir
) == TRUE
)
3941 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3943 if (DoesFileExist(L
"\\Device\\Floppy0", L
"\\") == FALSE
)
3945 MUIDisplayError(ERROR_NO_FLOPPY
, Ir
, POPUP_WAIT_ENTER
);
3946 return BOOT_LOADER_FLOPPY_PAGE
;
3949 Status
= InstallFatBootcodeToFloppy(&SourceRootPath
, &DestinationArcPath
);
3950 if (!NT_SUCCESS(Status
))
3952 /* Print error message */
3953 return BOOT_LOADER_FLOPPY_PAGE
;
3956 return SUCCESS_PAGE
;
3960 return BOOT_LOADER_FLOPPY_PAGE
;
3964 BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir
)
3966 UCHAR PartitionType
;
3969 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3971 Status
= InstallVBRToPartition(&SystemRootPath
,
3973 &DestinationArcPath
,
3975 if (!NT_SUCCESS(Status
))
3977 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
3981 return SUCCESS_PAGE
;
3985 BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir
)
3987 UCHAR PartitionType
;
3989 WCHAR DestinationDevicePathBuffer
[MAX_PATH
];
3990 WCHAR SourceMbrPathBuffer
[MAX_PATH
];
3992 /* Step 1: Write the VBR */
3993 PartitionType
= PartitionList
->ActiveBootPartition
->PartitionType
;
3995 Status
= InstallVBRToPartition(&SystemRootPath
,
3997 &DestinationArcPath
,
3999 if (!NT_SUCCESS(Status
))
4001 MUIDisplayError(ERROR_WRITE_BOOT
, Ir
, POPUP_WAIT_ENTER
);
4005 /* Step 2: Write the MBR */
4006 swprintf(DestinationDevicePathBuffer
,
4007 L
"\\Device\\Harddisk%d\\Partition0",
4008 PartitionList
->ActiveBootDisk
->DiskNumber
);
4010 wcscpy(SourceMbrPathBuffer
, SourceRootPath
.Buffer
);
4011 wcscat(SourceMbrPathBuffer
, L
"\\loader\\dosmbr.bin");
4013 DPRINT("Install MBR bootcode: %S ==> %S\n",
4014 SourceMbrPathBuffer
, DestinationDevicePathBuffer
);
4016 Status
= InstallMbrBootCodeToDisk(SourceMbrPathBuffer
,
4017 DestinationDevicePathBuffer
);
4018 if (!NT_SUCCESS (Status
))
4020 DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
4022 MUIDisplayError(ERROR_INSTALL_BOOTCODE
, Ir
, POPUP_WAIT_ENTER
);
4026 return SUCCESS_PAGE
;
4031 QuitPage(PINPUT_RECORD Ir
)
4033 MUIDisplayPage(QUIT_PAGE
);
4035 /* Destroy partition list */
4036 if (PartitionList
!= NULL
)
4038 DestroyPartitionList (PartitionList
);
4039 PartitionList
= NULL
;
4042 /* Destroy filesystem list */
4043 if (FileSystemList
!= NULL
)
4045 DestroyFileSystemList (FileSystemList
);
4046 FileSystemList
= NULL
;
4049 /* Destroy computer settings list */
4050 if (ComputerList
!= NULL
)
4052 DestroyGenericList(ComputerList
, TRUE
);
4053 ComputerList
= NULL
;
4056 /* Destroy display settings list */
4057 if (DisplayList
!= NULL
)
4059 DestroyGenericList(DisplayList
, TRUE
);
4063 /* Destroy keyboard settings list */
4064 if (KeyboardList
!= NULL
)
4066 DestroyGenericList(KeyboardList
, TRUE
);
4067 KeyboardList
= NULL
;
4070 /* Destroy keyboard layout list */
4071 if (LayoutList
!= NULL
)
4073 DestroyGenericList(LayoutList
, TRUE
);
4077 if (LanguageList
!= NULL
)
4079 DestroyGenericList(LanguageList
, FALSE
);
4080 LanguageList
= NULL
;
4083 CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2
));
4087 CONSOLE_ConInKey(Ir
);
4089 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4098 SuccessPage(PINPUT_RECORD Ir
)
4100 MUIDisplayPage(SUCCESS_PAGE
);
4102 if (IsUnattendedSetup
)
4109 CONSOLE_ConInKey(Ir
);
4111 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
4120 FlushPage(PINPUT_RECORD Ir
)
4122 MUIDisplayPage(FLUSH_PAGE
);
4128 PnpEventThread(IN LPVOID lpParameter
);
4139 NtQuerySystemTime(&Time
);
4141 Status
= RtlCreateUserThread(NtCurrentProcess(),
4151 if (!NT_SUCCESS(Status
))
4152 hPnpThread
= INVALID_HANDLE_VALUE
;
4154 if (!CONSOLE_Init())
4156 PrintString(MUIGetString(STRING_CONSOLEFAIL1
));
4157 PrintString(MUIGetString(STRING_CONSOLEFAIL2
));
4158 PrintString(MUIGetString(STRING_CONSOLEFAIL3
));
4160 /* Raise a hard error (crash the system/BSOD) */
4161 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
4165 /* Initialize global unicode strings */
4166 RtlInitUnicodeString(&SourcePath
, NULL
);
4167 RtlInitUnicodeString(&SourceRootPath
, NULL
);
4168 RtlInitUnicodeString(&SourceRootDir
, NULL
);
4169 RtlInitUnicodeString(&InstallPath
, NULL
);
4170 RtlInitUnicodeString(&DestinationPath
, NULL
);
4171 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
4172 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
4173 RtlInitUnicodeString(&SystemRootPath
, NULL
);
4175 /* Hide the cursor */
4176 CONSOLE_SetCursorType(TRUE
, FALSE
);
4179 while (Page
!= REBOOT_PAGE
&& Page
!= RECOVERY_PAGE
)
4181 CONSOLE_ClearScreen();
4184 //CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
4191 Page
= SetupStartPage(&Ir
);
4196 Page
= LanguagePage(&Ir
);
4201 Page
= LicensePage(&Ir
);
4206 Page
= IntroPage(&Ir
);
4210 case INSTALL_INTRO_PAGE
:
4211 Page
= InstallIntroPage(&Ir
);
4215 case SCSI_CONTROLLER_PAGE
:
4216 Page
= ScsiControllerPage(&Ir
);
4221 case OEM_DRIVER_PAGE
:
4222 Page
= OemDriverPage(&Ir
);
4226 case DEVICE_SETTINGS_PAGE
:
4227 Page
= DeviceSettingsPage(&Ir
);
4230 case COMPUTER_SETTINGS_PAGE
:
4231 Page
= ComputerSettingsPage(&Ir
);
4234 case DISPLAY_SETTINGS_PAGE
:
4235 Page
= DisplaySettingsPage(&Ir
);
4238 case KEYBOARD_SETTINGS_PAGE
:
4239 Page
= KeyboardSettingsPage(&Ir
);
4242 case LAYOUT_SETTINGS_PAGE
:
4243 Page
= LayoutSettingsPage(&Ir
);
4246 case SELECT_PARTITION_PAGE
:
4247 Page
= SelectPartitionPage(&Ir
);
4250 case CREATE_PRIMARY_PARTITION_PAGE
:
4251 Page
= CreatePrimaryPartitionPage(&Ir
);
4254 case CREATE_EXTENDED_PARTITION_PAGE
:
4255 Page
= CreateExtendedPartitionPage(&Ir
);
4258 case CREATE_LOGICAL_PARTITION_PAGE
:
4259 Page
= CreateLogicalPartitionPage(&Ir
);
4262 case DELETE_PARTITION_PAGE
:
4263 Page
= DeletePartitionPage(&Ir
);
4266 case SELECT_FILE_SYSTEM_PAGE
:
4267 Page
= SelectFileSystemPage(&Ir
);
4270 case FORMAT_PARTITION_PAGE
:
4271 Page
= (PAGE_NUMBER
) FormatPartitionPage(&Ir
);
4274 case CHECK_FILE_SYSTEM_PAGE
:
4275 Page
= (PAGE_NUMBER
) CheckFileSystemPage(&Ir
);
4278 case INSTALL_DIRECTORY_PAGE
:
4279 Page
= InstallDirectoryPage(&Ir
);
4282 case PREPARE_COPY_PAGE
:
4283 Page
= PrepareCopyPage(&Ir
);
4286 case FILE_COPY_PAGE
:
4287 Page
= FileCopyPage(&Ir
);
4291 Page
= RegistryPage(&Ir
);
4294 case BOOT_LOADER_PAGE
:
4295 Page
= BootLoaderPage(&Ir
);
4298 case BOOT_LOADER_FLOPPY_PAGE
:
4299 Page
= BootLoaderFloppyPage(&Ir
);
4302 case BOOT_LOADER_HARDDISK_MBR_PAGE
:
4303 Page
= BootLoaderHarddiskMbrPage(&Ir
);
4306 case BOOT_LOADER_HARDDISK_VBR_PAGE
:
4307 Page
= BootLoaderHarddiskVbrPage(&Ir
);
4311 case REPAIR_INTRO_PAGE
:
4312 Page
= RepairIntroPage(&Ir
);
4316 Page
= SuccessPage(&Ir
);
4320 Page
= FlushPage(&Ir
);
4324 Page
= QuitPage(&Ir
);
4333 if (Page
== RECOVERY_PAGE
)
4338 /* Avoid bugcheck */
4339 Time
.QuadPart
+= 50000000;
4340 NtDelayExecution(FALSE
, &Time
);
4343 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, TRUE
, FALSE
, &Old
);
4344 NtShutdownSystem(ShutdownReboot
);
4345 RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE
, Old
, FALSE
, &Old
);
4346 NtTerminateProcess(NtCurrentProcess(), 0);
4353 NtProcessStartup(PPEB Peb
)
4355 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
4357 ProcessHeap
= Peb
->ProcessHeap
;
4358 InfSetHeap(ProcessHeap
);
4361 #endif /* __REACTOS__ */