3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/usetup.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMER: Eric Kohl
27 #include <ddk/ntddk.h>
28 #include <ntdll/rtl.h>
30 #include <ntos/minmax.h>
31 #include <reactos/resource.h>
37 #include "filequeue.h"
44 #define INSTALL_INTRO_PAGE 2
46 #define SELECT_PARTITION_PAGE 4
47 #define SELECT_FILE_SYSTEM_PAGE 5
48 #define CHECK_FILE_SYSTEM_PAGE 6
49 #define PREPARE_COPY_PAGE 7
50 #define INSTALL_DIRECTORY_PAGE 8
51 #define FILE_COPY_PAGE 9
52 #define REGISTRY_PAGE 10
53 #define BOOT_LOADER_PAGE 11
55 #define REPAIR_INTRO_PAGE 20
57 #define SUCCESS_PAGE 100
59 #define REBOOT_PAGE 102
62 typedef struct _COPYCONTEXT
64 ULONG TotalOperations;
65 ULONG CompletedOperations;
66 PPROGRESS ProgressBar;
67 } COPYCONTEXT, *PCOPYCONTEXT;
70 /* GLOBALS ******************************************************************/
74 BOOLEAN PartDataValid;
77 BOOLEAN ActivePartitionValid;
78 PARTDATA ActivePartition;
80 UNICODE_STRING SourcePath;
81 UNICODE_STRING SourceRootPath;
83 UNICODE_STRING InstallPath;
84 UNICODE_STRING DestinationPath;
85 UNICODE_STRING DestinationArcPath;
86 UNICODE_STRING DestinationRootPath;
88 UNICODE_STRING SystemRootPath; /* Path to the active partition */
92 HSPFILEQ SetupFileQueue = NULL;
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,
113 NtDisplayString(&UnicodeString);
114 RtlFreeUnicodeString(&UnicodeString);
119 PopupError(PCHAR Text,
137 /* Count text lines and longest line */
143 p = strchr(pnext, '\n');
146 Length = strlen(pnext);
151 Length = (ULONG)(p - pnext);
156 if (Length > MaxLength)
159 if (LastLine == TRUE)
165 /* Check length of status line */
168 Length = strlen(Status);
169 if (Length > MaxLength)
173 GetScreenSize(&xScreen, &yScreen);
175 Width = MaxLength + 4;
180 yTop = (yScreen - Height) / 2;
181 xLeft = (xScreen - Width) / 2;
184 /* Set screen attributes */
186 for (coPos.Y = yTop; coPos.Y < yTop + Height; coPos.Y++)
188 FillConsoleOutputAttribute(0x74,
194 /* draw upper left corner */
197 FillConsoleOutputCharacter(0xDA, // '+',
202 /* draw upper edge */
205 FillConsoleOutputCharacter(0xC4, // '-',
210 /* draw upper right corner */
211 coPos.X = xLeft + Width - 1;
213 FillConsoleOutputCharacter(0xBF, // '+',
218 /* Draw right edge, inner space and left edge */
219 for (coPos.Y = yTop + 1; coPos.Y < yTop + Height - 1; coPos.Y++)
222 FillConsoleOutputCharacter(0xB3, // '|',
228 FillConsoleOutputCharacter(' ',
233 coPos.X = xLeft + Width - 1;
234 FillConsoleOutputCharacter(0xB3, // '|',
240 /* draw lower left corner */
242 coPos.Y = yTop + Height - 1;
243 FillConsoleOutputCharacter(0xC0, // '+',
248 /* draw lower edge */
250 coPos.Y = yTop + Height - 1;
251 FillConsoleOutputCharacter(0xC4, // '-',
256 /* draw lower right corner */
257 coPos.X = xLeft + Width - 1;
258 coPos.Y = yTop + Height - 1;
259 FillConsoleOutputCharacter(0xD9, // '+',
264 /* Print message text */
269 p = strchr(pnext, '\n');
272 Length = strlen(pnext);
277 Length = (ULONG)(p - pnext);
284 WriteConsoleOutputCharacters(pnext,
289 if (LastLine == TRUE)
296 /* Print separator line and status text */
299 coPos.Y = yTop + Height - 3;
301 FillConsoleOutputCharacter(0xC3, // '+',
307 FillConsoleOutputCharacter(0xC4, // '-',
312 coPos.X = xLeft + Width - 1;
313 FillConsoleOutputCharacter(0xB4, // '+',
320 WriteConsoleOutputCharacters(Status,
321 min(strlen(Status), Width - 4),
331 * FALSE: Don't quit setup.
334 ConfirmQuit(PINPUT_RECORD Ir)
338 PopupError("ReactOS is not completely installed on your\n"
339 "computer. If you quit Setup now, you will need to\n"
340 "run Setup again to install ReactOS.\n"
342 " * Press ENTER to continue Setup.\n"
343 " * Press F3 to quit Setup.",
344 "F3= Quit ENTER = Continue");
350 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
351 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
356 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
371 * Number of the next page.
374 StartPage(PINPUT_RECORD Ir)
377 WCHAR FileNameBuffer[MAX_PATH];
378 UNICODE_STRING FileName;
380 PINICACHESECTION Section;
384 SetStatusText(" Please wait...");
386 Status = GetSourcePaths(&SourcePath,
388 if (!NT_SUCCESS(Status))
390 PrintTextXY(6, 15, "GetSourcePath() failed (Status 0x%08lx)", Status);
394 PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath);
395 PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath);
399 /* Load txtsetup.sif from install media. */
400 wcscpy(FileNameBuffer, SourceRootPath.Buffer);
401 wcscat(FileNameBuffer, L"\\install\\txtsetup.sif");
402 RtlInitUnicodeString(&FileName,
406 Status = IniCacheLoad(&IniCache,
409 if (!NT_SUCCESS(Status))
411 PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
412 "ENTER = Reboot computer");
418 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
425 /* Open 'Version' section */
426 Section = IniCacheGetSection(IniCache,
430 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
431 "ENTER = Reboot computer");
437 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
445 /* Get pointer 'Signature' key */
446 Status = IniCacheGetKey(Section,
449 if (!NT_SUCCESS(Status))
451 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
452 "ENTER = Reboot computer");
458 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
465 /* Check 'Signature' string */
466 if (_wcsicmp(Value, L"$ReactOS$") != 0)
468 PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
469 "ENTER = Reboot computer");
475 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
488 RepairIntroPage(PINPUT_RECORD Ir)
490 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
491 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
493 SetTextXY(6, 12, "The repair functions are not implemented yet.");
495 SetTextXY(8, 15, "\xfa Press ESC to return to the main page.");
497 SetTextXY(8, 17, "\xfa Press ENTER to reboot your computer.");
499 SetStatusText(" ESC = Main page ENTER = Reboot");
505 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
509 else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
510 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
516 return(REPAIR_INTRO_PAGE);
523 * TRUE: setup/repair completed successfully
524 * FALSE: setup/repair terminated by user
527 IntroPage(PINPUT_RECORD Ir)
529 SetHighlightedTextXY(6, 8, "Welcome to ReactOS Setup");
531 SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your");
532 SetTextXY(6, 12, "computer and prepares the second part of the setup.");
534 SetTextXY(8, 15, "\xfa Press ENTER to install ReactOS.");
536 SetTextXY(8, 17, "\xfa Press E to start the emergency repair console.");
538 SetTextXY(8, 19, "\xfa Press R to repair ReactOS.");
540 SetTextXY(8, 21, "\xfa Press F3 to quit without installing ReactOS.");
543 SetStatusText(" ENTER = Continue F3 = Quit");
549 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
550 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
552 if (ConfirmQuit(Ir) == TRUE)
556 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
558 return(INSTALL_INTRO_PAGE);
561 else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'E') /* E */
563 return(RepairConsole());
566 else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R') /* R */
568 return(REPAIR_INTRO_PAGE);
577 InstallIntroPage(PINPUT_RECORD Ir)
579 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
580 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
582 SetTextXY(6, 12, "The following functions are missing:");
583 SetTextXY(8, 13, "- Creating and deleting harddisk partitions.");
584 SetTextXY(8, 14, "- Formatting partitions.");
585 SetTextXY(8, 15, "- Support for non-FAT file systems.");
586 SetTextXY(8, 16, "- Checking file systems.");
590 SetTextXY(8, 21, "\xfa Press ENTER to install ReactOS.");
592 SetTextXY(8, 23, "\xfa Press F3 to quit without installing ReactOS.");
595 SetStatusText(" ENTER = Continue F3 = Quit");
601 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
602 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
604 if (ConfirmQuit(Ir) == TRUE)
608 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
610 return(SELECT_PARTITION_PAGE);
614 return(INSTALL_INTRO_PAGE);
619 SelectPartitionPage(PINPUT_RECORD Ir)
621 WCHAR PathBuffer[MAX_PATH];
626 SetTextXY(6, 8, "The list below shows existing partitions and unused disk");
627 SetTextXY(6, 9, "space for new partitions.");
629 SetTextXY(8, 11, "\xfa Press UP or DOWN to select a list entry.");
630 SetTextXY(8, 13, "\xfa Press ENTER to install ReactOS onto the selected partition.");
631 SetTextXY(8, 15, "\xfa Press C to create a new partition.");
632 SetTextXY(8, 17, "\xfa Press D to delete an existing partition.");
634 SetStatusText(" Please wait...");
636 RtlFreeUnicodeString(&DestinationPath);
637 RtlFreeUnicodeString(&DestinationRootPath);
639 GetScreenSize(&xScreen, &yScreen);
641 PartList = CreatePartitionList(2, 19, xScreen - 3, yScreen - 3);
642 if (PartList == NULL)
644 /* FIXME: show an error dialog */
648 SetStatusText(" ENTER = Continue F3 = Quit");
654 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
655 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
657 if (ConfirmQuit(Ir) == TRUE)
659 DestroyPartitionList(PartList);
664 else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
665 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
667 ScrollDownPartitionList(PartList);
669 else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
670 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
672 ScrollUpPartitionList(PartList);
674 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
676 PartDataValid = GetSelectedPartition(PartList,
678 ActivePartitionValid = GetActiveBootPartition(PartList,
680 DestroyPartitionList(PartList);
682 RtlFreeUnicodeString(&DestinationRootPath);
684 L"\\Device\\Harddisk%lu\\Partition%lu",
686 PartData.PartNumber);
687 RtlCreateUnicodeString(&DestinationRootPath,
690 RtlFreeUnicodeString(&SystemRootPath);
692 L"\\Device\\Harddisk%lu\\Partition%lu",
693 ActivePartition.DiskNumber,
694 ActivePartition.PartNumber);
695 RtlCreateUnicodeString(&SystemRootPath,
698 return(SELECT_FILE_SYSTEM_PAGE);
701 /* FIXME: Update status text */
705 DestroyPartitionList(PartList);
707 return(SELECT_PARTITION_PAGE);
712 SelectFileSystemPage(PINPUT_RECORD Ir)
720 if (PartDataValid == FALSE)
722 /* FIXME: show an error dialog */
726 /* adjust disk size */
727 if (PartData.DiskSize >= 0x280000000ULL) /* 10 GB */
729 DiskSize = (PartData.DiskSize + (1 << 29)) >> 30;
734 DiskSize = (PartData.DiskSize + (1 << 19)) >> 20;
738 /* adjust partition size */
739 if (PartData.PartSize >= 0x280000000ULL) /* 10 GB */
741 PartSize = (PartData.PartSize + (1 << 29)) >> 30;
746 PartSize = (PartData.PartSize + (1 << 19)) >> 20;
750 /* adjust partition type */
751 if ((PartData.PartType == PARTITION_FAT_12) ||
752 (PartData.PartType == PARTITION_FAT_16) ||
753 (PartData.PartType == PARTITION_HUGE) ||
754 (PartData.PartType == PARTITION_XINT13))
758 else if ((PartData.PartType == PARTITION_FAT32) ||
759 (PartData.PartType == PARTITION_FAT32_XINT13))
763 else if (PartData.PartType == PARTITION_IFS)
765 PartType = "NTFS"; /* FIXME: Not quite correct! */
769 PartType = "Unknown";
772 SetTextXY(6, 8, "Setup will install ReactOS on");
774 PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s on",
780 PrintTextXY(8, 12, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
787 &PartData.DriverName);
790 SetTextXY(6, 17, "Select a file system for the partition from the list below.");
792 SetTextXY(8, 19, "\xfa Press UP or DOWN to select a file system.");
793 SetTextXY(8, 21, "\xfa Press ENTER to format the partition.");
794 SetTextXY(8, 23, "\xfa Press ESC to select another partition.");
796 /* FIXME: use a real list later */
797 SetInvertedTextXY(6, 26, " Keep current file system (no changes) ");
800 SetStatusText(" ENTER = Continue ESC = Cancel F3 = Quit");
806 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
807 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
809 if (ConfirmQuit(Ir) == TRUE)
813 else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
814 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
816 return(SELECT_PARTITION_PAGE);
818 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
820 return(CHECK_FILE_SYSTEM_PAGE);
824 return(SELECT_FILE_SYSTEM_PAGE);
829 CheckFileSystemPage(PINPUT_RECORD Ir)
831 SetTextXY(6, 8, "Check file system");
833 SetTextXY(6, 10, "At present, ReactOS can not check file systems.");
835 SetStatusText(" Please wait ...");
838 SetStatusText(" ENTER = Continue F3 = Quit");
844 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
845 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
847 if (ConfirmQuit(Ir) == TRUE)
851 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
853 return(INSTALL_DIRECTORY_PAGE);
857 return(CHECK_FILE_SYSTEM_PAGE);
862 InstallDirectoryPage(PINPUT_RECORD Ir)
864 PINICACHESECTION Section;
865 WCHAR PathBuffer[MAX_PATH];
866 WCHAR InstallDir[51];
871 /* Open 'SetupData' section */
872 Section = IniCacheGetSection(IniCache,
876 PopupError("Setup failed to find the 'SetupData' section\n"
877 "in TXTSETUP.SIF.\n",
878 "ENTER = Reboot computer");
884 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
891 /* Read the 'DefaultPath' key */
892 Status = IniCacheGetKey(Section,
895 if (!NT_SUCCESS(Status))
897 wcscpy(InstallDir, L"\\reactos");
901 wcscpy(InstallDir, DefaultPath);
903 Length = wcslen(InstallDir);
905 SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
906 SetTextXY(6, 9, "directory where you want ReactOS to be installed:");
908 SetInputTextXY(8, 11, 51, InstallDir);
910 SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete");
911 SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to");
912 SetTextXY(6, 16, "be installed.");
914 SetStatusText(" ENTER = Continue F3 = Quit");
920 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
921 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
923 if (ConfirmQuit(Ir) == TRUE)
927 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
929 /* Create 'InstallPath' string */
930 RtlFreeUnicodeString(&InstallPath);
931 RtlCreateUnicodeString(&InstallPath,
934 /* Create 'DestinationPath' string */
935 RtlFreeUnicodeString(&DestinationPath);
937 DestinationRootPath.Buffer);
938 if (InstallDir[0] != L'\\')
941 wcscat(PathBuffer, InstallDir);
942 RtlCreateUnicodeString(&DestinationPath,
945 /* Create 'DestinationArcPath' */
946 RtlFreeUnicodeString(&DestinationArcPath);
948 L"multi(0)disk(0)rdisk(%lu)partition(%lu)",
950 PartData.PartNumber);
951 if (InstallDir[0] != L'\\')
954 wcscat(PathBuffer, InstallDir);
955 RtlCreateUnicodeString(&DestinationArcPath,
958 return(PREPARE_COPY_PAGE);
960 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x08) /* BACKSPACE */
965 InstallDir[Length] = 0;
966 SetInputTextXY(8, 11, 51, InstallDir);
969 else if (isprint(Ir->Event.KeyEvent.uChar.AsciiChar))
973 InstallDir[Length] = (WCHAR)Ir->Event.KeyEvent.uChar.AsciiChar;
975 InstallDir[Length] = 0;
976 SetInputTextXY(8, 11, 51, InstallDir);
981 return(INSTALL_DIRECTORY_PAGE);
986 PrepareCopyPage(PINPUT_RECORD Ir)
988 WCHAR PathBuffer[MAX_PATH];
989 PINICACHESECTION DirSection;
990 PINICACHESECTION FilesSection;
991 PINICACHEITERATOR Iterator;
1002 SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. ");
1005 // SetTextXY(8, 12, "Build file copy list");
1007 // SetTextXY(8, 14, "Create directories");
1009 // SetStatusText(" Please wait...");
1013 * Build the file copy list
1015 SetStatusText(" Building the file copy list...");
1016 // SetInvertedTextXY(8, 12, "Build file copy list");
1019 /* Open 'Directories' section */
1020 DirSection = IniCacheGetSection(IniCache,
1022 if (DirSection == NULL)
1024 PopupError("Setup failed to find the 'Directories' section\n"
1025 "in TXTSETUP.SIF.\n",
1026 "ENTER = Reboot computer");
1032 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1039 /* Open 'SourceFiles' section */
1040 FilesSection = IniCacheGetSection(IniCache,
1042 if (FilesSection == NULL)
1044 PopupError("Setup failed to find the 'SourceFiles' section\n"
1045 "in TXTSETUP.SIF.\n",
1046 "ENTER = Reboot computer");
1052 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1060 /* Create the file queue */
1061 SetupFileQueue = SetupOpenFileQueue();
1062 if (SetupFileQueue == NULL)
1064 PopupError("Setup failed to open the copy file queue.\n",
1065 "ENTER = Reboot computer");
1071 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1079 * Enumerate the files in the 'SourceFiles' section
1080 * and add them to the file queue.
1082 Iterator = IniCacheFindFirstValue(FilesSection,
1085 if (Iterator != NULL)
1089 DPRINT1("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
1091 /* Lookup target directory */
1092 Status = IniCacheGetKey(DirSection,
1095 if (!NT_SUCCESS(Status))
1097 /* FIXME: Handle error! */
1098 DPRINT1("IniCacheGetKey() failed (Status 0x%lX)\n", Status);
1101 if (SetupQueueCopy(SetupFileQueue,
1102 SourceRootPath.Buffer,
1108 /* FIXME: Handle error! */
1109 DPRINT1("SetupQueueCopy() failed\n");
1112 while (IniCacheFindNextValue(Iterator, &FileKeyName, &FileKeyValue));
1114 IniCacheFindClose(Iterator);
1117 /* Report that the file queue has been built */
1118 // SetTextXY(8, 12, "Build file copy list");
1119 // SetHighlightedTextXY(50, 12, "Done");
1121 /* create directories */
1122 SetStatusText(" Creating directories...");
1123 // SetInvertedTextXY(8, 14, "Create directories");
1128 * Install directories like '\reactos\test' are not handled yet.
1131 /* Get destination path */
1132 wcscpy(PathBuffer, DestinationPath.Buffer);
1134 /* Remove trailing backslash */
1135 Length = wcslen(PathBuffer);
1136 if ((Length > 0) && (PathBuffer[Length - 1] == '\\'))
1137 PathBuffer[Length - 1] = 0;
1139 /* Create the install directory */
1140 Status = CreateDirectory(PathBuffer);
1141 if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
1143 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer, Status);
1145 PopupError("Setup could not create the install directory.",
1146 "ENTER = Reboot computer");
1152 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1160 /* Enumerate the directory values and create the subdirectories */
1161 Iterator = IniCacheFindFirstValue(DirSection,
1164 if (Iterator != NULL)
1168 if (KeyValue[0] == L'\\' && KeyValue[1] != 0)
1170 DPRINT("Absolute Path: '%S'\n", KeyValue);
1172 wcscpy(PathBuffer, DestinationRootPath.Buffer);
1173 wcscat(PathBuffer, KeyValue);
1175 DPRINT("FullPath: '%S'\n", PathBuffer);
1177 else if (KeyValue[0] != L'\\')
1179 DPRINT("RelativePath: '%S'\n", KeyValue);
1180 wcscpy(PathBuffer, DestinationPath.Buffer);
1181 wcscat(PathBuffer, L"\\");
1182 wcscat(PathBuffer, KeyValue);
1184 DPRINT("FullPath: '%S'\n", PathBuffer);
1186 Status = CreateDirectory(PathBuffer);
1187 if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
1189 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer, Status);
1191 PopupError("Setup could not create install directories.",
1192 "ENTER = Reboot computer");
1198 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1200 IniCacheFindClose(Iterator);
1207 while (IniCacheFindNextValue(Iterator, &KeyName, &KeyValue));
1209 IniCacheFindClose(Iterator);
1213 return(FILE_COPY_PAGE);
1216 SetTextXY(8, 14, "Create directories");
1217 SetHighlightedTextXY(50, 14, "Done");
1220 SetStatusText(" ENTER = Continue F3 = Quit");
1226 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1227 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1229 if (ConfirmQuit(Ir) == TRUE)
1233 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1235 return(FILE_COPY_PAGE);
1239 return(PREPARE_COPY_PAGE);
1245 FileCopyCallback(PVOID Context,
1250 PCOPYCONTEXT CopyContext;
1252 CopyContext = (PCOPYCONTEXT)Context;
1254 switch (Notification)
1256 case SPFILENOTIFY_STARTSUBQUEUE:
1257 CopyContext->TotalOperations = (ULONG)Param2;
1258 ProgressSetStepCount(CopyContext->ProgressBar,
1259 CopyContext->TotalOperations);
1262 case SPFILENOTIFY_STARTCOPY:
1263 /* Display copy message */
1264 PrintTextXYN(6, 16, 60, "Copying file: %S", (PWSTR)Param1);
1266 PrintTextXYN(6, 18, 60, "File %lu of %lu",
1267 CopyContext->CompletedOperations + 1,
1268 CopyContext->TotalOperations);
1272 case SPFILENOTIFY_ENDCOPY:
1273 CopyContext->CompletedOperations++;
1274 ProgressNextStep(CopyContext->ProgressBar);
1283 FileCopyPage(PINPUT_RECORD Ir)
1285 COPYCONTEXT CopyContext;
1289 SetStatusText(" Please wait...");
1291 SetTextXY(6, 8, "Copying files");
1293 GetScreenSize(&xScreen, &yScreen);
1295 CopyContext.TotalOperations = 0;
1296 CopyContext.CompletedOperations = 0;
1297 CopyContext.ProgressBar = CreateProgressBar(6,
1302 SetupCommitFileQueue(SetupFileQueue,
1303 DestinationRootPath.Buffer,
1305 (PSP_FILE_CALLBACK)FileCopyCallback,
1308 SetupCloseFileQueue(SetupFileQueue);
1310 DestroyProgressBar(CopyContext.ProgressBar);
1312 return(REGISTRY_PAGE);
1315 SetStatusText(" ENTER = Continue F3 = Quit");
1321 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1322 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1324 if (ConfirmQuit(Ir) == TRUE)
1328 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1330 return(REGISTRY_PAGE);
1334 return(FILE_COPY_PAGE);
1341 RegistryPage(PINPUT_RECORD Ir)
1343 OBJECT_ATTRIBUTES ObjectAttributes;
1344 UNICODE_STRING KeyName;
1345 UNICODE_STRING ValueName;
1349 SetTextXY(6, 8, "Setup initializes system settings");
1352 // SetTextXY(6, 12, "Create registry hives");
1354 // SetTextXY(6, 14, "Update registry hives");
1357 // SetStatusText(" Please wait...");
1359 SetStatusText(" Creating registry hives...");
1361 /* Create the 'secret' InstallPath key */
1362 RtlInitUnicodeStringFromLiteral(&KeyName,
1363 L"\\Registry\\Machine\\HARDWARE");
1364 InitializeObjectAttributes(&ObjectAttributes,
1366 OBJ_CASE_INSENSITIVE,
1369 Status = NtOpenKey(&KeyHandle,
1372 if (!NT_SUCCESS(Status))
1374 DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
1375 PopupError("Setup failed to open the HARDWARE registry key.",
1376 "ENTER = Reboot computer");
1382 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1389 RtlInitUnicodeStringFromLiteral(&ValueName,
1392 Status = NtSetValueKey(KeyHandle,
1396 (PVOID)DestinationPath.Buffer,
1397 DestinationPath.Length);
1399 if (!NT_SUCCESS(Status))
1401 DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
1402 PopupError("Setup failed to set the \'InstallPath\' registry value.",
1403 "ENTER = Reboot computer");
1409 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1416 /* Create the standard hives */
1417 Status = NtInitializeRegistry(TRUE);
1418 if (!NT_SUCCESS(Status))
1420 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status);
1421 PopupError("Setup failed to initialize the registry.",
1422 "ENTER = Reboot computer");
1428 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1436 /* Update registry */
1437 SetStatusText(" Updating registry hives...");
1439 /* FIXME: Create key '\Registry\Machine\System\Setup' */
1441 /* FIXME: Create value 'SystemSetupInProgress' */
1444 return(BOOT_LOADER_PAGE);
1447 SetStatusText(" ENTER = Continue F3 = Quit");
1453 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
1454 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
1456 if (ConfirmQuit(Ir) == TRUE)
1460 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1462 return(BOOT_LOADER_PAGE);
1466 return(REGISTRY_PAGE);
1472 BootLoaderPage(PINPUT_RECORD Ir)
1474 WCHAR SrcPath[MAX_PATH];
1475 WCHAR DstPath[MAX_PATH];
1477 PINICACHESECTION IniSection;
1480 SetTextXY(6, 8, "Installing the boot loader");
1482 SetStatusText(" Please wait...");
1484 if (ActivePartitionValid == FALSE)
1486 DPRINT1("Error: no active partition found\n");
1487 PopupError("Setup could not find an active partiton\n",
1488 "ENTER = Reboot computer");
1494 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1501 if (ActivePartition.PartType == PARTITION_ENTRY_UNUSED)
1503 DPRINT1("Error: active partition invalid (unused)\n");
1504 PopupError("The active partition is unused (invalid).\n",
1505 "ENTER = Reboot computer");
1511 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1518 if (ActivePartition.PartType == 0x0A)
1520 /* OS/2 boot manager partition */
1521 DPRINT1("Found OS/2 boot manager partition\n");
1522 PopupError("Setup found an OS/2 boot manager partiton.\n"
1523 "The OS/2 boot manager is not supported yet!",
1524 "ENTER = Reboot computer");
1530 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1536 else if (ActivePartition.PartType == 0x83)
1538 /* Linux ext2 partition */
1539 DPRINT1("Found Linux ext2 partition\n");
1540 PopupError("Setup found a Linux ext2 partiton.\n"
1541 "Linux ext2 partitions are not supported yet!",
1542 "ENTER = Reboot computer");
1548 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1554 else if (ActivePartition.PartType == PARTITION_IFS)
1556 /* NTFS partition */
1557 DPRINT1("Found NTFS partition\n");
1558 PopupError("Setup found an NTFS partiton.\n"
1559 "NTFS partitions are not supported yet!",
1560 "ENTER = Reboot computer");
1566 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1572 else if ((ActivePartition.PartType == PARTITION_FAT_12) ||
1573 (ActivePartition.PartType == PARTITION_FAT_16) ||
1574 (ActivePartition.PartType == PARTITION_HUGE) ||
1575 (ActivePartition.PartType == PARTITION_XINT13) ||
1576 (ActivePartition.PartType == PARTITION_FAT32) ||
1577 (ActivePartition.PartType == PARTITION_FAT32_XINT13))
1579 /* FAT or FAT32 partition */
1580 DPRINT1("System path: '%wZ'\n", &SystemRootPath);
1582 if (DoesFileExist(SystemRootPath.Buffer, L"ntldr") == TRUE ||
1583 DoesFileExist(SystemRootPath.Buffer, L"boot.ini") == TRUE)
1585 /* Search root directory for 'ntldr' and 'boot.ini'. */
1586 DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
1588 /* Copy FreeLoader to the boot partition */
1589 wcscpy(SrcPath, SourceRootPath.Buffer);
1590 wcscat(SrcPath, L"\\loader\\freeldr.sys");
1591 wcscpy(DstPath, SystemRootPath.Buffer);
1592 wcscat(DstPath, L"\\freeldr.sys");
1594 DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
1595 Status = SetupCopyFile(SrcPath, DstPath);
1596 if (!NT_SUCCESS(Status))
1598 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
1599 PopupError("Setup failed to copy 'freeldr.sys'.",
1600 "ENTER = Reboot computer");
1606 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1613 /* Create or update freeldr.ini */
1614 if (DoesFileExist(SystemRootPath.Buffer, L"freeldr.ini") == FALSE)
1616 /* Create new 'freeldr.ini' */
1617 DPRINT1("Create new 'freeldr.ini'\n");
1618 wcscpy(DstPath, SystemRootPath.Buffer);
1619 wcscat(DstPath, L"\\freeldr.ini");
1621 Status = CreateFreeLoaderIniForReactos(DstPath,
1622 DestinationArcPath.Buffer);
1623 if (!NT_SUCCESS(Status))
1625 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status);
1626 PopupError("Setup failed to create 'freeldr.ini'.",
1627 "ENTER = Reboot computer");
1633 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1640 /* Install new bootcode */
1641 if ((ActivePartition.PartType == PARTITION_FAT32) ||
1642 (ActivePartition.PartType == PARTITION_FAT32_XINT13))
1644 /* Install FAT32 bootcode */
1645 wcscpy(SrcPath, SourceRootPath.Buffer);
1646 wcscat(SrcPath, L"\\loader\\fat32.bin");
1647 wcscpy(DstPath, SystemRootPath.Buffer);
1648 wcscat(DstPath, L"\\bootsect.ros");
1650 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, DstPath);
1651 Status = InstallFat32BootCodeToFile(SrcPath,
1653 SystemRootPath.Buffer);
1654 if (!NT_SUCCESS(Status))
1656 DPRINT1("InstallFat32BootCodeToFile() failed (Status %lx)\n", Status);
1657 PopupError("Setup failed to install the FAT32 bootcode.",
1658 "ENTER = Reboot computer");
1664 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1673 /* Install FAT16 bootcode */
1674 wcscpy(SrcPath, SourceRootPath.Buffer);
1675 wcscat(SrcPath, L"\\loader\\fat.bin");
1676 wcscpy(DstPath, SystemRootPath.Buffer);
1677 wcscat(DstPath, L"\\bootsect.ros");
1679 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
1680 Status = InstallFat16BootCodeToFile(SrcPath,
1682 SystemRootPath.Buffer);
1683 if (!NT_SUCCESS(Status))
1685 DPRINT1("InstallFat16BootCodeToFile() failed (Status %lx)\n", Status);
1686 PopupError("Setup failed to install the FAT bootcode.",
1687 "ENTER = Reboot computer");
1693 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1701 /* Update 'boot.ini' */
1702 wcscpy(DstPath, SystemRootPath.Buffer);
1703 wcscat(DstPath, L"\\boot.ini");
1705 DPRINT1("Update 'boot.ini': %S\n", DstPath);
1706 Status = UpdateBootIni(DstPath,
1707 L"C:\\bootsect.ros",
1709 if (!NT_SUCCESS(Status))
1711 DPRINT1("UpdateBootIni() failed (Status %lx)\n", Status);
1712 PopupError("Setup failed to update \'boot.ini\'.",
1713 "ENTER = Reboot computer");
1719 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1728 /* Update existing 'freeldr.ini' */
1729 DPRINT1("Update existing 'freeldr.ini'\n");
1730 wcscpy(DstPath, SystemRootPath.Buffer);
1731 wcscat(DstPath, L"\\freeldr.ini");
1733 Status = UpdateFreeLoaderIni(DstPath,
1734 DestinationArcPath.Buffer);
1735 if (!NT_SUCCESS(Status))
1737 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
1738 PopupError("Setup failed to update 'freeldr.ini'.",
1739 "ENTER = Reboot computer");
1745 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1753 else if (DoesFileExist(SystemRootPath.Buffer, L"io.sys") == TRUE ||
1754 DoesFileExist(SystemRootPath.Buffer, L"msdos.sys") == TRUE)
1756 /* Search for root directory for 'io.sys' and 'msdos.sys'. */
1757 DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
1759 /* Copy FreeLoader to the boot partition */
1760 wcscpy(SrcPath, SourceRootPath.Buffer);
1761 wcscat(SrcPath, L"\\loader\\freeldr.sys");
1762 wcscpy(DstPath, SystemRootPath.Buffer);
1763 wcscat(DstPath, L"\\freeldr.sys");
1765 DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
1766 Status = SetupCopyFile(SrcPath, DstPath);
1767 if (!NT_SUCCESS(Status))
1769 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
1770 PopupError("Setup failed to copy 'freeldr.sys'.",
1771 "ENTER = Reboot computer");
1777 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1784 /* Create or update 'freeldr.ini' */
1785 if (DoesFileExist(SystemRootPath.Buffer, L"freeldr.ini") == FALSE)
1787 /* Create new 'freeldr.ini' */
1788 DPRINT1("Create new 'freeldr.ini'\n");
1789 wcscpy(DstPath, SystemRootPath.Buffer);
1790 wcscat(DstPath, L"\\freeldr.ini");
1792 Status = CreateFreeLoaderIniForDos(DstPath,
1793 DestinationArcPath.Buffer);
1794 if (!NT_SUCCESS(Status))
1796 DPRINT1("CreateFreeLoaderIniForDos() failed (Status %lx)\n", Status);
1797 PopupError("Setup failed to create 'freeldr.ini'.",
1798 "ENTER = Reboot computer");
1804 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1811 /* Save current bootsector as 'BOOTSECT.DOS' */
1812 wcscpy(SrcPath, SystemRootPath.Buffer);
1813 wcscpy(DstPath, SystemRootPath.Buffer);
1814 wcscat(DstPath, L"\\bootsect.dos");
1816 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath, DstPath);
1817 Status = SaveCurrentBootSector(SrcPath,
1819 if (!NT_SUCCESS(Status))
1821 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status);
1822 PopupError("Setup failed to save the current bootsector.",
1823 "ENTER = Reboot computer");
1829 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1836 /* Install new bootsector */
1837 if ((ActivePartition.PartType == PARTITION_FAT32) ||
1838 (ActivePartition.PartType == PARTITION_FAT32_XINT13))
1840 wcscpy(SrcPath, SourceRootPath.Buffer);
1841 wcscat(SrcPath, L"\\loader\\fat32.bin");
1843 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath.Buffer);
1844 Status = InstallFat32BootCodeToDisk(SrcPath,
1845 SystemRootPath.Buffer);
1846 if (!NT_SUCCESS(Status))
1848 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status);
1849 PopupError("Setup failed to install the FAT32 bootcode.",
1850 "ENTER = Reboot computer");
1856 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1865 wcscpy(SrcPath, SourceRootPath.Buffer);
1866 wcscat(SrcPath, L"\\loader\\fat.bin");
1868 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, SystemRootPath.Buffer);
1869 Status = InstallFat16BootCodeToDisk(SrcPath,
1870 SystemRootPath.Buffer);
1871 if (!NT_SUCCESS(Status))
1873 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status);
1874 PopupError("Setup failed to install the FAT bootcode.",
1875 "ENTER = Reboot computer");
1881 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1891 /* Update existing 'freeldr.ini' */
1892 wcscpy(DstPath, SystemRootPath.Buffer);
1893 wcscat(DstPath, L"\\freeldr.ini");
1895 Status = UpdateFreeLoaderIni(DstPath,
1896 DestinationArcPath.Buffer);
1897 if (!NT_SUCCESS(Status))
1899 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
1900 PopupError("Setup failed to update 'freeldr.ini'.",
1901 "ENTER = Reboot computer");
1907 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1917 /* No or unknown boot loader */
1918 DPRINT1("No or unknown boot loader found\n");
1920 /* Copy FreeLoader to the boot partition */
1921 wcscpy(SrcPath, SourceRootPath.Buffer);
1922 wcscat(SrcPath, L"\\loader\\freeldr.sys");
1923 wcscpy(DstPath, SystemRootPath.Buffer);
1924 wcscat(DstPath, L"\\freeldr.sys");
1926 DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
1927 Status = SetupCopyFile(SrcPath, DstPath);
1928 if (!NT_SUCCESS(Status))
1930 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
1931 PopupError("Setup failed to copy 'freeldr.sys'.",
1932 "ENTER = Reboot computer");
1938 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1945 /* Create or update 'freeldr.ini' */
1946 if (DoesFileExist(SystemRootPath.Buffer, L"freeldr.ini") == FALSE)
1948 /* Create new freeldr.ini */
1949 wcscpy(DstPath, SystemRootPath.Buffer);
1950 wcscat(DstPath, L"\\freeldr.ini");
1952 DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
1953 Status = CreateFreeLoaderIniForReactos(DstPath,
1954 DestinationArcPath.Buffer);
1955 if (!NT_SUCCESS(Status))
1957 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status);
1958 PopupError("Setup failed to create \'freeldr.ini\'.",
1959 "ENTER = Reboot computer");
1965 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1972 /* Save current bootsector as 'BOOTSECT.OLD' */
1973 wcscpy(SrcPath, SystemRootPath.Buffer);
1974 wcscpy(DstPath, SystemRootPath.Buffer);
1975 wcscat(DstPath, L"\\bootsect.old");
1977 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath, DstPath);
1978 Status = SaveCurrentBootSector(SrcPath,
1980 if (!NT_SUCCESS(Status))
1982 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status);
1983 PopupError("Setup failed save the current bootsector.",
1984 "ENTER = Reboot computer");
1990 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
1997 /* Install new bootsector */
1998 if ((ActivePartition.PartType == PARTITION_FAT32) ||
1999 (ActivePartition.PartType == PARTITION_FAT32_XINT13))
2001 wcscpy(SrcPath, SourceRootPath.Buffer);
2002 wcscat(SrcPath, L"\\loader\\fat32.bin");
2004 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath.Buffer);
2005 Status = InstallFat32BootCodeToDisk(SrcPath,
2006 SystemRootPath.Buffer);
2007 if (!NT_SUCCESS(Status))
2009 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status);
2010 PopupError("Setup failed to install the FAT32 bootcode.",
2011 "ENTER = Reboot computer");
2017 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
2026 wcscpy(SrcPath, SourceRootPath.Buffer);
2027 wcscat(SrcPath, L"\\loader\\fat.bin");
2029 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, SystemRootPath.Buffer);
2030 Status = InstallFat16BootCodeToDisk(SrcPath,
2031 SystemRootPath.Buffer);
2032 if (!NT_SUCCESS(Status))
2034 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status);
2035 PopupError("Setup failed to install the FAT bootcode.",
2036 "ENTER = Reboot computer");
2042 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
2052 /* Update existing 'freeldr.ini' */
2053 wcscpy(DstPath, SystemRootPath.Buffer);
2054 wcscat(DstPath, L"\\freeldr.ini");
2056 Status = UpdateFreeLoaderIni(DstPath,
2057 DestinationArcPath.Buffer);
2058 if (!NT_SUCCESS(Status))
2060 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status);
2061 PopupError("Setup failed to update 'freeldr.ini'.",
2062 "ENTER = Reboot computer");
2068 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
2079 /* Unknown partition */
2080 DPRINT1("Unknown partition found\n");
2081 PopupError("Setup found an unknown partiton type.\n"
2082 "This partition type is not supported!",
2083 "ENTER = Reboot computer");
2089 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
2096 return(SUCCESS_PAGE);
2099 SetStatusText(" ENTER = Continue F3 = Quit");
2105 if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
2106 (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
2108 if (ConfirmQuit(Ir) == TRUE)
2112 else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
2114 return(SUCCESS_PAGE);
2118 return(BOOT_LOADER_PAGE);
2125 QuitPage(PINPUT_RECORD Ir)
2127 SetTextXY(10, 6, "ReactOS is not completely installed");
2129 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2130 SetTextXY(10, 9, "all CD-ROMs from CD-Drives.");
2132 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2134 SetStatusText(" ENTER = Reboot computer");
2140 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
2142 return(REBOOT_PAGE);
2149 SuccessPage(PINPUT_RECORD Ir)
2151 SetTextXY(10, 6, "The basic components of ReactOS have been installed successfully.");
2153 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2154 SetTextXY(10, 9, "all CD-ROMs from CD-Drive.");
2156 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2158 SetStatusText(" ENTER = Reboot computer");
2164 if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
2166 return(REBOOT_PAGE);
2173 NtProcessStartup(PPEB Peb)
2179 RtlNormalizeProcessParams(Peb->ProcessParameters);
2181 ProcessHeap = Peb->ProcessHeap;
2183 Status = AllocConsole();
2184 if (!NT_SUCCESS(Status))
2186 PrintString("AllocConsole() failed (Status = 0x%08lx)\n", Status);
2188 /* Raise a hard error (crash the system/BSOD) */
2189 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
2193 PartDataValid = FALSE;
2195 /* Initialize global unicode strings */
2196 RtlInitUnicodeString(&SourcePath, NULL);
2197 RtlInitUnicodeString(&SourceRootPath, NULL);
2198 RtlInitUnicodeString(&InstallPath, NULL);
2199 RtlInitUnicodeString(&DestinationPath, NULL);
2200 RtlInitUnicodeString(&DestinationArcPath, NULL);
2201 RtlInitUnicodeString(&DestinationRootPath, NULL);
2202 RtlInitUnicodeString(&SystemRootPath, NULL);
2206 while (Page != REBOOT_PAGE)
2210 SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
2216 Page = StartPage(&Ir);
2221 Page = IntroPage(&Ir);
2225 case INSTALL_INTRO_PAGE:
2226 Page = InstallIntroPage(&Ir);
2230 case OEM_DRIVER_PAGE:
2231 Page = OemDriverPage(&Ir);
2236 case DEVICE_SETTINGS_PAGE:
2239 case SELECT_PARTITION_PAGE:
2240 Page = SelectPartitionPage(&Ir);
2243 case SELECT_FILE_SYSTEM_PAGE:
2244 Page = SelectFileSystemPage(&Ir);
2247 case CHECK_FILE_SYSTEM_PAGE:
2248 Page = CheckFileSystemPage(&Ir);
2251 case INSTALL_DIRECTORY_PAGE:
2252 Page = InstallDirectoryPage(&Ir);
2255 case PREPARE_COPY_PAGE:
2256 Page = PrepareCopyPage(&Ir);
2259 case FILE_COPY_PAGE:
2260 Page = FileCopyPage(&Ir);
2264 Page = RegistryPage(&Ir);
2267 case BOOT_LOADER_PAGE:
2268 Page = BootLoaderPage(&Ir);
2273 case REPAIR_INTRO_PAGE:
2274 Page = RepairIntroPage(&Ir);
2279 Page = SuccessPage(&Ir);
2283 Page = QuitPage(&Ir);
2290 NtShutdownSystem(ShutdownReboot);