mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcAppleDiskImageLib: Initialize a caller-provided context
This commit is contained in:
parent
faf7976d33
commit
aa76195a97
@ -36,7 +36,7 @@ BOOLEAN
|
||||
OcAppleDiskImageInitializeContext (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN BufferLength,
|
||||
OUT OC_APPLE_DISK_IMAGE_CONTEXT **Context
|
||||
OUT OC_APPLE_DISK_IMAGE_CONTEXT *Context
|
||||
);
|
||||
|
||||
VOID
|
||||
|
||||
@ -26,11 +26,10 @@ BOOLEAN
|
||||
OcAppleDiskImageInitializeContext (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN BufferLength,
|
||||
OUT OC_APPLE_DISK_IMAGE_CONTEXT **Context
|
||||
OUT OC_APPLE_DISK_IMAGE_CONTEXT *Context
|
||||
)
|
||||
{
|
||||
BOOLEAN Result;
|
||||
OC_APPLE_DISK_IMAGE_CONTEXT *DmgContext;
|
||||
UINTN TrailerOffset;
|
||||
UINT8 *BufferBytes;
|
||||
UINT8 *BufferBytesCurrent;
|
||||
@ -162,19 +161,12 @@ OcAppleDiskImageInitializeContext (
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DmgContext = AllocateZeroPool (sizeof (*DmgContext));
|
||||
if (DmgContext == NULL) {
|
||||
FreePool (DmgBlocks);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DmgContext->Buffer = BufferBytes;
|
||||
DmgContext->Length = (TrailerOffset + sizeof (*Trailer));
|
||||
DmgContext->BlockCount = DmgBlockCount;
|
||||
DmgContext->Blocks = DmgBlocks;
|
||||
DmgContext->SectorCount = SectorCount;
|
||||
|
||||
*Context = DmgContext;
|
||||
Context->Buffer = BufferBytes;
|
||||
Context->Length = (TrailerOffset + sizeof (*Trailer));
|
||||
Context->BlockCount = DmgBlockCount;
|
||||
Context->Blocks = DmgBlocks;
|
||||
Context->SectorCount = SectorCount;
|
||||
Context->BlockIoHandle = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -193,7 +185,6 @@ OcAppleDiskImageFreeContext (
|
||||
}
|
||||
|
||||
FreePool (Context->Blocks);
|
||||
FreePool (Context);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
|
||||
@ -62,7 +62,7 @@ int main (int argc, char *argv[]) {
|
||||
|
||||
BOOLEAN Result;
|
||||
EFI_STATUS Status;
|
||||
OC_APPLE_DISK_IMAGE_CONTEXT *DmgContext;
|
||||
OC_APPLE_DISK_IMAGE_CONTEXT DmgContext;
|
||||
|
||||
Result = OcAppleDiskImageInitializeContext (Dmg, DmgSize, &DmgContext);
|
||||
if (!Result) {
|
||||
@ -70,14 +70,14 @@ int main (int argc, char *argv[]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UncompSize = (DmgContext->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");
|
||||
continue;
|
||||
}
|
||||
|
||||
Result = OcAppleDiskImageRead (DmgContext, 0, UncompSize, UncompDmg);
|
||||
Result = OcAppleDiskImageRead (&DmgContext, 0, UncompSize, UncompDmg);
|
||||
if (!Result) {
|
||||
printf ("DMG read error\n");
|
||||
continue;
|
||||
@ -106,7 +106,7 @@ int main (int argc, char *argv[]) {
|
||||
|
||||
printf ("Decompressed the entire DMG...\n");
|
||||
|
||||
OcAppleDiskImageFreeContext (DmgContext);
|
||||
OcAppleDiskImageFreeContext (&DmgContext);
|
||||
|
||||
printf ("Success...\n");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user