usetup.c
来自「一个类似windows」· C语言 代码 · 共 2,599 行 · 第 1/5 页
C
2,599 行
*/
static PAGE_NUMBER
SetupStartPage(PINPUT_RECORD Ir)
{
SYSTEM_DEVICE_INFORMATION Sdi;
NTSTATUS Status;
WCHAR FileNameBuffer[MAX_PATH];
UNICODE_STRING FileName;
PINFCONTEXT Context;
PWCHAR Value;
ULONG ErrorLine;
ULONG ReturnSize;
SetStatusText(" Please wait...");
/* Check whether a harddisk is available */
Status = NtQuerySystemInformation (SystemDeviceInformation,
&Sdi,
sizeof(SYSTEM_DEVICE_INFORMATION),
&ReturnSize);
if (!NT_SUCCESS (Status))
{
PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status);
PopupError("Setup could not retrieve system drive information.\n",
"ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return QUIT_PAGE;
}
}
}
if (Sdi.NumberOfDisks == 0)
{
PopupError("Setup could not find a harddisk.\n",
"ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return QUIT_PAGE;
}
}
}
/* Get the source path and source root path */
Status = GetSourcePaths(&SourcePath,
&SourceRootPath);
if (!NT_SUCCESS(Status))
{
PrintTextXY(6, 15, "GetSourcePath() failed (Status 0x%08lx)", Status);
PopupError("Setup could not find its source drive.\n",
"ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return QUIT_PAGE;
}
}
}
#if 0
else
{
PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath);
PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath);
}
#endif
/* Load txtsetup.sif from install media. */
wcscpy(FileNameBuffer, SourceRootPath.Buffer);
wcscat(FileNameBuffer, L"\\reactos\\txtsetup.sif");
RtlInitUnicodeString(&FileName,
FileNameBuffer);
Status = InfOpenFile(&SetupInf,
&FileName,
&ErrorLine);
if (!NT_SUCCESS(Status))
{
PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
"ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return QUIT_PAGE;
}
}
}
/* Open 'Version' section */
if (!InfFindFirstLine (SetupInf, L"Version", L"Signature", &Context))
{
PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
"ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return QUIT_PAGE;
}
}
}
/* Get pointer 'Signature' key */
if (!InfGetData (Context, NULL, &Value))
{
InfFreeContext(Context);
PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
"ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return QUIT_PAGE;
}
}
}
/* Check 'Signature' string */
if (_wcsicmp(Value, L"$ReactOS$") != 0)
{
InfFreeContext(Context);
PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
"ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return QUIT_PAGE;
}
}
}
InfFreeContext(Context);
CheckUnattendedSetup();
return INTRO_PAGE;
}
/*
* First setup page
* RETURNS
* Next page number.
*/
static PAGE_NUMBER
IntroPage(PINPUT_RECORD Ir)
{
SetHighlightedTextXY(6, 8, "Welcome to ReactOS Setup");
SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your");
SetTextXY(6, 12, "computer and prepares the second part of the setup.");
SetTextXY(8, 15, "\x07 Press ENTER to install ReactOS.");
SetTextXY(8, 17, "\x07 Press R to repair ReactOS.");
SetTextXY(8, 19, "\x07 Press L to view the ReactOS Licensing Terms and Conditions");
SetTextXY(8, 21, "\x07 Press F3 to quit without installing ReactOS.");
SetTextXY(6, 23, "For more information on ReactOS, please visit:");
SetHighlightedTextXY(6, 24, "http://www.reactos.org");
SetStatusText(" ENTER = Continue R = Repair F3 = Quit");
if (IsUnattendedSetup)
{
return INSTALL_INTRO_PAGE;
}
while (TRUE)
{
ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
if (ConfirmQuit(Ir) == TRUE)
return QUIT_PAGE;
break;
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return INSTALL_INTRO_PAGE;
break;
}
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R') /* R */
{
return REPAIR_INTRO_PAGE;
break;
}
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'L') /* R */
{
return LICENSE_PAGE;
break;
}
}
return INTRO_PAGE;
}
/*
* License Page
* RETURNS
* Back to main setup page.
*/
static PAGE_NUMBER
LicensePage(PINPUT_RECORD Ir)
{
SetHighlightedTextXY(6, 6, "Licensing:");
SetTextXY(8, 8, "The ReactOS System is licensed under the terms of the");
SetTextXY(8, 9, "GNU GPL with parts containing code from other compatible");
SetTextXY(8, 10, "licenses such as the X11 or BSD and GNU LGPL licenses.");
SetTextXY(8, 11, "All software that is part of the ReactOS system is");
SetTextXY(8, 12, "therefore released under the GNU GPL as well as maintaining");
SetTextXY(8, 13, "the original license.");
SetTextXY(8, 15, "This software comes with NO WARRANTY or restrictions on usage");
SetTextXY(8, 16, "save applicable local and international law. The licensing of");
SetTextXY(8, 17, "ReactOS only covers distribution to third parties.");
SetTextXY(8, 18, "If for some reason you did not receive a copy of the");
SetTextXY(8, 19, "GNU General Public License with ReactOS please visit");
SetHighlightedTextXY(8, 20, "http://www.gnu.org/licenses/licenses.html");
SetHighlightedTextXY(6, 22, "Warranty:");
SetTextXY(8, 24, "This is free software; see the source for copying conditions.");
SetTextXY(8, 25, "There is NO warranty; not even for MERCHANTABILITY or");
SetTextXY(8, 26, "FITNESS FOR A PARTICULAR PURPOSE");
SetStatusText(" ENTER = Return");
while (TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return INTRO_PAGE;
break;
}
}
return LICENSE_PAGE;
}
static PAGE_NUMBER
RepairIntroPage(PINPUT_RECORD Ir)
{
SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
SetTextXY(6, 12, "The repair functions are not implemented yet.");
SetTextXY(8, 15, "\x07 Press R for the Recovery Console.");
SetTextXY(8, 17, "\x07 Press ESC to return to the main page.");
SetTextXY(8, 19, "\x07 Press ENTER to reboot your computer.");
SetStatusText(" ESC = Main page ENTER = Reboot");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return REBOOT_PAGE;
}
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R') /* R */
{
return INTRO_PAGE;
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
{
return INTRO_PAGE;
}
}
return REPAIR_INTRO_PAGE;
}
static PAGE_NUMBER
InstallIntroPage(PINPUT_RECORD Ir)
{
SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
SetTextXY(6, 12, "The following limitations apply:");
SetTextXY(8, 13, "- Setup can not handle more than one primary partition per disk.");
SetTextXY(8, 14, "- Setup can not delete a primary partition from a disk");
SetTextXY(8, 15, " as long as extended partitions exist on this disk.");
SetTextXY(8, 16, "- Setup can not delete the first extended partition from a disk");
SetTextXY(8, 17, " as long as other extended partitions exist on this disk.");
SetTextXY(8, 18, "- Setup supports FAT file systems only.");
SetTextXY(8, 19, "- File system checks are not implemented yet.");
SetTextXY(8, 23, "\x07 Press ENTER to install ReactOS.");
SetTextXY(8, 25, "\x07 Press F3 to quit without installing ReactOS.");
SetStatusText(" ENTER = Continue F3 = Quit");
if (IsUnattendedSetup)
{
return SELECT_PARTITION_PAGE;
}
while(TRUE)
{
ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
if (ConfirmQuit(Ir) == TRUE)
return QUIT_PAGE;
break;
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return DEVICE_SETTINGS_PAGE;
// return SCSI_CONTROLLER_PAGE;
}
}
return INSTALL_INTRO_PAGE;
}
#if 0
static PAGE_NUMBER
ScsiControllerPage(PINPUT_RECORD Ir)
{
SetTextXY(6, 8, "Setup detected the following mass storage devices:");
/* FIXME: print loaded mass storage driver descriptions */
#if 0
SetTextXY(8, 10, "TEST device");
#endif
SetStatusText(" ENTER = Continue F3 = Quit");
while(TRUE)
{
ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
if (ConfirmQuit(Ir) == TRUE)
return QUIT_PAGE;
break;
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return DEVICE_SETTINGS_PAGE;
}
}
return SCSI_CONTROLLER_PAGE;
}
#endif
static PAGE_NUMBER
DeviceSettingsPage(PINPUT_RECORD Ir)
{
static ULONG Line = 16;
/* Initialize the computer settings list */
if (ComputerList == NULL)
{
ComputerList = CreateComputerTypeList(SetupInf);
if (ComputerList == NULL)
{
/* FIXME: report error */
}
}
/* Initialize the display settings list */
if (DisplayList == NULL)
{
DisplayList = CreateDisplayDriverList(SetupInf);
if (DisplayList == NULL)
{
/* FIXME: report error */
}
}
/* Initialize the keyboard settings list */
if (KeyboardList == NULL)
{
KeyboardList = CreateKeyboardDriverList(SetupInf);
if (KeyboardList == NULL)
{
/* FIXME: report error */
}
}
/* Initialize the keyboard layout list */
if (LayoutList == NULL)
{
LayoutList = CreateKeyboardLayoutList(SetupInf);
if (LayoutList == NULL)
{
/* FIXME: report error */
PopupError("Setup failed to load the keyboard layout list.\n",
"ENTER = Reboot computer");
while (TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
return QUIT_PAGE;
}
}
}
}
SetTextXY(6, 8, "The list below shows the current device settings.");
SetTextXY(8, 11, " Computer:");
SetTextXY(8, 12, " Display:");
SetTextXY(8, 13, " Keyboard:");
SetTextXY(8, 14, "Keyboard layout:");
SetTextXY(8, 16, " Accept:");
SetTextXY(25, 11, GetGenericListEntry(ComputerList)->Text);
SetTextXY(25, 12, GetGenericListEntry(DisplayList)->Text);
SetTextXY(25, 13, GetGenericListEntry(KeyboardList)->Text);
SetTextXY(25, 14, GetGenericListEntry(LayoutList)->Text);
SetTextXY(25, 16, "Accept these device settings");
InvertTextXY (24, Line, 48, 1);
SetTextXY(6, 19, "You can change the hardware settings by pressing the UP or DOWN keys");
SetTextXY(6, 20, "to select an entry. Then press the ENTER key to select alternative");
SetTextXY(6, 21, "settings.");
SetTextXY(6, 23, "When all settings are correct, select \"Accept these device settings\"");
SetTextXY(6, 24, "and press ENTER.");
SetStatusText(" ENTER = Continue F3 = Quit");
while(TRUE)
{
ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
NormalTextXY (24, Line, 48, 1);
if (Line == 14)
Line = 16;
else if (Line == 16)
Line = 11;
else
Line++;
InvertTextXY (24, Line, 48, 1);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
NormalTextXY (24, Line, 48, 1);
if (Line == 11)
Line = 16;
else if (Line == 16)
Line = 14;
else
Line--;
InvertTextXY (24, Line, 48, 1);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
if (ConfirmQuit(Ir) == TRUE)
return QUIT_PAGE;
break;
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
if (Line == 11)
return COMPUTER_SETTINGS_PAGE;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?