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"
48 typedef enum _PAGE_NUMBER
54 SELECT_PARTITION_PAGE
,
55 CREATE_PARTITION_PAGE
,
56 DELETE_PARTITION_PAGE
,
58 SELECT_FILE_SYSTEM_PAGE
,
59 FORMAT_PARTITION_PAGE
,
60 CHECK_FILE_SYSTEM_PAGE
,
63 INSTALL_DIRECTORY_PAGE
,
74 REBOOT_PAGE
, /* virtual page */
75 } PAGE_NUMBER
, *PPAGE_NUMBER
;
77 typedef struct _COPYCONTEXT
79 ULONG TotalOperations
;
80 ULONG CompletedOperations
;
81 PPROGRESS ProgressBar
;
82 } COPYCONTEXT
, *PCOPYCONTEXT
;
85 /* GLOBALS ******************************************************************/
88 UNICODE_STRING SourceRootPath
;
91 /* LOCALS *******************************************************************/
93 static PPARTLIST PartitionList
= NULL
;
95 static PDISKENTRY ActiveBootDisk
= NULL
;
96 static PPARTENTRY ActiveBootPartition
= NULL
;
98 static PFILE_SYSTEM_LIST FileSystemList
= NULL
;
101 static UNICODE_STRING SourcePath
;
103 static UNICODE_STRING InstallPath
;
105 /* Path to the install directory */
106 static UNICODE_STRING DestinationPath
;
107 static UNICODE_STRING DestinationArcPath
;
108 static UNICODE_STRING DestinationRootPath
;
110 /* Path to the active partition (boot manager) */
111 static UNICODE_STRING SystemRootPath
;
113 static HINF SetupInf
;
115 static HSPFILEQ SetupFileQueue
= NULL
;
118 /* FUNCTIONS ****************************************************************/
121 PrintString(char* fmt
,...)
125 UNICODE_STRING UnicodeString
;
126 ANSI_STRING AnsiString
;
129 vsprintf(buffer
, fmt
, ap
);
132 RtlInitAnsiString(&AnsiString
, buffer
);
133 RtlAnsiStringToUnicodeString(&UnicodeString
,
136 NtDisplayString(&UnicodeString
);
137 RtlFreeUnicodeString(&UnicodeString
);
142 PopupError(PCHAR Text
,
160 /* Count text lines and longest line */
166 p
= strchr(pnext
, '\n');
169 Length
= strlen(pnext
);
174 Length
= (ULONG
)(p
- pnext
);
179 if (Length
> MaxLength
)
182 if (LastLine
== TRUE
)
188 /* Check length of status line */
191 Length
= strlen(Status
);
192 if (Length
> MaxLength
)
196 GetScreenSize(&xScreen
, &yScreen
);
198 Width
= MaxLength
+ 4;
203 yTop
= (yScreen
- Height
) / 2;
204 xLeft
= (xScreen
- Width
) / 2;
207 /* Set screen attributes */
209 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
211 FillConsoleOutputAttribute(0x74,
217 /* draw upper left corner */
220 FillConsoleOutputCharacter(0xDA, // '+',
225 /* draw upper edge */
228 FillConsoleOutputCharacter(0xC4, // '-',
233 /* draw upper right corner */
234 coPos
.X
= xLeft
+ Width
- 1;
236 FillConsoleOutputCharacter(0xBF, // '+',
241 /* Draw right edge, inner space and left edge */
242 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
245 FillConsoleOutputCharacter(0xB3, // '|',
251 FillConsoleOutputCharacter(' ',
256 coPos
.X
= xLeft
+ Width
- 1;
257 FillConsoleOutputCharacter(0xB3, // '|',
263 /* draw lower left corner */
265 coPos
.Y
= yTop
+ Height
- 1;
266 FillConsoleOutputCharacter(0xC0, // '+',
271 /* draw lower edge */
273 coPos
.Y
= yTop
+ Height
- 1;
274 FillConsoleOutputCharacter(0xC4, // '-',
279 /* draw lower right corner */
280 coPos
.X
= xLeft
+ Width
- 1;
281 coPos
.Y
= yTop
+ Height
- 1;
282 FillConsoleOutputCharacter(0xD9, // '+',
287 /* Print message text */
292 p
= strchr(pnext
, '\n');
295 Length
= strlen(pnext
);
300 Length
= (ULONG
)(p
- pnext
);
307 WriteConsoleOutputCharacters(pnext
,
312 if (LastLine
== TRUE
)
319 /* Print separator line and status text */
322 coPos
.Y
= yTop
+ Height
- 3;
324 FillConsoleOutputCharacter(0xC3, // '+',
330 FillConsoleOutputCharacter(0xC4, // '-',
335 coPos
.X
= xLeft
+ Width
- 1;
336 FillConsoleOutputCharacter(0xB4, // '+',
343 WriteConsoleOutputCharacters(Status
,
344 min(strlen(Status
), Width
- 4),
354 * FALSE: Don't quit setup.
357 ConfirmQuit(PINPUT_RECORD Ir
)
361 PopupError("ReactOS is not completely installed on your\n"
362 "computer. If you quit Setup now, you will need to\n"
363 "run Setup again to install ReactOS.\n"
365 " \x07 Press ENTER to continue Setup.\n"
366 " \x07 Press F3 to quit Setup.",
367 "F3= Quit ENTER = Continue");
373 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
374 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
379 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
394 * Number of the next page.
397 StartPage(PINPUT_RECORD Ir
)
400 WCHAR FileNameBuffer
[MAX_PATH
];
401 UNICODE_STRING FileName
;
406 SetStatusText(" Please wait...");
408 Status
= GetSourcePaths(&SourcePath
,
410 if (!NT_SUCCESS(Status
))
412 PrintTextXY(6, 15, "GetSourcePath() failed (Status 0x%08lx)", Status
);
413 PopupError("Setup could not find its source drive.\n",
414 "ENTER = Reboot computer");
419 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
428 PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
429 PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
433 /* Load txtsetup.sif from install media. */
434 wcscpy(FileNameBuffer
, SourceRootPath
.Buffer
);
435 wcscat(FileNameBuffer
, L
"\\reactos\\txtsetup.sif");
436 RtlInitUnicodeString(&FileName
,
439 Status
= InfOpenFile(&SetupInf
,
442 if (!NT_SUCCESS(Status
))
444 PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
445 "ENTER = Reboot computer");
451 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
458 /* Open 'Version' section */
459 if (!InfFindFirstLine (SetupInf
, L
"Version", L
"Signature", &Context
))
461 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
462 "ENTER = Reboot computer");
468 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
476 /* Get pointer 'Signature' key */
477 if (!InfGetData (&Context
, NULL
, &Value
))
479 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
480 "ENTER = Reboot computer");
486 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
493 /* Check 'Signature' string */
494 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
496 PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
497 "ENTER = Reboot computer");
503 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
520 IntroPage(PINPUT_RECORD Ir
)
522 SetHighlightedTextXY(6, 8, "Welcome to ReactOS Setup");
524 SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your");
525 SetTextXY(6, 12, "computer and prepares the second part of the setup.");
527 SetTextXY(8, 15, "\x07 Press ENTER to install ReactOS.");
529 SetTextXY(8, 17, "\x07 Press E to start the emergency console.");
531 SetTextXY(8, 19, "\x07 Press R to repair ReactOS.");
533 SetTextXY(8, 21, "\x07 Press F3 to quit without installing ReactOS.");
536 SetStatusText(" ENTER = Continue F3 = Quit");
542 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
543 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
545 if (ConfirmQuit(Ir
) == TRUE
)
549 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
551 return(INSTALL_INTRO_PAGE
);
553 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'E') /* E */
555 return(EMERGENCY_INTRO_PAGE
);
557 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
559 return(REPAIR_INTRO_PAGE
);
568 EmergencyIntroPage(PINPUT_RECORD Ir
)
570 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
571 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
573 SetTextXY(6, 12, "The emergency console is not implemented yet.");
575 SetTextXY(8, 15, "\x07 Press ESC to return to the main page.");
577 SetTextXY(8, 17, "\x07 Press ENTER to reboot your computer.");
579 SetStatusText(" ESC = Main page ENTER = Reboot");
585 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
589 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
590 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
596 return(REPAIR_INTRO_PAGE
);
601 RepairIntroPage(PINPUT_RECORD Ir
)
603 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
604 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
606 SetTextXY(6, 12, "The repair functions are not implemented yet.");
608 SetTextXY(8, 15, "\x07 Press ESC to return to the main page.");
610 SetTextXY(8, 17, "\x07 Press ENTER to reboot your computer.");
612 SetStatusText(" ESC = Main page ENTER = Reboot");
618 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
622 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
623 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
629 return(REPAIR_INTRO_PAGE
);
634 InstallIntroPage(PINPUT_RECORD Ir
)
636 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
637 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
639 SetTextXY(6, 12, "The following functions are missing:");
640 SetTextXY(8, 13, "- Creating and deleting harddisk partitions.");
641 SetTextXY(8, 14, "- Formatting partitions.");
642 SetTextXY(8, 15, "- Support for non-FAT file systems.");
643 SetTextXY(8, 16, "- Checking file systems.");
647 SetTextXY(8, 21, "\x07 Press ENTER to install ReactOS.");
649 SetTextXY(8, 23, "\x07 Press F3 to quit without installing ReactOS.");
652 SetStatusText(" ENTER = Continue F3 = Quit");
658 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
659 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
661 if (ConfirmQuit(Ir
) == TRUE
)
665 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
667 return(SELECT_PARTITION_PAGE
);
671 return(INSTALL_INTRO_PAGE
);
676 SelectPartitionPage(PINPUT_RECORD Ir
)
678 WCHAR PathBuffer
[MAX_PATH
];
682 SetTextXY(6, 8, "The list below shows existing partitions and unused disk");
683 SetTextXY(6, 9, "space for new partitions.");
685 SetTextXY(8, 11, "\x07 Press UP or DOWN to select a list entry.");
686 SetTextXY(8, 13, "\x07 Press ENTER to install ReactOS onto the selected partition.");
687 SetTextXY(8, 15, "\x07 Press C to create a new partition.");
688 SetTextXY(8, 17, "\x07 Press D to delete an existing partition.");
690 SetStatusText(" Please wait...");
692 RtlFreeUnicodeString(&DestinationPath
);
693 RtlFreeUnicodeString(&DestinationRootPath
);
695 GetScreenSize(&xScreen
, &yScreen
);
697 if (PartitionList
== NULL
)
699 PartitionList
= CreatePartitionList (2,
703 if (PartitionList
== NULL
)
705 /* FIXME: show an error dialog */
711 DrawPartitionList (PartitionList
);
716 /* Update status text */
717 if (PartitionList
->CurrentPartition
== NULL
||
718 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
721 SetStatusText (" ENTER = Install C = Create Partition F3 = Quit");
723 SetStatusText (" C = Create Partition F3 = Quit");
727 SetStatusText (" ENTER = Install D = Delete Partition F3 = Quit");
732 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
733 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
735 if (ConfirmQuit(Ir
) == TRUE
)
737 DestroyPartitionList (PartitionList
);
738 PartitionList
= NULL
;
743 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
744 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
746 ScrollDownPartitionList (PartitionList
);
748 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
749 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
751 ScrollUpPartitionList (PartitionList
);
753 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
755 if (PartitionList
->CurrentPartition
== NULL
||
756 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
758 PopupError ("You can not install ReactOS on\n"
759 "unpartitioned disk space!\n"
761 " * Press any key to select an other partition.",
765 return SELECT_PARTITION_PAGE
;
769 RtlFreeUnicodeString (&DestinationRootPath
);
770 swprintf (PathBuffer
,
771 L
"\\Device\\Harddisk%lu\\Partition%lu",
772 PartitionList
->CurrentDisk
->DiskNumber
,
773 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
774 RtlCreateUnicodeString (&DestinationRootPath
,
777 GetActiveBootPartition (PartitionList
,
779 &ActiveBootPartition
);
781 RtlFreeUnicodeString (&SystemRootPath
);
782 if (ActiveBootDisk
!= NULL
&& ActiveBootPartition
!= NULL
)
784 swprintf (PathBuffer
,
785 L
"\\Device\\Harddisk%lu\\Partition%lu",
786 ActiveBootDisk
->DiskNumber
,
787 ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
793 * Check whether partition can be activated.
794 * We may have to force Disk0\Partition1.
795 * Mark partition active.
797 swprintf (PathBuffer
,
798 L
"\\Device\\Harddisk%lu\\Partition%lu",
799 PartitionList
->CurrentDisk
->DiskNumber
,
800 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
802 RtlCreateUnicodeString (&SystemRootPath
,
805 DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
806 DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath
);
809 PopupError ("You chose to install ReactOS on\n"
810 "a valid Partition.\n"
812 " * Press any key to continue.",
816 return SELECT_PARTITION_PAGE
;
818 return SELECT_FILE_SYSTEM_PAGE
;
821 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_C
) /* C */
823 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
825 PopupError ("You can not create a new Partition inside\n"
826 "of an already existing Partition!\n"
828 " * Press any key to continue.",
832 return SELECT_PARTITION_PAGE
;
835 return CREATE_PARTITION_PAGE
;
837 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_D
) /* D */
839 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
841 PopupError ("You can not delete unpartitioned disk space!\n"
843 " * Press any key to continue.",
847 return SELECT_PARTITION_PAGE
;
850 return DELETE_PARTITION_PAGE
;
854 return SELECT_PARTITION_PAGE
;
859 DrawInputField(ULONG FieldLength
,
869 memset(buf
, '_', sizeof(buf
));
870 buf
[FieldLength
- strlen(FieldContent
)] = 0;
871 strcat(buf
, FieldContent
);
873 WriteConsoleOutputCharacters (buf
,
879 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
882 ShowPartitionSizeInputBox(SHORT Left
,
907 /* draw upper left corner */
910 FillConsoleOutputCharacter(0xDA, // '+',
915 /* draw upper edge */
918 FillConsoleOutputCharacter(0xC4, // '-',
923 /* draw upper right corner */
926 FillConsoleOutputCharacter(0xBF, // '+',
931 /* draw left and right edge */
932 for (i
= Top
+ 1; i
< Bottom
; i
++)
936 FillConsoleOutputCharacter(0xB3, // '|',
942 FillConsoleOutputCharacter(0xB3, //'|',
948 /* draw lower left corner */
951 FillConsoleOutputCharacter(0xC0, // '+',
956 /* draw lower edge */
959 FillConsoleOutputCharacter(0xC4, // '-',
964 /* draw lower right corner */
967 FillConsoleOutputCharacter(0xD9, // '+',
975 strcpy (Buffer
, "Size of new partition:");
976 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
978 WriteConsoleOutputCharacters (Buffer
,
982 sprintf (Buffer
, "MB (max. %d MB)", MaxSize
);
983 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
985 WriteConsoleOutputCharacters (Buffer
,
991 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1000 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1001 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1008 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1012 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
1019 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
1024 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1029 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
1030 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
1032 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
1033 if ((ch
>= '0') && (ch
<= '9'))
1038 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
1046 strcpy (InputBuffer
,
1052 CreatePartitionPage (PINPUT_RECORD Ir
)
1054 WCHAR PathBuffer
[MAX_PATH
];
1055 PDISKENTRY DiskEntry
;
1056 PPARTENTRY PartEntry
;
1062 CHAR InputBuffer
[50];
1069 if (PartitionList
== NULL
||
1070 PartitionList
->CurrentDisk
== NULL
||
1071 PartitionList
->CurrentPartition
== NULL
)
1073 /* FIXME: show an error dialog */
1077 DiskEntry
= PartitionList
->CurrentDisk
;
1078 PartEntry
= PartitionList
->CurrentPartition
;
1080 SetStatusText (" Please wait...");
1082 GetScreenSize (&xScreen
, &yScreen
);
1084 SetTextXY (6, 8, "You have chosen to create a new partition on");
1087 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1089 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1095 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1101 if (DiskEntry
->DriverName
.Length
> 0)
1104 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1107 DiskEntry
->DiskNumber
,
1111 &DiskEntry
->DriverName
);
1116 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1119 DiskEntry
->DiskNumber
,
1126 SetTextXY (6, 12, "Please enter the size of the new partition in megabytes.");
1129 PrintTextXY (8, 10, "Maximum size of the new partition is %I64u MB",
1130 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1133 SetStatusText (" ENTER = Create Partition ESC = Cancel F3 = Quit");
1135 PartEntry
= PartitionList
->CurrentPartition
;
1138 // MaxSize = PartEntry->UnpartitionedLength / (1024 * 1024); /* in MBytes */
1139 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1140 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1141 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1144 if (ConfirmQuit (Ir
) == TRUE
)
1149 else if (Cancel
== TRUE
)
1151 return SELECT_PARTITION_PAGE
;
1155 PartSize
= atoi(InputBuffer
);
1162 if (PartSize
> MaxSize
)
1168 /* Convert to bytes */
1169 if (PartSize
== MaxSize
)
1171 /* Use all of the unpartitioned disk space */
1172 PartSize
= PartEntry
->UnpartitionedLength
;
1176 /* Round-up by cylinder size */
1177 PartSize
= ROUND_UP (PartSize
* 1024 * 1024,
1178 DiskEntry
->CylinderSize
);
1180 /* But never get larger than the unpartitioned disk space */
1181 if (PartSize
> PartEntry
->UnpartitionedLength
)
1182 PartSize
= PartEntry
->UnpartitionedLength
;
1185 if (PartSize
== PartEntry
->UnpartitionedLength
)
1187 /* FIXME: Convert current entry to 'new (unformatted)' */
1188 PartEntry
->PartInfo
[0].StartingOffset
.QuadPart
=
1189 PartEntry
->UnpartitionedOffset
+ DiskEntry
->TrackSize
;
1190 PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
=
1191 PartEntry
->UnpartitionedLength
- DiskEntry
->TrackSize
;
1192 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_ENTRY_UNUSED
;
1193 PartEntry
->PartInfo
[0].BootIndicator
= FALSE
; /* FIXME */
1194 PartEntry
->PartInfo
[0].RewritePartition
= TRUE
;
1196 /* FIXME: Update extended partition entries */
1199 PartEntry
->New
= TRUE
;
1200 PartEntry
->Unpartitioned
= FALSE
;
1201 PartEntry
->UnpartitionedOffset
= 0ULL;
1202 PartEntry
->UnpartitionedLength
= 0ULL;
1208 * Insert new 'new (unformatted)' entry before the
1209 * current entry and adjust offsets and sizes.
1213 DPRINT1 ("Partition size: %I64u bytes\n", PartSize
);
1215 PopupError ("Entered valid partition size!\n"
1217 " * Press any key to continue.",
1223 PartEntry
->PartType
= PARTITION_ENTRY_UNUSED
;
1224 PartEntry
->Used
= TRUE
;
1226 PartDataValid
= GetSelectedPartition(PartList
,
1230 PartData
.CreatePartition
= TRUE
;
1231 PartData
.NewPartSize
= PartSize
;
1233 ActivePartitionValid
= GetActiveBootPartition(PartList
,
1236 RtlFreeUnicodeString(&DestinationRootPath
);
1237 swprintf(PathBuffer
,
1238 L
"\\Device\\Harddisk%lu\\Partition%lu",
1239 DiskEntry
->DiskNumber
,
1240 PartData
.PartNumber
);
1241 RtlCreateUnicodeString(&DestinationRootPath
,
1244 RtlFreeUnicodeString(&SystemRootPath
);
1246 if (ActivePartitionValid
)
1248 swprintf(PathBuffer
,
1249 L
"\\Device\\Harddisk%lu\\Partition%lu",
1250 ActivePartition
.DiskNumber
,
1251 ActivePartition
.PartNumber
);
1255 /* We mark the selected partition as bootable */
1256 swprintf(PathBuffer
,
1257 L
"\\Device\\Harddisk%lu\\Partition%lu",
1258 DiskEntry
->DiskNumber
,
1259 PartData
.PartNumber
);
1261 RtlCreateUnicodeString(&SystemRootPath
,
1264 return(SELECT_FILE_SYSTEM_PAGE
);
1268 /* FIXME: show an error dialog */
1269 return(SELECT_PARTITION_PAGE
);
1272 return SELECT_PARTITION_PAGE
;
1276 return CREATE_PARTITION_PAGE
;
1281 DeletePartitionPage (PINPUT_RECORD Ir
)
1283 PDISKENTRY DiskEntry
;
1284 PPARTENTRY PartEntry
;
1290 if (PartitionList
== NULL
||
1291 PartitionList
->CurrentDisk
== NULL
||
1292 PartitionList
->CurrentPartition
== NULL
)
1294 /* FIXME: show an error dialog */
1298 DiskEntry
= PartitionList
->CurrentDisk
;
1299 PartEntry
= PartitionList
->CurrentPartition
;
1301 SetTextXY(6, 8, "You have chosen to delete the partition");
1303 /* Determine partition type */
1305 if (PartEntry
->New
== TRUE
)
1307 PartType
= "New (Unformatted)";
1309 else if (PartEntry
->Unpartitioned
== FALSE
)
1311 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1312 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1313 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1314 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1318 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1319 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1323 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1325 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1330 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000ULL
) /* 10 GB */
1332 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1337 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0xA00000ULL
) /* 10 MB */
1339 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1344 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1348 if (PartType
== NULL
)
1351 // " %c%c Type %-3lu %6I64u %s",
1352 " %c%c Type %lu %I64u %s",
1353 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1354 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1355 PartEntry
->PartInfo
[0].PartitionType
,
1362 // " %c%c %-8s %6I64u %s",
1363 " %c%c %s %I64u %s",
1364 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1365 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1372 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1374 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1380 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1386 if (DiskEntry
->DriverName
.Length
> 0)
1389 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1392 DiskEntry
->DiskNumber
,
1396 &DiskEntry
->DriverName
);
1401 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1404 DiskEntry
->DiskNumber
,
1410 SetTextXY(8, 18, "\x07 Press D to delete the partition.");
1411 SetTextXY(11, 19, "WARNING: All data on this partition will be lost!");
1413 SetTextXY(8, 21, "\x07 Press ESC to cancel.");
1415 SetStatusText(" D = Delete Partition ESC = Cancel F3 = Quit");
1421 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1422 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1424 if (ConfirmQuit(Ir
) == TRUE
)
1430 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1432 return SELECT_PARTITION_PAGE
;
1434 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_D
) /* D */
1436 /* FIXME: delete partition here! */
1439 DeleteSelectedPartition(CurrentPartitionList
);
1442 return SELECT_PARTITION_PAGE
;
1446 return DELETE_PARTITION_PAGE
;
1450 static PFILE_SYSTEM_LIST
1451 CreateFileSystemList(SHORT Left
,
1453 BOOLEAN ForceFormat
,
1454 FILE_SYSTEM ForceFileSystem
)
1456 PFILE_SYSTEM_LIST List
;
1458 List
= (PFILE_SYSTEM_LIST
)RtlAllocateHeap(ProcessHeap
, 0, sizeof(FILE_SYSTEM_LIST
));
1465 List
->ForceFormat
= ForceFormat
;
1466 List
->FileSystemCount
= 1;
1469 List
->CurrentFileSystem
= ForceFileSystem
;
1473 List
->FileSystemCount
++;
1474 List
->CurrentFileSystem
= FsKeep
;
1481 DestroyFileSystemList(PFILE_SYSTEM_LIST List
)
1483 RtlFreeHeap(ProcessHeap
, 0, List
);
1488 DrawFileSystemList(PFILE_SYSTEM_LIST List
)
1496 coPos
.X
= List
->Left
;
1497 coPos
.Y
= List
->Top
+ index
;
1498 FillConsoleOutputAttribute(0x17,
1502 FillConsoleOutputCharacter(' ',
1507 if (List
->CurrentFileSystem
== FsFat
)
1509 SetInvertedTextXY(List
->Left
, List
->Top
+ index
, " Format partition as FAT file system ");
1513 SetTextXY(List
->Left
, List
->Top
+ index
, " Format partition as FAT file system ");
1517 if (!List
->ForceFormat
)
1519 coPos
.X
= List
->Left
;
1520 coPos
.Y
= List
->Top
+ index
;
1521 FillConsoleOutputAttribute(0x17,
1525 FillConsoleOutputCharacter(' ',
1530 if (List
->CurrentFileSystem
== FsKeep
)
1532 SetInvertedTextXY(List
->Left
, List
->Top
+ index
, " Keep current file system (no changes) ");
1536 SetTextXY(List
->Left
, List
->Top
+ index
, " Keep current file system (no changes) ");
1543 ScrollDownFileSystemList(PFILE_SYSTEM_LIST List
)
1545 if ((ULONG
) List
->CurrentFileSystem
< List
->FileSystemCount
- 1)
1547 (ULONG
) List
->CurrentFileSystem
++;
1548 DrawFileSystemList(List
);
1554 ScrollUpFileSystemList(PFILE_SYSTEM_LIST List
)
1556 if ((ULONG
) List
->CurrentFileSystem
> 0)
1558 (ULONG
) List
->CurrentFileSystem
--;
1559 DrawFileSystemList(List
);
1565 SelectFileSystemPage (PINPUT_RECORD Ir
)
1567 PDISKENTRY DiskEntry
;
1568 PPARTENTRY PartEntry
;
1569 BOOLEAN ForceFormat
;
1576 if (PartitionList
== NULL
||
1577 PartitionList
->CurrentDisk
== NULL
||
1578 PartitionList
->CurrentPartition
== NULL
)
1580 /* FIXME: show an error dialog */
1584 DiskEntry
= PartitionList
->CurrentDisk
;
1585 PartEntry
= PartitionList
->CurrentPartition
;
1587 /* adjust disk size */
1588 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1590 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1595 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1599 /* adjust partition size */
1600 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000ULL
) /* 10 GB */
1602 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1607 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1611 /* adjust partition type */
1612 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1613 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1614 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1615 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1619 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1620 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1624 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1626 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1628 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
1630 PartType
= "Unused";
1634 PartType
= "Unknown";
1637 SetTextXY(6, 8, "Setup will install ReactOS on");
1639 PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
1640 PartEntry
->PartInfo
[0].PartitionNumber
,
1645 PrintTextXY(8, 12, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
1646 DiskEntry
->DiskNumber
,
1652 &DiskEntry
->DriverName
);
1655 SetTextXY(6, 17, "Select a file system for the partition from the list below.");
1657 SetTextXY(8, 19, "\x07 Press UP or DOWN to select a file system.");
1658 SetTextXY(8, 21, "\x07 Press ENTER to format the partition.");
1659 SetTextXY(8, 23, "\x07 Press ESC to select another partition.");
1661 ForceFormat
= (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
);
1663 if (FileSystemList
== NULL
)
1665 FileSystemList
= CreateFileSystemList (6, 26, ForceFormat
, FsFat
);
1666 if (FileSystemList
== NULL
)
1668 /* FIXME: show an error dialog */
1674 DrawFileSystemList (FileSystemList
);
1677 SetStatusText(" ENTER = Continue ESC = Cancel F3 = Quit");
1683 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1684 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1686 if (ConfirmQuit(Ir
) == TRUE
)
1690 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1691 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1693 DestroyFileSystemList(FileSystemList
);
1694 return(SELECT_PARTITION_PAGE
);
1696 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1697 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1699 ScrollDownFileSystemList(FileSystemList
);
1701 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1702 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1704 ScrollUpFileSystemList(FileSystemList
);
1706 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1708 if (FileSystemList
->CurrentFileSystem
== FsKeep
)
1710 return(CHECK_FILE_SYSTEM_PAGE
);
1714 return(FORMAT_PARTITION_PAGE
);
1719 return SELECT_FILE_SYSTEM_PAGE
;
1724 FormatPartitionPage(PINPUT_RECORD Ir
)
1730 SetTextXY(6, 8, "Format partition");
1732 SetTextXY(6, 10, "Setup will now format the partition. Press ENTER to continue.");
1734 SetStatusText(" ENTER = Continue F3 = Quit");
1740 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1741 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1743 if (ConfirmQuit(Ir
) == TRUE
)
1749 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1751 SetStatusText(" Please wait ...");
1753 switch (FileSystemList
->CurrentFileSystem
)
1756 PartType
= PARTITION_FAT32_XINT13
;
1767 if (PartData
.CreatePartition
)
1769 Valid
= CreateSelectedPartition (PartitionList
, PartType
, PartData
.NewPartSize
);
1772 DPRINT("CreateSelectedPartition() failed\n");
1773 /* FIXME: show an error dialog */
1779 switch (FileSystemList
->CurrentFileSystem
)
1782 Status
= FormatPartition (&DestinationRootPath
);
1783 if (!NT_SUCCESS (Status
))
1785 DPRINT1("FormatPartition() failed with status 0x%.08x\n", Status
);
1786 /* FIXME: show an error dialog */
1798 return INSTALL_DIRECTORY_PAGE
;
1802 return INSTALL_DIRECTORY_PAGE
;
1807 CheckFileSystemPage(PINPUT_RECORD Ir
)
1809 SetTextXY(6, 8, "Check file system");
1811 SetTextXY(6, 10, "At present, ReactOS can not check file systems.");
1813 SetStatusText(" Please wait ...");
1816 SetStatusText(" ENTER = Continue F3 = Quit");
1822 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1823 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1825 if (ConfirmQuit(Ir
) == TRUE
)
1829 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1831 return(INSTALL_DIRECTORY_PAGE
);
1835 return(CHECK_FILE_SYSTEM_PAGE
);
1840 InstallDirectoryPage(PINPUT_RECORD Ir
)
1842 PDISKENTRY DiskEntry
;
1843 PPARTENTRY PartEntry
;
1844 WCHAR PathBuffer
[MAX_PATH
];
1845 WCHAR InstallDir
[51];
1851 if (PartitionList
== NULL
||
1852 PartitionList
->CurrentDisk
== NULL
||
1853 PartitionList
->CurrentPartition
== NULL
)
1855 /* FIXME: show an error dialog */
1859 DiskEntry
= PartitionList
->CurrentDisk
;
1860 PartEntry
= PartitionList
->CurrentPartition
;
1862 /* Search for 'DefaultPath' in the 'SetupData' section */
1863 if (!InfFindFirstLine (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
1865 PopupError("Setup failed to find the 'SetupData' section\n"
1866 "in TXTSETUP.SIF.\n",
1867 "ENTER = Reboot computer");
1873 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1880 /* Read the 'DefaultPath' data */
1881 if (InfGetData (&Context
, NULL
, &DefaultPath
))
1883 wcscpy(InstallDir
, DefaultPath
);
1887 wcscpy(InstallDir
, L
"\\ReactOS");
1889 Length
= wcslen(InstallDir
);
1891 SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
1892 SetTextXY(6, 9, "directory where you want ReactOS to be installed:");
1894 SetInputTextXY(8, 11, 51, InstallDir
);
1896 SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete");
1897 SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to");
1898 SetTextXY(6, 16, "be installed.");
1900 SetStatusText(" ENTER = Continue F3 = Quit");
1906 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1907 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1909 if (ConfirmQuit(Ir
) == TRUE
)
1913 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1915 /* Create 'InstallPath' string */
1916 RtlFreeUnicodeString(&InstallPath
);
1917 RtlCreateUnicodeString(&InstallPath
,
1920 /* Create 'DestinationPath' string */
1921 RtlFreeUnicodeString(&DestinationPath
);
1923 DestinationRootPath
.Buffer
);
1924 if (InstallDir
[0] != L
'\\')
1927 wcscat(PathBuffer
, InstallDir
);
1928 RtlCreateUnicodeString(&DestinationPath
,
1931 /* Create 'DestinationArcPath' */
1932 RtlFreeUnicodeString(&DestinationArcPath
);
1933 swprintf(PathBuffer
,
1934 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
1935 DiskEntry
->DiskNumber
,
1936 PartEntry
->PartInfo
[0].PartitionNumber
);
1937 if (InstallDir
[0] != L
'\\')
1940 wcscat(PathBuffer
, InstallDir
);
1941 RtlCreateUnicodeString(&DestinationArcPath
,
1944 return(PREPARE_COPY_PAGE
);
1946 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
1951 InstallDir
[Length
] = 0;
1952 SetInputTextXY(8, 11, 51, InstallDir
);
1955 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
1959 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
1961 InstallDir
[Length
] = 0;
1962 SetInputTextXY(8, 11, 51, InstallDir
);
1967 return(INSTALL_DIRECTORY_PAGE
);
1972 PrepareCopyPage(PINPUT_RECORD Ir
)
1974 WCHAR PathBuffer
[MAX_PATH
];
1975 INFCONTEXT FilesContext
;
1976 INFCONTEXT DirContext
;
1983 PWCHAR FileKeyValue
;
1987 SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. ");
1991 * Build the file copy list
1993 SetStatusText(" Building the file copy list...");
1995 /* Search for the 'SourceFiles' section */
1996 if (!InfFindFirstLine (SetupInf
, L
"SourceFiles", NULL
, &FilesContext
))
1998 PopupError("Setup failed to find the 'SourceFiles' section\n"
1999 "in TXTSETUP.SIF.\n",
2000 "ENTER = Reboot computer");
2006 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2014 /* Create the file queue */
2015 SetupFileQueue
= SetupOpenFileQueue();
2016 if (SetupFileQueue
== NULL
)
2018 PopupError("Setup failed to open the copy file queue.\n",
2019 "ENTER = Reboot computer");
2025 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2033 * Enumerate the files in the 'SourceFiles' section
2034 * and add them to the file queue.
2038 if (!InfGetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
2041 DPRINT1("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
2043 /* Lookup target directory */
2044 if (!InfFindFirstLine (SetupInf
, L
"Directories", FileKeyValue
, &DirContext
))
2046 /* FIXME: Handle error! */
2047 DPRINT1("InfFindFirstLine() failed\n");
2051 if (!InfGetData (&DirContext
, NULL
, &DirKeyValue
))
2053 /* FIXME: Handle error! */
2054 DPRINT1("InfGetData() failed\n");
2058 if (!SetupQueueCopy(SetupFileQueue
,
2059 SourceRootPath
.Buffer
,
2065 /* FIXME: Handle error! */
2066 DPRINT1("SetupQueueCopy() failed\n");
2069 while (InfFindNextLine(&FilesContext
, &FilesContext
));
2072 /* Create directories */
2073 SetStatusText(" Creating directories...");
2077 * Install directories like '\reactos\test' are not handled yet.
2080 /* Get destination path */
2081 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2083 /* Remove trailing backslash */
2084 Length
= wcslen(PathBuffer
);
2085 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2087 PathBuffer
[Length
- 1] = 0;
2090 /* Create the install directory */
2091 Status
= CreateDirectory(PathBuffer
);
2092 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2094 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2095 PopupError("Setup could not create the install directory.",
2096 "ENTER = Reboot computer");
2102 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2110 /* Search for the 'Directories' section */
2111 if (!InfFindFirstLine(SetupInf
, L
"Directories", NULL
, &DirContext
))
2113 PopupError("Setup failed to find the 'Directories' section\n"
2114 "in TXTSETUP.SIF.\n",
2115 "ENTER = Reboot computer");
2121 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2128 /* Enumerate the directory values and create the subdirectories */
2131 if (!InfGetData (&DirContext
, NULL
, &KeyValue
))
2134 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2136 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2138 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2139 wcscat(PathBuffer
, KeyValue
);
2141 DPRINT("FullPath: '%S'\n", PathBuffer
);
2143 else if (KeyValue
[0] != L
'\\')
2145 DPRINT("RelativePath: '%S'\n", KeyValue
);
2146 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2147 wcscat(PathBuffer
, L
"\\");
2148 wcscat(PathBuffer
, KeyValue
);
2150 DPRINT("FullPath: '%S'\n", PathBuffer
);
2152 Status
= CreateDirectory(PathBuffer
);
2153 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2155 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2156 PopupError("Setup could not create install directories.",
2157 "ENTER = Reboot computer");
2163 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2171 while (InfFindNextLine (&DirContext
, &DirContext
));
2173 return(FILE_COPY_PAGE
);
2178 FileCopyCallback(PVOID Context
,
2183 PCOPYCONTEXT CopyContext
;
2185 CopyContext
= (PCOPYCONTEXT
)Context
;
2187 switch (Notification
)
2189 case SPFILENOTIFY_STARTSUBQUEUE
:
2190 CopyContext
->TotalOperations
= (ULONG
)Param2
;
2191 ProgressSetStepCount(CopyContext
->ProgressBar
,
2192 CopyContext
->TotalOperations
);
2195 case SPFILENOTIFY_STARTCOPY
:
2196 /* Display copy message */
2197 PrintTextXYN(6, 16, 60, "Copying file: %S", (PWSTR
)Param1
);
2199 PrintTextXYN(6, 18, 60, "File %lu of %lu",
2200 CopyContext
->CompletedOperations
+ 1,
2201 CopyContext
->TotalOperations
);
2204 case SPFILENOTIFY_ENDCOPY
:
2205 CopyContext
->CompletedOperations
++;
2206 ProgressNextStep(CopyContext
->ProgressBar
);
2215 FileCopyPage(PINPUT_RECORD Ir
)
2217 COPYCONTEXT CopyContext
;
2221 SetStatusText(" Please wait...");
2223 SetTextXY(6, 8, "Copying files");
2225 GetScreenSize(&xScreen
, &yScreen
);
2227 CopyContext
.TotalOperations
= 0;
2228 CopyContext
.CompletedOperations
= 0;
2229 CopyContext
.ProgressBar
= CreateProgressBar(6,
2234 SetupCommitFileQueue(SetupFileQueue
,
2235 DestinationRootPath
.Buffer
,
2237 (PSP_FILE_CALLBACK
)FileCopyCallback
,
2240 SetupCloseFileQueue(SetupFileQueue
);
2242 DestroyProgressBar(CopyContext
.ProgressBar
);
2244 return(REGISTRY_PAGE
);
2249 RegistryPage(PINPUT_RECORD Ir
)
2251 INFCONTEXT InfContext
;
2260 SetTextXY(6, 8, "Setup is updating the system configuration");
2262 SetStatusText(" Creating registry hives...");
2264 if (!SetInstallPathValue(&DestinationPath
))
2266 DPRINT("SetInstallPathValue() failed\n");
2267 PopupError("Setup failed to set the initialize the registry.",
2268 "ENTER = Reboot computer");
2274 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2281 /* Create the default hives */
2282 Status
= NtInitializeRegistry(TRUE
);
2283 if (!NT_SUCCESS(Status
))
2285 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
2286 PopupError("Setup failed to create the registry hives.",
2287 "ENTER = Reboot computer");
2293 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2300 /* Update registry */
2301 SetStatusText(" Updating registry hives...");
2303 if (!InfFindFirstLine(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
2305 DPRINT1("InfFindFirstLine() failed\n");
2306 PopupError("Setup failed to find the registry data files.",
2307 "ENTER = Reboot computer");
2313 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2322 InfGetDataField (&InfContext
, 0, &Action
);
2323 InfGetDataField (&InfContext
, 1, &File
);
2324 InfGetDataField (&InfContext
, 2, &Section
);
2326 DPRINT1("Action: %S File: %S Section %S\n", Action
, File
, Section
);
2328 if (!_wcsicmp (Action
, L
"AddReg"))
2332 else if (!_wcsicmp (Action
, L
"DelReg"))
2341 SetStatusText(" Importing %S...", File
);
2343 if (!ImportRegistryFile(File
, Section
, Delete
))
2345 DPRINT1("Importing %S failed\n", File
);
2347 PopupError("Setup failed to import a hive file.",
2348 "ENTER = Reboot computer");
2354 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2361 while (InfFindNextLine (&InfContext
, &InfContext
));
2363 SetStatusText(" Done...");
2365 return(BOOT_LOADER_PAGE
);
2370 BootLoaderPage(PINPUT_RECORD Ir
)
2372 WCHAR SrcPath
[MAX_PATH
];
2373 WCHAR DstPath
[MAX_PATH
];
2375 PINICACHESECTION IniSection
;
2377 BOOLEAN InstallMBR
= FALSE
;
2379 SetTextXY(6, 8, "Installing the boot loader");
2381 SetStatusText(" Please wait...");
2384 if (ActivePartitionValid
== FALSE
)
2386 /* Mark the chosen partition as active since there is no active
2389 if (!MarkPartitionActive(PartData
.DiskNumber
,
2390 PartData
.PartNumber
, &ActivePartition
))
2392 PopupError("Setup could not mark the system partiton active\n",
2393 "ENTER = Reboot computer");
2399 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2410 WCHAR PathBuffer
[MAX_PATH
];
2411 UNICODE_STRING SystemRootMBRPath
;
2413 RtlFreeUnicodeString(&SystemRootMBRPath
);
2414 swprintf(PathBuffer
,
2415 L
"\\Device\\Harddisk%lu\\Partition0",
2416 PartData
.DiskNumber
);
2417 RtlCreateUnicodeString(&SystemRootMBRPath
,
2420 /* Install MBR bootcode */
2421 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2422 wcscat(SrcPath
, L
"\\loader\\dosmbr.bin");
2424 DPRINT1("Install MBR bootcode: %S ==> %S\n", SrcPath
, SystemRootMBRPath
.Buffer
);
2425 Status
= InstallMBRBootCodeToDisk(SrcPath
,
2426 SystemRootMBRPath
.Buffer
);
2427 if (!NT_SUCCESS(Status
))
2429 DPRINT1("InstallMBRBootCodeToDisk() failed (Status %lx)\n", Status
);
2430 PopupError("Setup failed to install the MBR bootcode.",
2431 "ENTER = Reboot computer");
2437 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2446 if (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
2448 DPRINT1("Error: active partition invalid (unused)\n");
2449 PopupError("The active partition is unused (invalid).\n",
2450 "ENTER = Reboot computer");
2456 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2463 if (ActiveBootPartition
->PartInfo
[0].PartitionType
== 0x0A)
2465 /* OS/2 boot manager partition */
2466 DPRINT1("Found OS/2 boot manager partition\n");
2467 PopupError("Setup found an OS/2 boot manager partiton.\n"
2468 "The OS/2 boot manager is not supported yet!",
2469 "ENTER = Reboot computer");
2475 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2481 else if (ActiveBootPartition
->PartInfo
[0].PartitionType
== 0x83)
2483 /* Linux ext2 partition */
2484 DPRINT1("Found Linux ext2 partition\n");
2485 PopupError("Setup found a Linux ext2 partiton.\n"
2486 "Linux ext2 partitions are not supported yet!",
2487 "ENTER = Reboot computer");
2493 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2499 else if (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
2501 /* NTFS partition */
2502 DPRINT1("Found NTFS partition\n");
2503 PopupError("Setup found an NTFS partiton.\n"
2504 "NTFS partitions are not supported yet!",
2505 "ENTER = Reboot computer");
2511 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2517 else if ((ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
2518 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
2519 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
2520 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_XINT13
) ||
2521 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2522 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2524 /* FAT or FAT32 partition */
2525 DPRINT1("System path: '%wZ'\n", &SystemRootPath
);
2527 if (DoesFileExist(SystemRootPath
.Buffer
, L
"ntldr") == TRUE
||
2528 DoesFileExist(SystemRootPath
.Buffer
, L
"boot.ini") == TRUE
)
2530 /* Search root directory for 'ntldr' and 'boot.ini'. */
2531 DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
2533 /* Copy FreeLoader to the boot partition */
2534 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2535 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2536 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2537 wcscat(DstPath
, L
"\\freeldr.sys");
2539 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2540 Status
= SetupCopyFile(SrcPath
, DstPath
);
2541 if (!NT_SUCCESS(Status
))
2543 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2544 PopupError("Setup failed to copy 'freeldr.sys'.",
2545 "ENTER = Reboot computer");
2551 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2558 /* Create or update freeldr.ini */
2559 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2561 /* Create new 'freeldr.ini' */
2562 DPRINT1("Create new 'freeldr.ini'\n");
2563 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2564 wcscat(DstPath
, L
"\\freeldr.ini");
2566 Status
= CreateFreeLoaderIniForReactos(DstPath
,
2567 DestinationArcPath
.Buffer
);
2568 if (!NT_SUCCESS(Status
))
2570 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
2571 PopupError("Setup failed to create 'freeldr.ini'.",
2572 "ENTER = Reboot computer");
2578 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2585 /* Install new bootcode */
2586 if ((ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2587 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2589 /* Install FAT32 bootcode */
2590 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2591 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2592 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2593 wcscat(DstPath
, L
"\\bootsect.ros");
2595 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, DstPath
);
2596 Status
= InstallFat32BootCodeToFile(SrcPath
,
2598 SystemRootPath
.Buffer
);
2599 if (!NT_SUCCESS(Status
))
2601 DPRINT1("InstallFat32BootCodeToFile() failed (Status %lx)\n", Status
);
2602 PopupError("Setup failed to install the FAT32 bootcode.",
2603 "ENTER = Reboot computer");
2609 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2618 /* Install FAT16 bootcode */
2619 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2620 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2621 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2622 wcscat(DstPath
, L
"\\bootsect.ros");
2624 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, DstPath
);
2625 Status
= InstallFat16BootCodeToFile(SrcPath
,
2627 SystemRootPath
.Buffer
);
2628 if (!NT_SUCCESS(Status
))
2630 DPRINT1("InstallFat16BootCodeToFile() failed (Status %lx)\n", Status
);
2631 PopupError("Setup failed to install the FAT bootcode.",
2632 "ENTER = Reboot computer");
2638 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2646 /* Update 'boot.ini' */
2647 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2648 wcscat(DstPath
, L
"\\boot.ini");
2650 DPRINT1("Update 'boot.ini': %S\n", DstPath
);
2651 Status
= UpdateBootIni(DstPath
,
2652 L
"C:\\bootsect.ros",
2654 if (!NT_SUCCESS(Status
))
2656 DPRINT1("UpdateBootIni() failed (Status %lx)\n", Status
);
2657 PopupError("Setup failed to update \'boot.ini\'.",
2658 "ENTER = Reboot computer");
2664 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2673 /* Update existing 'freeldr.ini' */
2674 DPRINT1("Update existing 'freeldr.ini'\n");
2675 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2676 wcscat(DstPath
, L
"\\freeldr.ini");
2678 Status
= UpdateFreeLoaderIni(DstPath
,
2679 DestinationArcPath
.Buffer
);
2680 if (!NT_SUCCESS(Status
))
2682 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
2683 PopupError("Setup failed to update 'freeldr.ini'.",
2684 "ENTER = Reboot computer");
2690 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2698 else if (DoesFileExist(SystemRootPath
.Buffer
, L
"io.sys") == TRUE
||
2699 DoesFileExist(SystemRootPath
.Buffer
, L
"msdos.sys") == TRUE
)
2701 /* Search for root directory for 'io.sys' and 'msdos.sys'. */
2702 DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
2704 /* Copy FreeLoader to the boot partition */
2705 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2706 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2707 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2708 wcscat(DstPath
, L
"\\freeldr.sys");
2710 DPRINT("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2711 Status
= SetupCopyFile(SrcPath
, DstPath
);
2712 if (!NT_SUCCESS(Status
))
2714 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2715 PopupError("Setup failed to copy 'freeldr.sys'.",
2716 "ENTER = Reboot computer");
2722 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2729 /* Create or update 'freeldr.ini' */
2730 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2732 /* Create new 'freeldr.ini' */
2733 DPRINT1("Create new 'freeldr.ini'\n");
2734 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2735 wcscat(DstPath
, L
"\\freeldr.ini");
2737 Status
= CreateFreeLoaderIniForDos(DstPath
,
2738 DestinationArcPath
.Buffer
);
2739 if (!NT_SUCCESS(Status
))
2741 DPRINT1("CreateFreeLoaderIniForDos() failed (Status %lx)\n", Status
);
2742 PopupError("Setup failed to create 'freeldr.ini'.",
2743 "ENTER = Reboot computer");
2749 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2756 /* Save current bootsector as 'BOOTSECT.DOS' */
2757 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
2758 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2759 wcscat(DstPath
, L
"\\bootsect.dos");
2761 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
2762 Status
= SaveCurrentBootSector(SrcPath
,
2764 if (!NT_SUCCESS(Status
))
2766 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
2767 PopupError("Setup failed to save the current bootsector.",
2768 "ENTER = Reboot computer");
2774 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2781 /* Install new bootsector */
2782 if ((ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2783 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2785 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2786 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2788 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2789 Status
= InstallFat32BootCodeToDisk(SrcPath
,
2790 SystemRootPath
.Buffer
);
2791 if (!NT_SUCCESS(Status
))
2793 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
2794 PopupError("Setup failed to install the FAT32 bootcode.",
2795 "ENTER = Reboot computer");
2801 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2810 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2811 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2813 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2814 Status
= InstallFat16BootCodeToDisk(SrcPath
,
2815 SystemRootPath
.Buffer
);
2816 if (!NT_SUCCESS(Status
))
2818 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
2819 PopupError("Setup failed to install the FAT bootcode.",
2820 "ENTER = Reboot computer");
2826 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2836 /* Update existing 'freeldr.ini' */
2837 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2838 wcscat(DstPath
, L
"\\freeldr.ini");
2840 Status
= UpdateFreeLoaderIni(DstPath
,
2841 DestinationArcPath
.Buffer
);
2842 if (!NT_SUCCESS(Status
))
2844 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
2845 PopupError("Setup failed to update 'freeldr.ini'.",
2846 "ENTER = Reboot computer");
2852 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2862 /* No or unknown boot loader */
2863 DPRINT1("No or unknown boot loader found\n");
2865 /* Copy FreeLoader to the boot partition */
2866 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2867 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2868 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2869 wcscat(DstPath
, L
"\\freeldr.sys");
2871 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2872 Status
= SetupCopyFile(SrcPath
, DstPath
);
2873 if (!NT_SUCCESS(Status
))
2875 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2876 PopupError("Setup failed to copy 'freeldr.sys'.",
2877 "ENTER = Reboot computer");
2883 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2890 /* Create or update 'freeldr.ini' */
2891 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2893 /* Create new freeldr.ini */
2894 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2895 wcscat(DstPath
, L
"\\freeldr.ini");
2897 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2898 Status
= CreateFreeLoaderIniForReactos(DstPath
,
2899 DestinationArcPath
.Buffer
);
2900 if (!NT_SUCCESS(Status
))
2902 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
2903 PopupError("Setup failed to create \'freeldr.ini\'.",
2904 "ENTER = Reboot computer");
2910 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2917 /* Save current bootsector as 'BOOTSECT.OLD' */
2918 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
2919 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2920 wcscat(DstPath
, L
"\\bootsect.old");
2922 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
2923 Status
= SaveCurrentBootSector(SrcPath
,
2925 if (!NT_SUCCESS(Status
))
2927 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
2928 PopupError("Setup failed save the current bootsector.",
2929 "ENTER = Reboot computer");
2935 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2942 /* Install new bootsector */
2943 if ((ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2944 (ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2946 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2947 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2949 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2950 Status
= InstallFat32BootCodeToDisk(SrcPath
,
2951 SystemRootPath
.Buffer
);
2952 if (!NT_SUCCESS(Status
))
2954 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
2955 PopupError("Setup failed to install the FAT32 bootcode.",
2956 "ENTER = Reboot computer");
2962 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2971 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2972 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2974 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2975 Status
= InstallFat16BootCodeToDisk(SrcPath
,
2976 SystemRootPath
.Buffer
);
2977 if (!NT_SUCCESS(Status
))
2979 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
2980 PopupError("Setup failed to install the FAT bootcode.",
2981 "ENTER = Reboot computer");
2987 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2997 /* Update existing 'freeldr.ini' */
2998 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2999 wcscat(DstPath
, L
"\\freeldr.ini");
3001 Status
= UpdateFreeLoaderIni(DstPath
,
3002 DestinationArcPath
.Buffer
);
3003 if (!NT_SUCCESS(Status
))
3005 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
3006 PopupError("Setup failed to update 'freeldr.ini'.",
3007 "ENTER = Reboot computer");
3013 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3024 /* Unknown partition */
3025 DPRINT1("Unknown partition found\n");
3026 PopupError("Setup found an unknown partiton type.\n"
3027 "This partition type is not supported!",
3028 "ENTER = Reboot computer");
3034 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3041 return(SUCCESS_PAGE
);
3047 QuitPage(PINPUT_RECORD Ir
)
3049 SetTextXY(10, 6, "ReactOS is not completely installed");
3051 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
3052 SetTextXY(10, 9, "all CD-ROMs from CD-Drives.");
3054 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
3056 SetStatusText(" Please wait ...");
3058 /* Destroy partition list */
3059 if (PartitionList
!= NULL
)
3061 DestroyPartitionList (PartitionList
);
3062 PartitionList
= NULL
;
3065 /* Destroy filesystem list */
3066 if (FileSystemList
!= NULL
)
3068 DestroyFileSystemList (FileSystemList
);
3069 FileSystemList
= NULL
;
3072 SetStatusText(" ENTER = Reboot computer");
3078 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3080 return(REBOOT_PAGE
);
3087 SuccessPage(PINPUT_RECORD Ir
)
3089 SetTextXY(10, 6, "The basic components of ReactOS have been installed successfully.");
3091 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
3092 SetTextXY(10, 9, "all CD-ROMs from CD-Drive.");
3094 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
3096 SetStatusText(" ENTER = Reboot computer");
3102 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
3104 return(REBOOT_PAGE
);
3111 NtProcessStartup(PPEB Peb
)
3117 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
3119 ProcessHeap
= Peb
->ProcessHeap
;
3121 Status
= AllocConsole();
3122 if (!NT_SUCCESS(Status
))
3124 PrintString("AllocConsole() failed (Status = 0x%08lx)\n", Status
);
3126 /* Raise a hard error (crash the system/BSOD) */
3127 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
3132 /* Initialize global unicode strings */
3133 RtlInitUnicodeString(&SourcePath
, NULL
);
3134 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3135 RtlInitUnicodeString(&InstallPath
, NULL
);
3136 RtlInitUnicodeString(&DestinationPath
, NULL
);
3137 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3138 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3139 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3143 while (Page
!= REBOOT_PAGE
)
3147 SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR
" Setup ");
3153 Page
= StartPage(&Ir
);
3158 Page
= IntroPage(&Ir
);
3162 case INSTALL_INTRO_PAGE
:
3163 Page
= InstallIntroPage(&Ir
);
3167 case OEM_DRIVER_PAGE
:
3168 Page
= OemDriverPage(&Ir
);
3173 case DEVICE_SETTINGS_PAGE
:
3176 case SELECT_PARTITION_PAGE
:
3177 Page
= SelectPartitionPage(&Ir
);
3180 case CREATE_PARTITION_PAGE
:
3181 Page
= CreatePartitionPage(&Ir
);
3184 case DELETE_PARTITION_PAGE
:
3185 Page
= DeletePartitionPage(&Ir
);
3188 case SELECT_FILE_SYSTEM_PAGE
:
3189 Page
= SelectFileSystemPage(&Ir
);
3192 case FORMAT_PARTITION_PAGE
:
3193 Page
= FormatPartitionPage(&Ir
);
3196 case CHECK_FILE_SYSTEM_PAGE
:
3197 Page
= CheckFileSystemPage(&Ir
);
3200 case INSTALL_DIRECTORY_PAGE
:
3201 Page
= InstallDirectoryPage(&Ir
);
3204 case PREPARE_COPY_PAGE
:
3205 Page
= PrepareCopyPage(&Ir
);
3208 case FILE_COPY_PAGE
:
3209 Page
= FileCopyPage(&Ir
);
3213 Page
= RegistryPage(&Ir
);
3216 case BOOT_LOADER_PAGE
:
3217 Page
= BootLoaderPage(&Ir
);
3222 case REPAIR_INTRO_PAGE
:
3223 Page
= RepairIntroPage(&Ir
);
3227 /* Emergency pages */
3228 case EMERGENCY_INTRO_PAGE
:
3229 Page
= EmergencyIntroPage(&Ir
);
3234 Page
= SuccessPage(&Ir
);
3238 Page
= QuitPage(&Ir
);
3245 NtShutdownSystem(ShutdownReboot
);