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 PFILE_SYSTEM_LIST FileSystemList
= NULL
;
100 static UNICODE_STRING SourcePath
;
102 static UNICODE_STRING InstallPath
;
104 /* Path to the install directory */
105 static UNICODE_STRING DestinationPath
;
106 static UNICODE_STRING DestinationArcPath
;
107 static UNICODE_STRING DestinationRootPath
;
109 /* Path to the active partition (boot manager) */
110 static UNICODE_STRING SystemRootPath
;
112 static HINF SetupInf
;
114 static HSPFILEQ SetupFileQueue
= NULL
;
117 /* FUNCTIONS ****************************************************************/
120 PrintString(char* fmt
,...)
124 UNICODE_STRING UnicodeString
;
125 ANSI_STRING AnsiString
;
128 vsprintf(buffer
, fmt
, ap
);
131 RtlInitAnsiString(&AnsiString
, buffer
);
132 RtlAnsiStringToUnicodeString(&UnicodeString
,
135 NtDisplayString(&UnicodeString
);
136 RtlFreeUnicodeString(&UnicodeString
);
141 PopupError(PCHAR Text
,
159 /* Count text lines and longest line */
165 p
= strchr(pnext
, '\n');
168 Length
= strlen(pnext
);
173 Length
= (ULONG
)(p
- pnext
);
178 if (Length
> MaxLength
)
181 if (LastLine
== TRUE
)
187 /* Check length of status line */
190 Length
= strlen(Status
);
191 if (Length
> MaxLength
)
195 GetScreenSize(&xScreen
, &yScreen
);
197 Width
= MaxLength
+ 4;
202 yTop
= (yScreen
- Height
) / 2;
203 xLeft
= (xScreen
- Width
) / 2;
206 /* Set screen attributes */
208 for (coPos
.Y
= yTop
; coPos
.Y
< yTop
+ Height
; coPos
.Y
++)
210 FillConsoleOutputAttribute(0x74,
216 /* draw upper left corner */
219 FillConsoleOutputCharacter(0xDA, // '+',
224 /* draw upper edge */
227 FillConsoleOutputCharacter(0xC4, // '-',
232 /* draw upper right corner */
233 coPos
.X
= xLeft
+ Width
- 1;
235 FillConsoleOutputCharacter(0xBF, // '+',
240 /* Draw right edge, inner space and left edge */
241 for (coPos
.Y
= yTop
+ 1; coPos
.Y
< yTop
+ Height
- 1; coPos
.Y
++)
244 FillConsoleOutputCharacter(0xB3, // '|',
250 FillConsoleOutputCharacter(' ',
255 coPos
.X
= xLeft
+ Width
- 1;
256 FillConsoleOutputCharacter(0xB3, // '|',
262 /* draw lower left corner */
264 coPos
.Y
= yTop
+ Height
- 1;
265 FillConsoleOutputCharacter(0xC0, // '+',
270 /* draw lower edge */
272 coPos
.Y
= yTop
+ Height
- 1;
273 FillConsoleOutputCharacter(0xC4, // '-',
278 /* draw lower right corner */
279 coPos
.X
= xLeft
+ Width
- 1;
280 coPos
.Y
= yTop
+ Height
- 1;
281 FillConsoleOutputCharacter(0xD9, // '+',
286 /* Print message text */
291 p
= strchr(pnext
, '\n');
294 Length
= strlen(pnext
);
299 Length
= (ULONG
)(p
- pnext
);
306 WriteConsoleOutputCharacters(pnext
,
311 if (LastLine
== TRUE
)
318 /* Print separator line and status text */
321 coPos
.Y
= yTop
+ Height
- 3;
323 FillConsoleOutputCharacter(0xC3, // '+',
329 FillConsoleOutputCharacter(0xC4, // '-',
334 coPos
.X
= xLeft
+ Width
- 1;
335 FillConsoleOutputCharacter(0xB4, // '+',
342 WriteConsoleOutputCharacters(Status
,
343 min(strlen(Status
), Width
- 4),
353 * FALSE: Don't quit setup.
356 ConfirmQuit(PINPUT_RECORD Ir
)
360 PopupError("ReactOS is not completely installed on your\n"
361 "computer. If you quit Setup now, you will need to\n"
362 "run Setup again to install ReactOS.\n"
364 " \x07 Press ENTER to continue Setup.\n"
365 " \x07 Press F3 to quit Setup.",
366 "F3= Quit ENTER = Continue");
372 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
373 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
378 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
393 * Number of the next page.
396 StartPage(PINPUT_RECORD Ir
)
399 WCHAR FileNameBuffer
[MAX_PATH
];
400 UNICODE_STRING FileName
;
405 SetStatusText(" Please wait...");
407 Status
= GetSourcePaths(&SourcePath
,
409 if (!NT_SUCCESS(Status
))
411 PrintTextXY(6, 15, "GetSourcePath() failed (Status 0x%08lx)", Status
);
412 PopupError("Setup could not find its source drive.\n",
413 "ENTER = Reboot computer");
418 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
427 PrintTextXY(6, 15, "SourcePath: '%wZ'", &SourcePath
);
428 PrintTextXY(6, 16, "SourceRootPath: '%wZ'", &SourceRootPath
);
432 /* Load txtsetup.sif from install media. */
433 wcscpy(FileNameBuffer
, SourceRootPath
.Buffer
);
434 wcscat(FileNameBuffer
, L
"\\reactos\\txtsetup.sif");
435 RtlInitUnicodeString(&FileName
,
438 Status
= InfOpenFile(&SetupInf
,
441 if (!NT_SUCCESS(Status
))
443 PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
444 "ENTER = Reboot computer");
450 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
457 /* Open 'Version' section */
458 if (!InfFindFirstLine (SetupInf
, L
"Version", L
"Signature", &Context
))
460 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
461 "ENTER = Reboot computer");
467 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
475 /* Get pointer 'Signature' key */
476 if (!InfGetData (&Context
, NULL
, &Value
))
478 PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
479 "ENTER = Reboot computer");
485 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
492 /* Check 'Signature' string */
493 if (_wcsicmp(Value
, L
"$ReactOS$") != 0)
495 PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
496 "ENTER = Reboot computer");
502 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
519 IntroPage(PINPUT_RECORD Ir
)
521 SetHighlightedTextXY(6, 8, "Welcome to ReactOS Setup");
523 SetTextXY(6, 11, "This part of the setup copies the ReactOS Operating System to your");
524 SetTextXY(6, 12, "computer and prepares the second part of the setup.");
526 SetTextXY(8, 15, "\x07 Press ENTER to install ReactOS.");
528 SetTextXY(8, 17, "\x07 Press E to start the emergency console.");
530 SetTextXY(8, 19, "\x07 Press R to repair ReactOS.");
532 SetTextXY(8, 21, "\x07 Press F3 to quit without installing ReactOS.");
535 SetStatusText(" ENTER = Continue F3 = Quit");
541 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
542 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
544 if (ConfirmQuit(Ir
) == TRUE
)
548 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
550 return(INSTALL_INTRO_PAGE
);
552 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'E') /* E */
554 return(EMERGENCY_INTRO_PAGE
);
556 else if (toupper(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
) == 'R') /* R */
558 return(REPAIR_INTRO_PAGE
);
567 EmergencyIntroPage(PINPUT_RECORD Ir
)
569 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
570 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
572 SetTextXY(6, 12, "The emergency console is not implemented yet.");
574 SetTextXY(8, 15, "\x07 Press ESC to return to the main page.");
576 SetTextXY(8, 17, "\x07 Press ENTER to reboot your computer.");
578 SetStatusText(" ESC = Main page ENTER = Reboot");
584 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
588 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
589 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
595 return(REPAIR_INTRO_PAGE
);
600 RepairIntroPage(PINPUT_RECORD Ir
)
602 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
603 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
605 SetTextXY(6, 12, "The repair functions are not implemented yet.");
607 SetTextXY(8, 15, "\x07 Press ESC to return to the main page.");
609 SetTextXY(8, 17, "\x07 Press ENTER to reboot your computer.");
611 SetStatusText(" ESC = Main page ENTER = Reboot");
617 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
621 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
622 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
628 return(REPAIR_INTRO_PAGE
);
633 InstallIntroPage(PINPUT_RECORD Ir
)
635 SetTextXY(6, 8, "ReactOS Setup is in an early development phase. It does not yet");
636 SetTextXY(6, 9, "support all the functions of a fully usable setup application.");
638 SetTextXY(6, 12, "The following functions are missing:");
639 SetTextXY(8, 13, "- Creating and deleting harddisk partitions.");
640 SetTextXY(8, 14, "- Formatting partitions.");
641 SetTextXY(8, 15, "- Support for non-FAT file systems.");
642 SetTextXY(8, 16, "- Checking file systems.");
646 SetTextXY(8, 21, "\x07 Press ENTER to install ReactOS.");
648 SetTextXY(8, 23, "\x07 Press F3 to quit without installing ReactOS.");
651 SetStatusText(" ENTER = Continue F3 = Quit");
657 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
658 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
660 if (ConfirmQuit(Ir
) == TRUE
)
664 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
666 return(SELECT_PARTITION_PAGE
);
670 return(INSTALL_INTRO_PAGE
);
675 SelectPartitionPage(PINPUT_RECORD Ir
)
680 SetTextXY(6, 8, "The list below shows existing partitions and unused disk");
681 SetTextXY(6, 9, "space for new partitions.");
683 SetTextXY(8, 11, "\x07 Press UP or DOWN to select a list entry.");
684 SetTextXY(8, 13, "\x07 Press ENTER to install ReactOS onto the selected partition.");
685 SetTextXY(8, 15, "\x07 Press C to create a new partition.");
686 SetTextXY(8, 17, "\x07 Press D to delete an existing partition.");
688 SetStatusText(" Please wait...");
690 GetScreenSize(&xScreen
, &yScreen
);
692 if (PartitionList
== NULL
)
694 PartitionList
= CreatePartitionList (2,
698 if (PartitionList
== NULL
)
700 /* FIXME: show an error dialog */
705 DrawPartitionList (PartitionList
);
709 /* Update status text */
710 if (PartitionList
->CurrentPartition
== NULL
||
711 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
713 SetStatusText (" ENTER = Install C = Create Partition F3 = Quit");
717 SetStatusText (" ENTER = Install D = Delete Partition F3 = Quit");
722 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
723 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
725 if (ConfirmQuit(Ir
) == TRUE
)
727 DestroyPartitionList (PartitionList
);
728 PartitionList
= NULL
;
733 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
734 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
736 ScrollDownPartitionList (PartitionList
);
738 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
739 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
741 ScrollUpPartitionList (PartitionList
);
743 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
745 if (PartitionList
->CurrentPartition
== NULL
||
746 PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
748 CreateNewPartition (PartitionList
,
753 return SELECT_FILE_SYSTEM_PAGE
;
755 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_C
) /* C */
757 if (PartitionList
->CurrentPartition
->Unpartitioned
== FALSE
)
759 PopupError ("You can not create a new Partition inside\n"
760 "of an already existing Partition!\n"
762 " * Press any key to continue.",
766 return SELECT_PARTITION_PAGE
;
769 return CREATE_PARTITION_PAGE
;
771 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_D
) /* D */
773 if (PartitionList
->CurrentPartition
->Unpartitioned
== TRUE
)
775 PopupError ("You can not delete unpartitioned disk space!\n"
777 " * Press any key to continue.",
781 return SELECT_PARTITION_PAGE
;
784 return DELETE_PARTITION_PAGE
;
788 return SELECT_PARTITION_PAGE
;
793 DrawInputField(ULONG FieldLength
,
803 memset(buf
, '_', sizeof(buf
));
804 buf
[FieldLength
- strlen(FieldContent
)] = 0;
805 strcat(buf
, FieldContent
);
807 WriteConsoleOutputCharacters (buf
,
813 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
816 ShowPartitionSizeInputBox(SHORT Left
,
841 /* draw upper left corner */
844 FillConsoleOutputCharacter(0xDA, // '+',
849 /* draw upper edge */
852 FillConsoleOutputCharacter(0xC4, // '-',
857 /* draw upper right corner */
860 FillConsoleOutputCharacter(0xBF, // '+',
865 /* draw left and right edge */
866 for (i
= Top
+ 1; i
< Bottom
; i
++)
870 FillConsoleOutputCharacter(0xB3, // '|',
876 FillConsoleOutputCharacter(0xB3, //'|',
882 /* draw lower left corner */
885 FillConsoleOutputCharacter(0xC0, // '+',
890 /* draw lower edge */
893 FillConsoleOutputCharacter(0xC4, // '-',
898 /* draw lower right corner */
901 FillConsoleOutputCharacter(0xD9, // '+',
909 strcpy (Buffer
, "Size of new partition:");
910 iLeft
= coPos
.X
+ strlen (Buffer
) + 1;
912 WriteConsoleOutputCharacters (Buffer
,
916 sprintf (Buffer
, "MB (max. %d MB)", MaxSize
);
917 coPos
.X
= iLeft
+ PARTITION_SIZE_INPUT_FIELD_LENGTH
+ 1;
919 WriteConsoleOutputCharacters (Buffer
,
925 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
934 if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
935 (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
942 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
946 else if (Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESCAPE */
953 else if ((Ir
.Event
.KeyEvent
.wVirtualKeyCode
== VK_BACK
) && /* BACKSPACE */
958 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
963 else if ((Ir
.Event
.KeyEvent
.uChar
.AsciiChar
!= 0x00) &&
964 (Index
< PARTITION_SIZE_INPUT_FIELD_LENGTH
))
966 ch
= Ir
.Event
.KeyEvent
.uChar
.AsciiChar
;
967 if ((ch
>= '0') && (ch
<= '9'))
972 DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH
,
986 CreatePartitionPage (PINPUT_RECORD Ir
)
988 PDISKENTRY DiskEntry
;
989 PPARTENTRY PartEntry
;
994 CHAR InputBuffer
[50];
1000 if (PartitionList
== NULL
||
1001 PartitionList
->CurrentDisk
== NULL
||
1002 PartitionList
->CurrentPartition
== NULL
)
1004 /* FIXME: show an error dialog */
1008 DiskEntry
= PartitionList
->CurrentDisk
;
1009 PartEntry
= PartitionList
->CurrentPartition
;
1011 SetStatusText (" Please wait...");
1013 GetScreenSize (&xScreen
, &yScreen
);
1015 SetTextXY (6, 8, "You have chosen to create a new partition on");
1018 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1020 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1026 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1032 if (DiskEntry
->DriverName
.Length
> 0)
1035 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1038 DiskEntry
->DiskNumber
,
1042 &DiskEntry
->DriverName
);
1047 "%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1050 DiskEntry
->DiskNumber
,
1057 SetTextXY (6, 12, "Please enter the size of the new partition in megabytes.");
1060 PrintTextXY (8, 10, "Maximum size of the new partition is %I64u MB",
1061 PartitionList
->CurrentPartition
->UnpartitionedLength
/ (1024*1024));
1064 SetStatusText (" ENTER = Create Partition ESC = Cancel F3 = Quit");
1066 PartEntry
= PartitionList
->CurrentPartition
;
1069 MaxSize
= (PartEntry
->UnpartitionedLength
+ (1 << 19)) >> 20; /* in MBytes (rounded) */
1070 ShowPartitionSizeInputBox (12, 14, xScreen
- 12, 17, /* left, top, right, bottom */
1071 MaxSize
, InputBuffer
, &Quit
, &Cancel
);
1074 if (ConfirmQuit (Ir
) == TRUE
)
1079 else if (Cancel
== TRUE
)
1081 return SELECT_PARTITION_PAGE
;
1085 PartSize
= atoi (InputBuffer
);
1092 if (PartSize
> MaxSize
)
1098 /* Convert to bytes */
1099 if (PartSize
== MaxSize
)
1101 /* Use all of the unpartitioned disk space */
1102 PartSize
= PartEntry
->UnpartitionedLength
;
1106 /* Round-up by cylinder size */
1107 PartSize
= ROUND_UP (PartSize
* 1024 * 1024,
1108 DiskEntry
->CylinderSize
);
1110 /* But never get larger than the unpartitioned disk space */
1111 if (PartSize
> PartEntry
->UnpartitionedLength
)
1112 PartSize
= PartEntry
->UnpartitionedLength
;
1115 DPRINT ("Partition size: %I64u bytes\n", PartSize
);
1117 CreateNewPartition (PartitionList
,
1121 return SELECT_PARTITION_PAGE
;
1125 return CREATE_PARTITION_PAGE
;
1130 DeletePartitionPage (PINPUT_RECORD Ir
)
1132 PDISKENTRY DiskEntry
;
1133 PPARTENTRY PartEntry
;
1139 if (PartitionList
== NULL
||
1140 PartitionList
->CurrentDisk
== NULL
||
1141 PartitionList
->CurrentPartition
== NULL
)
1143 /* FIXME: show an error dialog */
1147 DiskEntry
= PartitionList
->CurrentDisk
;
1148 PartEntry
= PartitionList
->CurrentPartition
;
1150 SetTextXY (6, 8, "You have chosen to delete the partition");
1152 /* Determine partition type */
1154 if (PartEntry
->New
== TRUE
)
1156 PartType
= "New (Unformatted)";
1158 else if (PartEntry
->Unpartitioned
== FALSE
)
1160 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1161 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1162 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1163 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1167 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1168 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1172 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1174 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1179 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000ULL
) /* 10 GB */
1181 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1186 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0xA00000ULL
) /* 10 MB */
1188 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1193 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 9)) >> 10;
1197 if (PartType
== NULL
)
1200 " %c%c Type %lu %I64u %s",
1201 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1202 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1203 PartEntry
->PartInfo
[0].PartitionType
,
1210 " %c%c %s %I64u %s",
1211 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1212 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1219 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1221 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1227 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1233 if (DiskEntry
->DriverName
.Length
> 0)
1236 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
1239 DiskEntry
->DiskNumber
,
1243 &DiskEntry
->DriverName
);
1248 "on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
1251 DiskEntry
->DiskNumber
,
1257 SetTextXY (8, 18, "\x07 Press D to delete the partition.");
1258 SetTextXY (11, 19, "WARNING: All data on this partition will be lost!");
1260 SetTextXY (8, 21, "\x07 Press ESC to cancel.");
1262 SetStatusText (" D = Delete Partition ESC = Cancel F3 = Quit");
1268 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1269 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1271 if (ConfirmQuit (Ir
) == TRUE
)
1277 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
) /* ESC */
1279 return SELECT_PARTITION_PAGE
;
1281 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_D
) /* D */
1283 DeleteCurrentPartition (PartitionList
);
1285 return SELECT_PARTITION_PAGE
;
1289 return DELETE_PARTITION_PAGE
;
1294 SelectFileSystemPage (PINPUT_RECORD Ir
)
1296 PDISKENTRY DiskEntry
;
1297 PPARTENTRY PartEntry
;
1304 if (PartitionList
== NULL
||
1305 PartitionList
->CurrentDisk
== NULL
||
1306 PartitionList
->CurrentPartition
== NULL
)
1308 /* FIXME: show an error dialog */
1312 DiskEntry
= PartitionList
->CurrentDisk
;
1313 PartEntry
= PartitionList
->CurrentPartition
;
1315 /* adjust disk size */
1316 if (DiskEntry
->DiskSize
>= 0x280000000ULL
) /* 10 GB */
1318 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 29)) >> 30;
1323 DiskSize
= (DiskEntry
->DiskSize
+ (1 << 19)) >> 20;
1327 /* adjust partition size */
1328 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
>= 0x280000000ULL
) /* 10 GB */
1330 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 29)) >> 30;
1335 PartSize
= (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
+ (1 << 19)) >> 20;
1339 /* adjust partition type */
1340 if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
1341 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
1342 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
1343 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_XINT13
))
1347 else if ((PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
1348 (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
1352 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
1354 PartType
= "NTFS"; /* FIXME: Not quite correct! */
1356 else if (PartEntry
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
1358 PartType
= "Unused";
1362 PartType
= "Unknown";
1365 if (PartEntry
->AutoCreate
== TRUE
)
1367 SetTextXY(6, 8, "Setup created a new partition on");
1370 PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of",
1371 PartEntry
->PartInfo
[0].PartitionNumber
,
1377 PrintTextXY(8, 10, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
1378 DiskEntry
->DiskNumber
,
1384 &DiskEntry
->DriverName
);
1386 SetTextXY(6, 12, "This Partition will be formatted next.");
1389 PartEntry
->AutoCreate
= FALSE
;
1391 else if (PartEntry
->New
== TRUE
)
1393 SetTextXY(6, 8, "You chose to install ReactOS on a new or unformatted Partition.");
1394 SetTextXY(6, 10, "This Partition will be formatted next.");
1398 SetTextXY(6, 8, "Setup install ReactOS onto Partition");
1400 if (PartType
== NULL
)
1403 "%c%c Type %lu %I64u %s",
1404 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1405 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1406 PartEntry
->PartInfo
[0].PartitionType
,
1414 (PartEntry
->DriveLetter
== 0) ? '-' : PartEntry
->DriveLetter
,
1415 (PartEntry
->DriveLetter
== 0) ? '-' : ':',
1421 PrintTextXY(6, 12, "on Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).",
1422 DiskEntry
->DiskNumber
,
1428 &DiskEntry
->DriverName
);
1432 SetTextXY(6, 17, "Select a file system from the list below.");
1434 SetTextXY(8, 19, "\x07 Press UP or DOWN to select a file system.");
1435 SetTextXY(8, 21, "\x07 Press ENTER to format the partition.");
1436 SetTextXY(8, 23, "\x07 Press ESC to select another partition.");
1438 if (FileSystemList
== NULL
)
1440 FileSystemList
= CreateFileSystemList (6, 26, PartEntry
->New
, FsFat
);
1441 if (FileSystemList
== NULL
)
1443 /* FIXME: show an error dialog */
1447 /* FIXME: Add file systems to list */
1449 DrawFileSystemList (FileSystemList
);
1451 SetStatusText (" ENTER = Continue ESC = Cancel F3 = Quit");
1457 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1458 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1460 if (ConfirmQuit (Ir
) == TRUE
)
1466 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1467 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_ESCAPE
)) /* ESC */
1469 return SELECT_PARTITION_PAGE
;
1471 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1472 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_DOWN
)) /* DOWN */
1474 ScrollDownFileSystemList (FileSystemList
);
1476 else if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1477 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_UP
)) /* UP */
1479 ScrollUpFileSystemList (FileSystemList
);
1481 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1483 if (FileSystemList
->CurrentFileSystem
== FsKeep
)
1485 return CHECK_FILE_SYSTEM_PAGE
;
1489 return FORMAT_PARTITION_PAGE
;
1494 return SELECT_FILE_SYSTEM_PAGE
;
1499 FormatPartitionPage (PINPUT_RECORD Ir
)
1501 WCHAR PathBuffer
[MAX_PATH
];
1502 PDISKENTRY DiskEntry
;
1503 PPARTENTRY PartEntry
;
1513 SetTextXY(6, 8, "Format partition");
1515 SetTextXY(6, 10, "Setup will now format the partition. Press ENTER to continue.");
1517 SetStatusText(" ENTER = Continue F3 = Quit");
1520 if (PartitionList
== NULL
||
1521 PartitionList
->CurrentDisk
== NULL
||
1522 PartitionList
->CurrentPartition
== NULL
)
1524 /* FIXME: show an error dialog */
1528 DiskEntry
= PartitionList
->CurrentDisk
;
1529 PartEntry
= PartitionList
->CurrentPartition
;
1535 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1536 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1538 if (ConfirmQuit (Ir
) == TRUE
)
1544 else if (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_RETURN
) /* ENTER */
1546 SetStatusText (" Please wait ...");
1548 switch (FileSystemList
->CurrentFileSystem
)
1551 if (DiskEntry
->UseLba
== FALSE
)
1553 if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (32ULL * 1024ULL * 1024ULL))
1555 /* FAT16 CHS partition (disk is smaller than 32MB) */
1556 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT_16
;
1560 /* FAT16 CHS partition (disk is smaller than 8.4GB) */
1561 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_HUGE
;
1564 else if (PartEntry
->PartInfo
[0].PartitionLength
.QuadPart
< (2ULL * 1024ULL * 1024ULL * 1024ULL))
1566 /* FAT16 LBA partition (partition is smaller than 2GB) */
1567 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_XINT13
;
1571 /* FAT32 LBA partition (partition is at least 2GB) */
1572 PartEntry
->PartInfo
[0].PartitionType
= PARTITION_FAT32_XINT13
;
1583 CheckActiveBootPartition (PartitionList
);
1587 "Disk: %I64u Cylinder: %I64u Track: %I64u",
1588 DiskEntry
->DiskSize
,
1589 DiskEntry
->CylinderSize
,
1590 DiskEntry
->TrackSize
);
1593 DiskEntry
= PartitionList
->CurrentDisk
;
1594 Entry
= DiskEntry
->PartListHead
.Flink
;
1595 while (Entry
!= &DiskEntry
->PartListHead
)
1597 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
1599 if (PartEntry
->Unpartitioned
== FALSE
)
1602 for (i
= 0; i
< 4; i
++)
1604 PrintTextXY (6, Line
,
1605 "%2u: %2u %c %12I64u %12I64u %2u %c",
1607 PartEntry
->PartInfo
[i
].PartitionNumber
,
1608 PartEntry
->PartInfo
[i
].BootIndicator
? 'A' : '-',
1609 PartEntry
->PartInfo
[i
].StartingOffset
.QuadPart
,
1610 PartEntry
->PartInfo
[i
].PartitionLength
.QuadPart
,
1611 PartEntry
->PartInfo
[i
].PartitionType
,
1612 PartEntry
->PartInfo
[i
].RewritePartition
? '*' : ' ');
1620 Entry
= Entry
->Flink
;
1624 if (WritePartitionsToDisk (PartitionList
) == FALSE
)
1626 DPRINT ("WritePartitionsToDisk() failed\n");
1628 PopupError ("Setup failed to write partition tables.\n",
1629 "ENTER = Reboot computer");
1635 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1643 /* Set DestinationRootPath */
1644 RtlFreeUnicodeString (&DestinationRootPath
);
1645 swprintf (PathBuffer
,
1646 L
"\\Device\\Harddisk%lu\\Partition%lu",
1647 PartitionList
->CurrentDisk
->DiskNumber
,
1648 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
1649 RtlCreateUnicodeString (&DestinationRootPath
,
1651 DPRINT1 ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
1654 /* Set SystemRootPath */
1655 RtlFreeUnicodeString (&SystemRootPath
);
1656 swprintf (PathBuffer
,
1657 L
"\\Device\\Harddisk%lu\\Partition%lu",
1658 PartitionList
->ActiveBootDisk
->DiskNumber
,
1659 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
1660 RtlCreateUnicodeString (&SystemRootPath
,
1662 DPRINT1 ("SystemRootPath: %wZ\n", &SystemRootPath
);
1665 switch (FileSystemList
->CurrentFileSystem
)
1668 Status
= FormatPartition (&DestinationRootPath
);
1669 if (!NT_SUCCESS (Status
))
1671 DPRINT1 ("FormatPartition() failed with status 0x%.08x\n", Status
);
1672 /* FIXME: show an error dialog */
1676 /* FIXME: Install boot code. This is a hack! */
1677 wcscpy (PathBuffer
, SourceRootPath
.Buffer
);
1678 wcscat (PathBuffer
, L
"\\loader\\fat32.bin");
1680 DPRINT1 ("Install FAT32 bootcode: %S ==> %S\n", PathBuffer
,
1681 DestinationRootPath
.Buffer
);
1682 Status
= InstallFat32BootCodeToDisk (PathBuffer
,
1683 DestinationRootPath
.Buffer
);
1684 if (!NT_SUCCESS (Status
))
1686 DPRINT1 ("InstallFat32BootCodeToDisk() failed with status 0x%.08x\n", Status
);
1687 /* FIXME: show an error dialog */
1699 SetStatusText (" Done. Press any key ...");
1702 return INSTALL_DIRECTORY_PAGE
;
1706 return FORMAT_PARTITION_PAGE
;
1711 CheckFileSystemPage(PINPUT_RECORD Ir
)
1713 WCHAR PathBuffer
[MAX_PATH
];
1715 SetTextXY(6, 8, "Check file system");
1717 SetTextXY(6, 10, "At present, ReactOS can not check file systems.");
1719 SetStatusText(" Please wait ...");
1722 SetStatusText(" ENTER = Continue F3 = Quit");
1725 /* Set DestinationRootPath */
1726 RtlFreeUnicodeString (&DestinationRootPath
);
1727 swprintf (PathBuffer
,
1728 L
"\\Device\\Harddisk%lu\\Partition%lu",
1729 PartitionList
->CurrentDisk
->DiskNumber
,
1730 PartitionList
->CurrentPartition
->PartInfo
[0].PartitionNumber
);
1731 RtlCreateUnicodeString (&DestinationRootPath
,
1733 DPRINT1 ("DestinationRootPath: %wZ\n", &DestinationRootPath
);
1735 /* Set SystemRootPath */
1736 RtlFreeUnicodeString (&SystemRootPath
);
1737 swprintf (PathBuffer
,
1738 L
"\\Device\\Harddisk%lu\\Partition%lu",
1739 PartitionList
->ActiveBootDisk
->DiskNumber
,
1740 PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionNumber
);
1741 RtlCreateUnicodeString (&SystemRootPath
,
1743 DPRINT1 ("SystemRootPath: %wZ\n", &SystemRootPath
);
1750 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1751 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1753 if (ConfirmQuit(Ir
) == TRUE
)
1757 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1759 return(INSTALL_DIRECTORY_PAGE
);
1763 return(CHECK_FILE_SYSTEM_PAGE
);
1768 InstallDirectoryPage(PINPUT_RECORD Ir
)
1770 PDISKENTRY DiskEntry
;
1771 PPARTENTRY PartEntry
;
1772 WCHAR PathBuffer
[MAX_PATH
];
1773 WCHAR InstallDir
[51];
1779 if (PartitionList
== NULL
||
1780 PartitionList
->CurrentDisk
== NULL
||
1781 PartitionList
->CurrentPartition
== NULL
)
1783 /* FIXME: show an error dialog */
1787 DiskEntry
= PartitionList
->CurrentDisk
;
1788 PartEntry
= PartitionList
->CurrentPartition
;
1790 /* Search for 'DefaultPath' in the 'SetupData' section */
1791 if (!InfFindFirstLine (SetupInf
, L
"SetupData", L
"DefaultPath", &Context
))
1793 PopupError("Setup failed to find the 'SetupData' section\n"
1794 "in TXTSETUP.SIF.\n",
1795 "ENTER = Reboot computer");
1801 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1808 /* Read the 'DefaultPath' data */
1809 if (InfGetData (&Context
, NULL
, &DefaultPath
))
1811 wcscpy(InstallDir
, DefaultPath
);
1815 wcscpy(InstallDir
, L
"\\ReactOS");
1817 Length
= wcslen(InstallDir
);
1819 SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
1820 SetTextXY(6, 9, "directory where you want ReactOS to be installed:");
1822 SetInputTextXY(8, 11, 51, InstallDir
);
1824 SetTextXY(6, 14, "To change the suggested directory, press BACKSPACE to delete");
1825 SetTextXY(6, 15, "characters and then type the directory where you want ReactOS to");
1826 SetTextXY(6, 16, "be installed.");
1828 SetStatusText(" ENTER = Continue F3 = Quit");
1834 if ((Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x00) &&
1835 (Ir
->Event
.KeyEvent
.wVirtualKeyCode
== VK_F3
)) /* F3 */
1837 if (ConfirmQuit(Ir
) == TRUE
)
1841 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1843 /* Create 'InstallPath' string */
1844 RtlFreeUnicodeString(&InstallPath
);
1845 RtlCreateUnicodeString(&InstallPath
,
1848 /* Create 'DestinationPath' string */
1849 RtlFreeUnicodeString(&DestinationPath
);
1851 DestinationRootPath
.Buffer
);
1852 if (InstallDir
[0] != L
'\\')
1855 wcscat(PathBuffer
, InstallDir
);
1856 RtlCreateUnicodeString(&DestinationPath
,
1859 /* Create 'DestinationArcPath' */
1860 RtlFreeUnicodeString(&DestinationArcPath
);
1861 swprintf(PathBuffer
,
1862 L
"multi(0)disk(0)rdisk(%lu)partition(%lu)",
1863 DiskEntry
->DiskNumber
,
1864 PartEntry
->PartInfo
[0].PartitionNumber
);
1865 if (InstallDir
[0] != L
'\\')
1868 wcscat(PathBuffer
, InstallDir
);
1869 RtlCreateUnicodeString(&DestinationArcPath
,
1872 return(PREPARE_COPY_PAGE
);
1874 else if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x08) /* BACKSPACE */
1879 InstallDir
[Length
] = 0;
1880 SetInputTextXY(8, 11, 51, InstallDir
);
1883 else if (isprint(Ir
->Event
.KeyEvent
.uChar
.AsciiChar
))
1887 InstallDir
[Length
] = (WCHAR
)Ir
->Event
.KeyEvent
.uChar
.AsciiChar
;
1889 InstallDir
[Length
] = 0;
1890 SetInputTextXY(8, 11, 51, InstallDir
);
1895 return(INSTALL_DIRECTORY_PAGE
);
1900 PrepareCopyPage(PINPUT_RECORD Ir
)
1902 WCHAR PathBuffer
[MAX_PATH
];
1903 INFCONTEXT FilesContext
;
1904 INFCONTEXT DirContext
;
1911 PWCHAR FileKeyValue
;
1915 SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. ");
1919 * Build the file copy list
1921 SetStatusText(" Building the file copy list...");
1923 /* Search for the 'SourceFiles' section */
1924 if (!InfFindFirstLine (SetupInf
, L
"SourceFiles", NULL
, &FilesContext
))
1926 PopupError("Setup failed to find the 'SourceFiles' section\n"
1927 "in TXTSETUP.SIF.\n",
1928 "ENTER = Reboot computer");
1934 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1942 /* Create the file queue */
1943 SetupFileQueue
= SetupOpenFileQueue();
1944 if (SetupFileQueue
== NULL
)
1946 PopupError("Setup failed to open the copy file queue.\n",
1947 "ENTER = Reboot computer");
1953 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
1961 * Enumerate the files in the 'SourceFiles' section
1962 * and add them to the file queue.
1966 if (!InfGetData (&FilesContext
, &FileKeyName
, &FileKeyValue
))
1969 DPRINT1("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName
, FileKeyValue
);
1971 /* Lookup target directory */
1972 if (!InfFindFirstLine (SetupInf
, L
"Directories", FileKeyValue
, &DirContext
))
1974 /* FIXME: Handle error! */
1975 DPRINT1("InfFindFirstLine() failed\n");
1979 if (!InfGetData (&DirContext
, NULL
, &DirKeyValue
))
1981 /* FIXME: Handle error! */
1982 DPRINT1("InfGetData() failed\n");
1986 if (!SetupQueueCopy(SetupFileQueue
,
1987 SourceRootPath
.Buffer
,
1993 /* FIXME: Handle error! */
1994 DPRINT1("SetupQueueCopy() failed\n");
1997 while (InfFindNextLine(&FilesContext
, &FilesContext
));
2000 /* Create directories */
2001 SetStatusText(" Creating directories...");
2005 * Install directories like '\reactos\test' are not handled yet.
2008 /* Get destination path */
2009 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2011 /* Remove trailing backslash */
2012 Length
= wcslen(PathBuffer
);
2013 if ((Length
> 0) && (PathBuffer
[Length
- 1] == '\\'))
2015 PathBuffer
[Length
- 1] = 0;
2018 /* Create the install directory */
2019 Status
= CreateDirectory(PathBuffer
);
2020 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2022 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2023 PopupError("Setup could not create the install directory.",
2024 "ENTER = Reboot computer");
2030 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2038 /* Search for the 'Directories' section */
2039 if (!InfFindFirstLine(SetupInf
, L
"Directories", NULL
, &DirContext
))
2041 PopupError("Setup failed to find the 'Directories' section\n"
2042 "in TXTSETUP.SIF.\n",
2043 "ENTER = Reboot computer");
2049 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2056 /* Enumerate the directory values and create the subdirectories */
2059 if (!InfGetData (&DirContext
, NULL
, &KeyValue
))
2062 if (KeyValue
[0] == L
'\\' && KeyValue
[1] != 0)
2064 DPRINT("Absolute Path: '%S'\n", KeyValue
);
2066 wcscpy(PathBuffer
, DestinationRootPath
.Buffer
);
2067 wcscat(PathBuffer
, KeyValue
);
2069 DPRINT("FullPath: '%S'\n", PathBuffer
);
2071 else if (KeyValue
[0] != L
'\\')
2073 DPRINT("RelativePath: '%S'\n", KeyValue
);
2074 wcscpy(PathBuffer
, DestinationPath
.Buffer
);
2075 wcscat(PathBuffer
, L
"\\");
2076 wcscat(PathBuffer
, KeyValue
);
2078 DPRINT("FullPath: '%S'\n", PathBuffer
);
2080 Status
= CreateDirectory(PathBuffer
);
2081 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_COLLISION
)
2083 DPRINT("Creating directory '%S' failed: Status = 0x%08lx", PathBuffer
, Status
);
2084 PopupError("Setup could not create install directories.",
2085 "ENTER = Reboot computer");
2091 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2099 while (InfFindNextLine (&DirContext
, &DirContext
));
2101 return(FILE_COPY_PAGE
);
2106 FileCopyCallback(PVOID Context
,
2111 PCOPYCONTEXT CopyContext
;
2113 CopyContext
= (PCOPYCONTEXT
)Context
;
2115 switch (Notification
)
2117 case SPFILENOTIFY_STARTSUBQUEUE
:
2118 CopyContext
->TotalOperations
= (ULONG
)Param2
;
2119 ProgressSetStepCount(CopyContext
->ProgressBar
,
2120 CopyContext
->TotalOperations
);
2123 case SPFILENOTIFY_STARTCOPY
:
2124 /* Display copy message */
2125 PrintTextXYN(6, 16, 60, "Copying file: %S", (PWSTR
)Param1
);
2127 PrintTextXYN(6, 18, 60, "File %lu of %lu",
2128 CopyContext
->CompletedOperations
+ 1,
2129 CopyContext
->TotalOperations
);
2132 case SPFILENOTIFY_ENDCOPY
:
2133 CopyContext
->CompletedOperations
++;
2134 ProgressNextStep(CopyContext
->ProgressBar
);
2143 FileCopyPage(PINPUT_RECORD Ir
)
2145 COPYCONTEXT CopyContext
;
2149 SetStatusText(" Please wait...");
2151 SetTextXY(6, 8, "Copying files");
2153 GetScreenSize(&xScreen
, &yScreen
);
2155 CopyContext
.TotalOperations
= 0;
2156 CopyContext
.CompletedOperations
= 0;
2157 CopyContext
.ProgressBar
= CreateProgressBar(6,
2162 SetupCommitFileQueue(SetupFileQueue
,
2163 DestinationRootPath
.Buffer
,
2165 (PSP_FILE_CALLBACK
)FileCopyCallback
,
2168 SetupCloseFileQueue(SetupFileQueue
);
2170 DestroyProgressBar(CopyContext
.ProgressBar
);
2172 return(REGISTRY_PAGE
);
2177 RegistryPage(PINPUT_RECORD Ir
)
2179 INFCONTEXT InfContext
;
2188 SetTextXY(6, 8, "Setup is updating the system configuration");
2190 SetStatusText(" Creating registry hives...");
2192 if (!SetInstallPathValue(&DestinationPath
))
2194 DPRINT("SetInstallPathValue() failed\n");
2195 PopupError("Setup failed to set the initialize the registry.",
2196 "ENTER = Reboot computer");
2202 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2209 /* Create the default hives */
2210 Status
= NtInitializeRegistry(TRUE
);
2211 if (!NT_SUCCESS(Status
))
2213 DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status
);
2214 PopupError("Setup failed to create the registry hives.",
2215 "ENTER = Reboot computer");
2221 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2228 /* Update registry */
2229 SetStatusText(" Updating registry hives...");
2231 if (!InfFindFirstLine(SetupInf
, L
"HiveInfs.Install", NULL
, &InfContext
))
2233 DPRINT1("InfFindFirstLine() failed\n");
2234 PopupError("Setup failed to find the registry data files.",
2235 "ENTER = Reboot computer");
2241 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2250 InfGetDataField (&InfContext
, 0, &Action
);
2251 InfGetDataField (&InfContext
, 1, &File
);
2252 InfGetDataField (&InfContext
, 2, &Section
);
2254 DPRINT1("Action: %S File: %S Section %S\n", Action
, File
, Section
);
2256 if (!_wcsicmp (Action
, L
"AddReg"))
2260 else if (!_wcsicmp (Action
, L
"DelReg"))
2269 SetStatusText(" Importing %S...", File
);
2271 if (!ImportRegistryFile(File
, Section
, Delete
))
2273 DPRINT1("Importing %S failed\n", File
);
2275 PopupError("Setup failed to import a hive file.",
2276 "ENTER = Reboot computer");
2282 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2289 while (InfFindNextLine (&InfContext
, &InfContext
));
2291 SetStatusText(" Done...");
2293 return(BOOT_LOADER_PAGE
);
2298 BootLoaderPage(PINPUT_RECORD Ir
)
2300 WCHAR SrcPath
[MAX_PATH
];
2301 WCHAR DstPath
[MAX_PATH
];
2303 PINICACHESECTION IniSection
;
2306 SetTextXY(6, 8, "Installing the boot loader");
2308 SetStatusText(" Please wait...");
2311 if (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_ENTRY_UNUSED
)
2313 DPRINT1("Error: active partition invalid (unused)\n");
2314 PopupError("The active partition is unused (invalid).\n",
2315 "ENTER = Reboot computer");
2321 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2328 if (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== 0x0A)
2330 /* OS/2 boot manager partition */
2331 DPRINT1("Found OS/2 boot manager partition\n");
2332 PopupError("Setup found an OS/2 boot manager partiton.\n"
2333 "The OS/2 boot manager is not supported yet!",
2334 "ENTER = Reboot computer");
2340 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2346 else if (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== 0x83)
2348 /* Linux ext2 partition */
2349 DPRINT1("Found Linux ext2 partition\n");
2350 PopupError("Setup found a Linux ext2 partiton.\n"
2351 "Linux ext2 partitions are not supported yet!",
2352 "ENTER = Reboot computer");
2358 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2364 else if (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_IFS
)
2366 /* NTFS partition */
2367 DPRINT1("Found NTFS partition\n");
2368 PopupError("Setup found an NTFS partiton.\n"
2369 "NTFS partitions are not supported yet!",
2370 "ENTER = Reboot computer");
2376 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2382 else if ((PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT_12
) ||
2383 (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT_16
) ||
2384 (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_HUGE
) ||
2385 (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_XINT13
) ||
2386 (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2387 (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2389 /* FAT or FAT32 partition */
2390 DPRINT1("System path: '%wZ'\n", &SystemRootPath
);
2392 if (DoesFileExist(SystemRootPath
.Buffer
, L
"ntldr") == TRUE
||
2393 DoesFileExist(SystemRootPath
.Buffer
, L
"boot.ini") == TRUE
)
2395 /* Search root directory for 'ntldr' and 'boot.ini'. */
2396 DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
2398 /* Copy FreeLoader to the boot partition */
2399 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2400 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2401 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2402 wcscat(DstPath
, L
"\\freeldr.sys");
2404 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2405 Status
= SetupCopyFile(SrcPath
, DstPath
);
2406 if (!NT_SUCCESS(Status
))
2408 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2409 PopupError("Setup failed to copy 'freeldr.sys'.",
2410 "ENTER = Reboot computer");
2416 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2423 /* Create or update freeldr.ini */
2424 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2426 /* Create new 'freeldr.ini' */
2427 DPRINT1("Create new 'freeldr.ini'\n");
2428 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2429 wcscat(DstPath
, L
"\\freeldr.ini");
2431 Status
= CreateFreeLoaderIniForReactos(DstPath
,
2432 DestinationArcPath
.Buffer
);
2433 if (!NT_SUCCESS(Status
))
2435 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
2436 PopupError("Setup failed to create 'freeldr.ini'.",
2437 "ENTER = Reboot computer");
2443 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2450 /* Install new bootcode */
2451 if ((PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2452 (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2454 /* Install FAT32 bootcode */
2455 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2456 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2457 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2458 wcscat(DstPath
, L
"\\bootsect.ros");
2460 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, DstPath
);
2461 Status
= InstallFat32BootCodeToFile(SrcPath
,
2463 SystemRootPath
.Buffer
);
2464 if (!NT_SUCCESS(Status
))
2466 DPRINT1("InstallFat32BootCodeToFile() failed (Status %lx)\n", Status
);
2467 PopupError("Setup failed to install the FAT32 bootcode.",
2468 "ENTER = Reboot computer");
2474 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2483 /* Install FAT16 bootcode */
2484 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2485 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2486 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2487 wcscat(DstPath
, L
"\\bootsect.ros");
2489 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, DstPath
);
2490 Status
= InstallFat16BootCodeToFile(SrcPath
,
2492 SystemRootPath
.Buffer
);
2493 if (!NT_SUCCESS(Status
))
2495 DPRINT1("InstallFat16BootCodeToFile() failed (Status %lx)\n", Status
);
2496 PopupError("Setup failed to install the FAT bootcode.",
2497 "ENTER = Reboot computer");
2503 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2511 /* Update 'boot.ini' */
2512 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2513 wcscat(DstPath
, L
"\\boot.ini");
2515 DPRINT1("Update 'boot.ini': %S\n", DstPath
);
2516 Status
= UpdateBootIni(DstPath
,
2517 L
"C:\\bootsect.ros",
2519 if (!NT_SUCCESS(Status
))
2521 DPRINT1("UpdateBootIni() failed (Status %lx)\n", Status
);
2522 PopupError("Setup failed to update \'boot.ini\'.",
2523 "ENTER = Reboot computer");
2529 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2538 /* Update existing 'freeldr.ini' */
2539 DPRINT1("Update existing 'freeldr.ini'\n");
2540 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2541 wcscat(DstPath
, L
"\\freeldr.ini");
2543 Status
= UpdateFreeLoaderIni(DstPath
,
2544 DestinationArcPath
.Buffer
);
2545 if (!NT_SUCCESS(Status
))
2547 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
2548 PopupError("Setup failed to update 'freeldr.ini'.",
2549 "ENTER = Reboot computer");
2555 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2563 else if (DoesFileExist(SystemRootPath
.Buffer
, L
"io.sys") == TRUE
||
2564 DoesFileExist(SystemRootPath
.Buffer
, L
"msdos.sys") == TRUE
)
2566 /* Search for root directory for 'io.sys' and 'msdos.sys'. */
2567 DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n");
2569 /* Copy FreeLoader to the boot partition */
2570 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2571 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2572 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2573 wcscat(DstPath
, L
"\\freeldr.sys");
2575 DPRINT("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2576 Status
= SetupCopyFile(SrcPath
, DstPath
);
2577 if (!NT_SUCCESS(Status
))
2579 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2580 PopupError("Setup failed to copy 'freeldr.sys'.",
2581 "ENTER = Reboot computer");
2587 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2594 /* Create or update 'freeldr.ini' */
2595 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2597 /* Create new 'freeldr.ini' */
2598 DPRINT1("Create new 'freeldr.ini'\n");
2599 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2600 wcscat(DstPath
, L
"\\freeldr.ini");
2602 Status
= CreateFreeLoaderIniForDos(DstPath
,
2603 DestinationArcPath
.Buffer
);
2604 if (!NT_SUCCESS(Status
))
2606 DPRINT1("CreateFreeLoaderIniForDos() failed (Status %lx)\n", Status
);
2607 PopupError("Setup failed to create 'freeldr.ini'.",
2608 "ENTER = Reboot computer");
2614 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2621 /* Save current bootsector as 'BOOTSECT.DOS' */
2622 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
2623 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2624 wcscat(DstPath
, L
"\\bootsect.dos");
2626 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
2627 Status
= SaveCurrentBootSector(SrcPath
,
2629 if (!NT_SUCCESS(Status
))
2631 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
2632 PopupError("Setup failed to save the current bootsector.",
2633 "ENTER = Reboot computer");
2639 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2646 /* Install new bootsector */
2647 if ((PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2648 (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2650 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2651 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2653 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2654 Status
= InstallFat32BootCodeToDisk(SrcPath
,
2655 SystemRootPath
.Buffer
);
2656 if (!NT_SUCCESS(Status
))
2658 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
2659 PopupError("Setup failed to install the FAT32 bootcode.",
2660 "ENTER = Reboot computer");
2666 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2675 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2676 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2678 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2679 Status
= InstallFat16BootCodeToDisk(SrcPath
,
2680 SystemRootPath
.Buffer
);
2681 if (!NT_SUCCESS(Status
))
2683 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
2684 PopupError("Setup failed to install the FAT bootcode.",
2685 "ENTER = Reboot computer");
2691 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2701 /* Update existing 'freeldr.ini' */
2702 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2703 wcscat(DstPath
, L
"\\freeldr.ini");
2705 Status
= UpdateFreeLoaderIni(DstPath
,
2706 DestinationArcPath
.Buffer
);
2707 if (!NT_SUCCESS(Status
))
2709 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
2710 PopupError("Setup failed to update 'freeldr.ini'.",
2711 "ENTER = Reboot computer");
2717 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2727 /* No or unknown boot loader */
2728 DPRINT1("No or unknown boot loader found\n");
2730 /* Copy FreeLoader to the boot partition */
2731 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2732 wcscat(SrcPath
, L
"\\loader\\freeldr.sys");
2733 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2734 wcscat(DstPath
, L
"\\freeldr.sys");
2736 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2737 Status
= SetupCopyFile(SrcPath
, DstPath
);
2738 if (!NT_SUCCESS(Status
))
2740 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status
);
2741 PopupError("Setup failed to copy 'freeldr.sys'.",
2742 "ENTER = Reboot computer");
2748 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2755 /* Create or update 'freeldr.ini' */
2756 if (DoesFileExist(SystemRootPath
.Buffer
, L
"freeldr.ini") == FALSE
)
2758 /* Create new freeldr.ini */
2759 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2760 wcscat(DstPath
, L
"\\freeldr.ini");
2762 DPRINT1("Copy: %S ==> %S\n", SrcPath
, DstPath
);
2763 Status
= CreateFreeLoaderIniForReactos(DstPath
,
2764 DestinationArcPath
.Buffer
);
2765 if (!NT_SUCCESS(Status
))
2767 DPRINT1("CreateFreeLoaderIniForReactos() failed (Status %lx)\n", Status
);
2768 PopupError("Setup failed to create \'freeldr.ini\'.",
2769 "ENTER = Reboot computer");
2775 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2782 /* Save current bootsector as 'BOOTSECT.OLD' */
2783 wcscpy(SrcPath
, SystemRootPath
.Buffer
);
2784 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2785 wcscat(DstPath
, L
"\\bootsect.old");
2787 DPRINT1("Save bootsector: %S ==> %S\n", SrcPath
, DstPath
);
2788 Status
= SaveCurrentBootSector(SrcPath
,
2790 if (!NT_SUCCESS(Status
))
2792 DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status
);
2793 PopupError("Setup failed save the current bootsector.",
2794 "ENTER = Reboot computer");
2800 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2807 /* Install new bootsector */
2808 if ((PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32
) ||
2809 (PartitionList
->ActiveBootPartition
->PartInfo
[0].PartitionType
== PARTITION_FAT32_XINT13
))
2811 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2812 wcscat(SrcPath
, L
"\\loader\\fat32.bin");
2814 DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2815 Status
= InstallFat32BootCodeToDisk(SrcPath
,
2816 SystemRootPath
.Buffer
);
2817 if (!NT_SUCCESS(Status
))
2819 DPRINT1("InstallFat32BootCodeToDisk() failed (Status %lx)\n", Status
);
2820 PopupError("Setup failed to install the FAT32 bootcode.",
2821 "ENTER = Reboot computer");
2827 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2836 wcscpy(SrcPath
, SourceRootPath
.Buffer
);
2837 wcscat(SrcPath
, L
"\\loader\\fat.bin");
2839 DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath
, SystemRootPath
.Buffer
);
2840 Status
= InstallFat16BootCodeToDisk(SrcPath
,
2841 SystemRootPath
.Buffer
);
2842 if (!NT_SUCCESS(Status
))
2844 DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status
);
2845 PopupError("Setup failed to install the FAT bootcode.",
2846 "ENTER = Reboot computer");
2852 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2862 /* Update existing 'freeldr.ini' */
2863 wcscpy(DstPath
, SystemRootPath
.Buffer
);
2864 wcscat(DstPath
, L
"\\freeldr.ini");
2866 Status
= UpdateFreeLoaderIni(DstPath
,
2867 DestinationArcPath
.Buffer
);
2868 if (!NT_SUCCESS(Status
))
2870 DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status
);
2871 PopupError("Setup failed to update 'freeldr.ini'.",
2872 "ENTER = Reboot computer");
2878 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2889 /* Unknown partition */
2890 DPRINT1("Unknown partition found\n");
2891 PopupError("Setup found an unknown partiton type.\n"
2892 "This partition type is not supported!",
2893 "ENTER = Reboot computer");
2899 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2906 return(SUCCESS_PAGE
);
2912 QuitPage(PINPUT_RECORD Ir
)
2914 SetTextXY(10, 6, "ReactOS is not completely installed");
2916 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2917 SetTextXY(10, 9, "all CD-ROMs from CD-Drives.");
2919 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2921 SetStatusText(" Please wait ...");
2923 /* Destroy partition list */
2924 if (PartitionList
!= NULL
)
2926 DestroyPartitionList (PartitionList
);
2927 PartitionList
= NULL
;
2930 /* Destroy filesystem list */
2931 if (FileSystemList
!= NULL
)
2933 DestroyFileSystemList (FileSystemList
);
2934 FileSystemList
= NULL
;
2937 SetStatusText(" ENTER = Reboot computer");
2943 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2945 return(REBOOT_PAGE
);
2952 SuccessPage(PINPUT_RECORD Ir
)
2954 SetTextXY(10, 6, "The basic components of ReactOS have been installed successfully.");
2956 SetTextXY(10, 8, "Remove floppy disk from Drive A: and");
2957 SetTextXY(10, 9, "all CD-ROMs from CD-Drive.");
2959 SetTextXY(10, 11, "Press ENTER to reboot your computer.");
2961 SetStatusText(" ENTER = Reboot computer");
2967 if (Ir
->Event
.KeyEvent
.uChar
.AsciiChar
== 0x0D) /* ENTER */
2969 return(REBOOT_PAGE
);
2976 NtProcessStartup(PPEB Peb
)
2982 RtlNormalizeProcessParams(Peb
->ProcessParameters
);
2984 ProcessHeap
= Peb
->ProcessHeap
;
2986 Status
= AllocConsole();
2987 if (!NT_SUCCESS(Status
))
2989 PrintString("AllocConsole() failed (Status = 0x%08lx)\n", Status
);
2991 /* Raise a hard error (crash the system/BSOD) */
2992 NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED
,
2997 /* Initialize global unicode strings */
2998 RtlInitUnicodeString(&SourcePath
, NULL
);
2999 RtlInitUnicodeString(&SourceRootPath
, NULL
);
3000 RtlInitUnicodeString(&InstallPath
, NULL
);
3001 RtlInitUnicodeString(&DestinationPath
, NULL
);
3002 RtlInitUnicodeString(&DestinationArcPath
, NULL
);
3003 RtlInitUnicodeString(&DestinationRootPath
, NULL
);
3004 RtlInitUnicodeString(&SystemRootPath
, NULL
);
3008 while (Page
!= REBOOT_PAGE
)
3012 SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR
" Setup ");
3018 Page
= StartPage(&Ir
);
3023 Page
= IntroPage(&Ir
);
3027 case INSTALL_INTRO_PAGE
:
3028 Page
= InstallIntroPage(&Ir
);
3032 case OEM_DRIVER_PAGE
:
3033 Page
= OemDriverPage(&Ir
);
3038 case DEVICE_SETTINGS_PAGE
:
3041 case SELECT_PARTITION_PAGE
:
3042 Page
= SelectPartitionPage(&Ir
);
3045 case CREATE_PARTITION_PAGE
:
3046 Page
= CreatePartitionPage(&Ir
);
3049 case DELETE_PARTITION_PAGE
:
3050 Page
= DeletePartitionPage(&Ir
);
3053 case SELECT_FILE_SYSTEM_PAGE
:
3054 Page
= SelectFileSystemPage(&Ir
);
3057 case FORMAT_PARTITION_PAGE
:
3058 Page
= FormatPartitionPage(&Ir
);
3061 case CHECK_FILE_SYSTEM_PAGE
:
3062 Page
= CheckFileSystemPage(&Ir
);
3065 case INSTALL_DIRECTORY_PAGE
:
3066 Page
= InstallDirectoryPage(&Ir
);
3069 case PREPARE_COPY_PAGE
:
3070 Page
= PrepareCopyPage(&Ir
);
3073 case FILE_COPY_PAGE
:
3074 Page
= FileCopyPage(&Ir
);
3078 Page
= RegistryPage(&Ir
);
3081 case BOOT_LOADER_PAGE
:
3082 Page
= BootLoaderPage(&Ir
);
3087 case REPAIR_INTRO_PAGE
:
3088 Page
= RepairIntroPage(&Ir
);
3092 /* Emergency pages */
3093 case EMERGENCY_INTRO_PAGE
:
3094 Page
= EmergencyIntroPage(&Ir
);
3099 Page
= SuccessPage(&Ir
);
3103 Page
= QuitPage(&Ir
);
3110 NtShutdownSystem(ShutdownReboot
);