64 BootEntry->BootFilePath =
NULL;
75 BootEntry->FriendlyName =
L"\"ReactOS\"";
76 Options->OsLoadOptions =
L"/FASTDETECT";
81 BootEntry->FriendlyName =
L"\"ReactOS (Debug)\"";
82 Options->OsLoadOptions =
L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS";
88 BootEntry->FriendlyName =
L"\"ReactOS (VBox Debug)\"";
89 Options->OsLoadOptions =
L"/DEBUG /DEBUGPORT=VBOX /SOS";
96 BootEntry->FriendlyName =
L"\"ReactOS (RosDbg)\"";
97 Options->OsLoadOptions =
L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /KDSERIAL";
103 BootEntry->FriendlyName =
L"\"ReactOS (Screen)\"";
104 Options->OsLoadOptions =
L"/DEBUG /DEBUGPORT=SCREEN /SOS";
109 BootEntry->FriendlyName =
L"\"ReactOS (Log file)\"";
110 Options->OsLoadOptions =
L"/DEBUG /DEBUGPORT=FILE /SOS";
115 BootEntry->FriendlyName =
L"\"ReactOS (RAM Disk)\"";
116 Options->OsLoadPath =
L"ramdisk(0)\\ReactOS";
117 Options->OsLoadOptions =
L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /RDPATH=reactos.img /RDIMAGEOFFSET=32256";
122 BootEntry->FriendlyName =
L"\"ReactOS (Emergency Management Services)\"";
124 Options->OsLoadOptions =
L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /redirect=com2 /redirectbaudrate=115200";
130#if DBG && !defined(_WINKD_)
170 PVOID BootStoreHandle;
196 PVOID BootStoreHandle;
211 DPRINT1(
"BootPath = '%S' points to disk #%d, partition #%d, path '%S'\n",
217 L"multi(0)disk(0)rdisk(%lu)partition(%lu)",
240 L"multi(0)disk(0)fdisk(%lu)", DiskNumber);
263 DPRINT1(
"Unhandled NT path '%S'\n", BootPath);
277 BootEntry->BootFilePath =
NULL;
284 Options->BootPath = BootPathBuffer;
336 DPRINT(
" An installation '%S' of unsupported type %lu\n",
337 BootEntry->FriendlyName, BootEntry->OsOptionsLength);
346 DPRINT1(
" A Win2k3 install '%S' without an ARC path?!\n", BootEntry->FriendlyName);
366 DPRINT(
" Found a candidate Win2k3 install '%S' with ARC path '%S'\n",
367 BootEntry->FriendlyName,
Options->OsLoadPath);
371 DPRINT(
"EnumerateReactOSEntries: OsLoadPath: '%S'\n",
Options->OsLoadPath);
384 L"ReactOS_%lu",
Data->i);
386 L"\"ReactOS %lu\"",
Data->i);
399 PVOID BootStoreHandle;
414 Data.ArcPath = ArcPath;
425 if (!
Data.UseExistingEntry)
431 BootEntry->BootFilePath =
NULL;
441 BootEntry->FriendlyName =
Data.OsName;
459 PVOID BootStoreHandle;
476 Data.ArcPath = EntryName;
487 if (!
Data.UseExistingEntry
490 BootEntry->Version =
NtLdr;
491 BootEntry->BootFilePath =
NULL;
498 Options->OsLoadPath = EntryName;
502 BootEntry->FriendlyName = EntryValue;
623 IN PFS_INSTALL_BOOTCODE InstallBootCode)
658 DPRINT1(
"Unable to lock the volume before installing boot code. Status 0x%08x. Expect problems.\n", LockStatus);
662 Status = InstallBootCode(SrcPath, PartitionHandle, PartitionHandle);
670 DPRINT1(
"Unable to dismount the volume after installing boot code. Status 0x%08x. Expect problems.\n", LockStatus);
676 DPRINT1(
"Unable to unlock the volume after installing boot code. Status 0x%08x. Expect problems.\n", LockStatus);
692 IN PFS_INSTALL_BOOTCODE InstallBootCode)
834 IN PCWSTR DestinationDevicePathBuffer)
849 L"\\Device\\Harddisk%d\\Partition0",
854 SourceRootPath->Buffer,
L"\\loader\\dosmbr.bin");
860 SystemRootPath->Buffer,
L"mbr.old");
862 DPRINT1(
"Save MBR: %S ==> %S\n", DestinationDevicePathBuffer,
DstPath);
871 DPRINT1(
"Install MBR bootcode: %S ==> %S\n",
872 SourceMbrPathBuffer, DestinationDevicePathBuffer);
876 DestinationDevicePathBuffer,
895 DPRINT(
"System path: '%wZ'\n", SystemRootPath);
911 if (DoesFreeLdrExist)
914 DPRINT1(
"Update existing 'freeldr.ini'\n");
918 DPRINT1(
"UpdateFreeLoaderIni() failed (Status %lx)\n",
Status);
932 DPRINT1(
"Found Microsoft Windows NT/2000/XP boot loader\n");
935 if (DoesFreeLdrExist ==
FALSE)
938 DPRINT1(
"Create new 'freeldr.ini'\n");
942 DPRINT1(
"CreateFreeLoaderIniForReactOS() failed (Status %lx)\n",
Status);
949 if (
wcsicmp(FileSystemName,
L"FAT32") == 0)
956 SystemRootPath->Buffer,
960 DPRINT1(
"InstallBootCodeToFile(FAT32) failed (Status %lx)\n",
Status);
971 SystemRootPath->Buffer,
975 DPRINT1(
"InstallBootCodeToFile(FAT16) failed (Status %lx)\n",
Status);
984 DPRINT1(
"Update 'boot.ini'\n");
1006 DPRINT1(
"Found COMPAQ MS-DOS 1.x (1.11, 1.12) / MS-DOS 1.25 boot loader\n");
1008 Section =
L"CPQDOS";
1018 DPRINT1(
"Found Microsoft DOS or Windows 9x boot loader\n");
1030 DPRINT1(
"Found IBM PC-DOS or DR-DOS 5.x or IBM OS/2 1.0\n");
1032 Section =
L"IBMDOS";
1033 Description =
L"\"IBM PC-DOS or DR-DOS 5.x or IBM OS/2 1.0\"";
1041 DPRINT1(
"Found DR-DOS 3.x\n");
1052 DPRINT1(
"Found Dell Real-Mode Kernel OS\n");
1064 DPRINT1(
"Found MS OS/2 1.x\n");
1076 DPRINT1(
"Found MS/IBM OS/2\n");
1078 Section =
L"IBMOS2";
1086 DPRINT1(
"Found FreeDOS boot loader\n");
1095 DPRINT1(
"No or unknown boot loader found\n");
1097 Section =
L"Unknown";
1103 if (DoesFreeLdrExist ==
FALSE)
1106 DPRINT1(
"Create new 'freeldr.ini'\n");
1111 SystemRootPath->Buffer, DestinationArcPath->Buffer,
1116 DPRINT1(
"CreateFreeLoaderIniForReactOSAndBootSector() failed (Status %lx)\n",
Status);
1123 DPRINT1(
"Save bootsector: %S ==> %S\n", SystemRootPath->Buffer,
DstPath);
1136 DPRINT1(
"CreateFreeLoaderIniForReactOS() failed (Status %lx)\n",
Status);
1142 if (
wcsicmp(FileSystemName,
L"FAT32") == 0)
1147 DPRINT1(
"Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
1152 DPRINT1(
"InstallBootCodeToDisk(FAT32) failed (Status %lx)\n",
Status);
1161 DPRINT1(
"Install FAT16 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
1165 DPRINT1(
"InstallBootCodeToDisk(FAT16) failed (Status %lx)\n",
Status);
1188 DPRINT(
"System path: '%wZ'\n", SystemRootPath);
1203 DoesFreeLdrExist =
DoesFileExist_2(SystemRootPath->Buffer,
L"freeldr.ini");
1204 if (DoesFreeLdrExist)
1207 DPRINT1(
"Update existing 'freeldr.ini'\n");
1211 DPRINT1(
"UpdateFreeLoaderIni() failed (Status %lx)\n",
Status);
1219 if (DoesFreeLdrExist ==
FALSE)
1222 DPRINT1(
"Create new 'freeldr.ini'\n");
1225 DPRINT1(
"*nix or unknown boot loader found\n");
1232 SystemRootPath->Buffer, DestinationArcPath->Buffer,
1233 L"Linux",
L"\"Linux\"",
1237 DPRINT1(
"CreateFreeLoaderIniForReactOSAndBootSector() failed (Status %lx)\n",
Status);
1244 DPRINT1(
"Save bootsector: %S ==> %S\n", SystemRootPath->Buffer,
DstPath);
1257 DPRINT1(
"CreateFreeLoaderIniForReactOS() failed (Status %lx)\n",
Status);
1266 DPRINT1(
"Install BTRFS bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
1270 DPRINT1(
"InstallBootCodeToDisk(BTRFS) failed (Status %lx)\n",
Status);
1291 DPRINT(
"System path: '%wZ'\n", SystemRootPath);
1306 DoesFreeLdrExist =
DoesFileExist_2(SystemRootPath->Buffer,
L"freeldr.ini");
1307 if (DoesFreeLdrExist)
1310 DPRINT1(
"Update existing 'freeldr.ini'\n");
1314 DPRINT1(
"UpdateFreeLoaderIni() failed (Status %lx)\n",
Status);
1323 DPRINT1(
"Create new 'freeldr.ini'\n");
1326 DPRINT1(
"*nix or unknown boot loader found\n");
1333 SystemRootPath->Buffer, DestinationArcPath->Buffer,
1334 L"Linux",
L"\"Linux\"",
1338 DPRINT1(
"CreateFreeLoaderIniForReactOSAndBootSector() failed (Status %lx)\n",
Status);
1345 DPRINT1(
"Save bootsector: %S ==> %S\n", SystemRootPath->Buffer,
DstPath);
1358 DPRINT1(
"CreateFreeLoaderIniForReactOS() failed (Status %lx)\n",
Status);
1368 DPRINT1(
"Install NTFS bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
1372 DPRINT1(
"InstallBootCodeToDisk(NTFS) failed (Status %lx)\n",
Status);
1387 if (
wcsicmp(FileSystemName,
L"FAT") == 0 ||
1388 wcsicmp(FileSystemName,
L"FAT32") == 0)
1395 else if (
wcsicmp(FileSystemName,
L"NTFS") == 0)
1399 DestinationArcPath);
1401 else if (
wcsicmp(FileSystemName,
L"BTRFS") == 0)
1405 DestinationArcPath);
1418 DPRINT1(
"Unknown file system '%S'\n", FileSystemName);
1452 DPRINT1(
"FAT FS non existent on this system?!\n");
1472 DPRINT(
"Create new 'freeldr.ini'\n");
1476 DPRINT1(
"CreateFreeLoaderIniForReactOS() failed (Status %lx)\n",
Status);
1484 DPRINT(
"Install FAT12 bootcode: %S ==> %S\n", SrcPath,
DstPath);
1488 DPRINT1(
"InstallBootCodeToDisk(FAT12) failed (Status %lx)\n",
Status);
PRTL_UNICODE_STRING_BUFFER Path
#define OBJ_NAME_PATH_SEPARATOR
NTSTATUS OpenBootStore(_Out_ PVOID *Handle, _In_ PCWSTR SystemPartition, _In_ BOOT_STORE_TYPE Type, _In_ BOOT_STORE_OPENMODE OpenMode, _In_ BOOT_STORE_ACCESS Access)
NTSTATUS SetBootStoreOptions(IN PVOID Handle, IN PBOOT_STORE_OPTIONS BootOptions, IN ULONG FieldsToChange)
NTSTATUS AddBootStoreEntry(IN PVOID Handle, IN PBOOT_STORE_ENTRY BootEntry, IN ULONG_PTR BootEntryKey)
NTSTATUS CloseBootStore(_In_ PVOID Handle)
NTSTATUS EnumerateBootStoreEntries(IN PVOID Handle, IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine, IN PVOID Parameter OPTIONAL)
struct _BOOTSECTOR_OPTIONS BOOTSECTOR_OPTIONS
#define BOOTSECTOR_OPTIONS_SIGNATURE
struct _NTOS_OPTIONS NTOS_OPTIONS
#define BOOT_OPTIONS_NEXT_BOOTENTRY_KEY
#define BOOT_OPTIONS_TIMEOUT
struct _NTOS_OPTIONS * PNTOS_OPTIONS
struct _BOOT_STORE_ENTRY * PBOOT_STORE_ENTRY
#define NTOS_OPTIONS_SIGNATURE
struct _BOOTSECTOR_OPTIONS * PBOOTSECTOR_OPTIONS
enum _BOOT_STORE_TYPE BOOT_STORE_TYPE
VOID FreeBootCode(IN OUT PBOOTCODE BootCodeInfo)
NTSTATUS ReadBootCodeByHandle(IN OUT PBOOTCODE BootCodeInfo, IN HANDLE FileHandle, IN ULONG Length OPTIONAL)
NTSTATUS ReadBootCodeFromFile(IN OUT PBOOTCODE BootCodeInfo, IN PUNICODE_STRING FilePath, IN ULONG Length OPTIONAL)
NTSTATUS InstallVBRToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN PCWSTR FileSystemName)
static NTSTATUS InstallMbrBootCode(IN PCWSTR SrcPath, IN HANDLE DstPath, IN HANDLE DiskHandle)
static NTSTATUS SaveBootSector(IN PCWSTR RootPath, IN PCWSTR DstPath, IN ULONG Length)
NTSTATUS InstallFatBootcodeToFloppy(IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
static NTSTATUS UpdateBootIni(IN PCWSTR IniPath, IN PCWSTR EntryName, IN PCWSTR EntryValue)
static NTSTATUS NTAPI EnumerateReactOSEntries(IN BOOT_STORE_TYPE Type, IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL)
static NTSTATUS CreateFreeLoaderIniForReactOS(IN PCWSTR IniPath, IN PCWSTR ArcPath)
static NTSTATUS InstallBootCodeToFile(IN PCWSTR SrcPath, IN PCWSTR DstPath, IN PCWSTR RootPath, IN PFS_INSTALL_BOOTCODE InstallBootCode)
NTSTATUS InstallMbrBootCodeToDisk(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PCWSTR DestinationDevicePathBuffer)
static NTSTATUS CreateFreeLoaderIniForReactOSAndBootSector(IN PCWSTR IniPath, IN PCWSTR ArcPath, IN PCWSTR Section, IN PCWSTR Description, IN PCWSTR BootPath, IN PCWSTR BootSector)
static BOOLEAN IsThereAValidBootSector(IN PCWSTR RootPath)
struct _ENUM_REACTOS_ENTRIES_DATA * PENUM_REACTOS_ENTRIES_DATA
static VOID TrimTrailingPathSeparators_UStr(IN OUT PUNICODE_STRING UnicodeString)
struct _ENUM_REACTOS_ENTRIES_DATA ENUM_REACTOS_ENTRIES_DATA
static NTSTATUS InstallBootCodeToDisk(IN PCWSTR SrcPath, IN PCWSTR RootPath, IN PFS_INSTALL_BOOTCODE InstallBootCode)
static NTSTATUS InstallFatBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN PCWSTR FileSystemName)
static NTSTATUS UpdateFreeLoaderIni(IN PCWSTR IniPath, IN PCWSTR ArcPath)
static VOID CreateFreeLoaderReactOSEntries(IN PVOID BootStoreHandle, IN PCWSTR ArcPath)
static NTSTATUS InstallNtfsBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
static NTSTATUS InstallBtrfsBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
_In_ PFCB _In_ LONGLONG FileOffset
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
static const WCHAR Description[]
#define FILE_ATTRIBUTE_NORMAL
static const WCHAR Signature[]
#define RtlCompareMemory(s1, s2, l)
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
BOOLEAN DoesFileExist_2(IN PCWSTR PathName OPTIONAL, IN PCWSTR FileName)
BOOLEAN NtPathToDiskPartComponents(IN PCWSTR NtPath, OUT PULONG pDiskNumber, OUT PULONG pPartNumber, OUT PCWSTR *PathComponent OPTIONAL)
NTSTATUS SetupCopyFile(IN PCWSTR SourceFileName, IN PCWSTR DestinationFileName, IN BOOLEAN FailIfExists)
#define DoesDirExist(RootDirectory, DirName)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
#define FILE_SYNCHRONOUS_IO_NONALERT
#define FILE_SEQUENTIAL_ONLY
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define OBJ_CASE_INSENSITIVE
#define RTL_FIELD_SIZE(type, field)
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
#define FSCTL_LOCK_VOLUME
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FSCTL_UNLOCK_VOLUME
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define FSCTL_DISMOUNT_VOLUME
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define STATUS_NO_MORE_ENTRIES
#define STATUS_NOT_SUPPORTED
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
NTSTRSAFEAPI RtlStringCchCatW(_Inout_updates_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
NTSTATUS InstallFat32BootCode(IN PCWSTR SrcPath, IN HANDLE DstPath, IN HANDLE RootPartition)
NTSTATUS FormatFileSystem(IN PCWSTR DriveRoot, IN PCWSTR FileSystemName, IN FMIFS_MEDIA_FLAG MediaFlag, IN PCWSTR Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
NTSTATUS InstallBtrfsBootCode(IN PCWSTR SrcPath, IN HANDLE DstPath, IN HANDLE RootPartition)
NTSTATUS InstallNtfsBootCode(IN PCWSTR SrcPath, IN HANDLE DstPath, IN HANDLE RootPartition)
IN HANDLE IN HANDLE RootPartition
#define NTFS_BOOTSECTOR_SIZE
#define InstallFat16BootCode
#define InstallFat12BootCode
#define BTRFS_BOOTSECTOR_SIZE
BOOLEAN IsUnattendedSetup
#define STATUS_DEVICE_NOT_READY
PULONG MinorVersion OPTIONAL
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
_In_ ULONG _In_ ULONG PartitionNumber
_Inout_opt_ PVOID Parameter