mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 17:34:15 +00:00
[SETUPLIB] Improve the bootloader 'validity' checks -- Addendum to f06734e5
(r74512).
Adapted from PR #89 by Serge Gautherie. This should improve the situation described in CORE-12672 and CORE-4870.
This commit is contained in:
parent
ad9e57895d
commit
a7a11dd60d
1 changed files with 8 additions and 8 deletions
|
@ -551,7 +551,6 @@ IsThereAValidBootSector(
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
LARGE_INTEGER FileOffset;
|
LARGE_INTEGER FileOffset;
|
||||||
PUCHAR BootSector;
|
PUCHAR BootSector;
|
||||||
ULONG Instruction;
|
|
||||||
|
|
||||||
/* Allocate buffer for bootsector */
|
/* Allocate buffer for bootsector */
|
||||||
BootSector = RtlAllocateHeap(ProcessHeap, 0, SECTORSIZE);
|
BootSector = RtlAllocateHeap(ProcessHeap, 0, SECTORSIZE);
|
||||||
|
@ -593,17 +592,18 @@ IsThereAValidBootSector(
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
goto Quit;
|
goto Quit;
|
||||||
|
|
||||||
/* Check the instruction; we use a ULONG to read three bytes */
|
/* Check for the existence of the bootsector signature */
|
||||||
Instruction = (*(PULONG)BootSector) & 0x00FFFFFF;
|
IsValid = (*(PUSHORT)(BootSector + 0x1FE) == 0xAA55);
|
||||||
IsValid = (Instruction != 0x00000000);
|
if (IsValid)
|
||||||
|
{
|
||||||
/* Check the bootsector signature */
|
/* Check for the first instruction encoded on three bytes */
|
||||||
IsValid &= (*(PUSHORT)(BootSector + 0x1fe) == 0xaa55);
|
IsValid = (((*(PULONG)BootSector) & 0x00FFFFFF) != 0x00000000);
|
||||||
|
}
|
||||||
|
|
||||||
Quit:
|
Quit:
|
||||||
/* Free the boot sector */
|
/* Free the boot sector */
|
||||||
RtlFreeHeap(ProcessHeap, 0, BootSector);
|
RtlFreeHeap(ProcessHeap, 0, BootSector);
|
||||||
return IsValid; // Status;
|
return IsValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue