ReactOS 0.4.15-dev-8109-gd7be748
bootsup.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NTSTATUS InstallMbrBootCodeToDisk (IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PCWSTR DestinationDevicePathBuffer)
 
NTSTATUS InstallVBRToPartition (IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN PCWSTR FileSystemName)
 
NTSTATUS InstallFatBootcodeToFloppy (IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
 

Function Documentation

◆ InstallFatBootcodeToFloppy()

NTSTATUS InstallFatBootcodeToFloppy ( IN PUNICODE_STRING  SourceRootPath,
IN PUNICODE_STRING  DestinationArcPath 
)

Definition at line 1426 of file bootsup.c.

1429{
1430 static const PCWSTR FloppyDevice = L"\\Device\\Floppy0\\";
1431
1433 WCHAR SrcPath[MAX_PATH];
1435
1436 /* Verify that the floppy disk is accessible */
1439
1440 /* Format the floppy disk */
1441 // FormatPartition(...)
1443 L"FAT",
1445 NULL,
1446 TRUE,
1447 0,
1448 NULL);
1449 if (!NT_SUCCESS(Status))
1450 {
1452 DPRINT1("FAT FS non existent on this system?!\n");
1453 else
1454 DPRINT1("VfatFormat() failed (Status %lx)\n", Status);
1455
1456 return Status;
1457 }
1458
1459 /* Copy FreeLoader to the boot partition */
1460 CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
1461 CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice, L"freeldr.sys");
1462
1463 DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
1464 Status = SetupCopyFile(SrcPath, DstPath, FALSE);
1465 if (!NT_SUCCESS(Status))
1466 {
1467 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
1468 return Status;
1469 }
1470
1471 /* Create new 'freeldr.ini' */
1472 DPRINT("Create new 'freeldr.ini'\n");
1473 Status = CreateFreeLoaderIniForReactOS(FloppyDevice, DestinationArcPath->Buffer);
1474 if (!NT_SUCCESS(Status))
1475 {
1476 DPRINT1("CreateFreeLoaderIniForReactOS() failed (Status %lx)\n", Status);
1477 return Status;
1478 }
1479
1480 /* Install FAT12 boosector */
1481 CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
1483
1484 DPRINT("Install FAT12 bootcode: %S ==> %S\n", SrcPath, DstPath);
1486 if (!NT_SUCCESS(Status))
1487 {
1488 DPRINT1("InstallBootCodeToDisk(FAT12) failed (Status %lx)\n", Status);
1489 return Status;
1490 }
1491
1492 return STATUS_SUCCESS;
1493}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
@ FloppyDevice
Definition: bl.h:262
static NTSTATUS CreateFreeLoaderIniForReactOS(IN PCWSTR IniPath, IN PCWSTR ArcPath)
Definition: bootsup.c:165
static NTSTATUS InstallBootCodeToDisk(IN PCWSTR SrcPath, IN PCWSTR RootPath, IN PFS_INSTALL_BOOTCODE InstallBootCode)
Definition: bootsup.c:620
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_PATH
Definition: compat.h:34
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:681
NTSTATUS SetupCopyFile(IN PCWSTR SourceFileName, IN PCWSTR DestinationFileName, IN BOOLEAN FailIfExists)
Definition: filesup.c:240
#define DoesDirExist(RootDirectory, DirName)
Definition: filesup.h:74
@ FMIFS_FLOPPY
Definition: fmifs.h:47
Status
Definition: gdiplustypes.h:25
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define L(x)
Definition: ntvdm.h:50
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)
Definition: fsutil.c:376
#define InstallFat12BootCode
Definition: fsutil.h:85
IN HANDLE DstPath
Definition: fsutil.h:76
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
const uint16_t * PCWSTR
Definition: typedefs.h:57
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by BootLoaderRemovableDiskPage().

◆ InstallMbrBootCodeToDisk()

NTSTATUS InstallMbrBootCodeToDisk ( IN PUNICODE_STRING  SystemRootPath,
IN PUNICODE_STRING  SourceRootPath,
IN PCWSTR  DestinationDevicePathBuffer 
)

Definition at line 831 of file bootsup.c.

835{
837 WCHAR SourceMbrPathBuffer[MAX_PATH];
839
840#if 0
841 /*
842 * The DestinationDevicePathBuffer parameter has been built with
843 * the following instruction by the caller; I'm not yet sure whether
844 * I actually want this function to build the path instead, hence
845 * I keep this code here but disabled for now...
846 */
847 WCHAR DestinationDevicePathBuffer[MAX_PATH];
848 RtlStringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer),
849 L"\\Device\\Harddisk%d\\Partition0",
850 DiskNumber);
851#endif
852
853 CombinePaths(SourceMbrPathBuffer, ARRAYSIZE(SourceMbrPathBuffer), 2,
854 SourceRootPath->Buffer, L"\\loader\\dosmbr.bin");
855
856 if (IsThereAValidBootSector(DestinationDevicePathBuffer))
857 {
858 /* Save current MBR */
860 SystemRootPath->Buffer, L"mbr.old");
861
862 DPRINT1("Save MBR: %S ==> %S\n", DestinationDevicePathBuffer, DstPath);
863 Status = SaveBootSector(DestinationDevicePathBuffer, DstPath, sizeof(PARTITION_SECTOR));
864 if (!NT_SUCCESS(Status))
865 {
866 DPRINT1("SaveBootSector() failed (Status %lx)\n", Status);
867 // Don't care if we succeeded or not saving the old MBR, just go ahead.
868 }
869 }
870
871 DPRINT1("Install MBR bootcode: %S ==> %S\n",
872 SourceMbrPathBuffer, DestinationDevicePathBuffer);
873
874 /* Install the MBR */
875 return InstallBootCodeToDisk(SourceMbrPathBuffer,
876 DestinationDevicePathBuffer,
878}
static NTSTATUS InstallMbrBootCode(IN PCWSTR SrcPath, IN HANDLE DstPath, IN HANDLE DiskHandle)
Definition: bootsup.c:767
static NTSTATUS SaveBootSector(IN PCWSTR RootPath, IN PCWSTR DstPath, IN ULONG Length)
Definition: bootsup.c:555
static BOOLEAN IsThereAValidBootSector(IN PCWSTR RootPath)
Definition: bootsup.c:515
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110

Referenced by BootLoaderHardDiskPage().

◆ InstallVBRToPartition()

NTSTATUS InstallVBRToPartition ( IN PUNICODE_STRING  SystemRootPath,
IN PUNICODE_STRING  SourceRootPath,
IN PUNICODE_STRING  DestinationArcPath,
IN PCWSTR  FileSystemName 
)

Definition at line 1381 of file bootsup.c.

1386{
1387 if (wcsicmp(FileSystemName, L"FAT") == 0 ||
1388 wcsicmp(FileSystemName, L"FAT32") == 0)
1389 {
1390 return InstallFatBootcodeToPartition(SystemRootPath,
1391 SourceRootPath,
1392 DestinationArcPath,
1393 FileSystemName);
1394 }
1395 else if (wcsicmp(FileSystemName, L"NTFS") == 0)
1396 {
1397 return InstallNtfsBootcodeToPartition(SystemRootPath,
1398 SourceRootPath,
1399 DestinationArcPath);
1400 }
1401 else if (wcsicmp(FileSystemName, L"BTRFS") == 0)
1402 {
1403 return InstallBtrfsBootcodeToPartition(SystemRootPath,
1404 SourceRootPath,
1405 DestinationArcPath);
1406 }
1407 /*
1408 else if (wcsicmp(FileSystemName, L"EXT2") == 0 ||
1409 wcsicmp(FileSystemName, L"EXT3") == 0 ||
1410 wcsicmp(FileSystemName, L"EXT4") == 0)
1411 {
1412 return STATUS_NOT_SUPPORTED;
1413 }
1414 */
1415 else
1416 {
1417 /* Unknown file system */
1418 DPRINT1("Unknown file system '%S'\n", FileSystemName);
1419 }
1420
1421 return STATUS_NOT_SUPPORTED;
1422}
static NTSTATUS InstallFatBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN PCWSTR FileSystemName)
Definition: bootsup.c:883
static NTSTATUS InstallNtfsBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
Definition: bootsup.c:1280
static NTSTATUS InstallBtrfsBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
Definition: bootsup.c:1177
#define wcsicmp
Definition: compat.h:15

Referenced by BootLoaderHardDiskPage().