Repository navigation
how it works
This page explains the data path from a .chd file to a mounted virtual drive. For the
application's internal structure, see Architecture.
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
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
The VideoGameFileSystemParser NuGet package (v1.4.0) 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+. The console alias registry in the library is the single source of truth for console selection.
The ChdContainer bridges the parsed FsNode tree to the driver-specific 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... -
FUSE:
ChdFuseVolumeimplements theIFuseVolumecontract of theLibFuseSharppackage —GetEntry/GetFolderListmap POSIX paths to container entries andReadFilecopies sector data into the FUSE read buffer. The blocking FUSE session runs on a background thread and is stopped throughFuseFileSystem.Exit().
The core in use is selected in Settings → Mount core: Dokan (default) or WinFsp on Windows; FUSE on Linux and macOS.
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.
- 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.
- Architecture — services, logging and threading
- Console Types — the alias reference
- Mount Cores — Dokan, WinFsp and FUSE compared