[FREELDR:ARCH] hwide.c: Don't rely on DEVICE_UNIT P; to be at the beginning of the HW_DEVICE_UNIT structure (#8732)

This commit is contained in:
Hermès Bélusca-Maïto
2026-03-13 22:08:39 +01:00
parent 9f42210478
commit 62d71ebbd3

View File

@@ -1233,7 +1233,7 @@ AtaReadLogicalSectors(
_In_ ULONG SectorCount,
_Out_writes_bytes_all_(SectorCount * DeviceUnit->SectorSize) PVOID Buffer)
{
PHW_DEVICE_UNIT Unit = (PHW_DEVICE_UNIT)DeviceUnit;
PHW_DEVICE_UNIT Unit = CONTAINING_RECORD(DeviceUnit, HW_DEVICE_UNIT, P);
ATA_DEVICE_REQUEST Request = { 0 };
ASSERT(Unit);
@@ -1271,8 +1271,7 @@ AtaGetDevice(
_In_ UCHAR UnitNumber)
{
if (UnitNumber < RTL_NUMBER_OF(AtapUnits))
return (PDEVICE_UNIT)AtapUnits[UnitNumber];
return &(AtapUnits[UnitNumber]->P);
return NULL;
}