ReactOS 0.4.15-dev-7942-gd23573b
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 1378 of file bootsup.c.

1381{
1382 static const PCWSTR FloppyDevice = L"\\Device\\Floppy0\\";
1383
1385 WCHAR SrcPath[MAX_PATH];
1387
1388 /* Verify that the floppy disk is accessible */
1391
1392 /* Format the floppy disk */
1393 // FormatPartition(...)
1395 L"FAT",
1397 NULL,
1398 TRUE,
1399 0,
1400 NULL);
1401 if (!NT_SUCCESS(Status))
1402 {
1404 DPRINT1("FAT FS non existent on this system?!\n");
1405 else
1406 DPRINT1("VfatFormat() failed (Status %lx)\n", Status);
1407
1408 return Status;
1409 }
1410
1411 /* Copy FreeLoader to the boot partition */
1412 CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
1413 CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice, L"freeldr.sys");
1414
1415 DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
1416 Status = SetupCopyFile(SrcPath, DstPath, FALSE);
1417 if (!NT_SUCCESS(Status))
1418 {
1419 DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
1420 return Status;
1421 }
1422
1423 /* Create new 'freeldr.ini' */
1424 DPRINT("Create new 'freeldr.ini'\n");
1425 Status = CreateFreeLoaderIniForReactOS(FloppyDevice, DestinationArcPath->Buffer);
1426 if (!NT_SUCCESS(Status))
1427 {
1428 DPRINT1("CreateFreeLoaderIniForReactOS() failed (Status %lx)\n", Status);
1429 return Status;
1430 }
1431
1432 /* Install FAT12 boosector */
1433 CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
1435
1436 DPRINT("Install FAT12 bootcode: %S ==> %S\n", SrcPath, DstPath);
1438 if (!NT_SUCCESS(Status))
1439 {
1440 DPRINT1("InstallBootCodeToDisk(FAT12) failed (Status %lx)\n", Status);
1441 return Status;
1442 }
1443
1444 return STATUS_SUCCESS;
1445}
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:552
#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:71
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 763 of file bootsup.c.

767{
769 WCHAR SourceMbrPathBuffer[MAX_PATH];
771
772#if 0
773 /*
774 * The DestinationDevicePathBuffer parameter has been built with
775 * the following instruction by the caller; I'm not yet sure whether
776 * I actually want this function to build the path instead, hence
777 * I keep this code here but disabled for now...
778 */
779 WCHAR DestinationDevicePathBuffer[MAX_PATH];
780 RtlStringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer),
781 L"\\Device\\Harddisk%d\\Partition0",
782 DiskNumber);
783#endif
784
785 CombinePaths(SourceMbrPathBuffer, ARRAYSIZE(SourceMbrPathBuffer), 2,
786 SourceRootPath->Buffer, L"\\loader\\dosmbr.bin");
787
788 if (IsThereAValidBootSector(DestinationDevicePathBuffer))
789 {
790 /* Save current MBR */
792 SystemRootPath->Buffer, L"mbr.old");
793
794 DPRINT1("Save MBR: %S ==> %S\n", DestinationDevicePathBuffer, DstPath);
795 Status = SaveBootSector(DestinationDevicePathBuffer, DstPath, sizeof(PARTITION_SECTOR));
796 if (!NT_SUCCESS(Status))
797 {
798 DPRINT1("SaveBootSector() failed (Status %lx)\n", Status);
799 // Don't care if we succeeded or not saving the old MBR, just go ahead.
800 }
801 }
802
803 DPRINT1("Install MBR bootcode: %S ==> %S\n",
804 SourceMbrPathBuffer, DestinationDevicePathBuffer);
805
806 /* Install the MBR */
807 return InstallBootCodeToDisk(SourceMbrPathBuffer,
808 DestinationDevicePathBuffer,
810}
static NTSTATUS InstallMbrBootCode(IN PCWSTR SrcPath, IN HANDLE DstPath, IN HANDLE DiskHandle)
Definition: bootsup.c:699
static NTSTATUS SaveBootSector(IN PCWSTR RootPath, IN PCWSTR DstPath, IN ULONG Length)
Definition: bootsup.c:487
static BOOLEAN IsThereAValidBootSector(IN PCWSTR RootPath)
Definition: bootsup.c:447
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 1333 of file bootsup.c.

1338{
1339 if (wcsicmp(FileSystemName, L"FAT") == 0 ||
1340 wcsicmp(FileSystemName, L"FAT32") == 0)
1341 {
1342 return InstallFatBootcodeToPartition(SystemRootPath,
1343 SourceRootPath,
1344 DestinationArcPath,
1345 FileSystemName);
1346 }
1347 else if (wcsicmp(FileSystemName, L"NTFS") == 0)
1348 {
1349 return InstallNtfsBootcodeToPartition(SystemRootPath,
1350 SourceRootPath,
1351 DestinationArcPath);
1352 }
1353 else if (wcsicmp(FileSystemName, L"BTRFS") == 0)
1354 {
1355 return InstallBtrfsBootcodeToPartition(SystemRootPath,
1356 SourceRootPath,
1357 DestinationArcPath);
1358 }
1359 /*
1360 else if (wcsicmp(FileSystemName, L"EXT2") == 0 ||
1361 wcsicmp(FileSystemName, L"EXT3") == 0 ||
1362 wcsicmp(FileSystemName, L"EXT4") == 0)
1363 {
1364 return STATUS_NOT_SUPPORTED;
1365 }
1366 */
1367 else
1368 {
1369 /* Unknown file system */
1370 DPRINT1("Unknown file system '%S'\n", FileSystemName);
1371 }
1372
1373 return STATUS_NOT_SUPPORTED;
1374}
static NTSTATUS InstallFatBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN PCWSTR FileSystemName)
Definition: bootsup.c:815
static NTSTATUS InstallNtfsBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
Definition: bootsup.c:1232
static NTSTATUS InstallBtrfsBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath)
Definition: bootsup.c:1129
#define wcsicmp
Definition: compat.h:15

Referenced by BootLoaderHardDiskPage().