How It Works
CHD reading
CHD (Compressed Hunks of Data) is MAME's lossless compression format for CD/DVD/HDD images. CHDMounter uses CHDSharp to read all five CHD versions (V1–V5) and all compression codecs:
- General: zlib (deflate), LZMA, FLAC (headerless, 16-bit stereo), dynamic Huffman, Zstd
- CD-sector: CDZL (zlib), CDLZ (LZMA), CDFL (FLAC), CDZS (Zstd) — with ECC regeneration
- AV: AVHuff — audio+video Huffman for laserdisc/arcade captures
Sector reading
The SectorReader maps logical block addresses (LBAs) to byte offsets within CHD hunks. It:
- Parses track metadata (
CHT2/CHTR/CHGDtags) for multi-track CD images - Maps LBA to CHD frame number using track offsets (handles the GD-ROM 45000-LBA shift)
- Reads and caches the compressed hunk via
ReadHunk() - Detects the sector mode (Mode 1 = 16-byte header, Mode 2 = 24-byte header) by scanning for
the CD sync pattern
00 FF×10 00 - Strips headers to deliver 2048 bytes of user data per sector
File system parsing
The VideoGameFileSystemParser library (vendored into this solution) parses console file systems from raw sectors and reconstructs directory trees. Supported file systems include ISO 9660 (with Joliet/Rock Ridge), XDVDFS (Xbox), OperaFS (3DO), CD-i Green Book, UDF and HFS/HFS+.
VFS operations
The ChdContainer bridges the parsed FsNode tree to the Dokan/WinFsp VFS layer:
- Dokan:
ChdFsimplementsIDokanOperations—CreateFileresolves paths,ReadFilemaps file offsets to sector reads,FindFileslists directories,GetVolumeInformationreports a read-only "CHDFS" volume. - WinFsp:
ChdFsextendsFileSystemBase—Openresolves paths and returns aFileEntryas both file node and descriptor,Readcopies sector data into native memory viaMarshal.Copy,ReadDirectoryEntryenumerates children including.and...
Virtual CUE/BIN/ISO/WAV export
For CUE/BIN/ISO/WAV modes, the container generates virtual entries dynamically:
- The
.cuefile contains standardFILE,TRACKandINDEXdescriptors built from CHD track metadata. - The
.bin/.isofile maps reads to raw sector data (2352 or 2048 bytes per sector). .wavfiles are generated per audio track with standard WAV headers.
For SingleFile mode, the container serves the entire decompressed CHD image as a single
image.iso file.
Mount safety
- Images are opened read-only; CHDMounter never writes to a CHD file.
- When running as Administrator with WinFsp, CHDMounter uses cross-integrity folder mounts with a permissive DACL so standard (non-elevated) processes can access the mounted drive.