mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-02-01 22:41:28 +01:00
Sum will never overflow
This commit is contained in:
parent
80c5b67d7e
commit
4b9b2b4251
@ -17,26 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
//#include <AppleSupportPkgVersion.h>
|
||||
#include <Uefi/UefiGpt.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
//#include <Library/OcAppleImageVerificationLib.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/DiskIo.h>
|
||||
#include <Protocol/BlockIo2.h>
|
||||
#include <Protocol/DiskIo2.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/ComponentName.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Protocol/PartitionInfo.h>
|
||||
#include <Protocol/ApplePartitionInfo.h>
|
||||
#include <Protocol/ApfsEfiBootRecordInfo.h>
|
||||
#include <Protocol/NullTextOutput.h>
|
||||
|
||||
#define APPLE_SUPPORT_VERSION L"2.0.9"
|
||||
#include "ApfsDriverLoader.h"
|
||||
@ -56,11 +36,13 @@ ApfsBlockChecksumCalculate (
|
||||
UINT64 Check1 = 0;
|
||||
UINT64 Sum2 = 0;
|
||||
UINT64 Check2 = 0;
|
||||
CONST UINT64 ModValue = 0xFFFFFFFF;
|
||||
CONST UINT64 ModValue = 0xFFFFFFFFull;
|
||||
|
||||
for (Index = 0; Index < DataSize / sizeof (UINT32); Index++) {
|
||||
Sum1 = ((Sum1 + (UINT64)Data[Index]) % ModValue);
|
||||
Sum2 = (Sum2 + Sum1) % ModValue;
|
||||
// Sum1 = ((Sum1 + (UINT64)Data[Index]) % ModValue);
|
||||
// Sum2 = (Sum2 + Sum1) % ModValue;
|
||||
Sum1 += (UINT64)*Data++;
|
||||
Sum2 += Sum1;
|
||||
}
|
||||
|
||||
Check1 = ModValue - ((Sum1 + Sum2) % ModValue);
|
||||
@ -811,7 +793,7 @@ ApfsDriverLoaderStart (
|
||||
|
||||
//
|
||||
// Free ApfsBlock and allocate one of a correct size.
|
||||
// ContainerSuperBlock & EfiBootRecordBlockPtr will not valid now
|
||||
// ContainerSuperBlock (& EfiBootRecordBlockPtr ?) will not valid now
|
||||
//
|
||||
FreePool (ApfsBlock);
|
||||
ApfsBlock = AllocateZeroPool (ApfsBlockSize);
|
||||
@ -849,6 +831,7 @@ ApfsDriverLoaderStart (
|
||||
//
|
||||
ContainerSuperBlock = (APFS_CSB *)ApfsBlock;
|
||||
CopyMem (&ContainerUuid, &ContainerSuperBlock->Uuid, sizeof (EFI_GUID));
|
||||
EfiBootRecordBlockPtr = ContainerSuperBlock->EfiBootRecordBlock;
|
||||
|
||||
//
|
||||
// Calculate Offset of EfiBootRecordBlock
|
||||
|
@ -19,6 +19,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#ifndef APFS_DRIVER_LOADER_H_
|
||||
#define APFS_DRIVER_LOADER_H_
|
||||
|
||||
#include <Uefi/UefiGpt.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
//#include <Library/OcAppleImageVerificationLib.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/DiskIo.h>
|
||||
#include <Protocol/BlockIo2.h>
|
||||
#include <Protocol/DiskIo2.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/ComponentName.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Protocol/PartitionInfo.h>
|
||||
#include <Protocol/ApplePartitionInfo.h>
|
||||
#include <Protocol/ApfsEfiBootRecordInfo.h>
|
||||
#include <Protocol/NullTextOutput.h>
|
||||
|
||||
|
||||
#define APFS_DRIVER_INFO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('A', 'F', 'J', 'S')
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user