Skip to content
Sean P. Myrick V19.1.7.2 edited this page Sep 19, 2021 · 1 revision

DMG

Apple Disk Image format

https://github.com/seanpm2001/WacOS/blob/master/Graphics/DMG/Mac_OS_X_Disk_Image.png

The Apple Disk image format (*.dmg, *smi, or *.img) is a proprietary disk image format commonly used with MacOS since Mac OS 9. It can be mounted by dragging it onto the dock, and then it can function as an application installer to install a program.

Metadata

The file format is encoded in Big Endian. Despite the format being proprietary and poorly documented, it has since been successfully reverse engineered. It uses UDIF (Universal Disk Image Format) Metadata, which can be written in C like so:

typedef struct {
  uint8_t  Signature[4];           // magic 'koly'
  uint32_t Version;                // 4 (as of 2013)
  uint32_t HeaderSize;             // sizeof(this) =  512 (as of 2013)
  uint32_t Flags;                 
  uint64_t RunningDataForkOffset;
  uint64_t DataForkOffset;         // usually 0, beginning of file
  uint64_t DataForkLength;
  uint64_t RsrcForkOffset;         // resource fork offset and length
  uint64_t RsrcForkLength;        
  uint32_t SegmentNumber;          // Usually 1, can be 0
  uint32_t SegmentCount;           // Usually 1, can be 0
  uuid_t   SegmentID; 
  uint32_t DataChecksumType;       // Data fork checksum
  uint32_t DataChecksumSize;
  uint32_t DataChecksum[32];
  uint64_t XMLOffset;              // Position of XML property list in file
  uint64_t XMLLength; 
  uint8_t  Reserved1[120];
  uint32_t ChecksumType;           // Master checksum
  uint32_t ChecksumSize;
  uint32_t Checksum[32];
  uint32_t ImageVariant;           // Unknown, commonly 1
  uint64_t SectorCount;
  uint32_t reserved2;
  uint32_t reserved3;
  uint32_t reserved4;
} __attribute__((packed, scalar_storage_order("big-endian"))) UDIFResourceFile;

The metadata goes at the end of the file, not the beginning.


Sources

Wikipedia

More sources needed, Wikipedia should not be the only source.


Article info

Written on: 2021 Saturday September 18th at 9:39 pm

Last revised on: 2021 Saturday September 18th at 9:39 pm

File format Markdown document (*.md *.mkd *.markdown)

Article version: 1 (2021 Saturday September 18th at 9:39 pm)



https://github.com/seanpm2001/WacOS/blob/master/Graphics/Branding/Old/WACOS_LogoPrototype1.png

The WacOS project - Project Wiki (Sidebar)

Back home (/WacOS/Wiki/)


Featured articles:


https://github.com/seanpm2001/WacOS/blob/master/Graphics/Branding/Old/LogoPrototype1.png

Where to start

Read the rules for editing this Wiki

WacOS and ElementaryOS, 2 good choices

Click the dropdown for Wiki pages and find out what else interests you.

This section needs improvement.


Top sources

( (RosettaCode) | (Wikipedia) | (Apple) | (GitHub) )


WacOS project - Project Wiki

Sidebar version: 3 (Wednesday, 2021 September 29th at 9:39 pm)

End of sidebar


Clone this wiki locally