[FREELDR] Fix the DPTE validity check, addendum to commit 4190b48924

Which is also an addendum to commit b3f11cfb38 (r17484).

The Enhanced Disk Drive Specification tells us that if the (far) pointer
to the Device Parameter Table Extension is set to FFFF:FFFF, the pointer
is invalid.

However there are some BIOSes, incl UEFI ones when running in Legacy
mode (e.g. GIGABYTE UEFI DualBIOS), that set this pointer to 0000:0000
instead, which is also an invalid value.
This commit is contained in:
Hermès Bélusca-Maïto
2025-09-28 17:19:13 +02:00
parent 4ffe8e86f0
commit 10b7a85991

View File

@@ -346,8 +346,10 @@ DiskGetExtendedDriveParameters(
if (Ptr[0] >= 0x1e)
{
// Ptr[13]: offset, Ptr[14]: segment
TRACE("EDD configuration parameters: %x:%x\n", Ptr[14], Ptr[13]);
if (Ptr[13] != 0xffff && Ptr[14] != 0xffff)
TRACE("EDD configuration parameters (DPTE): %x:%x\n", Ptr[14], Ptr[13]);
/* The DPTE pointer is valid if it's != FFFF:FFFF (per the Enhanced Disk
* Drive Specification), but also, when it's != 0000:0000 (broken BIOSes) */
if (!(Ptr[13] == 0xFFFF && Ptr[14] == 0xFFFF) && !(Ptr[13] == 0 && Ptr[14] == 0))
{
PUCHAR SpecPtr = (PUCHAR)(ULONG_PTR)((Ptr[14] << 4) + Ptr[13]);
TRACE("SpecPtr: 0x%x\n", SpecPtr);