Add compressed DMG support (based on dmgwiz)#149
Open
Lazza wants to merge 2 commits intoydkhatri:masterfrom
Open
Add compressed DMG support (based on dmgwiz)#149Lazza wants to merge 2 commits intoydkhatri:masterfrom
Lazza wants to merge 2 commits intoydkhatri:masterfrom
Conversation
…n span handling and cache management) - Introduced per-partition non-overlapping spans for better memory management. - Replaced dictionary-based chunk cache with an OrderedDict to maintain insertion order and improve cache eviction logic. - Updated methods to build partition spans and read partition slices, enhancing performance and reliability. - Increased maximum chunk cache size from 48 to 64.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief description
With this patch,
mac_aptcan now open many compressed Apple disk images (DMG) that use Apple’s UDIF layout, such as those created by Fuji. Previously, only uncompressed DMGs worked well with the generic disk reader; zlib-, bzip2-, and LZFSE-based images are now handled explicitly.The behavior is modeled on the open-source tool dmgwiz (MIT licensed), which is a solid reference for how these images store and decompress their payload.
How it works
When you choose
DMGas the input type,mac_aptchecks whether the file looks like a compressed DMG. If so, it decompresses it on the fly into a raw disk stream and feeds that to TSK (similar to what is done forSPARSEimages). If it isn’t that kind of DMG, it treats it like a raw disk disk image, as before.DDinputs are unchanged.Limitations
Some DMG variants were not implemented. Specifically, ADC-compressed chunks and encrypted disk images are not supported yet.
Full disclosure
Most of the implementation was produced by converting and adapting dmgwiz-style logic with AI assistance in Cursor, then optimized for performance and tested on real data. It has been tested against an ASR (Apple Software Restore) style image produced with Fuji.
Coding style
To avoid conflicting with other parts of the code, the main
mac_apt.pyfile has not been normalized with Black. Conversely, the new fileapple_disk_image.pyadheres to Black and PEP8 conventions.