3 * Copyright (C) 2002, 2003 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
25 * Casper S. Hornstrup (chorns@users.sourceforge.net)
28 #include <ddk/ntddk.h>
29 #include <ntdll/rtl.h>
31 #include <ntos/minmax.h>
32 #include <reactos/resource.h>
39 #include "filequeue.h"
50 typedef enum _PAGE_NUMBER
56 SELECT_PARTITION_PAGE
,
57 CREATE_PARTITION_PAGE
,
58 DELETE_PARTITION_PAGE
,
60 SELECT_FILE_SYSTEM_PAGE
,
61 FORMAT_PARTITION_PAGE
,
62 CHECK_FILE_SYSTEM_PAGE
,
65 INSTALL_DIRECTORY_PAGE
,
76 REBOOT_PAGE
, /* virtual page */
77 } PAGE_NUMBER
, *PPAGE_NUMBER
;
79 typedef struct _COPYCONTEXT
81 ULONG TotalOperations
;
82 ULONG CompletedOperations
;
83 PPROGRESS ProgressBar
;
84 } COPYCONTEXT
, *PCOPYCONTEXT
;
87 /* GLOBALS ******************************************************************/
90 UNICODE_STRING SourceRootPath
;
93 /* LOCALS *******************************************************************/
95 static PPARTLIST PartitionList
= NULL
;
97 static PDISKENTRY ActiveBootDisk
= NULL
;
98 static PPARTENTRY ActiveBootPartition
= NULL
;
100 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
103 static UNICODE_STRING SourcePath
;
105 static UNICODE_STRING InstallPath
;
107 /* Path to the install directory */
108 static UNICODE_STRING DestinationPath
;
109 static UNICODE_STRING DestinationArcPath
;
110 static UNICODE_STRING DestinationRootPath
;
112 /* Path to the active partition (boot manager) */
113 static UNICODE_STRING SystemRootPath
;
115 static HINF SetupInf
;
117 static HSPFILEQ SetupFileQueue
= NULL
;
120 /* FUNCTIONS ****************************************************************/
123 PrintString(char* fmt
,...)
127 UNICODE_STRING UnicodeString
;
128 ANSI_STRING AnsiString
;
131 vsprintf(buffer
, fmt
, ap
);
134 RtlInitAnsiString(&AnsiString
, buffer
);
135 RtlAnsiStringToUnicodeString(&UnicodeString
,
138 NtDisplayString(&UnicodeString
);
139 RtlFreeUnicodeString(&UnicodeString
);
144 PopupError(PCHAR Text
,
162 /* Count text lines and longest line */
168 p
= strchr(pnext
, '\n');
171 Length
= strlen(pnext
);
176 Length
= (ULONG
)(p
- pnext
);
181 if (Length
> MaxLength
)
184 if (LastLine
== TRUE
)
190 /* Check length of status line */
193 Length
= strlen(Status
);
194 if (Length
> MaxLength
)
198 GetScreenSize(&xScreen
, &yScreen
);
200 Width
= MaxLength
+ 4;
205 yTop
= (yScreen
- Height
) / 2;
206 xLeft
= (xScreen
- Width
) / 2;
209 /* Set screen attributes */
211 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
213 FillConsoleOutputAttribute(0x74,
219 /* draw upper left corner */
222 FillConsoleOutputCharacter(0xDA, // '+',
227 /* draw upper edge */
230 FillConsoleOutputCharacter(0xC4, // '-',
235 /* draw upper right corner */
236 coPos
.X
= xLeft
+ Width
- 1;
238 FillConsoleOutputCharacter(0xBF, // '+',
243 /* Draw right edge, inner space and left edge */
244 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
247 FillConsoleOutputCharacter(0xB3, // '|',
253 FillConsoleOutputCharacter(' ',
258 coPos
.X
= xLeft
+ Width
- 1;
259 FillConsoleOutputCharacter(0xB3, // '|',
265 /* draw lower left corner */
267 coPos
.Y
= yTop
+ Height
- 1;
268 FillConsoleOutputCharacter(0xC0, // '+',
273 /* draw lower edge */
275 coPos
.Y
= yTop
+ Height
- 1;
276 FillConsoleOutputCharacter(0xC4, // '-',
281 /* draw lower right corner */
282 coPos
.X
= xLeft
+ Width
- 1;
283 coPos
.Y
= yTop
+ Height
- 1;
284 FillConsoleOutputCharacter(0xD9, // '+',
289 /* Print message text */
294 p
= strchr(pnext
, '\n');
297 Length
= strlen(pnext
);
302 Length
= (ULONG
)(p
- pnext
);
309 WriteConsoleOutputCharacters(pnext
,
314 if (LastLine
== TRUE
)
321 /* Print separator line and status text */
324 coPos
.Y
= yTop
+ Height
- 3;
326 FillConsoleOutputCharacter(0xC3, // '+',
332 FillConsoleOutputCharacter(0xC4, // '-',
337 coPos
.X
= xLeft
+ Width
- 1;
338 FillConsoleOutputCharacter(0xB4, // '+',
345 WriteConsoleOutputCharacters(Status
,
346 min(strlen(Status
), Width
- 4),
356 * FALSE: Don't quit setup.
359 ConfirmQuit(PINPUT_RECORD Ir
)
363 PopupError("ReactOS is not completely installed on your\n"
364 "computer. If you quit Setup now, you will need to\n"
365 "run Setup again to install ReactOS.\n"
367 " \x07 Press ENTER to continue Setup.\n"
368 " \x07 Press F3 to quit Setup.",
369 "F3= Quit ENTER = Continue");
375 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
376 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
381 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
396 * Number of the next page.
399 StartPage(PINPUT_RECORD Ir
)
402 WCHAR FileNameBuffer
[MAX_PATH
];
403 UNICODE_STRING FileName
;
408 SetStatusText(" Please wait...");
410 Status
= GetSourcePaths(&SourcePath
,
412 if (!NT_SUCCESS(Status
))
414 PrintTextXY(6, 15, "GetSourcePath() failed (Status 0x%08lx)", Status
);
415 PopupError("Setup could not find its source drive.\n",
416 "ENTER = Reboot computer");
421 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
430 PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
431 PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
435 /* Load txtsetup.sif from install media. */
436 wcscpy(FileNameBuffer
, SourceRootPath
.Buffer
);
437 wcscat(FileNameBuffer
, L
"\\reactos\\txtsetup.sif");
438 RtlInitUnicodeString(&FileName
,
441 Status
= InfOpenFile(&SetupInf
,
444 if (!NT_SUCCESS(Status
))
446 PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
447 "ENTER = Reboot computer");
453 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
460 /* Open 'Version' section */
461 if (!InfFindFirstLine (SetupInf
, L
"Version", L
"Signature", &Context
))
463 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
464 "ENTER = Reboot computer");
470 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
478 /* Get pointer 'Signature' key */
479 if (!InfGetData (&Context
, NULL
, &Value
))
481 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
482 "ENTER = Reboot computer");
488 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
495 /* Check 'Signature' string */
496 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
498 PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
499 "ENTER = Reboot computer");
505 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
522 IntroPage(PINPUT_RECORD Ir
)
524 SetHighlightedTextXY(6, 8, "Welcome to ReactOS Setup");
526 SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your");
527 SetTextXY(6, 12, "computer and prepares the second part of the setup.");
529 SetTextXY(8, 15, "\x07 Press ENTER to install ReactOS.");
531 SetTextXY(8, 17, "\x07 Press E to start the emergency console.");
533 SetTextXY(8, 19, "\x07 Press R to repair ReactOS.");
535 SetTextXY(8, 21, "\x07 Press F3 to quit without installing ReactOS.");
538 SetStatusText(" ENTER = Continue F3 = Quit");
544 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
545 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
547 if (ConfirmQuit(Ir
) == TRUE
)
551 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
553 return(INSTALL_INTRO_PAGE
);
555 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'E') /* E */
557 return(EMERGENCY_INTRO_PAGE
);
559 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
561 return(REPAIR_INTRO_PAGE
);
570 EmergencyIntroPage(PINPUT_RECORD Ir
)
572 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
573 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
575 SetTextXY(6, 12, "The emergency console is not implemented yet.");
577 SetTextXY(8, 15, "\x07 Press ESC to return to the main page.");
579 SetTextXY(8, 17, "\x07 Press ENTER to reboot your computer.");
581 SetStatusText(" ESC = Main page ENTER = Reboot");
587 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
591 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
592 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
598 return(REPAIR_INTRO_PAGE
);
603 RepairIntroPage(PINPUT_RECORD Ir
)
605 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
606 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
608 SetTextXY(6, 12, "The repair functions are not implemented yet.");
610 SetTextXY(8, 15, "\x07 Press ESC to return to the main page.");
612 SetTextXY(8, 17, "\x07 Press ENTER to reboot your computer.");
614 SetStatusText(" ESC = Main page ENTER = Reboot");
620 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
624 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
625 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
631 return(REPAIR_INTRO_PAGE
);
636 InstallIntroPage(PINPUT_RECORD Ir
)
638 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
639 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
641 SetTextXY(6, 12, "The following functions are missing:");
642 SetTextXY(8, 13, "- Creating and deleting harddisk partitions.");
643 SetTextXY(8, 14, "- Formatting partitions.");
644 SetTextXY(8, 15, "- Support for non-FAT file systems.");
645 SetTextXY(8, 16, "- Checking file systems.");
649 SetTextXY(8, 21, "\x07 Press ENTER to install ReactOS.");
651 SetTextXY(8, 23, "\x07 Press F3 to quit without installing ReactOS.");
654 SetStatusText(" ENTER = Continue F3 = Quit");
660 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
661 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
663 if (ConfirmQuit(Ir
) == TRUE
)
667 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
669 return(SELECT_PARTITION_PAGE
);
673 return(INSTALL_INTRO_PAGE
);
678 SelectPartitionPage(PINPUT_RECORD Ir
)
680 WCHAR PathBuffer
[MAX_PATH
];
684 SetTextXY(6, 8, "The list below shows existing partitions and unused disk");
685 SetTextXY(6, 9, "space for new partitions.");
687 SetTextXY(8, 11, "\x07 Press UP or DOWN to select a list entry.");
688 SetTextXY(8, 13, "\x07 Press ENTER to install ReactOS onto the selected partition.");
689 SetTextXY(8, 15, "\x07 Press C to create a new partition.");
690 SetTextXY(8, 17, "\x07 Press D to delete an existing partition.");
692 SetStatusText(" Please wait...");
694 RtlFreeUnicodeString(&DestinationPath
);
695 RtlFreeUnicodeString(&DestinationRootPath
);
697 GetScreenSize(&xScreen
, &yScreen
);
699 if (PartitionList
== NULL
)
701 PartitionList
= CreatePartitionList (2,
705 if (PartitionList
== NULL
)
707 /* FIXME: show an error dialog */
712 DrawPartitionList (PartitionList
);
716 /* Update status text */
717 if (PartitionList
->CurrentPartition
== NULL
||
718 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
720 SetStatusText (" ENTER = Install C = Create Partition F3 = Quit");
724 SetStatusText (" ENTER = Install D = Delete Partition F3 = Quit");
729 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
730 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
732 if (ConfirmQuit(Ir
) == TRUE
)
734 DestroyPartitionList (PartitionList
);
735 PartitionList
= NULL
;
740 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
741 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
743 ScrollDownPartitionList (PartitionList
);
745 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
746 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
748 ScrollUpPartitionList (PartitionList
);
750 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
752 if (PartitionList
->CurrentPartition
== NULL
||
753 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
755 CreateNewPartition (PartitionList
,
759 /* FIXME: Update drive letters and partition numbers */
761 return SELECT_FILE_SYSTEM_PAGE
;
765 RtlFreeUnicodeString (&DestinationRootPath
);
766 swprintf (PathBuffer
,
767 L
"\\Device\\Harddisk%lu\\Partition%lu",
768 PartitionList
->CurrentDisk
->DiskNumber
,
769 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
770 RtlCreateUnicodeString (&DestinationRootPath
,
773 GetActiveBootPartition (PartitionList
,
775 &ActiveBootPartition
);
777 RtlFreeUnicodeString (&SystemRootPath
);
778 if (ActiveBootDisk
!= NULL
&& ActiveBootPartition
!= NULL
)
780 swprintf (PathBuffer
,
781 L
"\\Device\\Harddisk%lu\\Partition%lu",
782 ActiveBootDisk
->DiskNumber
,
783 ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
789 * Check whether partition can be activated.
790 * We may have to force Disk0\Partition1.
791 * Mark partition active.
793 swprintf (PathBuffer
,
794 L
"\\Device\\Harddisk%lu\\Partition%lu",
795 PartitionList
->CurrentDisk
->DiskNumber
,
796 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
798 RtlCreateUnicodeString (&SystemRootPath
,
801 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
802 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
804 return SELECT_FILE_SYSTEM_PAGE
;
807 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_C
) /* C */
809 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
811 PopupError ("You can not create a new Partition inside\n"
812 "of an already existing Partition!\n"
814 " * Press any key to continue.",
818 return SELECT_PARTITION_PAGE
;
821 return CREATE_PARTITION_PAGE
;
823 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_D
) /* D */
825 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
827 PopupError ("You can not delete unpartitioned disk space!\n"
829 " * Press any key to continue.",
833 return SELECT_PARTITION_PAGE
;
836 return DELETE_PARTITION_PAGE
;
840 return SELECT_PARTITION_PAGE
;
845 DrawInputField(ULONG FieldLength
,
855 memset(buf
, '_', sizeof(buf
));
856 buf
[FieldLength
- strlen(FieldContent
)] = 0;
857 strcat(buf
, FieldContent
);
859 WriteConsoleOutputCharacters (buf
,
865 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
868 ShowPartitionSizeInputBox(SHORT Left
,
893 /* draw upper left corner */
896 FillConsoleOutputCharacter(0xDA, // '+',
901 /* draw upper edge */
904 FillConsoleOutputCharacter(0xC4, // '-',
909 /* draw upper right corner */
912 FillConsoleOutputCharacter(0xBF, // '+',
917 /* draw left and right edge */
918 for (i
= Top
+ 1; i
< Bottom
; i
++)
922 FillConsoleOutputCharacter(0xB3, // '|',
928 FillConsoleOutputCharacter(0xB3, //'|',
934 /* draw lower left corner */
937 FillConsoleOutputCharacter(0xC0, // '+',
942 /* draw lower edge */
945 FillConsoleOutputCharacter(0xC4, // '-',
950 /* draw lower right corner */
953 FillConsoleOutputCharacter(0xD9, // '+',
961 strcpy (Buffer
, "Size of new partition:");
962 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
964 WriteConsoleOutputCharacters (Buffer
,
968 sprintf (Buffer
, "MB (max. %d MB)", MaxSize
);
969 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
971 WriteConsoleOutputCharacters (Buffer
,
977 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
986 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
987 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
994 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
998 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1005 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1010 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1015 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1016 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1018 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1019 if ((ch
>= '0') && (ch
<= '9'))
1024 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1032 strcpy (InputBuffer
,
1038 CreatePartitionPage (PINPUT_RECORD Ir
)
1040 PDISKENTRY DiskEntry
;
1041 PPARTENTRY PartEntry
;
1046 CHAR InputBuffer
[50];
1052 if (PartitionList
== NULL
||
1053 PartitionList
->CurrentDisk
== NULL
||
1054 PartitionList
->CurrentPartition
== NULL
)
1056 /* FIXME: show an error dialog */
1060 DiskEntry
= PartitionList
->CurrentDisk
;
1061 PartEntry
= PartitionList
->CurrentPartition
;
1063 SetStatusText (" Please wait...");
1065 GetScreenSize (&xScreen
, &yScreen
);
1067 SetTextXY (6, 8, "You have chosen to create a new partition on");
1070 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1072 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1078 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1084 if (DiskEntry
->DriverName
.Length
> 0)
1087 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1090 DiskEntry
->DiskNumber
,
1094 &DiskEntry
->DriverName
);
1099 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1102 DiskEntry
->DiskNumber
,
1109 SetTextXY (6, 12, "Please enter the size of the new partition in megabytes.");
1112 PrintTextXY (8, 10, "Maximum size of the new partition is %I64u MB",
1113 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1116 SetStatusText (" ENTER = Create Partition ESC = Cancel F3 = Quit");
1118 PartEntry
= PartitionList
->CurrentPartition
;
1121 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1122 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1123 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1126 if (ConfirmQuit (Ir
) == TRUE
)
1131 else if (Cancel
== TRUE
)
1133 return SELECT_PARTITION_PAGE
;
1137 PartSize
= atoi (InputBuffer
);
1144 if (PartSize
> MaxSize
)
1150 /* Convert to bytes */
1151 if (PartSize
== MaxSize
)
1153 /* Use all of the unpartitioned disk space */
1154 PartSize
= PartEntry
->UnpartitionedLength
;
1158 /* Round-up by cylinder size */
1159 PartSize
= ROUND_UP (PartSize
* 1024 * 1024,
1160 DiskEntry
->CylinderSize
);
1162 /* But never get larger than the unpartitioned disk space */
1163 if (PartSize
> PartEntry
->UnpartitionedLength
)
1164 PartSize
= PartEntry
->UnpartitionedLength
;
1167 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1169 CreateNewPartition (PartitionList
,
1173 return SELECT_PARTITION_PAGE
;
1177 return CREATE_PARTITION_PAGE
;
1182 DeletePartitionPage (PINPUT_RECORD Ir
)
1184 PDISKENTRY DiskEntry
;
1185 PPARTENTRY PartEntry
;
1191 if (PartitionList
== NULL
||
1192 PartitionList
->CurrentDisk
== NULL
||
1193 PartitionList
->CurrentPartition
== NULL
)
1195 /* FIXME: show an error dialog */
1199 DiskEntry
= PartitionList
->CurrentDisk
;
1200 PartEntry
= PartitionList
->CurrentPartition
;
1202 SetTextXY (6, 8, "You have chosen to delete the partition");
1204 /* Determine partition type */
1206 if (PartEntry
->New
== TRUE
)
1208 PartType
= "New (Unformatted)";
1210 else if (PartEntry
->Unpartitioned
== FALSE
)
1212 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1213 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1214 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1215 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1219 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1220 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1224 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1226 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1231 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000ULL
) /* 10 GB */
1233 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1238 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0xA00000ULL
) /* 10 MB */
1240 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1245 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1249 if (PartType
== NULL
)
1252 " %c%c Type %lu %I64u %s",
1253 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1254 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1255 PartEntry
->PartInfo
[0].PartitionType
,
1262 " %c%c %s %I64u %s",
1263 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1264 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1271 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1273 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1279 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1285 if (DiskEntry
->DriverName
.Length
> 0)
1288 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1291 DiskEntry
->DiskNumber
,
1295 &DiskEntry
->DriverName
);
1300 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1303 DiskEntry
->DiskNumber
,
1309 SetTextXY (8, 18, "\x07 Press D to delete the partition.");
1310 SetTextXY (11, 19, "WARNING: All data on this partition will be lost!");
1312 SetTextXY (8, 21, "\x07 Press ESC to cancel.");
1314 SetStatusText (" D = Delete Partition ESC = Cancel F3 = Quit");
1320 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1321 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1323 if (ConfirmQuit (Ir
) == TRUE
)
1329 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1331 return SELECT_PARTITION_PAGE
;
1333 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_D
) /* D */
1335 DeleteCurrentPartition (PartitionList
);
1337 return SELECT_PARTITION_PAGE
;
1341 return DELETE_PARTITION_PAGE
;
1346 SelectFileSystemPage (PINPUT_RECORD Ir
)
1348 PDISKENTRY DiskEntry
;
1349 PPARTENTRY PartEntry
;
1350 // BOOLEAN ForceFormat;
1357 if (PartitionList
== NULL
||
1358 PartitionList
->CurrentDisk
== NULL
||
1359 PartitionList
->CurrentPartition
== NULL
)
1361 /* FIXME: show an error dialog */
1365 DiskEntry
= PartitionList
->CurrentDisk
;
1366 PartEntry
= PartitionList
->CurrentPartition
;
1368 /* adjust disk size */
1369 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1371 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1376 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1380 /* adjust partition size */
1381 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000ULL
) /* 10 GB */
1383 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1388 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1392 /* adjust partition type */
1393 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1394 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1395 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1396 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1400 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1401 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1405 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1407 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1409 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
1411 PartType
= "Unused";
1415 PartType
= "Unknown";
1418 if (PartEntry
->AutoCreate
== TRUE
)
1420 SetTextXY(6, 8, "Setup created a new partition on");
1423 PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
1424 PartEntry
->PartInfo
[0].PartitionNumber
,
1430 PrintTextXY(8, 10, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
1431 DiskEntry
->DiskNumber
,
1437 &DiskEntry
->DriverName
);
1439 SetTextXY(6, 12, "This Partition will be formatted next.");
1442 PartEntry
->AutoCreate
= FALSE
;
1444 else if (PartEntry
->New
== TRUE
)
1446 SetTextXY(6, 8, "You chose to install ReactOS on a new or unformatted Partition.");
1447 SetTextXY(6, 10, "This Partition will be formatted next.");
1451 SetTextXY(6, 8, "Setup install ReactOS onto Partition");
1453 if (PartType
== NULL
)
1456 "%c%c Type %lu %I64u %s",
1457 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1458 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1459 PartEntry
->PartInfo
[0].PartitionType
,
1467 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1468 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1474 PrintTextXY(6, 12, "on Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
1475 DiskEntry
->DiskNumber
,
1481 &DiskEntry
->DriverName
);
1485 SetTextXY(6, 17, "Select a file system from the list below.");
1487 SetTextXY(8, 19, "\x07 Press UP or DOWN to select a file system.");
1488 SetTextXY(8, 21, "\x07 Press ENTER to format the partition.");
1489 SetTextXY(8, 23, "\x07 Press ESC to select another partition.");
1491 // ForceFormat = (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED);
1493 if (FileSystemList
== NULL
)
1495 // FileSystemList = CreateFileSystemList (6, 26, ForceFormat, FsFat);
1496 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, FsFat
);
1497 if (FileSystemList
== NULL
)
1499 /* FIXME: show an error dialog */
1503 /* FIXME: Add file systems to list */
1505 DrawFileSystemList (FileSystemList
);
1507 SetStatusText (" ENTER = Continue ESC = Cancel F3 = Quit");
1513 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1514 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1516 if (ConfirmQuit (Ir
) == TRUE
)
1522 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1523 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1525 return SELECT_PARTITION_PAGE
;
1527 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1528 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1530 ScrollDownFileSystemList (FileSystemList
);
1532 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1533 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1535 ScrollUpFileSystemList (FileSystemList
);
1537 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1540 if (FileSystemList
->CurrentFileSystem
== FsKeep
)
1542 return CHECK_FILE_SYSTEM_PAGE
;
1546 return FORMAT_PARTITION_PAGE
;
1549 return FORMAT_PARTITION_PAGE
;
1553 return SELECT_FILE_SYSTEM_PAGE
;
1558 FormatPartitionPage (PINPUT_RECORD Ir
)
1560 PDISKENTRY DiskEntry
;
1561 PPARTENTRY PartEntry
;
1570 SetTextXY(6, 8, "Format partition");
1572 SetTextXY(6, 10, "Setup will now format the partition. Press ENTER to continue.");
1574 SetStatusText(" ENTER = Continue F3 = Quit");
1577 if (PartitionList
== NULL
||
1578 PartitionList
->CurrentDisk
== NULL
||
1579 PartitionList
->CurrentPartition
== NULL
)
1581 /* FIXME: show an error dialog */
1585 DiskEntry
= PartitionList
->CurrentDisk
;
1586 PartEntry
= PartitionList
->CurrentPartition
;
1592 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1593 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1595 if (ConfirmQuit (Ir
) == TRUE
)
1601 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1603 SetStatusText (" Please wait ...");
1605 switch (FileSystemList
->CurrentFileSystem
)
1608 if (DiskEntry
->UseLba
== FALSE
)
1610 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (32ULL * 1024ULL * 1024ULL))
1612 /* FAT16 CHS partition (disk is smaller than 32MB) */
1613 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_16
;
1617 /* FAT16 CHS partition (disk is smaller than 8.4GB) */
1618 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_HUGE
;
1621 else if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (2ULL * 1024ULL * 1024ULL * 1024ULL))
1623 /* FAT16 LBA partition (partition is smaller than 2GB) */
1624 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_XINT13
;
1628 /* FAT32 LBA partition (partition is at least 2GB) */
1629 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32_XINT13
;
1642 "Disk: %I64u Cylinder: %I64u Track: %I64u",
1643 DiskEntry
->DiskSize
,
1644 DiskEntry
->CylinderSize
,
1645 DiskEntry
->TrackSize
);
1648 DiskEntry
= PartitionList
->CurrentDisk
;
1649 Entry
= DiskEntry
->PartListHead
.Flink
;
1650 while (Entry
!= &DiskEntry
->PartListHead
)
1652 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
1654 if (PartEntry
->Unpartitioned
== FALSE
)
1657 for (i
= 0; i
< 4; i
++)
1659 PrintTextXY (6, Line
,
1660 "%u: %u %12I64u %12I64u %u %c",
1662 PartEntry
->PartInfo
[i
].PartitionNumber
,
1663 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
1664 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
1665 PartEntry
->PartInfo
[i
].PartitionType
,
1666 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
1674 Entry
= Entry
->Flink
;
1678 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
1680 DPRINT ("WritePartitionsToDisk() failed\n");
1682 PopupError ("Setup failed to write partition tables.\n",
1683 "ENTER = Reboot computer");
1689 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1696 SetStatusText (" Press any key ...");
1700 switch (FileSystemList
->CurrentFileSystem
)
1703 Status
= FormatPartition (&DestinationRootPath
);
1704 if (!NT_SUCCESS (Status
))
1706 DPRINT1("FormatPartition() failed with status 0x%.08x\n", Status
);
1707 /* FIXME: show an error dialog */
1719 return INSTALL_DIRECTORY_PAGE
;
1722 return SELECT_PARTITION_PAGE
;
1726 return FORMAT_PARTITION_PAGE
;
1731 CheckFileSystemPage(PINPUT_RECORD Ir
)
1733 SetTextXY(6, 8, "Check file system");
1735 SetTextXY(6, 10, "At present, ReactOS can not check file systems.");
1737 SetStatusText(" Please wait ...");
1740 SetStatusText(" ENTER = Continue F3 = Quit");
1746 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1747 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1749 if (ConfirmQuit(Ir
) == TRUE
)
1753 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1755 return(INSTALL_DIRECTORY_PAGE
);
1759 return(CHECK_FILE_SYSTEM_PAGE
);
1764 InstallDirectoryPage(PINPUT_RECORD Ir
)
1766 PDISKENTRY DiskEntry
;
1767 PPARTENTRY PartEntry
;
1768 WCHAR PathBuffer
[MAX_PATH
];
1769 WCHAR InstallDir
[51];
1775 if (PartitionList
== NULL
||
1776 PartitionList
->CurrentDisk
== NULL
||
1777 PartitionList
->CurrentPartition
== NULL
)
1779 /* FIXME: show an error dialog */
1783 DiskEntry
= PartitionList
->CurrentDisk
;
1784 PartEntry
= PartitionList
->CurrentPartition
;
1786 /* Search for 'DefaultPath' in the 'SetupData' section */
1787 if (!InfFindFirstLine (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
1789 PopupError("Setup failed to find the 'SetupData' section\n"
1790 "in TXTSETUP.SIF.\n",
1791 "ENTER = Reboot computer");
1797 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1804 /* Read the 'DefaultPath' data */
1805 if (InfGetData (&Context
, NULL
, &DefaultPath
))
1807 wcscpy(InstallDir
, DefaultPath
);
1811 wcscpy(InstallDir
, L
"\\ReactOS");
1813 Length
= wcslen(InstallDir
);
1815 SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
1816 SetTextXY(6, 9, "directory where you want ReactOS to be installed:");
1818 SetInputTextXY(8, 11, 51, InstallDir
);
1820 SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete");
1821 SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to");
1822 SetTextXY(6, 16, "be installed.");
1824 SetStatusText(" ENTER = Continue F3 = Quit");
1830 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1831 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1833 if (ConfirmQuit(Ir
) == TRUE
)
1837 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1839 /* Create 'InstallPath' string */
1840 RtlFreeUnicodeString(&InstallPath
);
1841 RtlCreateUnicodeString(&InstallPath
,
1844 /* Create 'DestinationPath' string */
1845 RtlFreeUnicodeString(&DestinationPath
);
1847 DestinationRootPath
.Buffer
);
1848 if (InstallDir
[0] != L
'\\')
1851 wcscat(PathBuffer
, InstallDir
);
1852 RtlCreateUnicodeString(&DestinationPath
,
1855 /* Create 'DestinationArcPath' */
1856 RtlFreeUnicodeString(&DestinationArcPath
);
1857 swprintf(PathBuffer
,
1858 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
1859 DiskEntry
->DiskNumber
,
1860 PartEntry
->PartInfo
[0].PartitionNumber
);
1861 if (InstallDir
[0] != L
'\\')
1864 wcscat(PathBuffer
, InstallDir
);
1865 RtlCreateUnicodeString(&DestinationArcPath
,
1868 return(PREPARE_COPY_PAGE
);
1870 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
1875 InstallDir
[Length
] = 0;
1876 SetInputTextXY(8, 11, 51, InstallDir
);
1879 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
1883 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
1885 InstallDir
[Length
] = 0;
1886 SetInputTextXY(8, 11, 51, InstallDir
);
1891 return(INSTALL_DIRECTORY_PAGE
);
1896 PrepareCopyPage(PINPUT_RECORD Ir
)
1898 WCHAR PathBuffer
[MAX_PATH
];
1899 INFCONTEXT FilesContext
;
1900 INFCONTEXT DirContext
;
1907 PWCHAR FileKeyValue
;
1911 SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. ");
1915 * Build the file copy list
1917 SetStatusText(" Building the file copy list...");
1919 /* Search for the 'SourceFiles' section */
1920 if (!InfFindFirstLine (SetupInf
, L
"SourceFiles", NULL
, &FilesContext
))
1922 PopupError("Setup failed to find the 'SourceFiles' section\n"
1923 "in TXTSETUP.SIF.\n",
1924 "ENTER = Reboot computer");
1930 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1938 /* Create the file queue */
1939 SetupFileQueue
= SetupOpenFileQueue();
1940 if (SetupFileQueue
== NULL
)
1942 PopupError("Setup failed to open the copy file queue.\n",
1943 "ENTER = Reboot computer");
1949 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1957 * Enumerate the files in the 'SourceFiles' section
1958 * and add them to the file queue.
1962 if (!InfGetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
1965 DPRINT1("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
1967 /* Lookup target directory */
1968 if (!InfFindFirstLine (SetupInf
, L
"Directories", FileKeyValue
, &DirContext
))
1970 /* FIXME: Handle error! */
1971 DPRINT1("InfFindFirstLine() failed\n");
1975 if (!InfGetData (&DirContext
, NULL
, &DirKeyValue
))
1977 /* FIXME: Handle error! */
1978 DPRINT1("InfGetData() failed\n");
1982 if (!SetupQueueCopy(SetupFileQueue
,
1983 SourceRootPath
.Buffer
,
1989 /* FIXME: Handle error! */
1990 DPRINT1("SetupQueueCopy() failed\n");
1993 while (InfFindNextLine(&FilesContext
, &FilesContext
));
1996 /* Create directories */
1997 SetStatusText(" Creating directories...");
2001 * Install directories like '\reactos\test' are not handled yet.
2004 /* Get destination path */
2005 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2007 /* Remove trailing backslash */
2008 Length
= wcslen(PathBuffer
);
2009 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2011 PathBuffer
[Length
- 1] = 0;
2014 /* Create the install directory */
2015 Status
= CreateDirectory(PathBuffer
);
2016 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2018 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2019 PopupError("Setup could not create the install directory.",
2020 "ENTER = Reboot computer");
2026 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2034 /* Search for the 'Directories' section */
2035 if (!InfFindFirstLine(SetupInf
, L
"Directories", NULL
, &DirContext
))
2037 PopupError("Setup failed to find the 'Directories' section\n"
2038 "in TXTSETUP.SIF.\n",
2039 "ENTER = Reboot computer");
2045 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2052 /* Enumerate the directory values and create the subdirectories */
2055 if (!InfGetData (&DirContext
, NULL
, &KeyValue
))
2058 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2060 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2062 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2063 wcscat(PathBuffer
, KeyValue
);
2065 DPRINT("FullPath: '%S'\n", PathBuffer
);
2067 else if (KeyValue
[0] != L
'\\')
2069 DPRINT("RelativePath: '%S'\n", KeyValue
);
2070 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2071 wcscat(PathBuffer
, L
"\\");
2072 wcscat(PathBuffer
, KeyValue
);
2074 DPRINT("FullPath: '%S'\n", PathBuffer
);
2076 Status
= CreateDirectory(PathBuffer
);
2077 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2079 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2080 PopupError("Setup could not create install directories.",
2081 "ENTER = Reboot computer");
2087 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2095 while (InfFindNextLine (&DirContext
, &DirContext
));
2097 return(FILE_COPY_PAGE
);
2102 FileCopyCallback(PVOID Context
,
2107 PCOPYCONTEXT CopyContext
;
2109 CopyContext
= (PCOPYCONTEXT
)Context
;
2111 switch (Notification
)
2113 case SPFILENOTIFY_STARTSUBQUEUE
:
2114 CopyContext
->TotalOperations
= (ULONG
)Param2
;
2115 ProgressSetStepCount(CopyContext
->ProgressBar
,
2116 CopyContext
->TotalOperations
);
2119 case SPFILENOTIFY_STARTCOPY
:
2120 /* Display copy message */
2121 PrintTextXYN(6, 16, 60, "Copying file: %S", (PWSTR
)Param1
);
2123 PrintTextXYN(6, 18, 60, "File %lu of %lu",
2124 CopyContext
->CompletedOperations
+ 1,
2125 CopyContext
->TotalOperations
);
2128 case SPFILENOTIFY_ENDCOPY
:
2129 CopyContext
->CompletedOperations
++;
2130 ProgressNextStep(CopyContext
->ProgressBar
);
2139 FileCopyPage(PINPUT_RECORD Ir
)
2141 COPYCONTEXT CopyContext
;
2145 SetStatusText(" Please wait...");
2147 SetTextXY(6, 8, "Copying files");
2149 GetScreenSize(&xScreen
, &yScreen
);
2151 CopyContext
.TotalOperations
= 0;
2152 CopyContext
.CompletedOperations
= 0;
2153 CopyContext
.ProgressBar
= CreateProgressBar(6,
2158 SetupCommitFileQueue(SetupFileQueue
,
2159 DestinationRootPath
.Buffer
,
2161 (PSP_FILE_CALLBACK
)FileCopyCallback
,
2164 SetupCloseFileQueue(SetupFileQueue
);
2166 DestroyProgressBar(CopyContext
.ProgressBar
);
2168 return(REGISTRY_PAGE
);
2173 RegistryPage(PINPUT_RECORD Ir
)
2175 INFCONTEXT InfContext
;
2184 SetTextXY(6, 8, "Setup is updating the system configuration");
2186 SetStatusText(" Creating registry hives...");
2188 if (!SetInstallPathValue(&DestinationPath
))
2190 DPRINT("SetInstallPathValue() failed\n");
2191 PopupError("Setup failed to set the initialize the registry.",
2192 "ENTER = Reboot computer");
2198 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2205 /* Create the default hives */
2206 Status
= NtInitializeRegistry(TRUE
);
2207 if (!NT_SUCCESS(Status
))
2209 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
2210 PopupError("Setup failed to create the registry hives.",
2211 "ENTER = Reboot computer");
2217 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2224 /* Update registry */
2225 SetStatusText(" Updating registry hives...");
2227 if (!InfFindFirstLine(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
2229 DPRINT1("InfFindFirstLine() failed\n");
2230 PopupError("Setup failed to find the registry data files.",
2231 "ENTER = Reboot computer");
2237 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2246 InfGetDataField (&InfContext
, 0, &Action
);
2247 InfGetDataField (&InfContext
, 1, &File
);
2248 InfGetDataField (&InfContext
, 2, &Section
);
2250 DPRINT1("Action: %S File: %S Section %S\n", Action
, File
, Section
);
2252 if (!_wcsicmp (Action
, L
"AddReg"))
2256 else if (!_wcsicmp (Action
, L
"DelReg"))
2265 SetStatusText(" Importing %S...", File
);
2267 if (!ImportRegistryFile(File
, Section
, Delete
))
2269 DPRINT1("Importing %S failed\n", File
);
2271 PopupError("Setup failed to import a hive file.",
2272 "ENTER = Reboot computer");
2278 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2285 while (InfFindNextLine (&InfContext
, &InfContext
));
2287 SetStatusText(" Done...");
2289 return(BOOT_LOADER_PAGE
);
2294 BootLoaderPage(PINPUT_RECORD Ir
)
2296 WCHAR SrcPath
[MAX_PATH
];
2297 WCHAR DstPath
[MAX_PATH
];
2299 PINICACHESECTION IniSection
;
2301 BOOLEAN InstallMBR
= FALSE
;
2303 SetTextXY(6, 8, "Installing the boot loader");
2305 SetStatusText(" Please wait...");
2308 if (ActivePartitionValid
== FALSE
)
2310 /* Mark the chosen partition as active since there is no active
2313 if (!MarkPartitionActive(PartData
.DiskNumber
,
2314 PartData
.PartNumber
, &ActivePartition
))
2316 PopupError("Setup could not mark the system partiton active\n",
2317 "ENTER = Reboot computer");
2323 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2334 WCHAR PathBuffer
[MAX_PATH
];
2335 UNICODE_STRING SystemRootMBRPath
;
2337 RtlFreeUnicodeString(&SystemRootMBRPath
);
2338 swprintf(PathBuffer
,
2339 L
"\\Device\\Harddisk%lu\\Partition0",
2340 PartData
.DiskNumber
);
2341 RtlCreateUnicodeString(&SystemRootMBRPath
,
2344 /* Install MBR bootcode */
2345 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2346 wcscat(SrcPath
, L
"\\loader\\dosmbr.bin");
2348 DPRINT1("Install MBR bootcode: %S ==> %S\n", SrcPath
, SystemRootMBRPath
.Buffer
);
2349 Status
= InstallMBRBootCodeToDisk(SrcPath
,
2350 SystemRootMBRPath
.Buffer
);
2351 if (!NT_SUCCESS(Status
))
2353 DPRINT1("InstallMBRBootCodeToDisk() failed (Status %lx)\n", Status
);
2354 PopupError("Setup failed to install the MBR bootcode.",
2355 "ENTER = Reboot computer");
2361 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2370 if (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
2372 DPRINT1("Error: active partition invalid (unused)\n");
2373 PopupError("The active partition is unused (invalid).\n",
2374 "ENTER = Reboot computer");
2380 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2387 if (ActiveBootPartition
->PartInfo
[0].PartitionType
== 0x0A)
2389 /* OS/2 boot manager partition */
2390 DPRINT1("Found OS/2 boot manager partition\n");
2391 PopupError("Setup found an OS/2 boot manager partiton.\n"
2392 "The OS/2 boot manager is not supported yet!",
2393 "ENTER = Reboot computer");
2399 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2405 else if (ActiveBootPartition
->PartInfo
[0].PartitionType
== 0x83)
2407 /* Linux ext2 partition */
2408 DPRINT1("Found Linux ext2 partition\n");
2409 PopupError("Setup found a Linux ext2 partiton.\n"
2410 "Linux ext2 partitions are not supported yet!",
2411 "ENTER = Reboot computer");
2417 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2423 else if (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
2425 /* NTFS partition */
2426 DPRINT1("Found NTFS partition\n");
2427 PopupError("Setup found an NTFS partiton.\n"
2428 "NTFS partitions are not supported yet!",
2429 "ENTER = Reboot computer");
2435 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2441 else if ((ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
2442 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
2443 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
2444 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_XINT13
) ||
2445 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2446 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2448 /* FAT or FAT32 partition */
2449 DPRINT1("System path: '%wZ'\n", &SystemRootPath
);
2451 if (DoesFileExist(SystemRootPath
.Buffer
, L
"ntldr") == TRUE
||
2452 DoesFileExist(SystemRootPath
.Buffer
, L
"boot.ini") == TRUE
)
2454 /* Search root directory for 'ntldr' and 'boot.ini'. */
2455 DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
2457 /* Copy FreeLoader to the boot partition */
2458 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2459 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2460 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2461 wcscat(DstPath
, L
"\\freeldr.sys");
2463 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2464 Status
= SetupCopyFile(SrcPath
, DstPath
);
2465 if (!NT_SUCCESS(Status
))
2467 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2468 PopupError("Setup failed to copy 'freeldr.sys'.",
2469 "ENTER = Reboot computer");
2475 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2482 /* Create or update freeldr.ini */
2483 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2485 /* Create new 'freeldr.ini' */
2486 DPRINT1("Create new 'freeldr.ini'\n");
2487 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2488 wcscat(DstPath
, L
"\\freeldr.ini");
2490 Status
= CreateFreeLoaderIniForReactos(DstPath
,
2491 DestinationArcPath
.Buffer
);
2492 if (!NT_SUCCESS(Status
))
2494 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
2495 PopupError("Setup failed to create 'freeldr.ini'.",
2496 "ENTER = Reboot computer");
2502 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2509 /* Install new bootcode */
2510 if ((ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2511 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2513 /* Install FAT32 bootcode */
2514 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2515 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2516 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2517 wcscat(DstPath
, L
"\\bootsect.ros");
2519 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, DstPath
);
2520 Status
= InstallFat32BootCodeToFile(SrcPath
,
2522 SystemRootPath
.Buffer
);
2523 if (!NT_SUCCESS(Status
))
2525 DPRINT1("InstallFat32BootCodeToFile() failed (Status %lx)\n", Status
);
2526 PopupError("Setup failed to install the FAT32 bootcode.",
2527 "ENTER = Reboot computer");
2533 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2542 /* Install FAT16 bootcode */
2543 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2544 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2545 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2546 wcscat(DstPath
, L
"\\bootsect.ros");
2548 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, DstPath
);
2549 Status
= InstallFat16BootCodeToFile(SrcPath
,
2551 SystemRootPath
.Buffer
);
2552 if (!NT_SUCCESS(Status
))
2554 DPRINT1("InstallFat16BootCodeToFile() failed (Status %lx)\n", Status
);
2555 PopupError("Setup failed to install the FAT bootcode.",
2556 "ENTER = Reboot computer");
2562 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2570 /* Update 'boot.ini' */
2571 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2572 wcscat(DstPath
, L
"\\boot.ini");
2574 DPRINT1("Update 'boot.ini': %S\n", DstPath
);
2575 Status
= UpdateBootIni(DstPath
,
2576 L
"C:\\bootsect.ros",
2578 if (!NT_SUCCESS(Status
))
2580 DPRINT1("UpdateBootIni() failed (Status %lx)\n", Status
);
2581 PopupError("Setup failed to update \'boot.ini\'.",
2582 "ENTER = Reboot computer");
2588 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2597 /* Update existing 'freeldr.ini' */
2598 DPRINT1("Update existing 'freeldr.ini'\n");
2599 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2600 wcscat(DstPath
, L
"\\freeldr.ini");
2602 Status
= UpdateFreeLoaderIni(DstPath
,
2603 DestinationArcPath
.Buffer
);
2604 if (!NT_SUCCESS(Status
))
2606 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
2607 PopupError("Setup failed to update 'freeldr.ini'.",
2608 "ENTER = Reboot computer");
2614 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2622 else if (DoesFileExist(SystemRootPath
.Buffer
, L
"io.sys") == TRUE
||
2623 DoesFileExist(SystemRootPath
.Buffer
, L
"msdos.sys") == TRUE
)
2625 /* Search for root directory for 'io.sys' and 'msdos.sys'. */
2626 DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
2628 /* Copy FreeLoader to the boot partition */
2629 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2630 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2631 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2632 wcscat(DstPath
, L
"\\freeldr.sys");
2634 DPRINT("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2635 Status
= SetupCopyFile(SrcPath
, DstPath
);
2636 if (!NT_SUCCESS(Status
))
2638 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2639 PopupError("Setup failed to copy 'freeldr.sys'.",
2640 "ENTER = Reboot computer");
2646 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2653 /* Create or update 'freeldr.ini' */
2654 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2656 /* Create new 'freeldr.ini' */
2657 DPRINT1("Create new 'freeldr.ini'\n");
2658 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2659 wcscat(DstPath
, L
"\\freeldr.ini");
2661 Status
= CreateFreeLoaderIniForDos(DstPath
,
2662 DestinationArcPath
.Buffer
);
2663 if (!NT_SUCCESS(Status
))
2665 DPRINT1("CreateFreeLoaderIniForDos() failed (Status %lx)\n", Status
);
2666 PopupError("Setup failed to create 'freeldr.ini'.",
2667 "ENTER = Reboot computer");
2673 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2680 /* Save current bootsector as 'BOOTSECT.DOS' */
2681 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
2682 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2683 wcscat(DstPath
, L
"\\bootsect.dos");
2685 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
2686 Status
= SaveCurrentBootSector(SrcPath
,
2688 if (!NT_SUCCESS(Status
))
2690 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
2691 PopupError("Setup failed to save the current bootsector.",
2692 "ENTER = Reboot computer");
2698 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2705 /* Install new bootsector */
2706 if ((ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2707 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2709 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2710 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2712 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2713 Status
= InstallFat32BootCodeToDisk(SrcPath
,
2714 SystemRootPath
.Buffer
);
2715 if (!NT_SUCCESS(Status
))
2717 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
2718 PopupError("Setup failed to install the FAT32 bootcode.",
2719 "ENTER = Reboot computer");
2725 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2734 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2735 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2737 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2738 Status
= InstallFat16BootCodeToDisk(SrcPath
,
2739 SystemRootPath
.Buffer
);
2740 if (!NT_SUCCESS(Status
))
2742 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
2743 PopupError("Setup failed to install the FAT bootcode.",
2744 "ENTER = Reboot computer");
2750 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2760 /* Update existing 'freeldr.ini' */
2761 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2762 wcscat(DstPath
, L
"\\freeldr.ini");
2764 Status
= UpdateFreeLoaderIni(DstPath
,
2765 DestinationArcPath
.Buffer
);
2766 if (!NT_SUCCESS(Status
))
2768 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
2769 PopupError("Setup failed to update 'freeldr.ini'.",
2770 "ENTER = Reboot computer");
2776 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2786 /* No or unknown boot loader */
2787 DPRINT1("No or unknown boot loader found\n");
2789 /* Copy FreeLoader to the boot partition */
2790 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2791 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2792 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2793 wcscat(DstPath
, L
"\\freeldr.sys");
2795 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2796 Status
= SetupCopyFile(SrcPath
, DstPath
);
2797 if (!NT_SUCCESS(Status
))
2799 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2800 PopupError("Setup failed to copy 'freeldr.sys'.",
2801 "ENTER = Reboot computer");
2807 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2814 /* Create or update 'freeldr.ini' */
2815 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2817 /* Create new freeldr.ini */
2818 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2819 wcscat(DstPath
, L
"\\freeldr.ini");
2821 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2822 Status
= CreateFreeLoaderIniForReactos(DstPath
,
2823 DestinationArcPath
.Buffer
);
2824 if (!NT_SUCCESS(Status
))
2826 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
2827 PopupError("Setup failed to create \'freeldr.ini\'.",
2828 "ENTER = Reboot computer");
2834 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2841 /* Save current bootsector as 'BOOTSECT.OLD' */
2842 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
2843 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2844 wcscat(DstPath
, L
"\\bootsect.old");
2846 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
2847 Status
= SaveCurrentBootSector(SrcPath
,
2849 if (!NT_SUCCESS(Status
))
2851 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
2852 PopupError("Setup failed save the current bootsector.",
2853 "ENTER = Reboot computer");
2859 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2866 /* Install new bootsector */
2867 if ((ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2868 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2870 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2871 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2873 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2874 Status
= InstallFat32BootCodeToDisk(SrcPath
,
2875 SystemRootPath
.Buffer
);
2876 if (!NT_SUCCESS(Status
))
2878 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
2879 PopupError("Setup failed to install the FAT32 bootcode.",
2880 "ENTER = Reboot computer");
2886 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2895 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2896 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2898 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2899 Status
= InstallFat16BootCodeToDisk(SrcPath
,
2900 SystemRootPath
.Buffer
);
2901 if (!NT_SUCCESS(Status
))
2903 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
2904 PopupError("Setup failed to install the FAT bootcode.",
2905 "ENTER = Reboot computer");
2911 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2921 /* Update existing 'freeldr.ini' */
2922 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2923 wcscat(DstPath
, L
"\\freeldr.ini");
2925 Status
= UpdateFreeLoaderIni(DstPath
,
2926 DestinationArcPath
.Buffer
);
2927 if (!NT_SUCCESS(Status
))
2929 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
2930 PopupError("Setup failed to update 'freeldr.ini'.",
2931 "ENTER = Reboot computer");
2937 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2948 /* Unknown partition */
2949 DPRINT1("Unknown partition found\n");
2950 PopupError("Setup found an unknown partiton type.\n"
2951 "This partition type is not supported!",
2952 "ENTER = Reboot computer");
2958 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2965 return(SUCCESS_PAGE
);
2971 QuitPage(PINPUT_RECORD Ir
)
2973 SetTextXY(10, 6, "ReactOS is not completely installed");
2975 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2976 SetTextXY(10, 9, "all CD-ROMs from CD-Drives.");
2978 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2980 SetStatusText(" Please wait ...");
2982 /* Destroy partition list */
2983 if (PartitionList
!= NULL
)
2985 DestroyPartitionList (PartitionList
);
2986 PartitionList
= NULL
;
2989 /* Destroy filesystem list */
2990 if (FileSystemList
!= NULL
)
2992 DestroyFileSystemList (FileSystemList
);
2993 FileSystemList
= NULL
;
2996 SetStatusText(" ENTER = Reboot computer");
3002 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3004 return(REBOOT_PAGE
);
3011 SuccessPage(PINPUT_RECORD Ir
)
3013 SetTextXY(10, 6, "The basic components of ReactOS have been installed successfully.");
3015 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
3016 SetTextXY(10, 9, "all CD-ROMs from CD-Drive.");
3018 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
3020 SetStatusText(" ENTER = Reboot computer");
3026 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3028 return(REBOOT_PAGE
);
3035 NtProcessStartup(PPEB Peb
)
3041 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3043 ProcessHeap
= Peb
->ProcessHeap
;
3045 Status
= AllocConsole();
3046 if (!NT_SUCCESS(Status
))
3048 PrintString("AllocConsole() failed (Status = 0x%08lx)\n", Status
);
3050 /* Raise a hard error (crash the system/BSOD) */
3051 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3056 /* Initialize global unicode strings */
3057 RtlInitUnicodeString(&SourcePath
, NULL
);
3058 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3059 RtlInitUnicodeString(&InstallPath
, NULL
);
3060 RtlInitUnicodeString(&DestinationPath
, NULL
);
3061 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3062 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3063 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3067 while (Page
!= REBOOT_PAGE
)
3071 SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR
" Setup ");
3077 Page
= StartPage(&Ir
);
3082 Page
= IntroPage(&Ir
);
3086 case INSTALL_INTRO_PAGE
:
3087 Page
= InstallIntroPage(&Ir
);
3091 case OEM_DRIVER_PAGE
:
3092 Page
= OemDriverPage(&Ir
);
3097 case DEVICE_SETTINGS_PAGE
:
3100 case SELECT_PARTITION_PAGE
:
3101 Page
= SelectPartitionPage(&Ir
);
3104 case CREATE_PARTITION_PAGE
:
3105 Page
= CreatePartitionPage(&Ir
);
3108 case DELETE_PARTITION_PAGE
:
3109 Page
= DeletePartitionPage(&Ir
);
3112 case SELECT_FILE_SYSTEM_PAGE
:
3113 Page
= SelectFileSystemPage(&Ir
);
3116 case FORMAT_PARTITION_PAGE
:
3117 Page
= FormatPartitionPage(&Ir
);
3120 case CHECK_FILE_SYSTEM_PAGE
:
3121 Page
= CheckFileSystemPage(&Ir
);
3124 case INSTALL_DIRECTORY_PAGE
:
3125 Page
= InstallDirectoryPage(&Ir
);
3128 case PREPARE_COPY_PAGE
:
3129 Page
= PrepareCopyPage(&Ir
);
3132 case FILE_COPY_PAGE
:
3133 Page
= FileCopyPage(&Ir
);
3137 Page
= RegistryPage(&Ir
);
3140 case BOOT_LOADER_PAGE
:
3141 Page
= BootLoaderPage(&Ir
);
3146 case REPAIR_INTRO_PAGE
:
3147 Page
= RepairIntroPage(&Ir
);
3151 /* Emergency pages */
3152 case EMERGENCY_INTRO_PAGE
:
3153 Page
= EmergencyIntroPage(&Ir
);
3158 Page
= SuccessPage(&Ir
);
3162 Page
= QuitPage(&Ir
);
3169 NtShutdownSystem(ShutdownReboot
);