OcAppleDiskImageLib: Only store SectorCount rather than Trailer in Context.

This commit is contained in:
Download-Fritz 2019-03-31 15:34:30 +02:00
parent ce0c2cf1c2
commit 3672891504
4 changed files with 11 additions and 11 deletions

View File

@ -23,8 +23,8 @@ typedef struct {
UINT8 *Buffer;
UINTN Length;
// Disk image info.
APPLE_DISK_IMAGE_TRAILER Trailer;
UINT64 SectorCount;
UINT32 BlockCount;
APPLE_DISK_IMAGE_BLOCK_DATA **Blocks;

View File

@ -127,7 +127,7 @@ DiskImageBlockIoReadBlocks (
DiskImageData = OC_APPLE_DISK_IMAGE_MOUNTED_DATA_FROM_THIS (This);
if (Lba >= DiskImageData->ImageContext->Trailer.SectorCount) {
if (Lba >= DiskImageData->ImageContext->SectorCount) {
return EFI_INVALID_PARAMETER;
}
@ -284,7 +284,7 @@ OcAppleDiskImageInstallBlockIo (
DiskImageData->BlockIoMedia.MediaPresent = TRUE;
DiskImageData->BlockIoMedia.ReadOnly = TRUE;
DiskImageData->BlockIoMedia.BlockSize = APPLE_DISK_IMAGE_SECTOR_SIZE;
DiskImageData->BlockIoMedia.LastBlock = (Context->Trailer.SectorCount - 1);
DiskImageData->BlockIoMedia.LastBlock = (Context->SectorCount - 1);
InternalConstructDmgDevicePath (DiskImageData, RamDmgAddress);

View File

@ -207,11 +207,11 @@ OcAppleDiskImageInitializeContext (
return FALSE;
}
DmgContext->Buffer = BufferBytes;
DmgContext->Length = (TrailerOffset + sizeof (DmgContext->Trailer));
DmgContext->BlockCount = DmgBlockCount;
DmgContext->Blocks = DmgBlocks;
CopyMem (&DmgContext->Trailer, &Trailer, sizeof (DmgContext->Trailer));
DmgContext->Buffer = BufferBytes;
DmgContext->Length = (TrailerOffset + sizeof (Trailer));
DmgContext->BlockCount = DmgBlockCount;
DmgContext->Blocks = DmgBlocks;
DmgContext->SectorCount = Trailer.SectorCount;
*Context = DmgContext;
@ -264,7 +264,7 @@ OcAppleDiskImageRead (
ASSERT (Context != NULL);
ASSERT (Buffer != NULL);
ASSERT (Lba < Context->Trailer.SectorCount);
ASSERT (Lba < Context->SectorCount);
LbaCurrent = Lba;
RemainingBufferSize = BufferSize;

View File

@ -70,7 +70,7 @@ int main (int argc, char *argv[]) {
continue;
}
UncompSize = (DmgContext->Trailer.SectorCount * APPLE_DISK_IMAGE_SECTOR_SIZE);
UncompSize = (DmgContext->SectorCount * APPLE_DISK_IMAGE_SECTOR_SIZE);
UncompDmg = malloc (UncompSize);
if (UncompDmg == NULL) {
printf ("DMG data allocation failed.\n");