return STATUS_SUCCESS;
}
-static
BOOLEAN
IsThereAValidBootSector(PWSTR RootPath)
{
return (Instruction != 0x00000000);
}
-static
NTSTATUS
-SaveCurrentBootSector(
+SaveBootSector(
PWSTR RootPath,
PWSTR DstPath,
ULONG Length)
NULL,
&IoStatusBlock,
OrigBootSector,
- SECTORSIZE,
+ sizeof(PARTITION_SECTOR),
&FileOffset,
NULL);
NtClose(FileHandle);
}
/* Copy partition table from old MBR to new */
- RtlCopyMemory (&NewBootSector->Signature,
- &OrigBootSector->Signature,
- sizeof(PARTITION_SECTOR) - offsetof(PARTITION_SECTOR, Signature) /* Length of partition table */);
+ RtlCopyMemory(&NewBootSector->Signature,
+ &OrigBootSector->Signature,
+ sizeof(PARTITION_SECTOR) - offsetof(PARTITION_SECTOR, Signature) /* Length of partition table */);
/* Free the original boot sector */
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
NULL,
&IoStatusBlock,
NewBootSector,
- SECTORSIZE,
+ sizeof(PARTITION_SECTOR),
&FileOffset,
NULL);
NtClose(FileHandle);
FIELD_OFFSET(FAT_BOOTSECTOR, BootCodeAndData) -
FIELD_OFFSET(FAT_BOOTSECTOR, OemName));
- NewBootSector->HiddenSectors = PartitionList->CurrentDisk->SectorsPerTrack;
-
/* Free the original boot sector */
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
FIELD_OFFSET(FAT32_BOOTSECTOR, BootCodeAndData) -
FIELD_OFFSET(FAT32_BOOTSECTOR, OemName));
- NewBootSector->HiddenSectors = PartitionList->CurrentDisk->SectorsPerTrack;
-
/* Get the location of the backup boot sector */
BackupBootSector = OrigBootSector->BackupBootSector;
/* FAT or FAT32 partition */
DPRINT("System path: '%wZ'\n", SystemRootPath);
- /* Copy FreeLoader to the boot partition */
+ /* Copy FreeLoader to the system partition */
wcscpy(SrcPath, SourceRootPath->Buffer);
wcscat(SrcPath, L"\\loader\\freeldr.sys");
wcscpy(DstPath, SystemRootPath->Buffer);
wcscat(DstPath, BootSectorFileName);
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
- Status = SaveCurrentBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE);
+ Status = SaveBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE);
if (!NT_SUCCESS(Status))
{
- DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status);
+ DPRINT1("SaveBootSector() failed (Status %lx)\n", Status);
return Status;
}
}
/* EXT2 partition */
DPRINT("System path: '%wZ'\n", SystemRootPath);
- /* Copy FreeLoader to the boot partition */
+ /* Copy FreeLoader to the system partition */
wcscpy(SrcPath, SourceRootPath->Buffer);
wcscat(SrcPath, L"\\loader\\freeldr.sys");
wcscpy(DstPath, SystemRootPath->Buffer);
wcscat(DstPath, L"\\bootsect.old");
DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath);
- Status = SaveCurrentBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR));
+ Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR));
if (!NT_SUCCESS(Status))
{
- DPRINT1("SaveCurrentBootSector() failed (Status %lx)\n", Status);
+ DPRINT1("SaveBootSector() failed (Status %lx)\n", Status);
return Status;
}
}