Format:Apple Disk Image (UDIF)
| Magic | 6B 6F 6C 79 (koly) at file size minus 512 |
|---|---|
| Extensions | .dmg |
| Endianness | big-endian |
| License | darling-dmg is GPL-3.0 |
| On this wiki | Facts · Code · Notes · Topics |
macOS .dmg disk images (UDIF): data blocks followed by an XML property list (resource-fork/blkx tables of chunk runs) and a 512-byte "koly" trailer at the very end of the file; chunks are raw, zero-fill, ADC, zlib, bzip2 or LZFSE.
Locating things
A UDIF .dmg has no magic at offset 0. The header ("koly" block, 512 bytes) is the trailer: the last 512 bytes of the file start with 6B 6F 6C 79 ("koly", UDIF_SIGNATURE 0x6B6F6C79). darling-dmg (commit 1a6de10c58, src/DMGDisk.cpp) tests it with offset = file length minus 512 and rejects files shorter than 512 bytes. All fields are big-endian.
koly block (src/dmg.h, packed)
signature u32, version u32, header size u32, flags u32 (1 = flattened), running data fork offset u64, data fork offset u64, data fork length u64, resource fork offset u64, resource fork length u64, segment number u32, segment count u32, segment id (4 x u32), data fork checksum (UDIFChecksum: type u32, size u32, 0x20 u32 data words), XML offset u64, XML length u64, 0x78 reserved bytes, master checksum (same shape), image variant u32 (1 device image, 2 partition image), sector count u64, 3 reserved u32.
The XML offset and length point to an Apple XML property list. darling-dmg reads /plist/dict/key[resource-fork] then the following dict's key blkx: an array of dicts, one per partition, each with a base64 Data blob that is a BLKXTable.
BLKX table
Signature u32 (ASCII "mish", 0x6D697368: darling-dmg only names the field fUDIFBlocksSignature (src/dmg.h line 118) and never checks it, while planetbeing/libdmg-hfsplus at 7ac55ec6 defines #define UDIF_BLOCK_SIGNATURE 0x6D697368 in includes/dmg/dmg.h line 26), info version u32, first sector number u64, sector count u64, data start u64, decompress buffer requested u32, blocks descriptor u32, 6 reserved u32, checksum, run count u32, then the runs. A BLKXRun is 40 bytes: type u32, reserved u32, sector start u64, sector count u64, compressed offset u64 (into the data fork), compressed length u64. Sectors are 512 bytes: darling-dmg src/DMGPartition.cpp defines SECTOR_SIZE = 512 (line 13) and src/DMGDisk.cpp multiplies firstSectorNumber and sectorCount by 512 (lines 135-136).
Run types (RunType enum in dmg.h)
| Value | Meaning |
|---|---|
| 0x00000000 | zero fill |
| 0x00000001 | raw copy |
| 0x00000002 | ignore / unknown |
| 0x80000004 | ADC compression |
| 0x80000005 | zlib (see Format:Zlib stream) |
| 0x80000006 | bzip2 (see Format:Bzip2) |
| 0x80000007 | LZFSE |
| 0x7FFFFFFE | comment |
| 0xFFFFFFFF | terminator |
The blkx entry named with the entire-device descriptor 0xFFFFFFFE (and 0xFFFFFFFF for the DDM descriptor) are special per dmg.h.
Content
After joining the runs, the result is a partitioned disk (Apple partition map or GPT: darling-dmg has AppleDisk and GPTDisk readers) holding usually an HFS+ volume (it has an HFS/HFS+ implementation including decmpfs/zlib-compressed files). Unverified: newer images may hold APFS, which darling-dmg does not read. The app inside is a bundle with a Format:Mach-O binary.
Sources
darlinghq/darling-dmg (GPL-3.0), src/dmg.h and src/DMGDisk.cpp, read in a clone.
Code & repositories
- https://github.com/darlinghq/darling-dmg @
1a6de10c5886c40a414090701b2520bd0417ce29· license: GPL-3.0
FUSE reader for DMG: koly block, blkx tables, run types, HFS+ and GPT readers (GPL-3.0)
Tested on: source read, not run: not run, source read · checked 2026-10-18; last activity 2025-10-18