return Status;
}
- /* Copy partition table from old MBR to new */
+ /*
+ * Copy the disk signature, the reserved fields and
+ * the partition table from the old MBR to the new one.
+ */
RtlCopyMemory(&NewBootSector->Signature,
&OrigBootSector->Signature,
sizeof(PARTITION_SECTOR) - offsetof(PARTITION_SECTOR, Signature) /* Length of partition table */);
DPRINT("System path: '%wZ'\n", SystemRootPath);
/* Copy FreeLoader to the system partition */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\freeldr.sys");
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.sys");
+ 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);
}
/* Prepare for possibly copying 'freeldr.ini' */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.ini");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
- DoesFreeLdrExist = DoesFileExist(NULL, SystemRootPath->Buffer, L"freeldr.ini");
+ DoesFreeLdrExist = DoesFileExist(NULL, NULL, DstPath);
if (DoesFreeLdrExist)
{
/* Update existing 'freeldr.ini' */
{
/* Create new 'freeldr.ini' */
DPRINT1("Create new 'freeldr.ini'\n");
- // wcscpy(DstPath, SystemRootPath->Buffer);
- // wcscat(DstPath, L"\\freeldr.ini");
+ // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer);
if (!NT_SUCCESS(Status))
}
/* Install new bootcode into a file */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\bootsect.ros");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\bootsect.ros");
if (PartitionType == PARTITION_FAT32 ||
PartitionType == PARTITION_FAT32_XINT13)
{
/* Install FAT32 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat32.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin");
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, DstPath);
Status = InstallFat32BootCodeToFile(SrcPath, DstPath,
else
{
/* Install FAT16 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
DPRINT1("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
Status = InstallFat16BootCodeToFile(SrcPath, DstPath,
}
/* Update 'boot.ini' */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\boot.ini");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\boot.ini");
DPRINT1("Update 'boot.ini': %S\n", DstPath);
Status = UpdateBootIni(DstPath,
{
/* Create new 'freeldr.ini' */
DPRINT1("Create new 'freeldr.ini'\n");
- // wcscpy(DstPath, SystemRootPath->Buffer);
- // wcscat(DstPath, L"\\freeldr.ini");
+ // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
if (IsThereAValidBootSector(SystemRootPath->Buffer))
{
}
/* Save current bootsector */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, BootSectorFileName);
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, BootSectorFileName);
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
Status = SaveBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE);
PartitionType == PARTITION_FAT32_XINT13)
{
/* Install FAT32 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat32.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin");
DPRINT1("Install FAT32 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
Status = InstallFat32BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
else
{
/* Install FAT16 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
DPRINT1("Install FAT16 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
Status = InstallFat16BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
DPRINT("System path: '%wZ'\n", SystemRootPath);
/* Copy FreeLoader to the system partition */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\freeldr.sys");
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.sys");
+ 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);
}
/* Prepare for possibly copying 'freeldr.ini' */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.ini");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
- DoesFreeLdrExist = DoesFileExist(NULL, SystemRootPath->Buffer, L"freeldr.ini");
+ DoesFreeLdrExist = DoesFileExist(NULL, NULL, DstPath);
if (DoesFreeLdrExist)
{
/* Update existing 'freeldr.ini' */
{
/* Create new 'freeldr.ini' */
DPRINT1("Create new 'freeldr.ini'\n");
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\freeldr.ini");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini");
/* Certainly SysLinux, GRUB, LILO... or an unknown boot loader */
DPRINT1("*nix or unknown boot loader found\n");
}
/* Save current bootsector */
- wcscpy(DstPath, SystemRootPath->Buffer);
- wcscat(DstPath, L"\\bootsect.old");
+ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\bootsect.old");
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR));
// if (PartitionType == PARTITION_EXT2)
{
/* Install EXT2 bootcode */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\ext2.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\ext2.bin");
DPRINT1("Install EXT2 bootcode: %S ==> %S\n", SrcPath, SystemRootPath->Buffer);
Status = InstallExt2BootCodeToDisk(SrcPath, SystemRootPath->Buffer);
}
/* Copy FreeLoader to the boot partition */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\freeldr.sys");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\freeldr.sys");
- wcscpy(DstPath, L"\\Device\\Floppy0\\freeldr.sys");
+ RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0\\freeldr.sys");
DPRINT("Copy: %S ==> %S\n", SrcPath, DstPath);
Status = SetupCopyFile(SrcPath, DstPath);
}
/* Create new 'freeldr.ini' */
- wcscpy(DstPath, L"\\Device\\Floppy0\\freeldr.ini");
+ RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0\\freeldr.ini");
DPRINT("Create new 'freeldr.ini'\n");
Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer);
}
/* Install FAT12/16 boosector */
- wcscpy(SrcPath, SourceRootPath->Buffer);
- wcscat(SrcPath, L"\\loader\\fat.bin");
+ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
- wcscpy(DstPath, L"\\Device\\Floppy0");
+ RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), L"\\Device\\Floppy0");
DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath);
Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath);