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>
38 #include "filequeue.h"
46 #define INSTALL_INTRO_PAGE 2
48 #define SELECT_PARTITION_PAGE 4
49 #define SELECT_FILE_SYSTEM_PAGE 5
50 #define CHECK_FILE_SYSTEM_PAGE 6
51 #define PREPARE_COPY_PAGE 7
52 #define INSTALL_DIRECTORY_PAGE 8
53 #define FILE_COPY_PAGE 9
54 #define REGISTRY_PAGE 10
55 #define BOOT_LOADER_PAGE 11
57 #define REPAIR_INTRO_PAGE 20
59 #define SUCCESS_PAGE 100
61 #define REBOOT_PAGE 102
64 typedef struct _COPYCONTEXT
66 ULONG TotalOperations
;
67 ULONG CompletedOperations
;
68 PPROGRESS ProgressBar
;
69 } COPYCONTEXT
, *PCOPYCONTEXT
;
72 /* GLOBALS ******************************************************************/
76 BOOLEAN PartDataValid
;
79 BOOLEAN ActivePartitionValid
;
80 PARTDATA ActivePartition
;
82 UNICODE_STRING SourcePath
;
83 UNICODE_STRING SourceRootPath
;
85 UNICODE_STRING InstallPath
;
86 UNICODE_STRING DestinationPath
;
87 UNICODE_STRING DestinationArcPath
;
88 UNICODE_STRING DestinationRootPath
;
90 UNICODE_STRING SystemRootPath
; /* Path to the active partition */
94 HSPFILEQ SetupFileQueue
= NULL
;
97 /* FUNCTIONS ****************************************************************/
100 PrintString(char* fmt
,...)
104 UNICODE_STRING UnicodeString
;
105 ANSI_STRING AnsiString
;
108 vsprintf(buffer
, fmt
, ap
);
111 RtlInitAnsiString(&AnsiString
, buffer
);
112 RtlAnsiStringToUnicodeString(&UnicodeString
,
115 NtDisplayString(&UnicodeString
);
116 RtlFreeUnicodeString(&UnicodeString
);
121 PopupError(PCHAR Text
,
139 /* Count text lines and longest line */
145 p
= strchr(pnext
, '\n');
148 Length
= strlen(pnext
);
153 Length
= (ULONG
)(p
- pnext
);
158 if (Length
> MaxLength
)
161 if (LastLine
== TRUE
)
167 /* Check length of status line */
170 Length
= strlen(Status
);
171 if (Length
> MaxLength
)
175 GetScreenSize(&xScreen
, &yScreen
);
177 Width
= MaxLength
+ 4;
182 yTop
= (yScreen
- Height
) / 2;
183 xLeft
= (xScreen
- Width
) / 2;
186 /* Set screen attributes */
188 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
190 FillConsoleOutputAttribute(0x74,
196 /* draw upper left corner */
199 FillConsoleOutputCharacter(0xDA, // '+',
204 /* draw upper edge */
207 FillConsoleOutputCharacter(0xC4, // '-',
212 /* draw upper right corner */
213 coPos
.X
= xLeft
+ Width
- 1;
215 FillConsoleOutputCharacter(0xBF, // '+',
220 /* Draw right edge, inner space and left edge */
221 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
224 FillConsoleOutputCharacter(0xB3, // '|',
230 FillConsoleOutputCharacter(' ',
235 coPos
.X
= xLeft
+ Width
- 1;
236 FillConsoleOutputCharacter(0xB3, // '|',
242 /* draw lower left corner */
244 coPos
.Y
= yTop
+ Height
- 1;
245 FillConsoleOutputCharacter(0xC0, // '+',
250 /* draw lower edge */
252 coPos
.Y
= yTop
+ Height
- 1;
253 FillConsoleOutputCharacter(0xC4, // '-',
258 /* draw lower right corner */
259 coPos
.X
= xLeft
+ Width
- 1;
260 coPos
.Y
= yTop
+ Height
- 1;
261 FillConsoleOutputCharacter(0xD9, // '+',
266 /* Print message text */
271 p
= strchr(pnext
, '\n');
274 Length
= strlen(pnext
);
279 Length
= (ULONG
)(p
- pnext
);
286 WriteConsoleOutputCharacters(pnext
,
291 if (LastLine
== TRUE
)
298 /* Print separator line and status text */
301 coPos
.Y
= yTop
+ Height
- 3;
303 FillConsoleOutputCharacter(0xC3, // '+',
309 FillConsoleOutputCharacter(0xC4, // '-',
314 coPos
.X
= xLeft
+ Width
- 1;
315 FillConsoleOutputCharacter(0xB4, // '+',
322 WriteConsoleOutputCharacters(Status
,
323 min(strlen(Status
), Width
- 4),
333 * FALSE: Don't quit setup.
336 ConfirmQuit(PINPUT_RECORD Ir
)
340 PopupError("ReactOS is not completely installed on your\n"
341 "computer. If you quit Setup now, you will need to\n"
342 "run Setup again to install ReactOS.\n"
344 " * Press ENTER to continue Setup.\n"
345 " * Press F3 to quit Setup.",
346 "F3= Quit ENTER = Continue");
352 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
353 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
358 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
373 * Number of the next page.
376 StartPage(PINPUT_RECORD Ir
)
379 WCHAR FileNameBuffer
[MAX_PATH
];
380 UNICODE_STRING FileName
;
387 SetStatusText(" Please wait...");
389 Status
= GetSourcePaths(&SourcePath
,
391 if (!NT_SUCCESS(Status
))
393 PrintTextXY(6, 15, "GetSourcePath() failed (Status 0x%08lx)", Status
);
397 PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
398 PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
402 /* Load txtsetup.sif from install media. */
403 wcscpy(FileNameBuffer
, SourceRootPath
.Buffer
);
404 wcscat(FileNameBuffer
, L
"\\install\\txtsetup.sif");
405 RtlInitUnicodeString(&FileName
,
408 Status
= InfOpenFile(&SetupInf
,
411 if (!NT_SUCCESS(Status
))
413 PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
414 "ENTER = Reboot computer");
420 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
427 /* Open 'Version' section */
428 if (!InfFindFirstLine (SetupInf
, L
"Version", L
"Signature", &Context
))
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 if (!InfGetData (&Context
, NULL
, &Value
))
448 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
449 "ENTER = Reboot computer");
455 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
462 /* Check 'Signature' string */
463 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
465 PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
466 "ENTER = Reboot computer");
472 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, "\xfa Press ESC to return to the main page.");
494 SetTextXY(8, 17, "\xfa 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, "\xfa Press ENTER to install ReactOS.");
533 SetTextXY(8, 17, "\xfa Press E to start the emergency repair console.");
535 SetTextXY(8, 19, "\xfa Press R to repair ReactOS.");
537 SetTextXY(8, 21, "\xfa 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.");
587 SetTextXY(8, 21, "\xfa Press ENTER to install ReactOS.");
589 SetTextXY(8, 23, "\xfa Press F3 to quit without installing ReactOS.");
592 SetStatusText(" ENTER = Continue F3 = Quit");
598 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
599 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
601 if (ConfirmQuit(Ir
) == TRUE
)
605 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
607 return(SELECT_PARTITION_PAGE
);
611 return(INSTALL_INTRO_PAGE
);
616 SelectPartitionPage(PINPUT_RECORD Ir
)
618 WCHAR PathBuffer
[MAX_PATH
];
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, "\xfa Press UP or DOWN to select a list entry.");
627 SetTextXY(8, 13, "\xfa Press ENTER to install ReactOS onto the selected partition.");
628 SetTextXY(8, 15, "\xfa Press C to create a new partition.");
629 SetTextXY(8, 17, "\xfa Press D to delete an existing partition.");
631 SetStatusText(" Please wait...");
633 RtlFreeUnicodeString(&DestinationPath
);
634 RtlFreeUnicodeString(&DestinationRootPath
);
636 GetScreenSize(&xScreen
, &yScreen
);
638 PartList
= CreatePartitionList(2, 19, xScreen
- 3, yScreen
- 3);
639 if (PartList
== NULL
)
641 /* FIXME: show an error dialog */
645 SetStatusText(" ENTER = Continue F3 = Quit");
651 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
652 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
654 if (ConfirmQuit(Ir
) == TRUE
)
656 DestroyPartitionList(PartList
);
661 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
662 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
664 ScrollDownPartitionList(PartList
);
666 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
667 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
669 ScrollUpPartitionList(PartList
);
671 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
673 PartDataValid
= GetSelectedPartition(PartList
,
675 ActivePartitionValid
= GetActiveBootPartition(PartList
,
677 DestroyPartitionList(PartList
);
679 RtlFreeUnicodeString(&DestinationRootPath
);
681 L
"\\Device\\Harddisk%lu\\Partition%lu",
683 PartData
.PartNumber
);
684 RtlCreateUnicodeString(&DestinationRootPath
,
687 RtlFreeUnicodeString(&SystemRootPath
);
689 L
"\\Device\\Harddisk%lu\\Partition%lu",
690 ActivePartition
.DiskNumber
,
691 ActivePartition
.PartNumber
);
692 RtlCreateUnicodeString(&SystemRootPath
,
695 return(SELECT_FILE_SYSTEM_PAGE
);
698 /* FIXME: Update status text */
702 DestroyPartitionList(PartList
);
704 return(SELECT_PARTITION_PAGE
);
709 SelectFileSystemPage(PINPUT_RECORD Ir
)
717 if (PartDataValid
== FALSE
)
719 /* FIXME: show an error dialog */
723 /* adjust disk size */
724 if (PartData
.DiskSize
>= 0x280000000ULL
) /* 10 GB */
726 DiskSize
= (PartData
.DiskSize
+ (1 << 29)) >> 30;
731 DiskSize
= (PartData
.DiskSize
+ (1 << 19)) >> 20;
735 /* adjust partition size */
736 if (PartData
.PartSize
>= 0x280000000ULL
) /* 10 GB */
738 PartSize
= (PartData
.PartSize
+ (1 << 29)) >> 30;
743 PartSize
= (PartData
.PartSize
+ (1 << 19)) >> 20;
747 /* adjust partition type */
748 if ((PartData
.PartType
== PARTITION_FAT_12
) ||
749 (PartData
.PartType
== PARTITION_FAT_16
) ||
750 (PartData
.PartType
== PARTITION_HUGE
) ||
751 (PartData
.PartType
== PARTITION_XINT13
))
755 else if ((PartData
.PartType
== PARTITION_FAT32
) ||
756 (PartData
.PartType
== PARTITION_FAT32_XINT13
))
760 else if (PartData
.PartType
== PARTITION_IFS
)
762 PartType
= "NTFS"; /* FIXME: Not quite correct! */
766 PartType
= "Unknown";
769 SetTextXY(6, 8, "Setup will install ReactOS on");
771 PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
777 PrintTextXY(8, 12, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
784 &PartData
.DriverName
);
787 SetTextXY(6, 17, "Select a file system for the partition from the list below.");
789 SetTextXY(8, 19, "\xfa Press UP or DOWN to select a file system.");
790 SetTextXY(8, 21, "\xfa Press ENTER to format the partition.");
791 SetTextXY(8, 23, "\xfa Press ESC to select another partition.");
793 /* FIXME: use a real list later */
794 SetInvertedTextXY(6, 26, " Keep current file system (no changes) ");
797 SetStatusText(" ENTER = Continue ESC = Cancel F3 = Quit");
803 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
804 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
806 if (ConfirmQuit(Ir
) == TRUE
)
810 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
811 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
813 return(SELECT_PARTITION_PAGE
);
815 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
817 return(CHECK_FILE_SYSTEM_PAGE
);
821 return(SELECT_FILE_SYSTEM_PAGE
);
826 CheckFileSystemPage(PINPUT_RECORD Ir
)
828 SetTextXY(6, 8, "Check file system");
830 SetTextXY(6, 10, "At present, ReactOS can not check file systems.");
832 SetStatusText(" Please wait ...");
835 SetStatusText(" ENTER = Continue F3 = Quit");
841 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
842 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
844 if (ConfirmQuit(Ir
) == TRUE
)
848 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
850 return(INSTALL_DIRECTORY_PAGE
);
854 return(CHECK_FILE_SYSTEM_PAGE
);
859 InstallDirectoryPage(PINPUT_RECORD Ir
)
861 WCHAR PathBuffer
[MAX_PATH
];
862 WCHAR InstallDir
[51];
868 /* Search for 'DefaultPath' in the 'SetupData' section */
869 if (!InfFindFirstLine (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
871 PopupError("Setup failed to find the 'SetupData' section\n"
872 "in TXTSETUP.SIF.\n",
873 "ENTER = Reboot computer");
879 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
886 /* Read the 'DefaultPath' data */
887 if (InfGetData (&Context
, NULL
, &DefaultPath
))
889 wcscpy(InstallDir
, DefaultPath
);
893 wcscpy(InstallDir
, L
"\\ReactOS");
895 Length
= wcslen(InstallDir
);
897 SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
898 SetTextXY(6, 9, "directory where you want ReactOS to be installed:");
900 SetInputTextXY(8, 11, 51, InstallDir
);
902 SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete");
903 SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to");
904 SetTextXY(6, 16, "be installed.");
906 SetStatusText(" ENTER = Continue F3 = Quit");
912 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
913 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
915 if (ConfirmQuit(Ir
) == TRUE
)
919 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
921 /* Create 'InstallPath' string */
922 RtlFreeUnicodeString(&InstallPath
);
923 RtlCreateUnicodeString(&InstallPath
,
926 /* Create 'DestinationPath' string */
927 RtlFreeUnicodeString(&DestinationPath
);
929 DestinationRootPath
.Buffer
);
930 if (InstallDir
[0] != L
'\\')
933 wcscat(PathBuffer
, InstallDir
);
934 RtlCreateUnicodeString(&DestinationPath
,
937 /* Create 'DestinationArcPath' */
938 RtlFreeUnicodeString(&DestinationArcPath
);
940 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
942 PartData
.PartNumber
);
943 if (InstallDir
[0] != L
'\\')
946 wcscat(PathBuffer
, InstallDir
);
947 RtlCreateUnicodeString(&DestinationArcPath
,
950 return(PREPARE_COPY_PAGE
);
952 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
957 InstallDir
[Length
] = 0;
958 SetInputTextXY(8, 11, 51, InstallDir
);
961 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
965 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
967 InstallDir
[Length
] = 0;
968 SetInputTextXY(8, 11, 51, InstallDir
);
973 return(INSTALL_DIRECTORY_PAGE
);
978 PrepareCopyPage(PINPUT_RECORD Ir
)
980 WCHAR PathBuffer
[MAX_PATH
];
981 INFCONTEXT FilesContext
;
982 INFCONTEXT DirContext
;
993 SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. ");
996 // SetTextXY(8, 12, "Build file copy list");
998 // SetTextXY(8, 14, "Create directories");
1000 // SetStatusText(" Please wait...");
1004 * Build the file copy list
1006 SetStatusText(" Building the file copy list...");
1007 // SetInvertedTextXY(8, 12, "Build file copy list");
1011 /* Search for the 'SourceFiles' section */
1012 if (!InfFindFirstLine (SetupInf
, L
"SourceFiles", NULL
, &FilesContext
))
1014 PopupError("Setup failed to find the 'SourceFiles' section\n"
1015 "in TXTSETUP.SIF.\n",
1016 "ENTER = Reboot computer");
1022 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1030 /* Create the file queue */
1031 SetupFileQueue
= SetupOpenFileQueue();
1032 if (SetupFileQueue
== NULL
)
1034 PopupError("Setup failed to open the copy file queue.\n",
1035 "ENTER = Reboot computer");
1041 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1049 * Enumerate the files in the 'SourceFiles' section
1050 * and add them to the file queue.
1054 if (!InfGetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
1057 DPRINT1("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
1059 /* Lookup target directory */
1060 if (!InfFindFirstLine (SetupInf
, L
"Directories", FileKeyValue
, &DirContext
))
1062 /* FIXME: Handle error! */
1063 DPRINT1("InfFindFirstLine() failed\n");
1067 if (!InfGetData (&DirContext
, NULL
, &DirKeyValue
))
1069 /* FIXME: Handle error! */
1070 DPRINT1("InfGetData() failed\n");
1074 if (!SetupQueueCopy(SetupFileQueue
,
1075 SourceRootPath
.Buffer
,
1081 /* FIXME: Handle error! */
1082 DPRINT1("SetupQueueCopy() failed\n");
1085 while (InfFindNextLine(&FilesContext
, &FilesContext
));
1088 /* Create directories */
1089 SetStatusText(" Creating directories...");
1093 * Install directories like '\reactos\test' are not handled yet.
1096 /* Get destination path */
1097 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
1099 /* Remove trailing backslash */
1100 Length
= wcslen(PathBuffer
);
1101 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
1103 PathBuffer
[Length
- 1] = 0;
1106 /* Create the install directory */
1107 Status
= CreateDirectory(PathBuffer
);
1108 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
1110 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
1111 PopupError("Setup could not create the install directory.",
1112 "ENTER = Reboot computer");
1118 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1126 /* Search for the 'Directories' section */
1127 if (!InfFindFirstLine(SetupInf
, L
"Directories", NULL
, &DirContext
))
1129 PopupError("Setup failed to find the 'Directories' section\n"
1130 "in TXTSETUP.SIF.\n",
1131 "ENTER = Reboot computer");
1137 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1144 /* Enumerate the directory values and create the subdirectories */
1147 if (!InfGetData (&DirContext
, NULL
, &KeyValue
))
1150 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
1152 DPRINT("Absolute Path: '%S'\n", KeyValue
);
1154 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
1155 wcscat(PathBuffer
, KeyValue
);
1157 DPRINT("FullPath: '%S'\n", PathBuffer
);
1159 else if (KeyValue
[0] != L
'\\')
1161 DPRINT("RelativePath: '%S'\n", KeyValue
);
1162 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
1163 wcscat(PathBuffer
, L
"\\");
1164 wcscat(PathBuffer
, KeyValue
);
1166 DPRINT("FullPath: '%S'\n", PathBuffer
);
1168 Status
= CreateDirectory(PathBuffer
);
1169 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
1171 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
1172 PopupError("Setup could not create install directories.",
1173 "ENTER = Reboot computer");
1179 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1187 while (InfFindNextLine (&DirContext
, &DirContext
));
1189 return(FILE_COPY_PAGE
);
1194 FileCopyCallback(PVOID Context
,
1199 PCOPYCONTEXT CopyContext
;
1201 CopyContext
= (PCOPYCONTEXT
)Context
;
1203 switch (Notification
)
1205 case SPFILENOTIFY_STARTSUBQUEUE
:
1206 CopyContext
->TotalOperations
= (ULONG
)Param2
;
1207 ProgressSetStepCount(CopyContext
->ProgressBar
,
1208 CopyContext
->TotalOperations
);
1211 case SPFILENOTIFY_STARTCOPY
:
1212 /* Display copy message */
1213 PrintTextXYN(6, 16, 60, "Copying file: %S", (PWSTR
)Param1
);
1215 PrintTextXYN(6, 18, 60, "File %lu of %lu",
1216 CopyContext
->CompletedOperations
+ 1,
1217 CopyContext
->TotalOperations
);
1220 case SPFILENOTIFY_ENDCOPY
:
1221 CopyContext
->CompletedOperations
++;
1222 ProgressNextStep(CopyContext
->ProgressBar
);
1231 FileCopyPage(PINPUT_RECORD Ir
)
1233 COPYCONTEXT CopyContext
;
1237 SetStatusText(" Please wait...");
1239 SetTextXY(6, 8, "Copying files");
1241 GetScreenSize(&xScreen
, &yScreen
);
1243 CopyContext
.TotalOperations
= 0;
1244 CopyContext
.CompletedOperations
= 0;
1245 CopyContext
.ProgressBar
= CreateProgressBar(6,
1250 SetupCommitFileQueue(SetupFileQueue
,
1251 DestinationRootPath
.Buffer
,
1253 (PSP_FILE_CALLBACK
)FileCopyCallback
,
1256 SetupCloseFileQueue(SetupFileQueue
);
1258 DestroyProgressBar(CopyContext
.ProgressBar
);
1260 return(REGISTRY_PAGE
);
1265 RegistryPage(PINPUT_RECORD Ir
)
1267 INFCONTEXT InfContext
;
1275 SetTextXY(6, 8, "Setup is updating the system configuration");
1277 SetStatusText(" Creating registry hives...");
1279 if (!SetInstallPathValue(&DestinationPath
))
1281 PopupError("Setup failed to set the initialize the registry.",
1282 "ENTER = Reboot computer");
1288 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1295 /* Create the default hives */
1296 Status
= NtInitializeRegistry(TRUE
);
1297 if (!NT_SUCCESS(Status
))
1299 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
1300 PopupError("Setup failed to create the registry hives.",
1301 "ENTER = Reboot computer");
1307 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1314 /* Update registry */
1315 SetStatusText(" Updating registry hives...");
1318 if (!InfFindFirstLine(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
1320 DPRINT1("InfFindFirstLine() failed\n");
1321 PopupError("Setup failed to find the registry hive inf-files.",
1322 "ENTER = Reboot computer");
1328 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1338 InfGetDataField (&InfContext
, 0, &Action
);
1339 InfGetDataField (&InfContext
, 1, &File
);
1340 InfGetDataField (&InfContext
, 2, &Section
);
1342 DPRINT1("Action: %S File: %S Section %S\n", Action
, File
, Section
);
1345 while (InfFindNextLine (&InfContext
, &InfContext
));
1349 Status
= SetupUpdateRegistry();
1350 if (!NT_SUCCESS(Status
))
1352 DPRINT1("SetupUpdateRegistry() failed (Status %lx)\n", Status
);
1353 PopupError("Setup failed to update the registry.",
1354 "ENTER = Reboot computer");
1360 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1367 return(BOOT_LOADER_PAGE
);
1372 BootLoaderPage(PINPUT_RECORD Ir
)
1374 WCHAR SrcPath
[MAX_PATH
];
1375 WCHAR DstPath
[MAX_PATH
];
1377 PINICACHESECTION IniSection
;
1380 SetTextXY(6, 8, "Installing the boot loader");
1382 SetStatusText(" Please wait...");
1384 if (ActivePartitionValid
== FALSE
)
1386 DPRINT1("Error: no active partition found\n");
1387 PopupError("Setup could not find an active partiton\n",
1388 "ENTER = Reboot computer");
1394 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1401 if (ActivePartition
.PartType
== PARTITION_ENTRY_UNUSED
)
1403 DPRINT1("Error: active partition invalid (unused)\n");
1404 PopupError("The active partition is unused (invalid).\n",
1405 "ENTER = Reboot computer");
1411 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1418 if (ActivePartition
.PartType
== 0x0A)
1420 /* OS/2 boot manager partition */
1421 DPRINT1("Found OS/2 boot manager partition\n");
1422 PopupError("Setup found an OS/2 boot manager partiton.\n"
1423 "The OS/2 boot manager is not supported yet!",
1424 "ENTER = Reboot computer");
1430 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1436 else if (ActivePartition
.PartType
== 0x83)
1438 /* Linux ext2 partition */
1439 DPRINT1("Found Linux ext2 partition\n");
1440 PopupError("Setup found a Linux ext2 partiton.\n"
1441 "Linux ext2 partitions are not supported yet!",
1442 "ENTER = Reboot computer");
1448 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1454 else if (ActivePartition
.PartType
== PARTITION_IFS
)
1456 /* NTFS partition */
1457 DPRINT1("Found NTFS partition\n");
1458 PopupError("Setup found an NTFS partiton.\n"
1459 "NTFS partitions are not supported yet!",
1460 "ENTER = Reboot computer");
1466 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1472 else if ((ActivePartition
.PartType
== PARTITION_FAT_12
) ||
1473 (ActivePartition
.PartType
== PARTITION_FAT_16
) ||
1474 (ActivePartition
.PartType
== PARTITION_HUGE
) ||
1475 (ActivePartition
.PartType
== PARTITION_XINT13
) ||
1476 (ActivePartition
.PartType
== PARTITION_FAT32
) ||
1477 (ActivePartition
.PartType
== PARTITION_FAT32_XINT13
))
1479 /* FAT or FAT32 partition */
1480 DPRINT1("System path: '%wZ'\n", &SystemRootPath
);
1482 if (DoesFileExist(SystemRootPath
.Buffer
, L
"ntldr") == TRUE
||
1483 DoesFileExist(SystemRootPath
.Buffer
, L
"boot.ini") == TRUE
)
1485 /* Search root directory for 'ntldr' and 'boot.ini'. */
1486 DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
1488 /* Copy FreeLoader to the boot partition */
1489 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1490 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
1491 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1492 wcscat(DstPath
, L
"\\freeldr.sys");
1494 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
1495 Status
= SetupCopyFile(SrcPath
, DstPath
);
1496 if (!NT_SUCCESS(Status
))
1498 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
1499 PopupError("Setup failed to copy 'freeldr.sys'.",
1500 "ENTER = Reboot computer");
1506 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1513 /* Create or update freeldr.ini */
1514 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
1516 /* Create new 'freeldr.ini' */
1517 DPRINT1("Create new 'freeldr.ini'\n");
1518 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1519 wcscat(DstPath
, L
"\\freeldr.ini");
1521 Status
= CreateFreeLoaderIniForReactos(DstPath
,
1522 DestinationArcPath
.Buffer
);
1523 if (!NT_SUCCESS(Status
))
1525 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
1526 PopupError("Setup failed to create 'freeldr.ini'.",
1527 "ENTER = Reboot computer");
1533 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1540 /* Install new bootcode */
1541 if ((ActivePartition
.PartType
== PARTITION_FAT32
) ||
1542 (ActivePartition
.PartType
== PARTITION_FAT32_XINT13
))
1544 /* Install FAT32 bootcode */
1545 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1546 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
1547 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1548 wcscat(DstPath
, L
"\\bootsect.ros");
1550 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, DstPath
);
1551 Status
= InstallFat32BootCodeToFile(SrcPath
,
1553 SystemRootPath
.Buffer
);
1554 if (!NT_SUCCESS(Status
))
1556 DPRINT1("InstallFat32BootCodeToFile() failed (Status %lx)\n", Status
);
1557 PopupError("Setup failed to install the FAT32 bootcode.",
1558 "ENTER = Reboot computer");
1564 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1573 /* Install FAT16 bootcode */
1574 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1575 wcscat(SrcPath
, L
"\\loader\\fat.bin");
1576 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1577 wcscat(DstPath
, L
"\\bootsect.ros");
1579 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, DstPath
);
1580 Status
= InstallFat16BootCodeToFile(SrcPath
,
1582 SystemRootPath
.Buffer
);
1583 if (!NT_SUCCESS(Status
))
1585 DPRINT1("InstallFat16BootCodeToFile() failed (Status %lx)\n", Status
);
1586 PopupError("Setup failed to install the FAT bootcode.",
1587 "ENTER = Reboot computer");
1593 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1601 /* Update 'boot.ini' */
1602 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1603 wcscat(DstPath
, L
"\\boot.ini");
1605 DPRINT1("Update 'boot.ini': %S\n", DstPath
);
1606 Status
= UpdateBootIni(DstPath
,
1607 L
"C:\\bootsect.ros",
1609 if (!NT_SUCCESS(Status
))
1611 DPRINT1("UpdateBootIni() failed (Status %lx)\n", Status
);
1612 PopupError("Setup failed to update \'boot.ini\'.",
1613 "ENTER = Reboot computer");
1619 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1628 /* Update existing 'freeldr.ini' */
1629 DPRINT1("Update existing 'freeldr.ini'\n");
1630 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1631 wcscat(DstPath
, L
"\\freeldr.ini");
1633 Status
= UpdateFreeLoaderIni(DstPath
,
1634 DestinationArcPath
.Buffer
);
1635 if (!NT_SUCCESS(Status
))
1637 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
1638 PopupError("Setup failed to update 'freeldr.ini'.",
1639 "ENTER = Reboot computer");
1645 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1653 else if (DoesFileExist(SystemRootPath
.Buffer
, L
"io.sys") == TRUE
||
1654 DoesFileExist(SystemRootPath
.Buffer
, L
"msdos.sys") == TRUE
)
1656 /* Search for root directory for 'io.sys' and 'msdos.sys'. */
1657 DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
1659 /* Copy FreeLoader to the boot partition */
1660 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1661 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
1662 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1663 wcscat(DstPath
, L
"\\freeldr.sys");
1665 DPRINT("Copy: %S ==> %S\n", SrcPath
, DstPath
);
1666 Status
= SetupCopyFile(SrcPath
, DstPath
);
1667 if (!NT_SUCCESS(Status
))
1669 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
1670 PopupError("Setup failed to copy 'freeldr.sys'.",
1671 "ENTER = Reboot computer");
1677 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1684 /* Create or update 'freeldr.ini' */
1685 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
1687 /* Create new 'freeldr.ini' */
1688 DPRINT1("Create new 'freeldr.ini'\n");
1689 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1690 wcscat(DstPath
, L
"\\freeldr.ini");
1692 Status
= CreateFreeLoaderIniForDos(DstPath
,
1693 DestinationArcPath
.Buffer
);
1694 if (!NT_SUCCESS(Status
))
1696 DPRINT1("CreateFreeLoaderIniForDos() failed (Status %lx)\n", Status
);
1697 PopupError("Setup failed to create 'freeldr.ini'.",
1698 "ENTER = Reboot computer");
1704 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1711 /* Save current bootsector as 'BOOTSECT.DOS' */
1712 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
1713 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1714 wcscat(DstPath
, L
"\\bootsect.dos");
1716 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
1717 Status
= SaveCurrentBootSector(SrcPath
,
1719 if (!NT_SUCCESS(Status
))
1721 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
1722 PopupError("Setup failed to save the current bootsector.",
1723 "ENTER = Reboot computer");
1729 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1736 /* Install new bootsector */
1737 if ((ActivePartition
.PartType
== PARTITION_FAT32
) ||
1738 (ActivePartition
.PartType
== PARTITION_FAT32_XINT13
))
1740 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1741 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
1743 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
1744 Status
= InstallFat32BootCodeToDisk(SrcPath
,
1745 SystemRootPath
.Buffer
);
1746 if (!NT_SUCCESS(Status
))
1748 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
1749 PopupError("Setup failed to install the FAT32 bootcode.",
1750 "ENTER = Reboot computer");
1756 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1765 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1766 wcscat(SrcPath
, L
"\\loader\\fat.bin");
1768 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
1769 Status
= InstallFat16BootCodeToDisk(SrcPath
,
1770 SystemRootPath
.Buffer
);
1771 if (!NT_SUCCESS(Status
))
1773 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
1774 PopupError("Setup failed to install the FAT bootcode.",
1775 "ENTER = Reboot computer");
1781 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1791 /* Update existing 'freeldr.ini' */
1792 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1793 wcscat(DstPath
, L
"\\freeldr.ini");
1795 Status
= UpdateFreeLoaderIni(DstPath
,
1796 DestinationArcPath
.Buffer
);
1797 if (!NT_SUCCESS(Status
))
1799 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
1800 PopupError("Setup failed to update 'freeldr.ini'.",
1801 "ENTER = Reboot computer");
1807 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1817 /* No or unknown boot loader */
1818 DPRINT1("No or unknown boot loader found\n");
1820 /* Copy FreeLoader to the boot partition */
1821 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1822 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
1823 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1824 wcscat(DstPath
, L
"\\freeldr.sys");
1826 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
1827 Status
= SetupCopyFile(SrcPath
, DstPath
);
1828 if (!NT_SUCCESS(Status
))
1830 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
1831 PopupError("Setup failed to copy 'freeldr.sys'.",
1832 "ENTER = Reboot computer");
1838 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1845 /* Create or update 'freeldr.ini' */
1846 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
1848 /* Create new freeldr.ini */
1849 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1850 wcscat(DstPath
, L
"\\freeldr.ini");
1852 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
1853 Status
= CreateFreeLoaderIniForReactos(DstPath
,
1854 DestinationArcPath
.Buffer
);
1855 if (!NT_SUCCESS(Status
))
1857 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
1858 PopupError("Setup failed to create \'freeldr.ini\'.",
1859 "ENTER = Reboot computer");
1865 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1872 /* Save current bootsector as 'BOOTSECT.OLD' */
1873 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
1874 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1875 wcscat(DstPath
, L
"\\bootsect.old");
1877 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
1878 Status
= SaveCurrentBootSector(SrcPath
,
1880 if (!NT_SUCCESS(Status
))
1882 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
1883 PopupError("Setup failed save the current bootsector.",
1884 "ENTER = Reboot computer");
1890 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1897 /* Install new bootsector */
1898 if ((ActivePartition
.PartType
== PARTITION_FAT32
) ||
1899 (ActivePartition
.PartType
== PARTITION_FAT32_XINT13
))
1901 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1902 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
1904 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
1905 Status
= InstallFat32BootCodeToDisk(SrcPath
,
1906 SystemRootPath
.Buffer
);
1907 if (!NT_SUCCESS(Status
))
1909 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
1910 PopupError("Setup failed to install the FAT32 bootcode.",
1911 "ENTER = Reboot computer");
1917 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1926 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1927 wcscat(SrcPath
, L
"\\loader\\fat.bin");
1929 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
1930 Status
= InstallFat16BootCodeToDisk(SrcPath
,
1931 SystemRootPath
.Buffer
);
1932 if (!NT_SUCCESS(Status
))
1934 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
1935 PopupError("Setup failed to install the FAT bootcode.",
1936 "ENTER = Reboot computer");
1942 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1952 /* Update existing 'freeldr.ini' */
1953 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1954 wcscat(DstPath
, L
"\\freeldr.ini");
1956 Status
= UpdateFreeLoaderIni(DstPath
,
1957 DestinationArcPath
.Buffer
);
1958 if (!NT_SUCCESS(Status
))
1960 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
1961 PopupError("Setup failed to update 'freeldr.ini'.",
1962 "ENTER = Reboot computer");
1968 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1979 /* Unknown partition */
1980 DPRINT1("Unknown partition found\n");
1981 PopupError("Setup found an unknown partiton type.\n"
1982 "This partition type is not supported!",
1983 "ENTER = Reboot computer");
1989 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1996 return(SUCCESS_PAGE
);
2002 QuitPage(PINPUT_RECORD Ir
)
2004 SetTextXY(10, 6, "ReactOS is not completely installed");
2006 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2007 SetTextXY(10, 9, "all CD-ROMs from CD-Drives.");
2009 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2011 SetStatusText(" ENTER = Reboot computer");
2017 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2019 return(REBOOT_PAGE
);
2026 SuccessPage(PINPUT_RECORD Ir
)
2028 SetTextXY(10, 6, "The basic components of ReactOS have been installed successfully.");
2030 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2031 SetTextXY(10, 9, "all CD-ROMs from CD-Drive.");
2033 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2035 SetStatusText(" ENTER = Reboot computer");
2041 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2043 return(REBOOT_PAGE
);
2050 NtProcessStartup(PPEB Peb
)
2056 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
2058 ProcessHeap
= Peb
->ProcessHeap
;
2060 Status
= AllocConsole();
2061 if (!NT_SUCCESS(Status
))
2063 PrintString("AllocConsole() failed (Status = 0x%08lx)\n", Status
);
2065 /* Raise a hard error (crash the system/BSOD) */
2066 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
2070 PartDataValid
= FALSE
;
2072 /* Initialize global unicode strings */
2073 RtlInitUnicodeString(&SourcePath
, NULL
);
2074 RtlInitUnicodeString(&SourceRootPath
, NULL
);
2075 RtlInitUnicodeString(&InstallPath
, NULL
);
2076 RtlInitUnicodeString(&DestinationPath
, NULL
);
2077 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
2078 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
2079 RtlInitUnicodeString(&SystemRootPath
, NULL
);
2083 while (Page
!= REBOOT_PAGE
)
2087 SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR
" Setup ");
2093 Page
= StartPage(&Ir
);
2098 Page
= IntroPage(&Ir
);
2102 case INSTALL_INTRO_PAGE
:
2103 Page
= InstallIntroPage(&Ir
);
2107 case OEM_DRIVER_PAGE
:
2108 Page
= OemDriverPage(&Ir
);
2113 case DEVICE_SETTINGS_PAGE
:
2116 case SELECT_PARTITION_PAGE
:
2117 Page
= SelectPartitionPage(&Ir
);
2120 case SELECT_FILE_SYSTEM_PAGE
:
2121 Page
= SelectFileSystemPage(&Ir
);
2124 case CHECK_FILE_SYSTEM_PAGE
:
2125 Page
= CheckFileSystemPage(&Ir
);
2128 case INSTALL_DIRECTORY_PAGE
:
2129 Page
= InstallDirectoryPage(&Ir
);
2132 case PREPARE_COPY_PAGE
:
2133 Page
= PrepareCopyPage(&Ir
);
2136 case FILE_COPY_PAGE
:
2137 Page
= FileCopyPage(&Ir
);
2141 Page
= RegistryPage(&Ir
);
2144 case BOOT_LOADER_PAGE
:
2145 Page
= BootLoaderPage(&Ir
);
2150 case REPAIR_INTRO_PAGE
:
2151 Page
= RepairIntroPage(&Ir
);
2156 Page
= SuccessPage(&Ir
);
2160 Page
= QuitPage(&Ir
);
2167 NtShutdownSystem(ShutdownReboot
);