Skip to content

Add compressed DMG support (based on dmgwiz)#149

Open
Lazza wants to merge 2 commits intoydkhatri:masterfrom
Lazza:compressed-dmgs
Open

Add compressed DMG support (based on dmgwiz)#149
Lazza wants to merge 2 commits intoydkhatri:masterfrom
Lazza:compressed-dmgs

Conversation

@Lazza
Copy link

@Lazza Lazza commented Mar 23, 2026

Brief description

With this patch, mac_apt can 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 DMG as the input type, mac_apt checks 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 for SPARSE images). If it isn’t that kind of DMG, it treats it like a raw disk disk image, as before. DD inputs 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.py file has not been normalized with Black. Conversely, the new file apple_disk_image.py adheres to Black and PEP8 conventions.

Lazza added 2 commits March 22, 2026 22:35
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant