Author: hbelusca Date: Wed May 31 01:43:12 2017 New Revision: 74713
URL: http://svn.reactos.org/svn/reactos?rev=74713&view=rev Log: [USETUP]: Several additions: - Add support for other bootloaders; - Update a couple of comments; - Remove deprecated __REACTOS__ stuff.
Modified: branches/setup_improvements/base/setup/usetup/bootsup.c
Modified: branches/setup_improvements/base/setup/usetup/bootsup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/us... ============================================================================== --- branches/setup_improvements/base/setup/usetup/bootsup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/bootsup.c [iso-8859-1] Wed May 31 01:43:12 2017 @@ -2255,7 +2255,6 @@ PUNICODE_STRING DestinationArcPath, UCHAR PartitionType) { -#ifdef __REACTOS__ NTSTATUS Status; BOOLEAN DoesFreeLdrExist; WCHAR SrcPath[MAX_PATH]; @@ -2264,9 +2263,9 @@ /* FAT or FAT32 partition */ DPRINT("System path: '%wZ'\n", SystemRootPath);
- /* Copy FreeLoader to the system partition */ + /* Copy FreeLoader to the system partition, always overwriting the older version */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\loader\freeldr.sys"); - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\freeldr.sys"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath); Status = SetupCopyFile(SrcPath, DstPath); @@ -2276,8 +2275,8 @@ return Status; }
- /* Prepare for possibly copying 'freeldr.ini' */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\freeldr.ini"); + /* Prepare for possibly updating 'freeldr.ini' */ + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
DoesFreeLdrExist = DoesFileExist(NULL, DstPath); if (DoesFreeLdrExist) @@ -2296,10 +2295,12 @@ /* Check for NT and other bootloaders */
// FIXME: Check for Vista+ bootloader! - if (DoesFileExist_2(SystemRootPath->Buffer, L"ntldr") == TRUE || - DoesFileExist_2(SystemRootPath->Buffer, L"boot.ini") == TRUE) - { - /* Search root directory for 'ntldr' and 'boot.ini' */ + /*** Status = FindNTOSBootLoader(PartitionHandle, NtLdr, &Version); ***/ + /*** Status = FindNTOSBootLoader(PartitionHandle, BootMgr, &Version); ***/ + if (DoesFileExist_2(SystemRootPath->Buffer, L"NTLDR") == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"BOOT.INI") == TRUE) + { + /* Search root directory for 'NTLDR' and 'BOOT.INI' */ DPRINT1("Found Microsoft Windows NT/2000/XP boot loader\n");
/* Create or update 'freeldr.ini' */ @@ -2307,7 +2308,7 @@ { /* Create new 'freeldr.ini' */ DPRINT1("Create new 'freeldr.ini'\n"); - // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\freeldr.ini"); + // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); if (!NT_SUCCESS(Status)) @@ -2317,7 +2318,7 @@ }
/* Install new bootcode into a file */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\bootsect.ros"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"bootsect.ros");
if (PartitionType == PARTITION_FAT32 || PartitionType == PARTITION_FAT32_XINT13) @@ -2351,7 +2352,7 @@ }
/* Update 'boot.ini' */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\boot.ini"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"boot.ini");
DPRINT1("Update 'boot.ini': %S\n", DstPath); Status = UpdateBootIni(DstPath, @@ -2367,31 +2368,97 @@ { /* Non-NT bootloaders: install our own bootloader */
- PWCHAR Section; - PWCHAR Description; - PWCHAR BootDrive; - PWCHAR BootPartition; - PWCHAR BootSector; - PWCHAR BootSectorFileName; - - if (DoesFileExist_2(SystemRootPath->Buffer, L"io.sys") == TRUE || - DoesFileExist_2(SystemRootPath->Buffer, L"msdos.sys") == TRUE) + PCWSTR Section; + PCWSTR Description; + PCWSTR BootDrive; + PCWSTR BootPartition; + PCWSTR BootSector; + + /* Search for COMPAQ MS-DOS 1.x (1.11, 1.12, based on MS-DOS 1.25) boot loader */ + if (DoesFileExist_2(SystemRootPath->Buffer, L"IOSYS.COM") == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"MSDOS.COM") == TRUE) { - /* Search for root directory for 'io.sys' and 'msdos.sys' */ - DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n"); + DPRINT1("Found COMPAQ MS-DOS 1.x (1.11, 1.12) / MS-DOS 1.25 boot loader\n");
Section = L"DOS"; - Description = L""DOS/Windows""; + Description = L""COMPAQ MS-DOS 1.x / MS-DOS 1.25""; BootDrive = L"hd0"; BootPartition = L"1"; BootSector = L"BOOTSECT.DOS"; - - BootSectorFileName = L"\bootsect.dos"; } else + /* Search for Microsoft DOS or Windows 9x boot loader */ + if (DoesFileExist_2(SystemRootPath->Buffer, L"IO.SYS") == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"MSDOS.SYS") == TRUE) + // WINBOOT.SYS + { + DPRINT1("Found Microsoft DOS or Windows 9x boot loader\n"); + + Section = L"DOS"; + Description = L""MS-DOS/Windows""; + BootDrive = L"hd0"; + BootPartition = L"1"; + BootSector = L"BOOTSECT.DOS"; + } + else + /* Search for IBM PC-DOS or DR-DOS 5.x boot loader */ + if (DoesFileExist_2(SystemRootPath->Buffer, L"IBMIO.COM" ) == TRUE || // Some people refer to this file instead of IBMBIO.COM... + DoesFileExist_2(SystemRootPath->Buffer, L"IBMBIO.COM") == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"IBMDOS.COM") == TRUE) + { + DPRINT1("Found IBM PC-DOS or DR-DOS 5.x or IBM OS/2 1.0\n"); + + Section = L"DOS"; + Description = L""IBM PC-DOS or DR-DOS 5.x or IBM OS/2 1.0""; + BootDrive = L"hd0"; + BootPartition = L"1"; + BootSector = L"BOOTSECT.DOS"; + } + else + /* Search for DR-DOS 3.x boot loader */ + if (DoesFileExist_2(SystemRootPath->Buffer, L"DRBIOS.SYS") == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"DRBDOS.SYS") == TRUE) + { + DPRINT1("Found DR-DOS 3.x\n"); + + Section = L"DOS"; + Description = L""DR-DOS 3.x""; + BootDrive = L"hd0"; + BootPartition = L"1"; + BootSector = L"BOOTSECT.DOS"; + } + else + /* Search for MS OS/2 1.x */ + if (DoesFileExist_2(SystemRootPath->Buffer, L"OS2BOOT.COM") == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"OS2BIO.COM" ) == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"OS2DOS.COM" ) == TRUE) + { + DPRINT1("Found MS OS/2 1.x\n"); + + Section = L"DOS"; + Description = L""MS OS/2 1.x""; + BootDrive = L"hd0"; + BootPartition = L"1"; + BootSector = L"BOOTSECT.OS2"; + } + else + /* Search for MS or IBM OS/2 */ + if (DoesFileExist_2(SystemRootPath->Buffer, L"OS2BOOT") == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"OS2LDR" ) == TRUE || + DoesFileExist_2(SystemRootPath->Buffer, L"OS2KRNL") == TRUE) + { + DPRINT1("Found MS/IBM OS/2\n"); + + Section = L"DOS"; + Description = L""MS/IBM OS/2""; + BootDrive = L"hd0"; + BootPartition = L"1"; + BootSector = L"BOOTSECT.OS2"; + } + else + /* Search for FreeDOS boot loader */ if (DoesFileExist_2(SystemRootPath->Buffer, L"kernel.sys") == TRUE) { - /* Search for root directory for 'kernel.sys' */ DPRINT1("Found FreeDOS boot loader\n");
Section = L"DOS"; @@ -2399,8 +2466,6 @@ BootDrive = L"hd0"; BootPartition = L"1"; BootSector = L"BOOTSECT.DOS"; - - BootSectorFileName = L"\bootsect.dos"; } else { @@ -2412,8 +2477,6 @@ BootDrive = L"hd0"; BootPartition = L"1"; BootSector = L"BOOTSECT.OLD"; - - BootSectorFileName = L"\bootsect.old"; }
/* Create or update 'freeldr.ini' */ @@ -2421,7 +2484,7 @@ { /* Create new 'freeldr.ini' */ DPRINT1("Create new 'freeldr.ini'\n"); - // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\freeldr.ini"); + // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
if (IsThereAValidBootSector(SystemRootPath->Buffer)) { @@ -2436,7 +2499,7 @@ }
/* Save current bootsector */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSectorFileName); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSector);
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath); Status = SaveBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE); @@ -2488,9 +2551,6 @@ }
return STATUS_SUCCESS; -#else - return STATUS_NOT_IMPLEMENTED; -#endif }
static @@ -2501,7 +2561,6 @@ PUNICODE_STRING DestinationArcPath, UCHAR PartitionType) { -#ifdef __REACTOS__ NTSTATUS Status; BOOLEAN DoesFreeLdrExist; WCHAR SrcPath[MAX_PATH]; @@ -2510,9 +2569,9 @@ /* EXT2 partition */ DPRINT("System path: '%wZ'\n", SystemRootPath);
- /* Copy FreeLoader to the system partition */ + /* Copy FreeLoader to the system partition, always overwriting the older version */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\loader\freeldr.sys"); - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\freeldr.sys"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath); Status = SetupCopyFile(SrcPath, DstPath); @@ -2523,7 +2582,7 @@ }
/* Prepare for possibly copying 'freeldr.ini' */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\freeldr.ini"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini");
DoesFreeLdrExist = DoesFileExist(NULL, DstPath); if (DoesFreeLdrExist) @@ -2553,10 +2612,12 @@
if (IsThereAValidBootSector(SystemRootPath->Buffer)) { + PCWSTR BootSector = L"BOOTSECT.OLD"; + Status = CreateFreeLoaderIniForReactOSAndBootSector( DstPath, DestinationArcPath->Buffer, L"Linux", L""Linux"", - L"hd0", L"1", L"BOOTSECT.OLD"); + L"hd0", L"1", BootSector); if (!NT_SUCCESS(Status)) { DPRINT1("CreateFreeLoaderIniForReactOSAndBootSector() failed (Status %lx)\n", Status); @@ -2564,7 +2625,7 @@ }
/* Save current bootsector */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\bootsect.old"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSector);
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath); Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR)); @@ -2601,9 +2662,6 @@ }
return STATUS_SUCCESS; -#else - return STATUS_NOT_IMPLEMENTED; -#endif }
@@ -2638,6 +2696,7 @@ }
case PARTITION_IFS: + DPRINT1("Partitions of type NTFS or HPFS are not supported yet!\n"); break;
default: @@ -2654,10 +2713,9 @@ PUNICODE_STRING SourceRootPath, PUNICODE_STRING DestinationArcPath) { -#ifdef __REACTOS__ NTSTATUS Status; PFILE_SYSTEM FatFS; - UNICODE_STRING FloppyDevice = RTL_CONSTANT_STRING(L"\Device\Floppy0"); + UNICODE_STRING FloppyDevice = RTL_CONSTANT_STRING(L"\Device\Floppy0\"); WCHAR SrcPath[MAX_PATH]; WCHAR DstPath[MAX_PATH];
@@ -2682,8 +2740,7 @@
/* Copy FreeLoader to the boot partition */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\loader\freeldr.sys"); - - StringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\Device\Floppy0\freeldr.sys"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice.Buffer, L"freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath); Status = SetupCopyFile(SrcPath, DstPath); @@ -2694,7 +2751,7 @@ }
/* Create new 'freeldr.ini' */ - StringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\Device\Floppy0\freeldr.ini"); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice.Buffer, L"freeldr.ini");
DPRINT("Create new 'freeldr.ini'\n"); Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); @@ -2704,23 +2761,19 @@ return Status; }
- /* Install FAT12/16 boosector */ + /* Install FAT12 boosector */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\loader\fat.bin"); - - StringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\Device\Floppy0"); + StringCchCopyW(DstPath, ARRAYSIZE(DstPath), FloppyDevice.Buffer);
DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath); Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath); if (!NT_SUCCESS(Status)) { - DPRINT1("InstallFat16BootCodeToDisk() failed (Status %lx)\n", Status); + DPRINT1("InstallFat12BootCodeToFloppy() failed (Status %lx)\n", Status); return Status; }
return STATUS_SUCCESS; -#else - return STATUS_NOT_IMPLEMENTED; -#endif }
/* EOF */