mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
[SETUPLIB] Introduce a helper for copying bootloader files (#7310)
This function could be generalized later to copy other files necessary for the bootloader; removing also the currently hardcoded placement in the installation source directory, and instead, using a configurable path (specified in txtsetup.sif); etc. Adapted from a commit by Timo Kreuzer (see PR #7420) Co-Authored-By: Timo Kreuzer <timo.kreuzer@reactos.org>
This commit is contained in:
parent
d6d3d0eacd
commit
636e2e9172
1 changed files with 34 additions and 21 deletions
|
@ -878,6 +878,31 @@ InstallMbrBootCodeToDisk(
|
|||
}
|
||||
|
||||
|
||||
static
|
||||
NTSTATUS
|
||||
InstallBootloaderFiles(
|
||||
_In_ PCUNICODE_STRING SystemRootPath,
|
||||
_In_ PCUNICODE_STRING SourceRootPath)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
WCHAR SrcPath[MAX_PATH];
|
||||
WCHAR DstPath[MAX_PATH];
|
||||
|
||||
/* 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");
|
||||
|
||||
DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = SetupCopyFile(SrcPath, DstPath, FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SetupCopyFile() failed (Status 0x%08lx)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
NTSTATUS
|
||||
InstallFatBootcodeToPartition(
|
||||
|
@ -894,15 +919,11 @@ InstallFatBootcodeToPartition(
|
|||
/* FAT or FAT32 partition */
|
||||
DPRINT("System path: '%wZ'\n", SystemRootPath);
|
||||
|
||||
/* 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");
|
||||
|
||||
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = SetupCopyFile(SrcPath, DstPath, FALSE);
|
||||
/* Install the bootloader */
|
||||
Status = InstallBootloaderFiles(SystemRootPath, SourceRootPath);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
||||
DPRINT1("InstallBootloaderFiles() failed (Status %lx)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1187,15 +1208,11 @@ InstallBtrfsBootcodeToPartition(
|
|||
/* BTRFS partition */
|
||||
DPRINT("System path: '%wZ'\n", SystemRootPath);
|
||||
|
||||
/* 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");
|
||||
|
||||
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = SetupCopyFile(SrcPath, DstPath, FALSE);
|
||||
/* Install the bootloader */
|
||||
Status = InstallBootloaderFiles(SystemRootPath, SourceRootPath);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
||||
DPRINT1("InstallBootloaderFiles() failed (Status %lx)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1290,15 +1307,11 @@ InstallNtfsBootcodeToPartition(
|
|||
/* NTFS partition */
|
||||
DPRINT("System path: '%wZ'\n", SystemRootPath);
|
||||
|
||||
/* 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");
|
||||
|
||||
DPRINT1("Copy: %S ==> %S\n", SrcPath, DstPath);
|
||||
Status = SetupCopyFile(SrcPath, DstPath, FALSE);
|
||||
/* Install the bootloader */
|
||||
Status = InstallBootloaderFiles(SystemRootPath, SourceRootPath);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SetupCopyFile() failed (Status %lx)\n", Status);
|
||||
DPRINT1("InstallBootloaderFiles() failed (Status %lx)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue