[NTOS:FSTUB] Addendum to 29615fee and 8d2fe541: Further remove useless casts.

Also, fix the MBR checksum calculation (missing ~CheckSum + 1), to fix
the calculation in accordance with how MS calculates the MBR checksums
(and what we do as well in
https://github.com/reactos/reactos/blob/master/base/setup/lib/utils/partlist.c#L1581
https://github.com/reactos/reactos/blob/master/boot/freeldr/freeldr/arch/i386/hwdisk.c#L291
).
This commit is contained in:
Hermès Bélusca-Maïto 2020-12-07 22:52:42 +01:00
parent fd053237cb
commit 3d980c4a2c
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -909,7 +909,7 @@ FstubReadHeaderEFI(IN PDISK_INFORMATION Disk,
Status = FstubReadSector(Disk->DeviceObject,
Disk->SectorSize,
EFIHeader->PartitionEntryLBA + i,
(PUSHORT)Sector);
Sector);
if (!NT_SUCCESS(Status))
{
ExFreePoolWithTag(Sector, TAG_FSTUB);
@ -929,7 +929,7 @@ FstubReadHeaderEFI(IN PDISK_INFORMATION Disk,
Status = FstubReadSector(Disk->DeviceObject,
Disk->SectorSize,
EFIHeader->PartitionEntryLBA + i,
(PUSHORT)Sector);
Sector);
if (!NT_SUCCESS(Status))
{
ExFreePoolWithTag(Sector, TAG_FSTUB);
@ -2189,7 +2189,7 @@ IoReadDiskSignature(IN PDEVICE_OBJECT DeviceObject,
Status = FstubReadSector(DeviceObject,
BytesPerSector,
0ULL,
(PUSHORT)Buffer);
Buffer);
if (!NT_SUCCESS(Status))
{
goto Cleanup;
@ -2208,7 +2208,7 @@ IoReadDiskSignature(IN PDEVICE_OBJECT DeviceObject,
Status = FstubReadSector(DeviceObject,
BytesPerSector,
1ULL,
(PUSHORT)Buffer);
Buffer);
if (!NT_SUCCESS(Status))
{
goto Cleanup;
@ -2245,10 +2245,11 @@ IoReadDiskSignature(IN PDEVICE_OBJECT DeviceObject,
else
{
/* Compute MBR checksum */
for (i = 0, CheckSum = 0; i < 512; i += sizeof(INT32))
for (i = 0, CheckSum = 0; i < 512; i += sizeof(UINT32))
{
CheckSum += *(PUINT32)&Buffer[i];
}
CheckSum = ~CheckSum + 1;
/* Set partition table style to MBR and return signature (offset 440) and checksum */
Signature->PartitionStyle = PARTITION_STYLE_MBR;