ReactOS  0.4.14-dev-114-gc8cbd56
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 UCHAR PartitionType)
 
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 2350 of file bootsup.c.

2353 {
2354  static const PCWSTR FloppyDevice = L"\\Device\\Floppy0\\";
2355 
2356  NTSTATUS Status;
2357  WCHAR SrcPath[MAX_PATH];
2358  WCHAR DstPath[MAX_PATH];
2359 
2360  /* Verify that the floppy disk is accessible */
2362  return STATUS_DEVICE_NOT_READY;
2363 
2364  /* Format the floppy disk */
2365  // FormatPartition(...)
2367  L"FAT",
2368  FMIFS_FLOPPY,
2369  NULL,
2370  TRUE,
2371  0,
2372  NULL);
2373  if (!NT_SUCCESS(Status))
2374  {
2376  DPRINT1("FAT FS non existent on this system?!\n");
2377  else
2378  DPRINT1("VfatFormat() failed (Status %lx)\n", Status);
2379 
2380  return Status;
2381  }
2382 
2383  /* Copy FreeLoader to the boot partition */
2384  CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
2385  CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice, L"freeldr.sys");
2386 
2387  DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
2388  Status = SetupCopyFile(SrcPath, DstPath, FALSE);
2389  if (!NT_SUCCESS(Status))
2390  {
2391  DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
2392  return Status;
2393  }
2394 
2395  /* Create new 'freeldr.ini' */
2396  DPRINT("Create new 'freeldr.ini'\n");
2397  Status = CreateFreeLoaderIniForReactOS(FloppyDevice, DestinationArcPath->Buffer);
2398  if (!NT_SUCCESS(Status))
2399  {
2400  DPRINT1("CreateFreeLoaderIniForReactOS() failed (Status %lx)\n", Status);
2401  return Status;
2402  }
2403 
2404  /* Install FAT12 boosector */
2405  CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
2406  CombinePaths(DstPath, ARRAYSIZE(DstPath), 1, FloppyDevice);
2407 
2408  DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
2409  Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath);
2410  if (!NT_SUCCESS(Status))
2411  {
2412  DPRINT1("InstallFat12BootCodeToFloppy() failed (Status %lx)\n", Status);
2413  return Status;
2414  }
2415 
2416  return STATUS_SUCCESS;
2417 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS SetupCopyFile(IN PCWSTR SourceFileName, IN PCWSTR DestinationFileName, IN BOOLEAN FailIfExists)
Definition: filesup.c:240
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static NTSTATUS CreateFreeLoaderIniForReactOS(IN PCWSTR IniPath, IN PCWSTR ArcPath)
Definition: bootsup.c:256
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
#define DoesDirExist(RootDirectory, DirName)
Definition: filesup.h:74
static const WCHAR L[]
Definition: oid.c:1250
static NTSTATUS InstallFat12BootCodeToFloppy(IN PCWSTR SrcPath, IN PCWSTR RootPath)
Definition: bootsup.c:927
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:431
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2966
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:681
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:65

Referenced by BootLoaderFloppyPage().

◆ InstallMbrBootCodeToDisk()

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

Definition at line 877 of file bootsup.c.

881 {
883  WCHAR SourceMbrPathBuffer[MAX_PATH];
884  WCHAR DstPath[MAX_PATH];
885 
886 #if 0
887  /*
888  * The DestinationDevicePathBuffer parameter has been built with
889  * the following instruction by the caller; I'm not yet sure whether
890  * I actually want this function to build the path instead, hence
891  * I keep this code here but disabled for now...
892  */
893  WCHAR DestinationDevicePathBuffer[MAX_PATH];
894  RtlStringCchPrintfW(DestinationDevicePathBuffer, ARRAYSIZE(DestinationDevicePathBuffer),
895  L"\\Device\\Harddisk%d\\Partition0",
896  DiskNumber);
897 #endif
898 
899  CombinePaths(SourceMbrPathBuffer, ARRAYSIZE(SourceMbrPathBuffer), 2,
900  SourceRootPath->Buffer, L"\\loader\\dosmbr.bin");
901 
902  if (IsThereAValidBootSector(DestinationDevicePathBuffer))
903  {
904  /* Save current MBR */
905  CombinePaths(DstPath, ARRAYSIZE(DstPath), 2,
906  SystemRootPath->Buffer, L"mbr.old");
907 
908  DPRINT1("Save MBR: %S ==> %S\n", DestinationDevicePathBuffer, DstPath);
909  Status = SaveBootSector(DestinationDevicePathBuffer, DstPath, sizeof(PARTITION_SECTOR));
910  if (!NT_SUCCESS(Status))
911  {
912  DPRINT1("SaveBootSector() failed (Status %lx)\n", Status);
913  // Don't care if we succeeded or not saving the old MBR, just go ahead.
914  }
915  }
916 
917  DPRINT1("Install MBR bootcode: %S ==> %S\n",
918  SourceMbrPathBuffer, DestinationDevicePathBuffer);
919 
920  return InstallMbrBootCodeToDiskHelper(SourceMbrPathBuffer,
921  DestinationDevicePathBuffer);
922 }
static NTSTATUS InstallMbrBootCodeToDiskHelper(IN PCWSTR SrcPath, IN PCWSTR RootPath)
Definition: bootsup.c:718
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
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static NTSTATUS SaveBootSector(IN PCWSTR RootPath, IN PCWSTR DstPath, IN ULONG Length)
Definition: bootsup.c:615
static BOOLEAN IsThereAValidBootSector(IN PCWSTR RootPath)
Definition: bootsup.c:538
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:681

Referenced by BootLoaderHarddiskMbrPage().

◆ InstallVBRToPartition()

NTSTATUS InstallVBRToPartition ( IN PUNICODE_STRING  SystemRootPath,
IN PUNICODE_STRING  SourceRootPath,
IN PUNICODE_STRING  DestinationArcPath,
IN UCHAR  PartitionType 
)

Definition at line 2307 of file bootsup.c.

2312 {
2313  switch (PartitionType)
2314  {
2315  case PARTITION_FAT_12:
2316  case PARTITION_FAT_16:
2317  case PARTITION_HUGE:
2318  case PARTITION_XINT13:
2319  case PARTITION_FAT32:
2321  {
2322  return InstallFatBootcodeToPartition(SystemRootPath,
2323  SourceRootPath,
2324  DestinationArcPath,
2325  PartitionType);
2326  }
2327 
2328  case PARTITION_LINUX:
2329  {
2330  return InstallBtrfsBootcodeToPartition(SystemRootPath,
2331  SourceRootPath,
2332  DestinationArcPath,
2333  PartitionType);
2334  }
2335 
2336  case PARTITION_IFS:
2337  DPRINT1("Partitions of type NTFS or HPFS are not supported yet!\n");
2338  break;
2339 
2340  default:
2341  DPRINT1("PartitionType 0x%02X unknown!\n", PartitionType);
2342  break;
2343  }
2344 
2345  return STATUS_UNSUCCESSFUL;
2346 }
#define PARTITION_FAT32
Definition: disk.h:95
static NTSTATUS InstallFatBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN UCHAR PartitionType)
Definition: bootsup.c:1887
#define PARTITION_XINT13
Definition: disk.h:97
static NTSTATUS InstallBtrfsBootcodeToPartition(IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, IN UCHAR PartitionType)
Definition: bootsup.c:2200
#define PARTITION_HUGE
Definition: disk.h:92
#define PARTITION_IFS
Definition: disk.h:93
#define PARTITION_FAT_16
Definition: disk.h:90
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define PARTITION_LINUX
Definition: partlist.c:36
#define DPRINT1
Definition: precomp.h:8
CHAR PartitionType
Definition: part_xbox.c:33
#define PARTITION_FAT_12
Definition: disk.h:87
#define PARTITION_FAT32_XINT13
Definition: disk.h:96

Referenced by BootLoaderHarddiskMbrPage(), and BootLoaderHarddiskVbrPage().