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>
42 #define INSTALL_INTRO_PAGE 2
44 #define SELECT_PARTITION_PAGE 4
45 #define SELECT_FILE_SYSTEM_PAGE 5
46 #define CHECK_FILE_SYSTEM_PAGE 6
47 #define PREPARE_COPY_PAGE 7
48 #define INSTALL_DIRECTORY_PAGE 8
49 #define FILE_COPY_PAGE 9
50 #define INIT_SYSTEM_PAGE 10
52 #define REPAIR_INTRO_PAGE 20
54 #define SUCCESS_PAGE 100
56 #define REBOOT_PAGE 102
59 /* GLOBALS ******************************************************************/
63 BOOLEAN PartDataValid
;
68 UNICODE_STRING SourcePath
;
69 UNICODE_STRING SourceRootPath
;
74 /* FUNCTIONS ****************************************************************/
77 PrintString(char* fmt
,...)
81 UNICODE_STRING UnicodeString
;
82 ANSI_STRING AnsiString
;
85 vsprintf(buffer
, fmt
, ap
);
88 RtlInitAnsiString(&AnsiString
, buffer
);
89 RtlAnsiStringToUnicodeString(&UnicodeString
,
92 NtDisplayString(&UnicodeString
);
93 RtlFreeUnicodeString(&UnicodeString
);
98 PopupError(PCHAR Text
,
117 /* Count text lines and longest line */
123 p
= strchr(pnext
, '\n');
126 Length
= strlen(pnext
);
131 Length
= (ULONG
)(p
- pnext
);
136 if (Length
> MaxLength
)
139 if (LastLine
== TRUE
)
145 /* Check length of status line */
148 Length
= strlen(Status
);
149 if (Length
> MaxLength
)
153 GetScreenSize(&xScreen
, &yScreen
);
155 Width
= MaxLength
+ 4;
160 yTop
= (yScreen
- Height
) / 2;
161 xLeft
= (xScreen
- Width
) / 2;
164 /* Set screen attributes */
166 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
168 FillConsoleOutputAttribute(0x74,
174 /* draw upper left corner */
177 FillConsoleOutputCharacter(0xDA, // '+',
182 /* draw upper edge */
185 FillConsoleOutputCharacter(0xC4, // '-',
190 /* draw upper right corner */
191 coPos
.X
= xLeft
+ Width
- 1;
193 FillConsoleOutputCharacter(0xBF, // '+',
198 /* Draw right edge, inner space and left edge */
199 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
202 FillConsoleOutputCharacter(0xB3, // '|',
208 FillConsoleOutputCharacter(' ',
213 coPos
.X
= xLeft
+ Width
- 1;
214 FillConsoleOutputCharacter(0xB3, // '|',
220 /* draw lower left corner */
222 coPos
.Y
= yTop
+ Height
- 1;
223 FillConsoleOutputCharacter(0xC0, // '+',
228 /* draw lower edge */
230 coPos
.Y
= yTop
+ Height
- 1;
231 FillConsoleOutputCharacter(0xC4, // '-',
236 /* draw lower right corner */
237 coPos
.X
= xLeft
+ Width
- 1;
238 coPos
.Y
= yTop
+ Height
- 1;
239 FillConsoleOutputCharacter(0xD9, // '+',
244 /* Print message text */
249 p
= strchr(pnext
, '\n');
252 Length
= strlen(pnext
);
257 Length
= (ULONG
)(p
- pnext
);
264 WriteConsoleOutputCharacters(pnext
,
269 if (LastLine
== TRUE
)
276 /* Print separator line and status text */
279 coPos
.Y
= yTop
+ Height
- 3;
281 FillConsoleOutputCharacter(0xC3, // '+',
287 FillConsoleOutputCharacter(0xC4, // '-',
292 coPos
.X
= xLeft
+ Width
- 1;
293 FillConsoleOutputCharacter(0xB4, // '+',
300 WriteConsoleOutputCharacters(Status
,
301 min(strlen(Status
), Width
- 4),
311 * FALSE: Don't quit setup.
314 ConfirmQuit(PINPUT_RECORD Ir
)
318 PopupError("ReactOS is not completely installed on your\n"
319 "computer. If you quit Setup now, you will need to\n"
320 "run Setup again to install ReactOS.\n"
322 " * Press ENTER to continue Setup.\n"
323 " * Press F3 to quit Setup.",
324 "F3= Quit ENTER = Continue");
330 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
331 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
336 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
351 * Number of the next page.
354 StartPage(PINPUT_RECORD Ir
)
357 WCHAR FileNameBuffer
[MAX_PATH
];
358 UNICODE_STRING FileName
;
360 PINICACHESECTION Section
;
364 SetStatusText(" Please wait...");
366 Status
= GetSourcePaths(&SourcePath
,
368 if (!NT_SUCCESS(Status
))
370 PrintTextXY(6, 15, "GetSourcePath() failed (Status 0x%08lx)", Status
);
374 PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
375 PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
379 /* Load txtsetup.sif from install media. */
380 wcscpy(FileNameBuffer
, SourceRootPath
.Buffer
);
381 wcscat(FileNameBuffer
, L
"\\install\\txtsetup.sif");
382 RtlInitUnicodeString(&FileName
,
386 Status
= IniCacheLoad(&IniCache
,
388 if (!NT_SUCCESS(Status
))
390 PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
391 "ENTER = Reboot computer");
397 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
404 /* Open 'Version' section */
405 Section
= IniCacheGetSection(IniCache
,
409 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
410 "ENTER = Reboot computer");
416 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
424 /* Get pointer 'Signature' key */
425 Status
= IniCacheGetKey(Section
,
428 if (!NT_SUCCESS(Status
))
430 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
431 "ENTER = Reboot computer");
437 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
444 /* Check 'Signature' string */
445 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
447 PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
448 "ENTER = Reboot computer");
454 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
462 PopupError("This is a test error.", "ENTER = Reboot computer");
464 SetStatusText(" ENTER = Continue");
470 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
485 RepairIntroPage(PINPUT_RECORD Ir
)
487 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
488 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
490 SetTextXY(6, 12, "The repair functions are not implemented yet.");
492 SetTextXY(8, 15, "\xf9 Press ESC to return to the main page.");
494 SetTextXY(8, 17, "\xf9 Press ENTER to reboot your computer.");
496 SetStatusText(" ESC = Main page ENTER = Reboot");
502 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
506 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
507 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
513 return(REPAIR_INTRO_PAGE
);
520 * TRUE: setup/repair completed successfully
521 * FALSE: setup/repair terminated by user
524 IntroPage(PINPUT_RECORD Ir
)
526 SetHighlightedTextXY(6, 8, "Welcome to ReactOS Setup");
528 SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your");
529 SetTextXY(6, 12, "computer and prepares the second part of the setup.");
531 SetTextXY(8, 15, "\xf9 Press ENTER to install ReactOS.");
533 SetTextXY(8, 17, "\xf9 Press E to start the emergency repair console.");
535 SetTextXY(8, 19, "\xf9 Press R to repair ReactOS.");
537 SetTextXY(8, 21, "\xf9 Press F3 to quit without installing ReactOS.");
540 SetStatusText(" ENTER = Continue F3 = Quit");
546 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
547 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
549 if (ConfirmQuit(Ir
) == TRUE
)
553 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
555 return(INSTALL_INTRO_PAGE
);
558 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'E') /* E */
560 return(RepairConsole());
563 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
565 return(REPAIR_INTRO_PAGE
);
574 InstallIntroPage(PINPUT_RECORD Ir
)
576 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
577 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
579 SetTextXY(6, 12, "The following functions are missing:");
580 SetTextXY(8, 13, "- Creating and deleting harddisk partitions.");
581 SetTextXY(8, 14, "- Formatting partitions.");
582 SetTextXY(8, 15, "- Support for non-FAT file systems.");
583 SetTextXY(8, 16, "- Checking file systems.");
584 SetTextXY(8, 17, "- Installing the bootloader.");
588 SetTextXY(8, 21, "\xf9 Press ENTER to install ReactOS.");
590 SetTextXY(8, 23, "\xf9 Press F3 to quit without installing ReactOS.");
593 SetStatusText(" ENTER = Continue F3 = Quit");
599 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
600 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
602 if (ConfirmQuit(Ir
) == TRUE
)
606 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
608 return(SELECT_PARTITION_PAGE
);
612 return(INSTALL_INTRO_PAGE
);
617 SelectPartitionPage(PINPUT_RECORD Ir
)
623 SetTextXY(6, 8, "The list below shows existing partitions and unused disk");
624 SetTextXY(6, 9, "space for new partitions.");
626 SetTextXY(8, 11, "\xf9 Press UP or DOWN to select a list entry.");
627 SetTextXY(8, 13, "\xf9 Press ENTER to install ReactOS onto the selected partition.");
628 SetTextXY(8, 15, "\xf9 Press C to create a new partition.");
629 SetTextXY(8, 17, "\xf9 Press D to delete an existing partition.");
631 SetStatusText(" Please wait...");
633 GetScreenSize(&xScreen
, &yScreen
);
635 PartList
= CreatePartitionList(2, 19, xScreen
- 3, yScreen
- 3);
636 if (PartList
== NULL
)
638 /* FIXME: show an error dialog */
642 SetStatusText(" ENTER = Continue F3 = Quit");
648 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
649 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
651 if (ConfirmQuit(Ir
) == TRUE
)
653 DestroyPartitionList(PartList
);
658 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
659 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
661 ScrollDownPartitionList(PartList
);
663 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
664 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
666 ScrollUpPartitionList(PartList
);
668 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
670 PartDataValid
= GetPartitionData(PartList
, &PartData
);
671 DestroyPartitionList(PartList
);
672 return(SELECT_FILE_SYSTEM_PAGE
);
675 /* FIXME: Update status text */
679 DestroyPartitionList(PartList
);
681 return(SELECT_PARTITION_PAGE
);
686 SelectFileSystemPage(PINPUT_RECORD Ir
)
694 if (PartDataValid
== FALSE
)
696 /* FIXME: show an error dialog */
700 /* adjust disk size */
701 if (PartData
.DiskSize
>= 0x280000000ULL
) /* 10 GB */
703 DiskSize
= (PartData
.DiskSize
+ (1 << 29)) >> 30;
708 DiskSize
= (PartData
.DiskSize
+ (1 << 19)) >> 20;
712 /* adjust partition size */
713 if (PartData
.PartSize
>= 0x280000000ULL
) /* 10 GB */
715 PartSize
= (PartData
.PartSize
+ (1 << 29)) >> 30;
720 PartSize
= (PartData
.PartSize
+ (1 << 19)) >> 20;
724 /* adjust partition type */
725 if ((PartData
.PartType
== PARTITION_FAT_12
) ||
726 (PartData
.PartType
== PARTITION_FAT_16
) ||
727 (PartData
.PartType
== PARTITION_HUGE
) ||
728 (PartData
.PartType
== PARTITION_XINT13
))
732 else if ((PartData
.PartType
== PARTITION_FAT32
) ||
733 (PartData
.PartType
== PARTITION_FAT32_XINT13
))
737 else if (PartData
.PartType
== PARTITION_IFS
)
739 PartType
= "NTFS"; /* FIXME: Not quite correct! */
743 PartType
= "Unknown";
746 SetTextXY(6, 8, "ReactOS will be installed");
748 PrintTextXY(8, 9, "on Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu.",
756 PrintTextXY(8, 10, "on Partition %lu (%I64u %s) %s",
762 SetTextXY(6, 13, "Select a file system for the partition from the list below.");
764 SetTextXY(8, 15, "\xf9 Press UP or DOWN to select a file system.");
765 SetTextXY(8, 17, "\xf9 Press ENTER to format the partition.");
766 SetTextXY(8, 19, "\xf9 Press ESC to select another partition.");
768 /* FIXME: use a real list later */
769 SetInvertedTextXY(6, 22, " Keep current file system (no changes) ");
772 SetStatusText(" ENTER = Continue ESC = Cancel F3 = Quit");
778 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
779 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
781 if (ConfirmQuit(Ir
) == TRUE
)
785 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
786 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
788 return(SELECT_PARTITION_PAGE
);
790 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
792 return(CHECK_FILE_SYSTEM_PAGE
);
796 return(SELECT_FILE_SYSTEM_PAGE
);
801 CheckFileSystemPage(PINPUT_RECORD Ir
)
803 SetTextXY(6, 8, "Check file system");
805 SetTextXY(6, 10, "At present, ReactOS can not check file systems.");
807 SetStatusText(" Please wait ...");
810 SetStatusText(" ENTER = Continue F3 = Quit");
816 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
817 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
819 if (ConfirmQuit(Ir
) == TRUE
)
823 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
825 return(INSTALL_DIRECTORY_PAGE
);
829 return(CHECK_FILE_SYSTEM_PAGE
);
834 InstallDirectoryPage(PINPUT_RECORD Ir
)
838 SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
839 SetTextXY(6, 9, "directory where you want ReactOS to be installed:");
841 wcscpy(InstallDir
, L
"\\reactos");
842 Length
= wcslen(InstallDir
);
844 SetInputTextXY(8, 11, 51, InstallDir
);
846 SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete");
847 SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to");
848 SetTextXY(6, 16, "be installed.");
851 SetStatusText(" ENTER = Continue F3 = Quit");
857 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
858 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
860 if (ConfirmQuit(Ir
) == TRUE
)
864 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
867 return(PREPARE_COPY_PAGE
);
869 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
874 InstallDir
[Length
] = 0;
875 SetInputTextXY(8, 11, 51, InstallDir
);
878 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
882 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
884 InstallDir
[Length
] = 0;
885 SetInputTextXY(8, 11, 51, InstallDir
);
890 return(INSTALL_DIRECTORY_PAGE
);
895 PrepareCopyPage(PINPUT_RECORD Ir
)
897 WCHAR PathBuffer
[MAX_PATH
];
898 PINICACHESECTION Section
;
899 PINICACHEITERATOR Iterator
;
906 SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. ");
909 SetTextXY(8, 12, "Build file copy list");
911 SetTextXY(8, 14, "Create directories");
913 SetStatusText(" Please wait...");
916 /* build the file copy list */
918 SetInvertedTextXY(8, 12, "Build file copy list");
920 /* FIXME: build that list */
922 SetTextXY(8, 12, "Build file copy list");
923 SetHighlightedTextXY(50, 12, "Done");
928 /* create directories */
929 SetInvertedTextXY(8, 14, "Create directories");
932 /* Open 'Directories' section */
933 Section
= IniCacheGetSection(IniCache
,
937 PopupError("Setup failed to find the 'Directories' section\n"
938 "in TXTSETUP.SIF.\n",
939 "ENTER = Reboot computer");
945 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
954 * Install directories like '\reactos\test' are not handled yet.
957 /* Build full install directory name */
959 L
"\\Device\\Harddisk%lu\\Partition%lu",
961 PartData
.PartNumber
);
962 if (InstallDir
[0] != L
'\\')
963 wcscat(PathBuffer
, L
"\\");
964 wcscat(PathBuffer
, InstallDir
);
966 /* Remove trailing backslash */
967 Length
= wcslen(PathBuffer
);
968 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
969 PathBuffer
[Length
- 1] = 0;
971 /* Create the install directory */
972 Status
= CreateDirectory(PathBuffer
);
973 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
975 DPRINT1("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
977 PopupError("Setup could not create the install directory.",
978 "ENTER = Reboot computer");
984 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
992 /* Enumerate the directory values and create the subdirectories */
993 Iterator
= IniCacheFindFirstValue(Section
,
996 if (Iterator
!= NULL
)
1000 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
1002 DPRINT("Absolute Path: '%S'\n", KeyValue
);
1004 swprintf(PathBuffer
,
1005 L
"\\Device\\Harddisk%lu\\Partition%lu",
1006 PartData
.DiskNumber
,
1007 PartData
.PartNumber
);
1008 wcscat(PathBuffer
, KeyValue
);
1010 DPRINT("FullPath: '%S'\n", PathBuffer
);
1012 else if (KeyValue
[0] != L
'\\')
1014 DPRINT("RelativePath: '%S'\n", KeyValue
);
1015 swprintf(PathBuffer
,
1016 L
"\\Device\\Harddisk%lu\\Partition%lu",
1017 PartData
.DiskNumber
,
1018 PartData
.PartNumber
);
1020 if (InstallDir
[0] != L
'\\')
1021 wcscat(PathBuffer
, L
"\\");
1022 wcscat(PathBuffer
, InstallDir
);
1023 wcscat(PathBuffer
, L
"\\");
1024 wcscat(PathBuffer
, KeyValue
);
1026 DPRINT("FullPath: '%S'\n", PathBuffer
);
1028 Status
= CreateDirectory(PathBuffer
);
1029 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
1031 DPRINT1("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
1033 PopupError("Setup could not create install directories.",
1034 "ENTER = Reboot computer");
1040 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1042 IniCacheFindClose(Iterator
);
1049 while (IniCacheFindNextValue(Iterator
, &KeyName
, &KeyValue
));
1051 IniCacheFindClose(Iterator
);
1055 SetTextXY(8, 14, "Create directories");
1056 SetHighlightedTextXY(50, 14, "Done");
1059 SetStatusText(" ENTER = Continue F3 = Quit");
1065 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1066 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1068 if (ConfirmQuit(Ir
) == TRUE
)
1072 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1074 return(FILE_COPY_PAGE
);
1078 return(PREPARE_COPY_PAGE
);
1083 FileCopyPage(PINPUT_RECORD Ir
)
1086 SetTextXY(6, 8, "Copying files");
1089 SetStatusText(" ENTER = Continue F3 = Quit");
1095 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1096 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1098 if (ConfirmQuit(Ir
) == TRUE
)
1102 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1104 return(INIT_SYSTEM_PAGE
);
1108 return(FILE_COPY_PAGE
);
1114 UpdateSystemRootLink(VOID
)
1116 OBJECT_ATTRIBUTES ObjectAttributes
;
1117 UNICODE_STRING LinkName
;
1118 UNICODE_STRING TargetName
;
1119 CHAR TargetBuffer
[MAX_PATH
];
1123 RtlInitUnicodeString(&LinkName
,
1126 InitializeObjectAttributes(&ObjectAttributes
,
1132 Status
= NtOpenSymbolicLinkObject(&Handle
,
1133 SYMBOLIC_LINK_ALL_ACCESS
,
1135 if (!NT_SUCCESS(Status
))
1138 Status
= NtMakeTemporaryObject(Handle
);
1140 if (!NT_SUCCESS(Status
))
1143 sprintf(TargetBuffer
,
1144 "\\Device\\Harddisk%lu\\Partition%lu",
1145 PartData
.DiskNumber
,
1146 PartData
.PartNumber
);
1147 if (InstallDir
[0] != '\\')
1148 strcat(TargetBuffer
, "\\");
1149 strcat(TargetBuffer
, InstallDir
);
1151 RtlCreateUnicodeStringFromAsciiz(&TargetName
,
1154 Status
= NtCreateSymbolicLinkObject(&Handle
,
1155 SYMBOLIC_LINK_ALL_ACCESS
,
1159 RtlFreeUnicodeString(&TargetName
);
1161 if (!NT_SUCCESS(Status
))
1166 return(STATUS_SUCCESS
);
1172 InitSystemPage(PINPUT_RECORD Ir
)
1178 SetTextXY(6, 8, "Initializing system settings");
1181 SetTextXY(6, 12, "Create registry hives");
1183 SetTextXY(6, 14, "Update registry hives");
1185 SetTextXY(6, 16, "Install/update boot manager");
1187 SetStatusText(" Please wait...");
1191 * Initialize registry
1194 /* Update 'SystemRoot' link */
1195 Status
= UpdateSystemRootLink();
1196 if (!NT_SUCCESS(Status
))
1199 PrintTextXY(6, 25, "UpdateSystemRootLink() failed (Status = 0x%08lx)", Status
);
1203 Status
= NtInitializeRegistry(TRUE
);
1204 if (!NT_SUCCESS(Status
))
1207 PrintTextXY(6, 26, "NtInitializeRegistry() failed (Status = 0x%08lx)", Status
);
1215 /* FIXME: Create key '\Registry\Machine\System\Setup' */
1217 /* FIXME: Create value 'SystemSetupInProgress' */
1221 SetStatusText(" ENTER = Continue F3 = Quit");
1227 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1228 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1230 if (ConfirmQuit(Ir
) == TRUE
)
1234 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1236 return(SUCCESS_PAGE
);
1240 return(INIT_SYSTEM_PAGE
);
1245 QuitPage(PINPUT_RECORD Ir
)
1247 SetTextXY(10, 6, "ReactOS is not completely installed");
1249 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
1250 SetTextXY(10, 9, "all CD-ROMs from CD-Drive.");
1252 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
1254 SetStatusText(" ENTER = Reboot computer");
1260 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1262 return(REBOOT_PAGE
);
1269 SuccessPage(PINPUT_RECORD Ir
)
1271 SetTextXY(10, 6, "The basic components of ReactOS have been installed successfully.");
1273 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
1274 SetTextXY(10, 9, "all CD-ROMs from CD-Drive.");
1276 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
1278 SetStatusText(" ENTER = Reboot computer");
1284 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1286 return(REBOOT_PAGE
);
1293 NtProcessStartup(PPEB Peb
)
1299 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
1301 ProcessHeap
= Peb
->ProcessHeap
;
1303 Status
= AllocConsole();
1304 if (!NT_SUCCESS(Status
))
1306 PrintString("AllocConsole() failed (Status = 0x%08lx)\n", Status
);
1308 /* Raise a hard error (crash the system/BSOD) */
1309 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
1313 PartDataValid
= FALSE
;
1316 while (Page
!= REBOOT_PAGE
)
1320 SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR
" Setup ");
1326 Page
= StartPage(&Ir
);
1331 Page
= IntroPage(&Ir
);
1335 case INSTALL_INTRO_PAGE
:
1336 Page
= InstallIntroPage(&Ir
);
1340 case OEM_DRIVER_PAGE
:
1341 Page
= OemDriverPage(&Ir
);
1346 case DEVICE_SETTINGS_PAGE
:
1349 case SELECT_PARTITION_PAGE
:
1350 Page
= SelectPartitionPage(&Ir
);
1353 case SELECT_FILE_SYSTEM_PAGE
:
1354 Page
= SelectFileSystemPage(&Ir
);
1357 case CHECK_FILE_SYSTEM_PAGE
:
1358 Page
= CheckFileSystemPage(&Ir
);
1361 case INSTALL_DIRECTORY_PAGE
:
1362 Page
= InstallDirectoryPage(&Ir
);
1365 case PREPARE_COPY_PAGE
:
1366 Page
= PrepareCopyPage(&Ir
);
1369 case FILE_COPY_PAGE
:
1370 Page
= FileCopyPage(&Ir
);
1373 case INIT_SYSTEM_PAGE
:
1374 Page
= InitSystemPage(&Ir
);
1379 case REPAIR_INTRO_PAGE
:
1380 Page
= RepairIntroPage(&Ir
);
1385 Page
= SuccessPage(&Ir
);
1389 Page
= QuitPage(&Ir
);
1396 NtShutdownSystem(ShutdownReboot
);