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)
464 if (_wcsicmp(Value
, L
"\"$ReactOS$\"") != 0)
466 PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
467 "ENTER = Reboot computer");
473 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
486 RepairIntroPage(PINPUT_RECORD Ir
)
488 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
489 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
491 SetTextXY(6, 12, "The repair functions are not implemented yet.");
493 SetTextXY(8, 15, "\xfa Press ESC to return to the main page.");
495 SetTextXY(8, 17, "\xfa Press ENTER to reboot your computer.");
497 SetStatusText(" ESC = Main page ENTER = Reboot");
503 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
507 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
508 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
514 return(REPAIR_INTRO_PAGE
);
521 * TRUE: setup/repair completed successfully
522 * FALSE: setup/repair terminated by user
525 IntroPage(PINPUT_RECORD Ir
)
527 SetHighlightedTextXY(6, 8, "Welcome to ReactOS Setup");
529 SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your");
530 SetTextXY(6, 12, "computer and prepares the second part of the setup.");
532 SetTextXY(8, 15, "\xfa Press ENTER to install ReactOS.");
534 SetTextXY(8, 17, "\xfa Press E to start the emergency repair console.");
536 SetTextXY(8, 19, "\xfa Press R to repair ReactOS.");
538 SetTextXY(8, 21, "\xfa Press F3 to quit without installing ReactOS.");
541 SetStatusText(" ENTER = Continue F3 = Quit");
547 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
548 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
550 if (ConfirmQuit(Ir
) == TRUE
)
554 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
556 return(INSTALL_INTRO_PAGE
);
559 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'E') /* E */
561 return(RepairConsole());
564 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
566 return(REPAIR_INTRO_PAGE
);
575 InstallIntroPage(PINPUT_RECORD Ir
)
577 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
578 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
580 SetTextXY(6, 12, "The following functions are missing:");
581 SetTextXY(8, 13, "- Creating and deleting harddisk partitions.");
582 SetTextXY(8, 14, "- Formatting partitions.");
583 SetTextXY(8, 15, "- Support for non-FAT file systems.");
584 SetTextXY(8, 16, "- Checking file systems.");
588 SetTextXY(8, 21, "\xfa Press ENTER to install ReactOS.");
590 SetTextXY(8, 23, "\xfa 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
)
619 WCHAR PathBuffer
[MAX_PATH
];
624 SetTextXY(6, 8, "The list below shows existing partitions and unused disk");
625 SetTextXY(6, 9, "space for new partitions.");
627 SetTextXY(8, 11, "\xfa Press UP or DOWN to select a list entry.");
628 SetTextXY(8, 13, "\xfa Press ENTER to install ReactOS onto the selected partition.");
629 SetTextXY(8, 15, "\xfa Press C to create a new partition.");
630 SetTextXY(8, 17, "\xfa Press D to delete an existing partition.");
632 SetStatusText(" Please wait...");
634 RtlFreeUnicodeString(&DestinationPath
);
635 RtlFreeUnicodeString(&DestinationRootPath
);
637 GetScreenSize(&xScreen
, &yScreen
);
639 PartList
= CreatePartitionList(2, 19, xScreen
- 3, yScreen
- 3);
640 if (PartList
== NULL
)
642 /* FIXME: show an error dialog */
646 SetStatusText(" ENTER = Continue F3 = Quit");
652 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
653 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
655 if (ConfirmQuit(Ir
) == TRUE
)
657 DestroyPartitionList(PartList
);
662 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
663 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
665 ScrollDownPartitionList(PartList
);
667 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
668 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
670 ScrollUpPartitionList(PartList
);
672 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
674 PartDataValid
= GetSelectedPartition(PartList
,
676 ActivePartitionValid
= GetActiveBootPartition(PartList
,
678 DestroyPartitionList(PartList
);
680 RtlFreeUnicodeString(&DestinationRootPath
);
682 L
"\\Device\\Harddisk%lu\\Partition%lu",
684 PartData
.PartNumber
);
685 RtlCreateUnicodeString(&DestinationRootPath
,
688 RtlFreeUnicodeString(&SystemRootPath
);
690 L
"\\Device\\Harddisk%lu\\Partition%lu",
691 ActivePartition
.DiskNumber
,
692 ActivePartition
.PartNumber
);
693 RtlCreateUnicodeString(&SystemRootPath
,
696 return(SELECT_FILE_SYSTEM_PAGE
);
699 /* FIXME: Update status text */
703 DestroyPartitionList(PartList
);
705 return(SELECT_PARTITION_PAGE
);
710 SelectFileSystemPage(PINPUT_RECORD Ir
)
718 if (PartDataValid
== FALSE
)
720 /* FIXME: show an error dialog */
724 /* adjust disk size */
725 if (PartData
.DiskSize
>= 0x280000000ULL
) /* 10 GB */
727 DiskSize
= (PartData
.DiskSize
+ (1 << 29)) >> 30;
732 DiskSize
= (PartData
.DiskSize
+ (1 << 19)) >> 20;
736 /* adjust partition size */
737 if (PartData
.PartSize
>= 0x280000000ULL
) /* 10 GB */
739 PartSize
= (PartData
.PartSize
+ (1 << 29)) >> 30;
744 PartSize
= (PartData
.PartSize
+ (1 << 19)) >> 20;
748 /* adjust partition type */
749 if ((PartData
.PartType
== PARTITION_FAT_12
) ||
750 (PartData
.PartType
== PARTITION_FAT_16
) ||
751 (PartData
.PartType
== PARTITION_HUGE
) ||
752 (PartData
.PartType
== PARTITION_XINT13
))
756 else if ((PartData
.PartType
== PARTITION_FAT32
) ||
757 (PartData
.PartType
== PARTITION_FAT32_XINT13
))
761 else if (PartData
.PartType
== PARTITION_IFS
)
763 PartType
= "NTFS"; /* FIXME: Not quite correct! */
767 PartType
= "Unknown";
770 SetTextXY(6, 8, "Setup will install ReactOS on");
772 PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
778 PrintTextXY(8, 12, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
785 &PartData
.DriverName
);
788 SetTextXY(6, 17, "Select a file system for the partition from the list below.");
790 SetTextXY(8, 19, "\xfa Press UP or DOWN to select a file system.");
791 SetTextXY(8, 21, "\xfa Press ENTER to format the partition.");
792 SetTextXY(8, 23, "\xfa Press ESC to select another partition.");
794 /* FIXME: use a real list later */
795 SetInvertedTextXY(6, 26, " Keep current file system (no changes) ");
798 SetStatusText(" ENTER = Continue ESC = Cancel F3 = Quit");
804 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
805 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
807 if (ConfirmQuit(Ir
) == TRUE
)
811 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
812 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
814 return(SELECT_PARTITION_PAGE
);
816 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
818 return(CHECK_FILE_SYSTEM_PAGE
);
822 return(SELECT_FILE_SYSTEM_PAGE
);
827 CheckFileSystemPage(PINPUT_RECORD Ir
)
829 SetTextXY(6, 8, "Check file system");
831 SetTextXY(6, 10, "At present, ReactOS can not check file systems.");
833 SetStatusText(" Please wait ...");
836 SetStatusText(" ENTER = Continue F3 = Quit");
842 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
843 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
845 if (ConfirmQuit(Ir
) == TRUE
)
849 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
851 return(INSTALL_DIRECTORY_PAGE
);
855 return(CHECK_FILE_SYSTEM_PAGE
);
860 InstallDirectoryPage(PINPUT_RECORD Ir
)
862 WCHAR PathBuffer
[MAX_PATH
];
863 WCHAR InstallDir
[51];
869 /* Search for 'DefaultPath' in the 'SetupData' section */
870 if (!InfFindFirstLine (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
872 PopupError("Setup failed to find the 'SetupData' section\n"
873 "in TXTSETUP.SIF.\n",
874 "ENTER = Reboot computer");
880 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
887 /* Read the 'DefaultPath' data */
888 if (InfGetData (&Context
, NULL
, &DefaultPath
))
890 wcscpy(InstallDir
, DefaultPath
);
894 wcscpy(InstallDir
, L
"\\ReactOS");
896 Length
= wcslen(InstallDir
);
898 SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
899 SetTextXY(6, 9, "directory where you want ReactOS to be installed:");
901 SetInputTextXY(8, 11, 51, InstallDir
);
903 SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete");
904 SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to");
905 SetTextXY(6, 16, "be installed.");
907 SetStatusText(" ENTER = Continue F3 = Quit");
913 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
914 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
916 if (ConfirmQuit(Ir
) == TRUE
)
920 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
922 /* Create 'InstallPath' string */
923 RtlFreeUnicodeString(&InstallPath
);
924 RtlCreateUnicodeString(&InstallPath
,
927 /* Create 'DestinationPath' string */
928 RtlFreeUnicodeString(&DestinationPath
);
930 DestinationRootPath
.Buffer
);
931 if (InstallDir
[0] != L
'\\')
934 wcscat(PathBuffer
, InstallDir
);
935 RtlCreateUnicodeString(&DestinationPath
,
938 /* Create 'DestinationArcPath' */
939 RtlFreeUnicodeString(&DestinationArcPath
);
941 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
943 PartData
.PartNumber
);
944 if (InstallDir
[0] != L
'\\')
947 wcscat(PathBuffer
, InstallDir
);
948 RtlCreateUnicodeString(&DestinationArcPath
,
951 return(PREPARE_COPY_PAGE
);
953 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
958 InstallDir
[Length
] = 0;
959 SetInputTextXY(8, 11, 51, InstallDir
);
962 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
966 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
968 InstallDir
[Length
] = 0;
969 SetInputTextXY(8, 11, 51, InstallDir
);
974 return(INSTALL_DIRECTORY_PAGE
);
979 PrepareCopyPage(PINPUT_RECORD Ir
)
981 WCHAR PathBuffer
[MAX_PATH
];
982 INFCONTEXT FilesContext
;
983 INFCONTEXT DirContext
;
994 SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. ");
997 // SetTextXY(8, 12, "Build file copy list");
999 // SetTextXY(8, 14, "Create directories");
1001 // SetStatusText(" Please wait...");
1005 * Build the file copy list
1007 SetStatusText(" Building the file copy list...");
1008 // SetInvertedTextXY(8, 12, "Build file copy list");
1012 /* Search for the 'SourceFiles' section */
1013 if (!InfFindFirstLine (SetupInf
, L
"SourceFiles", NULL
, &FilesContext
))
1015 PopupError("Setup failed to find the 'SourceFiles' section\n"
1016 "in TXTSETUP.SIF.\n",
1017 "ENTER = Reboot computer");
1023 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1031 /* Create the file queue */
1032 SetupFileQueue
= SetupOpenFileQueue();
1033 if (SetupFileQueue
== NULL
)
1035 PopupError("Setup failed to open the copy file queue.\n",
1036 "ENTER = Reboot computer");
1042 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1050 * Enumerate the files in the 'SourceFiles' section
1051 * and add them to the file queue.
1055 if (!InfGetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
1058 DPRINT1("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
1060 /* Lookup target directory */
1061 if (!InfFindFirstLine (SetupInf
, L
"Directories", FileKeyValue
, &DirContext
))
1063 /* FIXME: Handle error! */
1064 DPRINT1("InfFindFirstLine() failed\n");
1068 if (!InfGetData (&DirContext
, NULL
, &DirKeyValue
))
1070 /* FIXME: Handle error! */
1071 DPRINT1("InfGetData() failed\n");
1075 if (!SetupQueueCopy(SetupFileQueue
,
1076 SourceRootPath
.Buffer
,
1082 /* FIXME: Handle error! */
1083 DPRINT1("SetupQueueCopy() failed\n");
1086 while (InfFindNextLine(&FilesContext
, &FilesContext
));
1089 /* Create directories */
1090 SetStatusText(" Creating directories...");
1094 * Install directories like '\reactos\test' are not handled yet.
1097 /* Get destination path */
1098 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
1100 /* Remove trailing backslash */
1101 Length
= wcslen(PathBuffer
);
1102 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
1104 PathBuffer
[Length
- 1] = 0;
1107 /* Create the install directory */
1108 Status
= CreateDirectory(PathBuffer
);
1109 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
1111 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
1112 PopupError("Setup could not create the install directory.",
1113 "ENTER = Reboot computer");
1119 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1127 /* Search for the 'Directories' section */
1128 if (!InfFindFirstLine(SetupInf
, L
"Directories", NULL
, &DirContext
))
1130 PopupError("Setup failed to find the 'Directories' section\n"
1131 "in TXTSETUP.SIF.\n",
1132 "ENTER = Reboot computer");
1138 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1145 /* Enumerate the directory values and create the subdirectories */
1148 if (!InfGetData (&DirContext
, NULL
, &KeyValue
))
1151 // if (KeyValue[0] == L'\\' && KeyValue[1] != 0)
1152 if (wcscmp (KeyValue
, L
"\"\\\"") == 0)
1154 DPRINT("Absolute Path: '%S'\n", KeyValue
);
1156 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
1157 wcscat(PathBuffer
, KeyValue
);
1159 DPRINT("FullPath: '%S'\n", PathBuffer
);
1161 else if (KeyValue
[0] != L
'\\')
1163 DPRINT("RelativePath: '%S'\n", KeyValue
);
1164 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
1165 wcscat(PathBuffer
, L
"\\");
1166 wcscat(PathBuffer
, KeyValue
);
1168 DPRINT("FullPath: '%S'\n", PathBuffer
);
1170 Status
= CreateDirectory(PathBuffer
);
1171 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
1173 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
1174 PopupError("Setup could not create install directories.",
1175 "ENTER = Reboot computer");
1181 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1189 while (InfFindNextLine (&DirContext
, &DirContext
));
1191 return(FILE_COPY_PAGE
);
1196 FileCopyCallback(PVOID Context
,
1201 PCOPYCONTEXT CopyContext
;
1203 CopyContext
= (PCOPYCONTEXT
)Context
;
1205 switch (Notification
)
1207 case SPFILENOTIFY_STARTSUBQUEUE
:
1208 CopyContext
->TotalOperations
= (ULONG
)Param2
;
1209 ProgressSetStepCount(CopyContext
->ProgressBar
,
1210 CopyContext
->TotalOperations
);
1213 case SPFILENOTIFY_STARTCOPY
:
1214 /* Display copy message */
1215 PrintTextXYN(6, 16, 60, "Copying file: %S", (PWSTR
)Param1
);
1217 PrintTextXYN(6, 18, 60, "File %lu of %lu",
1218 CopyContext
->CompletedOperations
+ 1,
1219 CopyContext
->TotalOperations
);
1222 case SPFILENOTIFY_ENDCOPY
:
1223 CopyContext
->CompletedOperations
++;
1224 ProgressNextStep(CopyContext
->ProgressBar
);
1233 FileCopyPage(PINPUT_RECORD Ir
)
1235 COPYCONTEXT CopyContext
;
1239 SetStatusText(" Please wait...");
1241 SetTextXY(6, 8, "Copying files");
1243 GetScreenSize(&xScreen
, &yScreen
);
1245 CopyContext
.TotalOperations
= 0;
1246 CopyContext
.CompletedOperations
= 0;
1247 CopyContext
.ProgressBar
= CreateProgressBar(6,
1252 SetupCommitFileQueue(SetupFileQueue
,
1253 DestinationRootPath
.Buffer
,
1255 (PSP_FILE_CALLBACK
)FileCopyCallback
,
1258 SetupCloseFileQueue(SetupFileQueue
);
1260 DestroyProgressBar(CopyContext
.ProgressBar
);
1262 return(REGISTRY_PAGE
);
1267 RegistryPage(PINPUT_RECORD Ir
)
1269 OBJECT_ATTRIBUTES ObjectAttributes
;
1270 UNICODE_STRING KeyName
;
1271 UNICODE_STRING ValueName
;
1275 SetTextXY(6, 8, "Setup updated the system configuration");
1277 SetStatusText(" Creating registry hives...");
1279 /* Create the 'secret' InstallPath key */
1280 RtlInitUnicodeStringFromLiteral(&KeyName
,
1281 L
"\\Registry\\Machine\\HARDWARE");
1282 InitializeObjectAttributes(&ObjectAttributes
,
1284 OBJ_CASE_INSENSITIVE
,
1287 Status
= NtOpenKey(&KeyHandle
,
1290 if (!NT_SUCCESS(Status
))
1292 DPRINT1("NtOpenKey() failed (Status %lx)\n", Status
);
1293 PopupError("Setup failed to open the HARDWARE registry key.",
1294 "ENTER = Reboot computer");
1300 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1307 RtlInitUnicodeStringFromLiteral(&ValueName
,
1310 Status
= NtSetValueKey(KeyHandle
,
1314 (PVOID
)DestinationPath
.Buffer
,
1315 DestinationPath
.Length
);
1317 if (!NT_SUCCESS(Status
))
1319 DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status
);
1320 PopupError("Setup failed to set the \'InstallPath\' registry value.",
1321 "ENTER = Reboot computer");
1327 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1334 /* Create the default hives */
1335 Status
= NtInitializeRegistry(TRUE
);
1336 if (!NT_SUCCESS(Status
))
1338 DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status
);
1339 PopupError("Setup failed to initialize the registry.",
1340 "ENTER = Reboot computer");
1346 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1353 /* Update registry */
1354 SetStatusText(" Updating registry hives...");
1356 Status
= SetupUpdateRegistry();
1357 if (!NT_SUCCESS(Status
))
1359 DPRINT1("SetupUpdateRegistry() failed (Status %lx)\n", Status
);
1360 PopupError("Setup failed to update the registry.",
1361 "ENTER = Reboot computer");
1367 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1374 return(BOOT_LOADER_PAGE
);
1379 BootLoaderPage(PINPUT_RECORD Ir
)
1381 WCHAR SrcPath
[MAX_PATH
];
1382 WCHAR DstPath
[MAX_PATH
];
1384 PINICACHESECTION IniSection
;
1387 SetTextXY(6, 8, "Installing the boot loader");
1389 SetStatusText(" Please wait...");
1391 if (ActivePartitionValid
== FALSE
)
1393 DPRINT1("Error: no active partition found\n");
1394 PopupError("Setup could not find an active partiton\n",
1395 "ENTER = Reboot computer");
1401 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1408 if (ActivePartition
.PartType
== PARTITION_ENTRY_UNUSED
)
1410 DPRINT1("Error: active partition invalid (unused)\n");
1411 PopupError("The active partition is unused (invalid).\n",
1412 "ENTER = Reboot computer");
1418 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1425 if (ActivePartition
.PartType
== 0x0A)
1427 /* OS/2 boot manager partition */
1428 DPRINT1("Found OS/2 boot manager partition\n");
1429 PopupError("Setup found an OS/2 boot manager partiton.\n"
1430 "The OS/2 boot manager is not supported yet!",
1431 "ENTER = Reboot computer");
1437 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1443 else if (ActivePartition
.PartType
== 0x83)
1445 /* Linux ext2 partition */
1446 DPRINT1("Found Linux ext2 partition\n");
1447 PopupError("Setup found a Linux ext2 partiton.\n"
1448 "Linux ext2 partitions are not supported yet!",
1449 "ENTER = Reboot computer");
1455 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1461 else if (ActivePartition
.PartType
== PARTITION_IFS
)
1463 /* NTFS partition */
1464 DPRINT1("Found NTFS partition\n");
1465 PopupError("Setup found an NTFS partiton.\n"
1466 "NTFS partitions are not supported yet!",
1467 "ENTER = Reboot computer");
1473 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1479 else if ((ActivePartition
.PartType
== PARTITION_FAT_12
) ||
1480 (ActivePartition
.PartType
== PARTITION_FAT_16
) ||
1481 (ActivePartition
.PartType
== PARTITION_HUGE
) ||
1482 (ActivePartition
.PartType
== PARTITION_XINT13
) ||
1483 (ActivePartition
.PartType
== PARTITION_FAT32
) ||
1484 (ActivePartition
.PartType
== PARTITION_FAT32_XINT13
))
1486 /* FAT or FAT32 partition */
1487 DPRINT1("System path: '%wZ'\n", &SystemRootPath
);
1489 if (DoesFileExist(SystemRootPath
.Buffer
, L
"ntldr") == TRUE
||
1490 DoesFileExist(SystemRootPath
.Buffer
, L
"boot.ini") == TRUE
)
1492 /* Search root directory for 'ntldr' and 'boot.ini'. */
1493 DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
1495 /* Copy FreeLoader to the boot partition */
1496 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1497 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
1498 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1499 wcscat(DstPath
, L
"\\freeldr.sys");
1501 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
1502 Status
= SetupCopyFile(SrcPath
, DstPath
);
1503 if (!NT_SUCCESS(Status
))
1505 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
1506 PopupError("Setup failed to copy 'freeldr.sys'.",
1507 "ENTER = Reboot computer");
1513 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1520 /* Create or update freeldr.ini */
1521 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
1523 /* Create new 'freeldr.ini' */
1524 DPRINT1("Create new 'freeldr.ini'\n");
1525 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1526 wcscat(DstPath
, L
"\\freeldr.ini");
1528 Status
= CreateFreeLoaderIniForReactos(DstPath
,
1529 DestinationArcPath
.Buffer
);
1530 if (!NT_SUCCESS(Status
))
1532 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
1533 PopupError("Setup failed to create 'freeldr.ini'.",
1534 "ENTER = Reboot computer");
1540 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1547 /* Install new bootcode */
1548 if ((ActivePartition
.PartType
== PARTITION_FAT32
) ||
1549 (ActivePartition
.PartType
== PARTITION_FAT32_XINT13
))
1551 /* Install FAT32 bootcode */
1552 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1553 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
1554 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1555 wcscat(DstPath
, L
"\\bootsect.ros");
1557 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, DstPath
);
1558 Status
= InstallFat32BootCodeToFile(SrcPath
,
1560 SystemRootPath
.Buffer
);
1561 if (!NT_SUCCESS(Status
))
1563 DPRINT1("InstallFat32BootCodeToFile() failed (Status %lx)\n", Status
);
1564 PopupError("Setup failed to install the FAT32 bootcode.",
1565 "ENTER = Reboot computer");
1571 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1580 /* Install FAT16 bootcode */
1581 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1582 wcscat(SrcPath
, L
"\\loader\\fat.bin");
1583 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1584 wcscat(DstPath
, L
"\\bootsect.ros");
1586 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, DstPath
);
1587 Status
= InstallFat16BootCodeToFile(SrcPath
,
1589 SystemRootPath
.Buffer
);
1590 if (!NT_SUCCESS(Status
))
1592 DPRINT1("InstallFat16BootCodeToFile() failed (Status %lx)\n", Status
);
1593 PopupError("Setup failed to install the FAT bootcode.",
1594 "ENTER = Reboot computer");
1600 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1608 /* Update 'boot.ini' */
1609 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1610 wcscat(DstPath
, L
"\\boot.ini");
1612 DPRINT1("Update 'boot.ini': %S\n", DstPath
);
1613 Status
= UpdateBootIni(DstPath
,
1614 L
"C:\\bootsect.ros",
1616 if (!NT_SUCCESS(Status
))
1618 DPRINT1("UpdateBootIni() failed (Status %lx)\n", Status
);
1619 PopupError("Setup failed to update \'boot.ini\'.",
1620 "ENTER = Reboot computer");
1626 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1635 /* Update existing 'freeldr.ini' */
1636 DPRINT1("Update existing 'freeldr.ini'\n");
1637 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1638 wcscat(DstPath
, L
"\\freeldr.ini");
1640 Status
= UpdateFreeLoaderIni(DstPath
,
1641 DestinationArcPath
.Buffer
);
1642 if (!NT_SUCCESS(Status
))
1644 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
1645 PopupError("Setup failed to update 'freeldr.ini'.",
1646 "ENTER = Reboot computer");
1652 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1660 else if (DoesFileExist(SystemRootPath
.Buffer
, L
"io.sys") == TRUE
||
1661 DoesFileExist(SystemRootPath
.Buffer
, L
"msdos.sys") == TRUE
)
1663 /* Search for root directory for 'io.sys' and 'msdos.sys'. */
1664 DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
1666 /* Copy FreeLoader to the boot partition */
1667 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1668 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
1669 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1670 wcscat(DstPath
, L
"\\freeldr.sys");
1672 DPRINT("Copy: %S ==> %S\n", SrcPath
, DstPath
);
1673 Status
= SetupCopyFile(SrcPath
, DstPath
);
1674 if (!NT_SUCCESS(Status
))
1676 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
1677 PopupError("Setup failed to copy 'freeldr.sys'.",
1678 "ENTER = Reboot computer");
1684 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1691 /* Create or update 'freeldr.ini' */
1692 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
1694 /* Create new 'freeldr.ini' */
1695 DPRINT1("Create new 'freeldr.ini'\n");
1696 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1697 wcscat(DstPath
, L
"\\freeldr.ini");
1699 Status
= CreateFreeLoaderIniForDos(DstPath
,
1700 DestinationArcPath
.Buffer
);
1701 if (!NT_SUCCESS(Status
))
1703 DPRINT1("CreateFreeLoaderIniForDos() failed (Status %lx)\n", Status
);
1704 PopupError("Setup failed to create 'freeldr.ini'.",
1705 "ENTER = Reboot computer");
1711 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1718 /* Save current bootsector as 'BOOTSECT.DOS' */
1719 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
1720 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1721 wcscat(DstPath
, L
"\\bootsect.dos");
1723 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
1724 Status
= SaveCurrentBootSector(SrcPath
,
1726 if (!NT_SUCCESS(Status
))
1728 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
1729 PopupError("Setup failed to save the current bootsector.",
1730 "ENTER = Reboot computer");
1736 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1743 /* Install new bootsector */
1744 if ((ActivePartition
.PartType
== PARTITION_FAT32
) ||
1745 (ActivePartition
.PartType
== PARTITION_FAT32_XINT13
))
1747 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1748 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
1750 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
1751 Status
= InstallFat32BootCodeToDisk(SrcPath
,
1752 SystemRootPath
.Buffer
);
1753 if (!NT_SUCCESS(Status
))
1755 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
1756 PopupError("Setup failed to install the FAT32 bootcode.",
1757 "ENTER = Reboot computer");
1763 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1772 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1773 wcscat(SrcPath
, L
"\\loader\\fat.bin");
1775 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
1776 Status
= InstallFat16BootCodeToDisk(SrcPath
,
1777 SystemRootPath
.Buffer
);
1778 if (!NT_SUCCESS(Status
))
1780 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
1781 PopupError("Setup failed to install the FAT bootcode.",
1782 "ENTER = Reboot computer");
1788 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1798 /* Update existing 'freeldr.ini' */
1799 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1800 wcscat(DstPath
, L
"\\freeldr.ini");
1802 Status
= UpdateFreeLoaderIni(DstPath
,
1803 DestinationArcPath
.Buffer
);
1804 if (!NT_SUCCESS(Status
))
1806 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
1807 PopupError("Setup failed to update 'freeldr.ini'.",
1808 "ENTER = Reboot computer");
1814 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1824 /* No or unknown boot loader */
1825 DPRINT1("No or unknown boot loader found\n");
1827 /* Copy FreeLoader to the boot partition */
1828 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1829 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
1830 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1831 wcscat(DstPath
, L
"\\freeldr.sys");
1833 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
1834 Status
= SetupCopyFile(SrcPath
, DstPath
);
1835 if (!NT_SUCCESS(Status
))
1837 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
1838 PopupError("Setup failed to copy 'freeldr.sys'.",
1839 "ENTER = Reboot computer");
1845 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1852 /* Create or update 'freeldr.ini' */
1853 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
1855 /* Create new freeldr.ini */
1856 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1857 wcscat(DstPath
, L
"\\freeldr.ini");
1859 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
1860 Status
= CreateFreeLoaderIniForReactos(DstPath
,
1861 DestinationArcPath
.Buffer
);
1862 if (!NT_SUCCESS(Status
))
1864 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
1865 PopupError("Setup failed to create \'freeldr.ini\'.",
1866 "ENTER = Reboot computer");
1872 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1879 /* Save current bootsector as 'BOOTSECT.OLD' */
1880 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
1881 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1882 wcscat(DstPath
, L
"\\bootsect.old");
1884 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
1885 Status
= SaveCurrentBootSector(SrcPath
,
1887 if (!NT_SUCCESS(Status
))
1889 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
1890 PopupError("Setup failed save the current bootsector.",
1891 "ENTER = Reboot computer");
1897 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1904 /* Install new bootsector */
1905 if ((ActivePartition
.PartType
== PARTITION_FAT32
) ||
1906 (ActivePartition
.PartType
== PARTITION_FAT32_XINT13
))
1908 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1909 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
1911 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
1912 Status
= InstallFat32BootCodeToDisk(SrcPath
,
1913 SystemRootPath
.Buffer
);
1914 if (!NT_SUCCESS(Status
))
1916 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
1917 PopupError("Setup failed to install the FAT32 bootcode.",
1918 "ENTER = Reboot computer");
1924 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1933 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
1934 wcscat(SrcPath
, L
"\\loader\\fat.bin");
1936 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
1937 Status
= InstallFat16BootCodeToDisk(SrcPath
,
1938 SystemRootPath
.Buffer
);
1939 if (!NT_SUCCESS(Status
))
1941 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
1942 PopupError("Setup failed to install the FAT bootcode.",
1943 "ENTER = Reboot computer");
1949 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1959 /* Update existing 'freeldr.ini' */
1960 wcscpy(DstPath
, SystemRootPath
.Buffer
);
1961 wcscat(DstPath
, L
"\\freeldr.ini");
1963 Status
= UpdateFreeLoaderIni(DstPath
,
1964 DestinationArcPath
.Buffer
);
1965 if (!NT_SUCCESS(Status
))
1967 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
1968 PopupError("Setup failed to update 'freeldr.ini'.",
1969 "ENTER = Reboot computer");
1975 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1986 /* Unknown partition */
1987 DPRINT1("Unknown partition found\n");
1988 PopupError("Setup found an unknown partiton type.\n"
1989 "This partition type is not supported!",
1990 "ENTER = Reboot computer");
1996 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2003 return(SUCCESS_PAGE
);
2009 QuitPage(PINPUT_RECORD Ir
)
2011 SetTextXY(10, 6, "ReactOS is not completely installed");
2013 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2014 SetTextXY(10, 9, "all CD-ROMs from CD-Drives.");
2016 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2018 SetStatusText(" ENTER = Reboot computer");
2024 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2026 return(REBOOT_PAGE
);
2033 SuccessPage(PINPUT_RECORD Ir
)
2035 SetTextXY(10, 6, "The basic components of ReactOS have been installed successfully.");
2037 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2038 SetTextXY(10, 9, "all CD-ROMs from CD-Drive.");
2040 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2042 SetStatusText(" ENTER = Reboot computer");
2048 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2050 return(REBOOT_PAGE
);
2057 NtProcessStartup(PPEB Peb
)
2063 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
2065 ProcessHeap
= Peb
->ProcessHeap
;
2067 Status
= AllocConsole();
2068 if (!NT_SUCCESS(Status
))
2070 PrintString("AllocConsole() failed (Status = 0x%08lx)\n", Status
);
2072 /* Raise a hard error (crash the system/BSOD) */
2073 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
2077 PartDataValid
= FALSE
;
2079 /* Initialize global unicode strings */
2080 RtlInitUnicodeString(&SourcePath
, NULL
);
2081 RtlInitUnicodeString(&SourceRootPath
, NULL
);
2082 RtlInitUnicodeString(&InstallPath
, NULL
);
2083 RtlInitUnicodeString(&DestinationPath
, NULL
);
2084 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
2085 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
2086 RtlInitUnicodeString(&SystemRootPath
, NULL
);
2090 while (Page
!= REBOOT_PAGE
)
2094 SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR
" Setup ");
2100 Page
= StartPage(&Ir
);
2105 Page
= IntroPage(&Ir
);
2109 case INSTALL_INTRO_PAGE
:
2110 Page
= InstallIntroPage(&Ir
);
2114 case OEM_DRIVER_PAGE
:
2115 Page
= OemDriverPage(&Ir
);
2120 case DEVICE_SETTINGS_PAGE
:
2123 case SELECT_PARTITION_PAGE
:
2124 Page
= SelectPartitionPage(&Ir
);
2127 case SELECT_FILE_SYSTEM_PAGE
:
2128 Page
= SelectFileSystemPage(&Ir
);
2131 case CHECK_FILE_SYSTEM_PAGE
:
2132 Page
= CheckFileSystemPage(&Ir
);
2135 case INSTALL_DIRECTORY_PAGE
:
2136 Page
= InstallDirectoryPage(&Ir
);
2139 case PREPARE_COPY_PAGE
:
2140 Page
= PrepareCopyPage(&Ir
);
2143 case FILE_COPY_PAGE
:
2144 Page
= FileCopyPage(&Ir
);
2148 Page
= RegistryPage(&Ir
);
2151 case BOOT_LOADER_PAGE
:
2152 Page
= BootLoaderPage(&Ir
);
2157 case REPAIR_INTRO_PAGE
:
2158 Page
= RepairIntroPage(&Ir
);
2163 Page
= SuccessPage(&Ir
);
2167 Page
= QuitPage(&Ir
);
2174 NtShutdownSystem(ShutdownReboot
);