ReactOS 0.4.16-dev-2617-g01a0906
winldr.h File Reference
#include <arc/setupblk.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for winldr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  RSDP_DESCRIPTOR
 
struct  _ARC_DISK_SIGNATURE_EX
 

Macros

#define TAG_WLDR_DTE   'eDlW'
 
#define TAG_WLDR_BDE   'dBlW'
 
#define TAG_WLDR_NAME   'mNlW'
 
#define BOOT_LOGGING   (1 << 0)
 
#define BOOT_VGA_MODE   (1 << 1)
 
#define BOOT_DEBUGGING   (1 << 2)
 

Typedefs

typedef struct RSDP_DESCRIPTORPRSDP_DESCRIPTOR
 
typedef struct _ARC_DISK_SIGNATURE_EX ARC_DISK_SIGNATURE_EX
 
typedef struct _ARC_DISK_SIGNATURE_EXPARC_DISK_SIGNATURE_EX
 

Enumerations

enum  BootOption {
  NO_OPTION = 0 , SAFEBOOT , SAFEBOOT_NETWORK , SAFEBOOT_ALTSHELL ,
  SAFEBOOT_DSREPAIR , LKG_CONFIG
}
 

Functions

VOID MenuNTOptions (_Inout_ OperatingSystemItem *OperatingSystem)
 
VOID AppendBootTimeOptions (_Inout_z_bytecount_(BootOptionsSize) PSTR BootOptions, _In_ SIZE_T BootOptionsSize)
 
ARC_STATUS LoadAndBootWindows (IN ULONG Argc, IN PCHAR Argv[], IN PCHAR Envp[])
 
ARC_STATUS LoadReactOSSetup (IN ULONG Argc, IN PCHAR Argv[], IN PCHAR Envp[])
 
PVOID VaToPa (PVOID Va)
 
PVOID PaToVa (PVOID Pa)
 
VOID List_PaToVa (_In_ LIST_ENTRY *ListEntry)
 

Variables

enum BootOption BootOptionChoice
 
LOGICAL BootFlags
 

Macro Definition Documentation

◆ BOOT_DEBUGGING

#define BOOT_DEBUGGING   (1 << 2)

Definition at line 61 of file winldr.h.

◆ BOOT_LOGGING

#define BOOT_LOGGING   (1 << 0)

Definition at line 59 of file winldr.h.

◆ BOOT_VGA_MODE

#define BOOT_VGA_MODE   (1 << 1)

Definition at line 60 of file winldr.h.

◆ TAG_WLDR_BDE

#define TAG_WLDR_BDE   'dBlW'

Definition at line 14 of file winldr.h.

◆ TAG_WLDR_DTE

#define TAG_WLDR_DTE   'eDlW'

Definition at line 13 of file winldr.h.

◆ TAG_WLDR_NAME

#define TAG_WLDR_NAME   'mNlW'

Definition at line 15 of file winldr.h.

Typedef Documentation

◆ ARC_DISK_SIGNATURE_EX

◆ PARC_DISK_SIGNATURE_EX

◆ PRSDP_DESCRIPTOR

Enumeration Type Documentation

◆ BootOption

Enumerator
NO_OPTION 
SAFEBOOT 
SAFEBOOT_NETWORK 
SAFEBOOT_ALTSHELL 
SAFEBOOT_DSREPAIR 
LKG_CONFIG 

Definition at line 47 of file winldr.h.

48{
49 NO_OPTION = 0,
50
55
57};
@ SAFEBOOT
Definition: winldr.h:51
@ LKG_CONFIG
Definition: winldr.h:56
@ SAFEBOOT_DSREPAIR
Definition: winldr.h:54
@ SAFEBOOT_NETWORK
Definition: winldr.h:52
@ SAFEBOOT_ALTSHELL
Definition: winldr.h:53
@ NO_OPTION
Definition: winldr.h:49

Function Documentation

◆ AppendBootTimeOptions()

VOID AppendBootTimeOptions ( _Inout_z_bytecount_(BootOptionsSize) PSTR  BootOptions,
_In_ SIZE_T  BootOptionsSize 
)

Definition at line 185 of file advopts.c.

189{
190 /* NOTE: Keep in sync with the 'enum BootOption' in winldr.h */
191 static const PCSTR OptionsStr[] =
192 {
193 /* NO_OPTION */ NULL,
194 /* SAFEBOOT */ "SAFEBOOT:MINIMAL SOS NOGUIBOOT",
195 /* SAFEBOOT_NETWORK */ "SAFEBOOT:NETWORK SOS NOGUIBOOT",
196 /* SAFEBOOT_ALTSHELL */ "SAFEBOOT:MINIMAL(ALTERNATESHELL) SOS NOGUIBOOT",
197 /* SAFEBOOT_DSREPAIR */ "SAFEBOOT:DSREPAIR SOS",
198 /* LKG_CONFIG */ NULL,
199 };
200
201 if (BootOptionsSize < sizeof(CHAR))
202 return;
203
204 switch (BootOptionChoice)
205 {
206 case SAFEBOOT:
207 case SAFEBOOT_NETWORK:
210 {
212 NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, OptionsStr[BootOptionChoice]);
213 break;
214 }
215
216 case LKG_CONFIG:
217 DbgPrint("Last known good configuration is not supported yet!\n");
218 break;
219
220 default:
221 break;
222 }
223
225 NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "BOOTLOG");
226
228 NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "BASEVIDEO");
229
231 NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "DEBUG");
232}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
LOGICAL BootFlags
Definition: advopts.c:44
enum BootOption BootOptionChoice
Definition: advopts.c:43
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define DbgPrint
Definition: hal.h:12
#define BOOT_DEBUGGING
Definition: winldr.h:61
#define BOOT_LOGGING
Definition: winldr.h:59
#define BOOT_VGA_MODE
Definition: winldr.h:60
#define ASSERT(a)
Definition: mode.c:44
VOID NtLdrAddOptions(IN OUT PSTR LoadOptions, IN ULONG BufferSize, IN BOOLEAN Append, IN PCSTR NewOptions OPTIONAL)
Definition: ntldropts.c:140
char CHAR
Definition: pedump.c:57
const char * PCSTR
Definition: typedefs.h:52

Referenced by LoadAndBootWindows(), and LoadReactOSSetup().

◆ List_PaToVa()

VOID List_PaToVa ( _In_ LIST_ENTRY ListEntry)

◆ LoadAndBootWindows()

ARC_STATUS LoadAndBootWindows ( IN ULONG  Argc,
IN PCHAR  Argv[],
IN PCHAR  Envp[] 
)

Definition at line 1179 of file winldr.c.

1183{
1185 PCSTR ArgValue;
1190 USHORT OperatingSystemVersion;
1191 PLOADER_PARAMETER_BLOCK LoaderBlock;
1192 CHAR BootPath[MAX_PATH];
1194 CHAR BootOptions[MAX_OPTIONS_LENGTH+1];
1195
1196 /* Retrieve the (mandatory) boot type */
1197 ArgValue = GetArgumentValue(Argc, Argv, "BootType");
1198 if (!ArgValue || !*ArgValue)
1199 {
1200 ERR("No 'BootType' value, aborting!\n");
1201 return EINVAL;
1202 }
1203
1204 /* Convert it to an OS version */
1205 if (_stricmp(ArgValue, "Windows") == 0 ||
1206 _stricmp(ArgValue, "Windows2003") == 0)
1207 {
1208 OperatingSystemVersion = _WIN32_WINNT_WS03;
1209 }
1210 else if (_stricmp(ArgValue, "WindowsNT40") == 0)
1211 {
1212 OperatingSystemVersion = _WIN32_WINNT_NT4;
1213 }
1214 else if (_stricmp(ArgValue, "WindowsVista") == 0)
1215 {
1216 OperatingSystemVersion = _WIN32_WINNT_VISTA;
1217 }
1218 else
1219 {
1220 ERR("Unknown 'BootType' value '%s', aborting!\n", ArgValue);
1221 return EINVAL;
1222 }
1223
1224 /* Retrieve the (mandatory) system partition */
1225 SystemPartition = GetArgumentValue(Argc, Argv, "SystemPartition");
1227 {
1228 ERR("No 'SystemPartition' specified, aborting!\n");
1229 return EINVAL;
1230 }
1231
1232 /* Let the user know we started loading */
1234 UiDrawStatusText("Loading...");
1235 UiDrawProgressBarCenter("Loading NT...");
1236
1237 /* Retrieve the system path */
1238 *BootPath = ANSI_NULL;
1239 ArgValue = GetArgumentValue(Argc, Argv, "SystemPath");
1240 if (ArgValue)
1241 RtlStringCbCopyA(BootPath, sizeof(BootPath), ArgValue);
1242
1243 /*
1244 * Check whether BootPath is a full path
1245 * and if not, create a full boot path.
1246 *
1247 * See FsOpenFile for the technique used.
1248 */
1249 if (strrchr(BootPath, ')') == NULL)
1250 {
1251 /* Temporarily save the boot path */
1252 RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
1253
1254 /* This is not a full path: prepend the SystemPartition */
1255 RtlStringCbCopyA(BootPath, sizeof(BootPath), SystemPartition);
1256
1257 /* Append a path separator if needed */
1258 if (*FilePath != '\\' && *FilePath != '/')
1259 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
1260
1261 /* Append the remaining path */
1262 RtlStringCbCatA(BootPath, sizeof(BootPath), FilePath);
1263 }
1264
1265 /* Append a path separator if needed */
1266 if (!*BootPath || BootPath[strlen(BootPath) - 1] != '\\')
1267 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
1268
1269 TRACE("BootPath: '%s'\n", BootPath);
1270
1271 /* Retrieve the boot options */
1272 *BootOptions = ANSI_NULL;
1273 ArgValue = GetArgumentValue(Argc, Argv, "Options");
1274 if (ArgValue && *ArgValue)
1275 RtlStringCbCopyA(BootOptions, sizeof(BootOptions), ArgValue);
1276 TRACE("BootOptions(1): '%s'\n", BootOptions);
1277
1278 /*
1279 * Set the "/HAL=" and "/KERNEL=" options if needed.
1280 * If already present on the standard "Options=" option line, they take
1281 * precedence over those passed via the separate "Hal=" and "Kernel="
1282 * options.
1283 */
1284 if (!NtLdrGetOption(BootOptions, "HAL="))
1285 {
1286 /*
1287 * Not found in the options, try to retrieve the
1288 * separate value and append it to the options.
1289 */
1290 ArgValue = GetArgumentValue(Argc, Argv, "Hal");
1291 if (ArgValue && *ArgValue)
1292 {
1293 RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /HAL=");
1294 RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
1295 }
1296 }
1297 if (!NtLdrGetOption(BootOptions, "KERNEL="))
1298 {
1299 /*
1300 * Not found in the options, try to retrieve the
1301 * separate value and append it to the options.
1302 */
1303 ArgValue = GetArgumentValue(Argc, Argv, "Kernel");
1304 if (ArgValue && *ArgValue)
1305 {
1306 RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /KERNEL=");
1307 RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
1308 }
1309 }
1310
1311 /* Append boot-time options */
1312 AppendBootTimeOptions(BootOptions, sizeof(BootOptions));
1313
1314 /* Post-process the boot options */
1315 NtLdrNormalizeOptions(BootOptions);
1316 TRACE("BootOptions(2): '%s'\n", BootOptions);
1317
1318 /* Check if a RAM disk file was given */
1319 FileName = NtLdrGetOptionEx(BootOptions, "RDPATH=", &FileNameLength);
1320 if (FileName && (FileNameLength >= 7))
1321 {
1322 /* Load the RAM disk */
1324 if (Status != ESUCCESS)
1325 {
1326 FileName += 7; FileNameLength -= 7;
1327 UiMessageBox("Failed to load RAM disk file '%.*s'",
1329 return Status;
1330 }
1331 }
1332
1333 /* Handle the SOS option */
1334 SosEnabled = !!NtLdrGetOption(BootOptions, "SOS");
1335 if (SosEnabled)
1336 UiResetForSOS();
1337
1338 /* Allocate and minimally-initialize the Loader Parameter Block */
1339 AllocateAndInitLPB(OperatingSystemVersion, &LoaderBlock);
1340
1341 /* Load the system hive */
1342 UiUpdateProgressBar(15, "Loading system hive...");
1343 Success = WinLdrInitSystemHive(LoaderBlock, BootPath, FALSE);
1344 TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
1345 /* Bail out if failure */
1346 if (!Success)
1347 return ENOEXEC;
1348
1349 /* Fixup the version number using data from the registry */
1350 if (OperatingSystemVersion == 0)
1351 OperatingSystemVersion = WinLdrDetectVersion();
1352 LoaderBlock->Extension->MajorVersion = (OperatingSystemVersion & 0xFF00) >> 8;
1353 LoaderBlock->Extension->MinorVersion = (OperatingSystemVersion & 0xFF);
1354
1355 /* Load NLS data, OEM font, and prepare boot drivers list */
1356 Success = WinLdrScanSystemHive(LoaderBlock, BootPath);
1357 TRACE("SYSTEM hive %s\n", (Success ? "scanned" : "not scanned"));
1358 /* Bail out if failure */
1359 if (!Success)
1360 return ENOEXEC;
1361
1362 /* Load the Firmware Errata file */
1363 Success = WinLdrInitErrataInf(LoaderBlock, OperatingSystemVersion, BootPath);
1364 TRACE("Firmware Errata file %s\n", (Success ? "loaded" : "not loaded"));
1365 /* Not necessarily fatal if not found - carry on going */
1366
1367 /* Finish loading */
1368 return LoadAndBootWindowsCommon(OperatingSystemVersion,
1369 LoaderBlock,
1370 BootOptions,
1372 BootPath);
1373}
PCWSTR FilePath
unsigned char BOOLEAN
Definition: actypes.h:127
PSTR GetArgumentValue(_In_ ULONG Argc, _In_ PCHAR Argv[], _In_ PCSTR ArgumentName)
Definition: arcsupp.c:42
PPARTENTRY SystemPartition
Definition: reactos.c:50
#define ERR(fmt,...)
Definition: precomp.h:57
ARC_STATUS RamDiskInitialize(IN BOOLEAN InitRamDisk, IN PCSTR LoadOptions OPTIONAL, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:229
VOID UiDrawBackdrop(ULONG DrawHeight)
Definition: ui.c:233
VOID UiUpdateProgressBar(_In_ ULONG Percentage, _In_opt_ PCSTR ProgressText)
Definition: ui.c:454
ULONG UiGetScreenHeight(VOID)
Definition: ui.c:655
VOID UiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: ui.c:487
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:286
VOID UiResetForSOS(VOID)
Definition: ui.c:639
VOID UiMessageBox(_In_ PCSTR Format,...)
Definition: ui.c:359
#define _stricmp
Definition: cat.c:22
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
#define EINVAL
Definition: errno.h:44
#define ENOEXEC
Definition: errno.h:31
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP char *__cdecl strrchr(const char *, int)
Definition: string.c:3298
@ Success
Definition: eventcreate.c:712
struct _FileName FileName
Definition: fatprocs.h:897
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ HANDLE _In_ ULONG FileNameLength
Definition: fltkernel.h:1129
Status
Definition: gdiplustypes.h:25
VOID AppendBootTimeOptions(_Inout_z_bytecount_(BootOptionsSize) PSTR BootOptions, _In_ SIZE_T BootOptionsSize)
Definition: advopts.c:185
#define ANSI_NULL
#define MAX_OPTIONS_LENGTH
Definition: winldr.h:44
BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot, IN BOOLEAN Setup)
Definition: wlregistry.c:125
BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot)
Definition: wlregistry.c:231
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
unsigned short USHORT
Definition: pedump.c:61
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
#define TRACE(s)
Definition: solgame.cpp:4
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:857
uint32_t ULONG
Definition: typedefs.h:59
VOID NtLdrNormalizeOptions(_Inout_ PSTR LoadOptions)
Normalize in-place the NT boot options by removing any leading '/', normalizing TABs to spaces,...
Definition: winldr.c:1151
USHORT WinLdrDetectVersion(VOID)
Definition: winldr.c:507
static BOOLEAN WinLdrInitErrataInf(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN USHORT OperatingSystemVersion, IN PCSTR SystemRoot)
Definition: winldr.c:1086
ARC_STATUS LoadAndBootWindowsCommon(_In_ USHORT OperatingSystemVersion, _In_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ PCSTR BootOptions, _In_ PCSTR SystemPartition, _In_ PCSTR BootPath)
Definition: winldr.c:1376
BOOLEAN SosEnabled
Definition: winldr.c:34
VOID AllocateAndInitLPB(IN USHORT VersionToBoot, OUT PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
Definition: winldr.c:80

◆ LoadReactOSSetup()

ARC_STATUS LoadReactOSSetup ( IN ULONG  Argc,
IN PCHAR  Argv[],
IN PCHAR  Envp[] 
)

Definition at line 492 of file setupldr.c.

496{
498 PCSTR ArgValue;
500 PCSTR SystemPath;
503 BOOLEAN BootFromFloppy;
505 HINF InfHandle;
506 INFCONTEXT InfContext;
507 ULONG i, ErrorLine;
508 PLOADER_PARAMETER_BLOCK LoaderBlock;
509 PSETUP_LOADER_BLOCK SetupBlock;
510 CHAR BootPath[MAX_PATH];
512 CHAR UserBootOptions[MAX_OPTIONS_LENGTH+1];
513 PCSTR BootOptions;
514
515 static PCSTR SourcePaths[] =
516 {
517 "", /* Only for floppy boot */
518#if defined(_M_IX86)
519 "I386\\",
520#elif defined(_M_MPPC)
521 "PPC\\",
522#elif defined(_M_MRX000)
523 "MIPS\\",
524#endif
525 "reactos\\",
526 NULL
527 };
528
529 /* Retrieve the (mandatory) boot type */
530 ArgValue = GetArgumentValue(Argc, Argv, "BootType");
531 if (!ArgValue || !*ArgValue)
532 {
533 ERR("No 'BootType' value, aborting!\n");
534 return EINVAL;
535 }
536 if (_stricmp(ArgValue, "ReactOSSetup") != 0)
537 {
538 ERR("Unknown 'BootType' value '%s', aborting!\n", ArgValue);
539 return EINVAL;
540 }
541
542 /* Retrieve the (mandatory) system partition */
543 SystemPartition = GetArgumentValue(Argc, Argv, "SystemPartition");
545 {
546 ERR("No 'SystemPartition' specified, aborting!\n");
547 return EINVAL;
548 }
549
550 /* Let the user know we started loading */
552 UiDrawStatusText("Setup is loading...");
553 UiDrawProgressBarCenter("Loading ReactOS Setup...");
554
555 /* Retrieve the system path */
556 *BootPath = ANSI_NULL;
557 ArgValue = GetArgumentValue(Argc, Argv, "SystemPath");
558 if (ArgValue)
559 {
560 RtlStringCbCopyA(BootPath, sizeof(BootPath), ArgValue);
561 }
562 else
563 {
564 /*
565 * IMPROVE: I don't want to use the SystemPartition here as a
566 * default choice because I can do it after (see few lines below).
567 * Instead I reset BootPath here so that we can build the full path
568 * using the general code from below.
569 */
570 // RtlStringCbCopyA(BootPath, sizeof(BootPath), SystemPartition);
571 *BootPath = ANSI_NULL;
572 }
573
574 /*
575 * Check whether BootPath is a full path
576 * and if not, create a full boot path.
577 *
578 * See FsOpenFile for the technique used.
579 */
580 if (strrchr(BootPath, ')') == NULL)
581 {
582 /* Temporarily save the boot path */
583 RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
584
585 /* This is not a full path: prepend the SystemPartition */
586 RtlStringCbCopyA(BootPath, sizeof(BootPath), SystemPartition);
587
588 /* Append a path separator if needed */
589 if (*FilePath != '\\' && *FilePath != '/')
590 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
591
592 /* Append the remaining path */
593 RtlStringCbCatA(BootPath, sizeof(BootPath), FilePath);
594 }
595
596 /* Append a path separator if needed */
597 if (!*BootPath || BootPath[strlen(BootPath) - 1] != '\\')
598 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
599
600 TRACE("BootPath: '%s'\n", BootPath);
601
602 /*
603 * Retrieve the boot options. Any options present here will supplement or
604 * override those that will be specified in TXTSETUP.SIF's OsLoadOptions.
605 */
606 BootOptions = GetArgumentValue(Argc, Argv, "Options");
607 if (!BootOptions)
608 BootOptions = "";
609 TRACE("BootOptions(1): '%s'\n", BootOptions);
610
611 /* Check if a RAM disk file was given */
612 FileName = (PSTR)NtLdrGetOptionEx(BootOptions, "RDPATH=", &FileNameLength);
613 if (FileName && (FileNameLength >= 7))
614 {
615 /* Load the RAM disk */
617 if (Status != ESUCCESS)
618 {
619 FileName += 7; FileNameLength -= 7;
620 UiMessageBox("Failed to load RAM disk file '%.*s'",
622 return Status;
623 }
624 }
625
626 /* Check if we booted from floppy */
627 BootFromFloppy = strstr(BootPath, "fdisk") != NULL;
628
629 /* Open 'txtsetup.sif' from any of the source paths */
630 FileName = BootPath + strlen(BootPath);
631 for (i = BootFromFloppy ? 0 : 1; ; i++)
632 {
633 SystemPath = SourcePaths[i];
634 if (!SystemPath)
635 {
636 UiMessageBox("Failed to open txtsetup.sif");
637 return ENOENT;
638 }
639 FileNameLength = (ULONG)(sizeof(BootPath) - (FileName - BootPath)*sizeof(CHAR));
641 RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
642 RtlStringCbCatA(FilePath, sizeof(FilePath), "txtsetup.sif");
643 if (InfOpenFile(&InfHandle, FilePath, &ErrorLine))
644 {
645 break;
646 }
647 }
648
649 TRACE("BootPath: '%s', SystemPath: '%s'\n", BootPath, SystemPath);
650
651 // UseLocalSif = NtLdrGetOption(BootOptions, "USELOCALSIF");
652 if (NtLdrGetOption(BootOptions, "SIFOPTIONSOVERRIDE"))
653 {
654 PCSTR OptionsToRemove[2] = {"SIFOPTIONSOVERRIDE", NULL};
655
656 /* Do not use any load options from TXTSETUP.SIF, but
657 * use instead those passed from the command line. */
658 RtlStringCbCopyA(UserBootOptions, sizeof(UserBootOptions), BootOptions);
659
660 /* Remove the private switch from the options */
661 NtLdrUpdateLoadOptions(UserBootOptions,
662 sizeof(UserBootOptions),
663 FALSE,
664 NULL,
665 OptionsToRemove);
666 }
667 else // if (!*BootOptions || NtLdrGetOption(BootOptions, "SIFOPTIONSADD"))
668 {
669 PCSTR LoadOptions = NULL;
670 PCSTR DbgLoadOptions = NULL;
671 PSTR ExtraOptions, HigherPriorityOptions;
672 PSTR OptionsToAdd[3];
673 PSTR OptionsToRemove[4];
674
675 /* Load the options from TXTSETUP.SIF */
676 if (InfFindFirstLine(InfHandle, "SetupData", "OsLoadOptions", &InfContext))
677 {
678 if (!InfGetDataField(&InfContext, 1, &LoadOptions))
679 WARN("Failed to get load options\n");
680 }
681
682#if !DBG
683 /* Non-debug mode: get the debug load options only if /DEBUG was specified
684 * in the Argv command-line options (was e.g. added to the options when
685 * the user selected "Debugging Mode" in the advanced boot menu). */
686 if (NtLdrGetOption(BootOptions, "DEBUG") ||
687 NtLdrGetOption(BootOptions, "DEBUG="))
688 {
689#else
690 /* Debug mode: always get the debug load options */
691#endif
692 if (InfFindFirstLine(InfHandle, "SetupData", "SetupDebugOptions", &InfContext))
693 {
694 if (!InfGetDataField(&InfContext, 1, &DbgLoadOptions))
695 WARN("Failed to get debug load options\n");
696 }
697 /* If none was found, default to enabling debugging */
698 if (!DbgLoadOptions)
699 DbgLoadOptions = "/DEBUG";
700#if !DBG
701 }
702#endif
703
704 /* Initialize the load options with those from TXTSETUP.SIF */
705 *UserBootOptions = ANSI_NULL;
706 if (LoadOptions && *LoadOptions)
707 RtlStringCbCopyA(UserBootOptions, sizeof(UserBootOptions), LoadOptions);
708
709 /* Merge the debug load options if any */
710 if (DbgLoadOptions)
711 {
712 RtlZeroMemory(OptionsToAdd, sizeof(OptionsToAdd));
713 RtlZeroMemory(OptionsToRemove, sizeof(OptionsToRemove));
714
715 /*
716 * Retrieve any option patterns that we should remove from the
717 * SIF load options because they are of higher precedence than
718 * those specified in the debug load options to be added.
719 * Also always remove NODEBUG (even if the debug load options
720 * do not contain explicitly the DEBUG option), since we want
721 * to have debugging enabled if possible.
722 */
723 OptionsToRemove[0] = "/NODEBUG";
724 NtLdrGetHigherPriorityOptions(DbgLoadOptions,
726 &HigherPriorityOptions);
727 OptionsToAdd[1] = (ExtraOptions ? ExtraOptions : "");
728 OptionsToRemove[1] = (HigherPriorityOptions ? HigherPriorityOptions : "");
729
730 /*
731 * Prepend the debug load options, so that in case it contains
732 * redundant options with respect to the SIF load options, the
733 * former can take precedence over the latter.
734 */
735 OptionsToAdd[0] = (PSTR)DbgLoadOptions;
736 OptionsToRemove[2] = (PSTR)DbgLoadOptions;
737 NtLdrUpdateLoadOptions(UserBootOptions,
738 sizeof(UserBootOptions),
739 FALSE,
740 (PCSTR*)OptionsToAdd,
741 (PCSTR*)OptionsToRemove);
742
743 if (ExtraOptions)
745 if (HigherPriorityOptions)
746 FrLdrHeapFree(HigherPriorityOptions, TAG_BOOT_OPTIONS);
747 }
748
749 RtlZeroMemory(OptionsToAdd, sizeof(OptionsToAdd));
750 RtlZeroMemory(OptionsToRemove, sizeof(OptionsToRemove));
751
752 /*
753 * Retrieve any option patterns that we should remove from the
754 * SIF load options because they are of higher precedence than
755 * those specified in the options to be added.
756 */
759 &HigherPriorityOptions);
760 OptionsToAdd[1] = (ExtraOptions ? ExtraOptions : "");
761 OptionsToRemove[0] = (HigherPriorityOptions ? HigherPriorityOptions : "");
762
763 /* Finally, prepend the user-specified options that
764 * take precedence over those from TXTSETUP.SIF. */
765 OptionsToAdd[0] = (PSTR)BootOptions;
766 OptionsToRemove[1] = (PSTR)BootOptions;
767 NtLdrUpdateLoadOptions(UserBootOptions,
768 sizeof(UserBootOptions),
769 FALSE,
770 (PCSTR*)OptionsToAdd,
771 (PCSTR*)OptionsToRemove);
772
773 if (ExtraOptions)
775 if (HigherPriorityOptions)
776 FrLdrHeapFree(HigherPriorityOptions, TAG_BOOT_OPTIONS);
777 }
778
779 /* Append boot-time options */
780 AppendBootTimeOptions(UserBootOptions, sizeof(UserBootOptions));
781
782 /* Post-process the boot options */
783 NtLdrNormalizeOptions(UserBootOptions);
784 BootOptions = UserBootOptions;
785 TRACE("BootOptions(2): '%s'\n", BootOptions);
786
787 /* Handle the SOS option */
788 SosEnabled = !!NtLdrGetOption(BootOptions, "SOS");
789 if (SosEnabled)
791
792 /* Allocate and minimally-initialize the Loader Parameter Block */
794
795 /* Allocate and initialize the setup loader block */
796 SetupBlock = &WinLdrSystemBlock->SetupBlock;
797 LoaderBlock->SetupLdrBlock = SetupBlock;
798
799 /* Set textmode setup flag */
800 SetupBlock->Flags = SETUPLDR_TEXT_MODE;
801
802 /* Load the "setupreg.hiv" setup system hive */
803 UiUpdateProgressBar(15, "Loading setup system hive...");
804 Success = WinLdrInitSystemHive(LoaderBlock, BootPath, TRUE);
805 TRACE("Setup SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
806 /* Bail out if failure */
807 if (!Success)
808 return ENOEXEC;
809
810 /* Load NLS data, they are in the System32 directory of the installation medium */
811 RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
812 RtlStringCbCatA(FilePath, sizeof(FilePath), "system32\\");
813 SetupLdrLoadNlsData(LoaderBlock, InfHandle, FilePath);
814
815 /* Load the Firmware Errata file from the installation medium */
816 Success = SetupLdrInitErrataInf(LoaderBlock, InfHandle, BootPath);
817 TRACE("Firmware Errata file %s\n", (Success ? "loaded" : "not loaded"));
818 /* Not necessarily fatal if not found - carry on going */
819
820 // UiDrawStatusText("Press F6 if you need to install a 3rd-party SCSI or RAID driver...");
821
822 /* Get a list of boot drivers */
823 SetupLdrScanBootDrivers(&LoaderBlock->BootDriverListHead, InfHandle, BootPath);
824
825 /* Close the inf file */
826 InfCloseFile(InfHandle);
827
828 UiDrawStatusText("The Setup program is starting...");
829
830 /* Finish loading */
832 LoaderBlock,
833 BootOptions,
835 BootPath);
836}
#define WARN(fmt,...)
Definition: precomp.h:61
VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: heap.c:539
#define ENOENT
Definition: errno.h:25
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3415
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOLEAN InfFindFirstLine(HINF InfHandle, PCSTR Section, PCSTR Key, PINFCONTEXT Context)
Definition: inffile.c:1050
BOOLEAN InfOpenFile(PHINF InfHandle, PCSTR FileName, PULONG ErrorLine)
Definition: inffile.c:918
#define SETUPLDR_TEXT_MODE
Definition: setupblk.h:7
VOID NtLdrUpdateLoadOptions(IN OUT PSTR LoadOptions, IN ULONG BufferSize, IN BOOLEAN Append, IN PCSTR OptionsToAdd[] OPTIONAL, IN PCSTR OptionsToRemove[] OPTIONAL)
Definition: setupldr.c:258
static VOID SetupLdrLoadNlsData(_Inout_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ HINF InfHandle, _In_ PCSTR SearchPath)
Definition: setupldr.c:36
static VOID SetupLdrScanBootDrivers(_Inout_ PLIST_ENTRY BootDriverListHead, _In_ HINF InfHandle, _In_ PCSTR SearchPath)
Definition: setupldr.c:149
PCSTR ExtraOptions
Definition: setupldr.c:353
VOID NtLdrGetHigherPriorityOptions(IN PCSTR BootOptions, OUT PSTR *ExtraOptions, OUT PSTR *HigherPriorityOptions)
Definition: setupldr.c:382
#define TAG_BOOT_OPTIONS
Definition: setupldr.c:379
static BOOLEAN SetupLdrInitErrataInf(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN HINF InfHandle, IN PCSTR SystemRoot)
Definition: setupldr.c:108
VOID AllocateAndInitLPB(IN USHORT VersionToBoot, OUT PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
Definition: winldr.c:80
LIST_ENTRY BootDriverListHead
Definition: arc.h:822
SETUP_LOADER_BLOCK SetupBlock
Definition: winldr.h:50
char * PSTR
Definition: typedefs.h:51
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
BOOLEAN InfGetDataField(PINFCONTEXT Context, ULONG FieldIndex, PWCHAR *Data)
Definition: infrosget.c:127
VOID InfCloseFile(HINF InfHandle)
Definition: inffile.c:1028
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
Definition: winldr.c:30

◆ MenuNTOptions()

VOID MenuNTOptions ( _Inout_ OperatingSystemItem OperatingSystem)

Definition at line 106 of file advopts.c.

108{
109 ULONG SelectedMenuItem;
110
111 /* Redraw the backdrop, but don't overwrite boot options */
113 DisplayBootTimeOptions(OperatingSystem);
114
115 if (!UiDisplayMenu("Please select an option:",
116 NULL,
119 10, // Use "Start ReactOS normally" as default; see the switch below.
120 -1,
121 &SelectedMenuItem,
122 TRUE,
123 NULL, NULL))
124 {
125 /* The user pressed ESC */
126 return;
127 }
128
129 switch (SelectedMenuItem)
130 {
131 case 0: // Safe Mode
134 break;
135 case 1: // Safe Mode with Networking
138 break;
139 case 2: // Safe Mode with Command Prompt
142 break;
143 // case 3: // Separator
144 // break;
145 case 4: // Enable Boot Logging
147 break;
148 case 5: // Enable VGA Mode
150 break;
151 case 6: // Last Known Good Configuration
153 break;
154 case 7: // Directory Services Restore Mode
156 break;
157 case 8: // Debugging Mode
159 break;
160 // case 9: // Separator
161 // break;
162 case 10: // Start ReactOS normally
163 // Reset all the parameters to their default values.
165 BootFlags = 0;
166 break;
167#ifdef HAS_OPTION_MENU_EDIT_CMDLINE
168 case 11: // Edit command line
169 EditOperatingSystemEntry(OperatingSystem);
170 break;
171#endif
172#ifdef HAS_OPTION_MENU_REBOOT
173 case 12: // Reboot
175 break;
176#endif
177 }
178
179 /* Update the human-readable boot-option description string */
180 GetBootOptionsDescription(OperatingSystem->AdvBootOptsDesc,
181 sizeof(OperatingSystem->AdvBootOptsDesc));
182}
static VOID GetBootOptionsDescription(_Inout_z_bytecount_(BootOptsDescSize) PSTR BootOptsDesc, _In_ SIZE_T BootOptsDescSize)
Definition: advopts.c:49
static PCSTR OptionsMenuList[]
Definition: advopts.c:17
VOID DisplayBootTimeOptions(_In_ OperatingSystemItem *OperatingSystem)
Definition: options.c:115
BOOLEAN UiDisplayMenu(IN PCSTR MenuHeader, IN PCSTR MenuFooter OPTIONAL, IN PCSTR MenuItemList[], IN ULONG MenuItemCount, IN ULONG DefaultMenuItem, IN LONG MenuTimeOut, OUT PULONG SelectedMenuItem, IN BOOLEAN CanEscape, IN UiMenuKeyPressFilterCallback KeyPressFilter OPTIONAL, IN PVOID Context OPTIONAL)
Definition: ui.c:605
VOID OptionMenuReboot(VOID)

◆ PaToVa()

◆ VaToPa()

Variable Documentation

◆ BootFlags

LOGICAL BootFlags
extern

Definition at line 44 of file advopts.c.

Referenced by AppendBootTimeOptions(), GetBootOptionsDescription(), and MenuNTOptions().

◆ BootOptionChoice

enum BootOption BootOptionChoice
extern

Definition at line 43 of file advopts.c.

Referenced by AppendBootTimeOptions(), GetBootOptionsDescription(), and MenuNTOptions().