RefurbishedDinosaurs.Media.Playback
12.3.1
dotnet add package RefurbishedDinosaurs.Media.Playback --version 12.3.1
NuGet\Install-Package RefurbishedDinosaurs.Media.Playback -Version 12.3.1
<PackageReference Include="RefurbishedDinosaurs.Media.Playback" Version="12.3.1" />
<PackageVersion Include="RefurbishedDinosaurs.Media.Playback" Version="12.3.1" />
<PackageReference Include="RefurbishedDinosaurs.Media.Playback" />
paket add RefurbishedDinosaurs.Media.Playback --version 12.3.1
#r "nuget: RefurbishedDinosaurs.Media.Playback, 12.3.1"
#:package RefurbishedDinosaurs.Media.Playback@12.3.1
#addin nuget:?package=RefurbishedDinosaurs.Media.Playback&version=12.3.1
#tool nuget:?package=RefurbishedDinosaurs.Media.Playback&version=12.3.1
Refurbished Dinosaurs runtime libraries
.NET libraries for clean-room restorations of legally owned games, from the refurbished-dinosaurs-toolkit.
RefurbishedDinosaurs.Core: dependency-free building blocks for importing, installing and checking content from the user's original, plus deterministic randomness, state comparison and display helpers.RefurbishedDinosaurs.LegacyFormats: PCX, bitmap, optical-disc, InstallShield cabinet, InstallShield 3 archive and PCM WAVE readers, and a PCM WAVE writer.RefurbishedDinosaurs.Media.Smacker: SMK containers, palette/video decoding and packed audio.RefurbishedDinosaurs.Media.Avi: AVI containers, Cinepak, cumulative RLE8 and Microsoft ADPCM.RefurbishedDinosaurs.Media.Fli: AF11 FLI indexing, streaming and indexed frame decoding.RefurbishedDinosaurs.Media.Audio: PCM conversion and disposable resource/voice ownership.RefurbishedDinosaurs.Media.Playback: host-driven cadence and sequential decoding coordination.
The runtime packages are released together and share a version. Media packages have no Core, MonoGame, native codec or FFmpeg dependency; install only the formats you use. ScientificMethod names remain reserved for analysis and research tools.
dotnet add package RefurbishedDinosaurs.Core
dotnet add package RefurbishedDinosaurs.LegacyFormats
The shared runtime libraries guide explains how a restoration adopts these packages and lists their migrations.
Every public type and member carries XML documentation, which IDEs show on hover. The build fails on an undocumented public member.
RefurbishedDinosaurs.Core
| Namespace | Types | Use |
|---|---|---|
Assets |
AssetManifest, AssetFileSpec, CddaTrackFingerprint |
One supported edition: its files' paths, sizes and XXH3-128 hashes, for a cue/bin or disc image source the fingerprints of its CD audio tracks, how the copy is read, and the edition's Fingerprint(). |
Assets |
FileFingerprint |
XXH3-128 of bytes, a file or a stream, in the documentation standard's form, and a bounded copy that hashes what it copies (CopyXxh3Async). |
Assets |
ImportDiskPlanner |
Free space an import needs, counting files it will replace. |
Assets |
StagedAssetPack |
Build a content directory beside the live one and swap it in, restoring the old one on failure. |
Assets |
InstalledContentWriter |
Write or copy one installed file atomically, skipping identical files. |
Assets |
ContentOverlay, ContentOverlayManifest |
Apply a patch or fix delivered as files to a staged pack, replacing each file only when it holds the bytes the overlay expects. |
Assets |
InstalledAssetManifest, InstalledAssetVerifier |
Record what an import installed, and check it at startup, with a reason code per problem. |
Assets |
InstalledContentUninstaller |
Remove only the files a manifest lists. |
Determinism |
IRandomSource, MsvcRandom |
The legacy Microsoft C rand() sequence, with saveable state. The static MsvcRandom.NextRaw(ref uint) and MsvcRandom.NextInt(ref uint, int) draw from a state the game keeps in its own save data, and MsvcRandom.NextState is the bare transition. |
Diagnostics |
StartupFailure |
Log a failed start and show the player what to do, without the Windows dialog for an unattended run. |
Discovery |
KnownDirectorySourceLocator, CompositeSourceLocator |
Offer likely install directories of the original. |
IO |
AtomicFile, SafePath, PortableAssetPath, PortablePathLayout |
Atomic writes, paths from untrusted names that cannot leave their root, legacy asset references resolved the same way on every host, and a set of relative paths given one spelling per directory ignoring case, with paths that clash ignoring case refused. |
Imaging |
IndexedPalette, IndexedPaletteDecoder |
256-colour palettes, including 6-bit VGA values. |
Imaging |
IndexedPngWriter |
Write 8-bit indexed pixels as a palette PNG. |
Input |
InputState<TButton>, InputBindings<TAction,TButton> |
Held, pressed and released queries over copied button snapshots; immutable OR bindings with rebinding and context overlays. |
Paths |
RestorationPaths |
Find imported content (portable or per-user) and the settings directory. |
Persistence |
JsonSettingsStore<T> |
JSON settings with a backup copy and migration. |
Presentation |
ViewportScaler, FixedWidthText |
Fit a fixed resolution into a window and map the mouse back; word-wrap fixed-width text. |
Validation |
JsonStateDiffer |
List value differences between a reference capture of game state and a restoration's. |
Portable asset references
PortableAssetPath.Relative accepts either separator and returns the reference with /. It rejects
the same references on every host, before anything touches the file system:
| Rejected | Why |
|---|---|
A rooted reference (UNC names included), an empty component, . and .. |
It is not relative, or leaves its root. |
C0 control characters (U+0000 to U+001F) and < > : " \| ? * |
Windows refuses them in a file name. : also rejects drive-relative names such as C:x.dat. |
| DEL (U+007F) and a UTF-16 surrogate without its pair | DEL is a control character no legacy code page uses for a letter. Linux and macOS cannot store an unpaired surrogate under the same name. |
A component that ends in a dot or a space, or a reserved device name such as CON or nul.dat |
Windows reads it as another name or as a device. |
Everything else is accepted, including spaces, ~ # & + ! ' ( ) [ ] { } @ = , ; % $, Latin-1 and other
non-ASCII letters, and C1 control characters (U+0080 to U+009F). The readers that decode legacy names
byte for byte as Latin-1 give C1 characters for bytes 0x80 to 0x9F, which hold letters in DOS code
pages and lead bytes in Shift-JIS, and every host stores them. The InvalidDataException message gives
the reference as a JSON string, with control characters and unpaired surrogates as \u escapes, and
names the rule it breaks.
WithoutDriveRoot explicitly
discards an ASCII Windows drive root when a game stores installation paths. ResolveFile matches
every component ignoring ordinal case, rejects a missing root, ambiguous matches and links, and
returns the actual relative spelling. A component with two matches is ambiguous even when one of
them is spelled exactly. It lists hidden and system entries and fails on an unreadable directory, so
it never skips a name another host would match. ResolveDirectory applies the same rules to a
directory, for a game that names a directory and then opens files in it by name, and throws when the
last component is a file. Both resolvers are for trusted, stable content directories; concurrent
filesystem replacement needs host controls.
AssetManifest, AssetVerifier, InstalledAssetVerifier, content overlays and
ContentOverlayResult.UpdateInstalledFiles, ContentSourceExtractor, OriginalContentSource
lookups and the cue sheet FILE check use the same rules. Every OriginalContentSource this package
opens, and Iso9660, list only paths Relative accepts: a directory file, ISO 9660 name or InstallShield member
whose path it rejects fails the open with a message naming the entry and the rule, since listing the
entry would claim a file the source cannot hand out under a portable name, and leaving it out would
claim the source holds less than it does. A null or blank reference from data, a blank manifest game or edition and a
missing file list throw InvalidDataException, like every other rejected reference; a blank root
or source path passed by the caller still throws ArgumentException.
Content overlays
A content overlay adds or replaces files in a content directory, usually a
StagedAssetPack.StagingDirectory, for example to bring an imported 1.0 edition to an official
1.1 patch. It is a zip archive (ContentOverlay.OpenZip) or a directory (OpenDirectory) holding
overlay.json, which schemas/content-overlay.schema.json describes, and each payload at
files/<path>. Each record gives the target path, the payload's size, the XXH3-128 the target must
have first (baseXxh3, null for an added file that must not exist) and the payload's XXH3-128.
OpenZip(stream) opens the zip from a readable, seekable stream, such as an overlay embedded as a
resource, with the same checks and limits as OpenZip(path). The archive starts at position 0. The
caller keeps the stream: the overlay reads payloads from it until it is disposed and never disposes
it. A stream that cannot read or seek throws ArgumentException.
Opening rejects a manifest with a duplicate path (ignoring case), a path PortableAssetPath.Relative
rejects, a path that is also a directory of another record, a missing, unlisted or linked payload,
a payload of another size than its record, an overlay.json or files directory that is a link,
and anything over ContentOverlayLimits (100,000 files, 1 GiB a file, 4 GiB in all and a 4 MiB
manifest by default).
ApplyAsync checks every target before it writes anything, finding each path component with the
rules of PortableAssetPath.ResolveFile. A target that already has the payload's size and hash
counts as applied and is not written, so a rerun writes nothing. A target with neither hash, a
replaced file that is missing, or an added file that exists throws ContentOverlayException with a
ContentOverlayProblem, the path and the hash found. Then every payload is copied into a scratch directory under the root and hashed as it
is copied; a payload whose size or hash differs from its record throws before any target is
replaced, and the scratch directory is always removed. Only then are the copies moved over their
targets. Those moves are not one transaction, so after any exception dispose the stage without
committing it.
ContentOverlayResult.Outputs lists each record's actual spelling, size, hash and
ContentOverlayAction. UpdateInstalledFiles puts the outputs into the importer's
InstalledAsset list: a matching record takes the new size and hash, keeps its media type, and gets
an AssetConversion whose method is the overlay's name. Each record's path goes through
PortableAssetPath.Relative before it is matched, so data\main.bin matches the output
DATA/MAIN.BIN and comes back under the output's spelling, and an unmatched docs\readme.txt comes
back as docs/readme.txt. It throws InvalidDataException for a null record, a path Relative
rejects (such as ./data/main.bin or ../x), or two records that name the same path ignoring case
and separators, with both spellings in the message. It does not check sizes, fingerprints or source
paths; InstalledAssetVerifier reports those.
An overlay cannot delete a file. The overlay's payloads, hashes and version names are the restoration's data.
Pinning a disc image's volume
Two pressings of a disc can carry the same files in different ISO 9660 volumes. An iso9660,
cue-bin or disc-image manifest can pin the volume as well as the files, with any of three fields:
| Field | Checked against | Problem when it differs |
|---|---|---|
VolumeIdentifier |
OriginalContentSource.Label, the primary volume descriptor's identifier without its trailing padding |
WrongVolumeIdentifier |
VolumeBlocks |
OriginalContentSource.VolumeBlocks, the declared volume space size in 2048-byte blocks |
WrongVolumeSize |
VolumeXxh3 |
XXH3-128 of OriginalContentSource.OpenVolume(), the declared blocks from block 0 |
WrongVolumeHash |
Label reads each byte of the descriptor's 32-byte identifier as the Latin-1 (ISO-8859-1) character
of the same value and drops the trailing spaces and NULs, so byte 0xC9 is É (U+00C9) and
identifiers that differ in a byte before their trailing padding give different labels.
VolumeIdentifier writes those characters and is compared with Label ordinally. A control byte
reads as its control character, so a Shift-JIS lead byte 0x85 is written "\u0085" in JSON.
Validate accepts 1 to 32 characters from U+0000 to U+00FF that do not end in a space or NUL,
which is every label a descriptor can give. The WrongVolumeIdentifier detail writes both
identifiers as JSON strings with control characters escaped, so the found value can be copied into
the manifest.
OpenVolume reads the same bytes from an .iso image, from the data track of a cue/bin image and
from every other form of one disc, and leaves out padding after the declared volume, so one
VolumeXxh3 serves them all.
Record it from a reference copy with FileFingerprint.Xxh3Async(source.OpenVolume()).
AssetVerifier checks the pins before the files, skips the hash when the identifier or size
already differs, and reports a source with no volume, or a volume it cannot read, as Unreadable.
AssetManifest.PinsVolume is true when a manifest gives any of the three fields, and only then is
the volume checked. IdentifyAsync reads the volume once per source and reports that read's hash,
or its failure, for every pinned edition. It checks every file whatever the pins found. The pins
enter Fingerprint(), so editions that differ only in their volume get different fingerprints.
Adding a pin to a manifest that has shipped changes its fingerprint, so a copy installed with the
unpinned manifest has a SourceFingerprint that no longer matches and has to be imported again.
Validate rejects a pin on any other source kind.
The .bin, .cue and .iso files themselves cannot be pinned: the cue's text and the .bin's
audio sectors change between rips of one disc.
ADR 0015
gives the reasons.
Input snapshots and bindings
InputState<TButton> copies down-button snapshots and answers held, pressed and released queries;
opposing digital axis inputs cancel. Hosts advance snapshots once per admitted input step and
decide focus-loss policy. InputBindings<TAction,TButton> owns immutable alternatives, supports
explicit conflict rejection on rebinding and context overlays. Alternatives are OR bindings: an
action is pressed when one of them becomes held while none was held before. An overlay replaces
that action's alternatives. Build bindings with InputBindings<TAction,TButton>.Create, which takes
any map of button collections, such as Dictionary<TAction, TButton[]>. Snapshots queried by
bindings, and contexts overlaid on them, must use the same comparers; a mismatch throws
ArgumentException instead of missing a press. Pressed queries do not allocate. Actions, default
keys, valid token admission, analog thresholds, pointer speed, replay timing and text input rules
stay in the game. There is no MonoGame dependency and no hidden event loop. Build bindings and
contexts outside per-frame loops.
RefurbishedDinosaurs.LegacyFormats
| Types | Reads |
|---|---|
AssetVerifier |
Check the player's original against an AssetManifest through any OriginalContentSource, and IdentifyAsync the supported edition it is, or that several editions match. |
OriginalContentSource, ContentSourceKinds |
An installed directory, a .iso image, a cue/bin raw disc image, a CD in any other image form (see Disc images), an InstallShield cabinet set or an InstallShield 3 archive behind one file listing and OpenRead. Open(path) picks the kind from the path, and from the first bytes for a CHD or an InstallShield 3 archive; Open(path, kind), OpenDirectory, OpenIso9660, OpenCueBin, OpenDiscImage, OpenInstallShieldCabinet and OpenInstallShieldArchive take it explicitly. ISO 9660 file and directory names read byte for byte as Latin-1 (ISO-8859-1), as the volume label does, and lose their ; version suffix and trailing dots unless that would give two entries of one directory the same name ignoring case, as README.;1 and README.;2 would; those keep their whole identifiers, as the documentation standard writes disc paths. OpenIso9660(stream) opens an .iso image from a readable, seekable stream the caller keeps and the source never disposes; the streams it opens each keep their own position over it. A cue/bin source reads a MODE1/2352 or MODE2/2352 Form 1 data track (see Cue/bin data tracks). It gives the sheet as Cue and the full paths of the files OpenCueBin chose as CuePath and BinPath. It reads the sheet once and gives those bytes as CueSheetBytes: hash them to record the sheet that was parsed, since the file at CuePath may have been replaced after the source opened. An .iso or cue/bin source opened from a path records the image's length and last-write time when it opens, and each read of the .iso or BIN through the source (OpenRead, OpenVolume, OpenBin and the audio checks) fails with an IOException when either has changed; a rewrite that keeps both is not detected. A stream opened from BinPath is not checked, so read the image with OpenBin. |
DiscImageFormats |
The forms a disc-image source reads, as its DiscImageFormat gives them: iso, cue, clonecd, alcohol-mds, nero-nrg and chd. See Disc images. |
InstallShieldArchiveSource, InstallShieldArchiveLimits |
The members of an InstallShield 3 archive held in one file (such as _SETUP.1), from a file, inside another source or from a stream. See InstallShield 3 archives. |
InstallShieldCabinetSource, InstallShieldCabinetLimits |
The members of an InstallShield cabinet set of major version 0, 5 or 6 (dataN.hdr and dataN.cab), on disk or inside another source. See InstallShield cabinets. |
InstallShieldMember, InstallShieldEntryMetadata, InstallShieldFileGroup, InstallShieldFileGroupMembership, InstallShieldFileGroupMembershipKind |
Each listed member's file-table entry (index, directory, name) and the file groups whose ranges hold it, from either InstallShield source's Members. See Member metadata and file groups. |
InstallShieldPathConflict |
A path that holds different files, with each file's metadata, from either InstallShield source's PathConflicts; OpenEntry(index) reads each. See Different files at one path. |
InstallShieldOutsideFile, InstallShieldOutsideFileStatus |
A cabinet file stored outside its volumes, from InstallShieldCabinetSource.OutsideFiles, with where it was looked for beside the header and what was found there; OpenEntry(index) reads an Available one. See Members stored outside the cabinet. |
ContentSourceExtractor, ContentExtractionOptions |
Copy the files of any OriginalContentSource, or a selection of them, into a staging directory and get an InstalledAsset record for each. See Extracting a source into a stage. |
CueBinSheet, CueBinTrack, CueBinFile, CueBinTrackExtent |
A checked cue sheet for a raw image: a MODE1/2352 or MODE2/2352 data track starting at 00:00:00 in the first FILE, which must be BINARY, then audio tracks, with every index in order, the data track's end, and each track's sectors from TrackExtent. Later FILE entries of any type may hold audio tracks only; Files lists every entry with its tracks, ImageTracks counts the tracks in the image, and TrackExtent throws for a track in another file. See Cue sheets. |
BuildListing, BuildListingDisc, BuildListingRecord, BuildListingMedium, BuildListingItem |
Make a build's listing record, the <ID>.listing.yaml of the documentation standard, from an installation directory and disc images. See Listing a build. |
CddaTrackFingerprints, CddaTrackVerification |
Record and check the fingerprint of a CD audio track in a cue/bin image, accepting a rip shifted by a drive read offset up to the fingerprint's tolerance. See CD audio across read offsets. |
CueSheet, RawMode1Image, Iso9660 |
Cue/bin raw disc images and the ISO 9660 file system on their data track. Iso9660 reads the volume with the reader behind OpenIso9660, so it applies the same checks, reads names as Latin-1, and fails on a name PortableAssetPath.Relative rejects. It checks each raw sector it reads for the MODE1/2352 sync pattern and mode byte, and reads MODE1 only: open a MODE2/2352 image with OpenCueBin. |
CddaWave |
A CD audio track of a raw image, written out as WAVE, synchronously or with WriteAsync. See Writing a CD audio track as WAVE. |
WavePcm16Reader |
16-bit mono or stereo PCM WAVE files. |
WavePcm16Stream |
16-bit mono or stereo PCM WAVE files, indexed and read in frame-aligned buffers without loading the track. |
WavePcm16Writer |
Writes canonical 16-bit mono or stereo PCM WAVE files. |
PcxDecoder, PcxImage, PcxShortStreamRepair, PcxStreamShortfall, RawIndexedImageDecoder, IndexedImage |
8-bit RLE PCX, and headerless indexed pixels, with RGBA conversion. See PCX images. |
ImageLimits |
DefaultMaximumPixels, the pixel limit BmpDecoder, PcxDecoder and RawIndexedImageDecoder apply when no maximumPixels is passed. |
Rle8BitmapDecoder |
8-bit BMP (BI_RLE8 or BI_RGB), rewritten as uncompressed BI_RGB. |
BmpDecoder, BmpImage |
8-bit BMP (BI_RGB or BI_RLE8) and 24-bit or 32-bit BI_RGB BMP, decoded to opaque RGBA rows top to bottom. See BMP images. |
Cue sheets
OpenCueBin takes the .bin, a directory holding a .cue and the image, or any other file, which
it reads as the cue sheet whatever its extension. A sheet shipped under another extension is opened
by passing its path to OpenCueBin or to Open(path, ContentSourceKinds.CueBin); Open(path)
recognizes a sheet only by the .cue extension. When a file given as the sheet does not parse, the
error says it was read as a cue sheet. A directory input still looks only for a .cue, and the
image is the file the sheet's first FILE names, whatever its extension.
The first FILE is the image. It must be BINARY and hold the data track, and may hold audio
tracks after it. Later FILE entries, of any type (BINARY, WAVE, MP3 and so on), may hold
only AUDIO tracks, such as a disc shipped as one image and one compressed audio file per track.
Each later entry's indices count from the start of its own file. Their paths pass the same
PortableAssetPath.Relative check as the image's, but the files are never opened and need not
exist. A sheet whose later FILE holds a data track, a FILE with no track, a TRACK before
the first FILE, or an INDEX between a FILE and its first TRACK, as a sheet that stores each
pregap at the end of the previous file writes it, is rejected with a message naming the rule.
Only the image's tracks are read. CueBinSheet.ImageTracks counts them, Files and FileOf give
each entry and the tracks it holds (setting Files on a sheet checks that the entries hold every track in order, and reading it throws InvalidOperationException once with has replaced the tracks they describe), and TrackExtent throws InvalidDataException for a track in
another file. The data track ends where the image's second track begins, or at the end of the
image when the image holds no other track. AssetVerifier reports a fingerprinted audio track
stored in another file as Unreadable, naming the file, CddaTrackFingerprints.RecordAsync
refuses to record one, and BuildListing, listing a sheet that is not named .cue through
OpenCueBin, gives it as a stopped item. CueSheet.Tracks reads
single-file sheets only and throws for a sheet with a second FILE.
Cue/bin data tracks
OpenCueBin reads the ISO 9660 volume from the user data of the sheet's first track, in the sector
layout the sheet declares for it. It checks every raw sector it reads against that layout, while
opening for the descriptors and directories and later for a file's or the volume's sectors, and
throws InvalidDataException naming the first sector that fails. A sheet whose first track is any
other type fails to parse.
| Track type | Sector checks | User data |
|---|---|---|
MODE1/2352 |
sync pattern, mode byte 1, or for OpenVolume and the descriptor and directory reads mode byte 2 with all 2336 bytes from byte 16 zero |
2048 bytes from byte 16 (zeros for an empty mode 2 sector) |
MODE2/2352 |
sync pattern, mode byte 2, the CD-XA subheader at bytes 16 to 19 equal to its copy at bytes 20 to 23, the submode's Form 2 bit (0x20) clear, or for OpenVolume and the descriptor and directory reads set with the 2324 data bytes from byte 24 all zero |
2048 bytes from byte 24 (Form 1, or zeros for an empty Form 2 sector) |
The two layouts of one disc list the same files and read the same file and volume bytes, so a
VolumeXxh3 pin holds for either. A MODE2/2352 track is read only as CD-XA Form 1. A sector of
another mode, a MODE2 sector whose subheader copies differ (such as a formless MODE2 track), and a
Form 2 sector throw InvalidDataException when read. Directories and volume descriptors hold
their records in Form 1 sectors, so a disc that stores some files in Form 2 sectors, such as
interleaved audio or video, still opens and lists them; reading such a file through OpenRead,
or the whole volume through OpenVolume, throws when it reaches the first Form 2 sector.
OpenVolume and the descriptor and directory reads while opening make an exception: a Form 2
sector whose 2324 data bytes are all zero, such as padding a CD-XA master leaves inside the volume
space, reads as 2048 zero bytes, which is what a MODE1/2352 image of the disc holds there, so such
a disc lists the same files and has the same VolumeXxh3 in either layout. A zero sector inside a
directory's extent holds no records, so a directory whose whole extent is such sectors lists no
files, as in a MODE1/2352 image. One where a volume descriptor is expected fails as an invalid
descriptor. OpenRead still throws for a file that covers an empty Form 2 sector, and every read
still throws for a Form 2 sector with any nonzero data byte.
They read a second kind of padding the same way: on a MODE1/2352 track, a mode 2 sector whose 2336 bytes after the header are all zero, which some mastering programs leave inside a MODE1 volume. OpenRead still throws for a file that covers one, and every read still throws for a mode 2 sector on a MODE1/2352 track with any nonzero byte after the header.
The EDC, the ECC and the address in each sector's header are not checked.
Disc images
Players hold a CD in many forms. OpenDiscImage(path), or Open(path, ContentSourceKinds.DiscImage),
opens any of the forms below as one disc-image source, and every form of one disc lists the same
files and gives the same Label, VolumeBlocks, OpenVolume bytes and CD audio. A manifest of kind
disc-image can therefore pin the volume and list AudioTracks once and identify the disc whichever
form the player has. DiscImageFormat says which form was read and ImageFiles the full path of
every file the source reads, its descriptor first.
Form (DiscImageFormat) |
Opened from | Read |
|---|---|---|
iso |
.iso, or a directory holding only one |
the 2048-byte sectors; no audio |
cue |
.cue, or a .bin through the .cue with its name |
every FILE: the data track as raw MODE1/2352 or MODE2/2352 sectors, or as an ISO of 2048-byte sectors declared MODE1/2048 or MODE2/2048; audio in the same BINARY file, later BINARY files of raw sectors, and WAVE files of PCM or FLAC |
clonecd |
.ccd, or its .img |
the .img from LBA 0 to the lead-out; the .sub is not read |
alcohol-mds |
.mds of version 1, or its .mdf |
the one .mdf it names (*.mdf is the descriptor's own name): Mode 1, Mode 2 (read as CD-XA Form 1) or Mode 2 Form 1 data and audio, raw or 2048-byte data sectors, with or without 96 bytes of subchannel per sector; a later track's pregap stored after the previous track's sectors, counted in that track's length or not, or not stored |
chd |
a file that starts with the CHD signature, whatever its extension, such as a .chd |
the BIN image chdman read, decoded from the hunks; see CHD images |
nero-nrg |
.nrg of version 1 (NERO footer) or 2 (NER5) |
the disc-at-once tracks its CUES/CUEX and DAOI/DAOX chunks describe, raw or 2048-byte data sectors, with or without 96 bytes of subchannel; a version 1 CUES time is read as BCD and as binary, and the reading that fits the DAOI offsets is used |
A directory is read through its one .cue, .ccd, .mds, .nrg or .chd, else its one .iso; a
directory holding several is refused. A .cue whose first FILE is the .img, .mdf or .nrg of
a .ccd, .mds or .nrg of its name beside it, such as the sheet CloneCD writes next to its
.ccd, describes that image and is passed over. Open(path) opens a .ccd, .mds, .mdx or .nrg, and any
file that starts with the CHD signature, as a disc image; it still opens a .cue with OpenCueBin.
Every form is held to the disc OpenCueBin reads: one session whose first track holds the data,
starting at sector 0, followed only by audio tracks. A raw data track is checked sector by sector as
in Cue/bin data tracks, including the empty Form 2 rule; a data track stored as
2048-byte sectors is read as an .iso is. Subchannel bytes stored after each sector are left out.
The source records the length and last-write time of every file it reads, and a read through it of a
file that has changed since fails with IOException.
OpenBin() gives the disc's tracks as one stream of 2352-byte sectors from the data track's
INDEX 01, and Cue lays them out as a sheet with one BINARY FILE named after the first data
file, so Cue.TrackExtent, CddaWave and CddaTrackFingerprints read a track the same way from
every form. Sectors no file stores are in the stream's layout but a read of them throws
InvalidDataException with the reason: a pregap a cue sheet declares with PREGAP, an Alcohol
image does not store or a CHD records without storing it, and the raw sectors of a data track stored as 2048-byte sectors.
A cue sheet read as a disc image follows the rules of Cue sheets with these
differences: the first track may also be MODE1/2048 or MODE2/2048, in a file that holds no other
track; PREGAP adds a pregap no file stores before a track's INDEX 01 (a track may not have both
PREGAP and INDEX 00); POSTGAP is refused; and the first track of each later FILE must start at
00:00:00. Audio is read from raw BINARY files and from WAVE files of 16-bit stereo 44.1 kHz PCM
(format 1) or FLAC (see FLAC audio tracks), the CD's own samples, whose audio is
a whole number of sectors. Ogg Vorbis and MP3 are lossy and can never match a fingerprint. An Ogg or
MP3 file, a WAVE or FLAC of another sample format, a missing file or one that is not a whole number
of sectors does not stop the source opening: its tracks and those of every later FILE follow the
image in Cue, and AssetVerifier reports each fingerprinted one as Unreadable with the reason,
such as it holds Ogg audio. The files, the volume and the tracks before it are
still verified.
Each form refuses what it cannot read with the reason, as NotSupportedException for a form or layout
outside the ones above and InvalidDataException for a descriptor or image that is malformed or
disagrees with itself:
| Form | Refused |
|---|---|
every form but iso |
more than one session (a CD-Extra or multisession copy), a first track that is not data or a later one that is, more sectors than a CD's 99:59:74 addresses reach |
clonecd |
a version other than 2 or 3, scrambled data tracks, table-of-contents points other than the tracks, A0, A1 and A2, a table of contents that disagrees with the [TRACK] sections, an .img that does not end at the lead-out, an unknown section or a line that is not key=value |
alcohol-mds |
version 2 descriptors and DAEMON Tools .mdx images, DVD media, Mode 2 Form 2 tracks and mode bytes whose low three bits are 0, 6 or 7, sector sizes other than 2352, 2448 and 2048, tracks split across several files, a track whose LBA or .mdf offset neither follows the previous track nor its own pregap after it, tracks that end before the session does |
chd |
see CHD images |
nero-nrg |
a file without the NER5 or NERO footer, an MTYP media type that is not a CD, track-at-once images (ETNF, ETN2), 2336-byte Mode 2 tracks and 2352-byte tracks with a 2048-byte mode code, a chunk it does not know, cue and track chunks that disagree on a track's sectors, CUES times that fit the tracks both as BCD and as binary with different sectors |
The table of contents of each form is read as libmirage's image-ccd, image-mds and image-nrg
parsers read it. The Alcohol and Nero layouts are checked against Aaru's Alcohol120 and Nero images where the two
differ: Alcohol's pregap storage, and whether a CUES time is BCD. The source files are cited in the
readers' comments. The readers are tested against synthetic images built to those layouts. A raw
data track whose sectors do not match the mode its descriptor declares fails naming the descriptor,
such as Sector 0 is mode 1, but the Alcohol .mds game.mds declares MODE2/2352.
CHD images
A CHD is read when the file starts with the CHD signature, whatever its extension. A CHD made from a
cue/bin image stores raw 2352-byte sectors, and OpenBin() reads them as the BIN image chdman read:
each track's stored frames in order, without the frames chdman adds to pad each track to a multiple
of 4, and with audio samples little-endian, where the CHD stores them big-endian. Cue names the
CHD as its one FILE and gives a pregap stored in the CHD as the track's INDEX 00. A pregap the
CHD records but does not store, as chdman writes for a sheet's PREGAP, is in the layout as sectors
no file stores, as for the sheet itself. So the samples and track extents equal those of the cue/bin
image the CHD was made from, and a fingerprint recorded from that image matches the CHD at shift 0.
A CHD that chdman made from an .iso holds one MODE1 track of 2048-byte sectors, read as a cue
sheet's MODE1/2048 track is.
| CHD feature | Read |
|---|---|
| Version | 5. Versions 3 and 4 are refused with NotSupportedException; chdman copy writes a version 5 copy. |
| Track metadata | CHT2 and CHTR. A CHD with only the old binary CHCD metadata, a GD-ROM (CHGD, CHGT), a DVD and a CHD with no CD track metadata are refused with NotSupportedException. |
| Track types | MODE1_RAW or MODE2_RAW first, then AUDIO, or one MODE1 track alone. Other types, a data track after the first, audio first, a pregap stored before track 1 and a postgap are refused with NotSupportedException. |
| Hunks | Uncompressed, cdlz (LZMA, with the sync pattern and ECC chdman removed from a data sector rebuilt), cdzl (deflate), cdfl (FLAC) and copies of an earlier hunk. Another codec, such as cdzs, is refused with NotSupportedException; chdman copy -c cdlz,cdzl,cdfl writes a copy the reader opens. |
| Parent CHDs | Refused with NotSupportedException: the reader does not open a parent. chdman copy with the parent given as -ip writes a CHD that holds the whole disc. |
The header, the track metadata and the hunk map are read when the source opens, and the map's
CRC-16 and every hunk's place in the file are checked then, so a truncated file fails to open. Each
hunk's CRC-16 is checked when it is decoded (a CHD with no codecs records none), and a stream that
reads every hunk from the first to the last, as reading OpenBin() to its end does, checks the
SHA-1 of the whole data against the header's, as chdman verify does. A failed check throws
InvalidDataException. The decoders are managed code in this package: the LZMA decoder is adapted
from the public-domain reference decoder of the LZMA SDK, and the FLAC decoder reads RFC 9639 frames
of two 16-bit channels, checking each frame's CRC-8 and CRC-16.
FLAC audio tracks
A cue sheet's WAVE file that starts with the FLAC signature is decoded, as the archiver's
iso-flac form and DOSBox sheets give FLAC tracks the WAVE type. Its STREAMINFO must declare
16-bit stereo 44.1 kHz audio and its sample count, which must be a whole number of sectors; other
audio is reported as Unreadable with the channels, bits and rate it holds. The frames are decoded
the first time a stream reads the file: each frame's CRC-8 and CRC-16 are checked, the samples must
add up to the declared count, and their MD5 must equal the one STREAMINFO records, unless it
records none. A failed check throws InvalidDataException from the read, which AssetVerifier
reports as Unreadable. The decoded samples are the WAVE's, so a fingerprint recorded from cue/bin
verifies against an ISO-plus-FLAC copy.
Listing a build
A build entry of the documentation standard may keep a listing record, spec/builds/<ID>.listing.yaml,
which @scientific-method/standard-checker compares with the build's manifest and list of other
files. BuildListing.Make writes one from the installation directory, the disc images, or both:
var record = BuildListing.Make(
Path.Combine(gameDir, "BLD-X"),
[new BuildListingDisc("CD:", Path.Combine(gameDir, "images", "game.cue"), "game.cue")],
DateOnly.FromDateTime(DateTime.Today));
File.WriteAllText("spec/builds/BLD-X.listing.yaml", record.ToYaml());
| Medium | What the record holds |
|---|---|
| Installation directory | Every file under it with its size, hidden and system files included, in every subdirectory. A symbolic link or junction is a link item with its target as stored, and is not entered (links: listed, cycles: null). Any other file reparse point, such as a cloud file's placeholder or a deduplicated file, is a file with the size the file system gives. Any other directory reparse point, a link whose target cannot be read, and a directory that cannot be entered are stopped items with the reason. |
.iso image |
Each file of the primary volume under the disc's prefix, named as OpenIso9660 names it, with layout 2048. |
.cue sheet or its .bin, CloneCD .ccd (or its .img when the .ccd of the same name is beside it), Alcohol .mds or .mdf, Nero .nrg, a CHD of any extension |
Opened with OpenDiscImage. The same for the data track, with layout MODE1/2352 or MODE2/2352 for raw sectors and 2048 for a data track of 2048-byte sectors (an ISO with WAVE or FLAC audio, a cooked CloneCD, Alcohol or Nero track, or a CHD made from an .iso), and each audio track as CD:track02 and so on, with the size of its raw audio from CueBinSheet.TrackExtent on the source's Cue. An audio track the image does not read, such as one in an Ogg or MP3 file, or one after it, is a stopped item giving the image's reason. |
| cue sheet with any other extension | Opened with OpenCueBin, and listed the same way. An audio track the sheet stores in a later FILE is a stopped item naming that file, since the listing does not read it. |
BuildListingDisc.Source is the image's path as the manifest or the list of other files writes it,
which the record gives as the medium's source. A mounted disc is refused, since the drive gives
the names it chooses, such as Joliet names, and not those of the primary volume. Items are sorted
by path compared byte by byte in UTF-8, and tool names this package and its version. The listing
goes inside no archive, so archives is []. Make throws on a name a listing path cannot hold:
a control character, |, an unpaired surrogate, a \ in a Linux or macOS name, or a top-level
name that starts like a disc path, such as CD:x. It refuses a disc Source that holds a \
before listing anything. A stopped item gives the kind of failure, such as
a directory it could not enter (UnauthorizedAccessException), and not the exception's message,
which names the full path on the machine that made the listing. ToYaml writes a value in single
quotes, or in double quotes when it holds a single quote and neither a double quote nor a backslash.
A value with a single quote and also a double quote or backslash, such as a link target under
C:\Users\O'Brien, goes in single quotes with the quote doubled (''), which
@scientific-method/standard-checker reads in releases after 2.9.0.
The record shows what the listing found. It reads no file, holds no hashes, and does not show which files the game uses.
PCX images
PcxDecoder.Decode(bytes) reads an 8-bit, single-plane RLE PCX file with the 256-colour palette
after a 0x0C marker at the end, and returns a PcxImage: one palette index per pixel, rows top to
bottom with the scanline padding removed, and the palette. Any other bit depth, plane count or
palette placement, a malformed run, a run past the declared scanlines, bytes left between the
pixels and the palette marker, and an image over maximumPixels throw InvalidDataException. So
does an RLE stream that ends before the declared scanlines are full.
Some writers left that stream short. PcxDecoder.Decode(bytes, new PcxShortStreamRepair(fillIndex))
reads such a file: every pixel the stream does not supply takes fillIndex, and
PcxImage.Shortfall reports the decoded scanline bytes that were missing (padding included) and how
many pixels were filled. The filled pixels are the last FilledPixels entries of Indices.
Shortfall is null when the stream was complete, and the image then has the dimensions, indices
and palette that Decode(bytes) returns. The repair covers only a stream that ends at a token
boundary: a run token directly before the palette marker, with no value byte, still throws. Which fill index matches what the original
program showed is for the caller to establish.
BMP images
BmpDecoder.Decode(bytes) reads a whole BMP file with a BITMAPINFOHEADER, or its V4 or V5 form, and
returns a BmpImage of RGBA pixels, four bytes each, rows top to bottom with no padding.
| Read | Rejected with InvalidDataException |
|---|---|
| 8-bit BI_RGB and BI_RLE8 through the file's palette of up to 256 colours. 24-bit and 32-bit BI_RGB, whose blue, green, red byte order becomes red, green, blue. Bottom-up rows, and top-down rows (negative height) for BI_RGB. | 1, 4 and 16-bit images, BI_RLE4, BI_BITFIELDS and every other compression. The 12-byte OS/2 header and other header sizes. A top-down BI_RLE8 image. |
Every pixel is opaque: the fourth byte of a 32-bit BI_RGB pixel is unused by the format and is ignored.
Pixels a BI_RLE8 stream skips take palette index 0. The file is checked before any pixel buffer is
allocated: the BM signature, a declared file size equal to the length, a positive width, a nonzero
height, one plane, a palette that ends before the pixel data, rows padded to 4 bytes that fit in the
file, and at most maximumPixels pixels (ImageLimits.DefaultMaximumPixels, 16,777,216, by
default). A pixel whose palette index is past the palette's last colour also throws. Pass
requireDeclaredFileSize: false for files whose writer left the size field zero or wrong.
Rle8BitmapDecoder keeps a different job: it rewrites an 8-bit BMP as an uncompressed 8-bit BMP for
libraries that cannot read BI_RLE8.
InstallShield cabinets
OriginalContentSource.OpenInstallShieldCabinet(path) opens a set from its dataN.hdr header, or
from a dataN.cab that holds the header. A .cab is read from its start only as far as the header's
structures (cabinet descriptor, file table, file descriptors and names) reach, wherever they lie
before the member data, as Unshield reads them; a data1.cab that holds the header is also read as
volume 1. As in Unshield, the cabinet descriptor size the header declares only has to be nonzero:
it does not bound what is read, in a .hdr or a .cab. OpenInstallShieldCabinet(container, headerPath) opens a set
inside another source, such as the ISO 9660 volume of a cue/bin image, and reads the volumes through
that source whenever a member is read. Volumes are data1.cab, data2.cab and so on beside the
header, matched ignoring case.
| Supported | Not supported |
|---|---|
Major versions 0, 5 and 6, as the header's version word gives them under Unshield's rule. Stored and compressed members, obfuscated members, members split across volumes, and version 6 members that link to another member's data. Compressed data in length-prefixed chunks (Unshield's default) or delimited by 00 00 FF FF markers with no chunk lengths (what Unshield reads with -O), as the caller selects (see Compressed formats). |
Every other major version, and a version word in neither encoding Unshield reads, which throw NotSupportedException naming the word. Members stored outside the cabinet are not listed: they are in SkippedFiles, and only one found beside the header with exactly its stored length is read, by index (see Members stored outside the cabinet). Components, and an installer's placement of files: members are listed by directory and name, and file groups are reported as metadata (see Member metadata and file groups). |
Opening reads the header and the volume headers and checks every listed member before any member is
read: its directory and name joined must pass PortableAssetPath.Relative, its data must lie inside the
volumes, and the set must stay within InstallShieldCabinetLimits (100,000 members, 8 GiB expanded,
64 MiB of header and 1,024-byte names by default). A .hdr is read whole, so a longer one fails the
open. In a .cab, a header structure that ends past the header limit fails the open with a message
naming the limit, and one that ends past the end of the file is reported as a truncated header.
A name is read only up to the name limit, so a listed member whose name is longer fails the open.
The major version comes from the header's version word as Unshield reads it: a top byte of 1 keeps it
in bits 12 to 15, and a top byte of 2 or 4 keeps a hundredfold version in the low word. Major version 0
(for example the word 0x01000004) has the version 5 file descriptor and volume header layout, with
two differences: its descriptors end after the data offset, and a member is split across volumes only
when its descriptor's split flag is set. Everything below that says version 5 holds for version 0 too.
Entries the cabinet marks invalid, or that have no name or no data offset, are left out and listed in
SkippedFiles with the reason. So is a version 6 entry whose link chain ends at such an entry; its
reason names the entry it links to. A link outside the file table or a link cycle fails the open.
Unshield does not read the names of entries left out, so a name or directory of theirs that does not
read, or that does not form a relative path, does not fail the open: the skipped entry's path is
null instead. Each InstallShieldSkippedFile has a Kind to test (MarkedInvalid, NoName,
NoDataOffset, LinksToUnavailableEntry, SharesListedData, DuplicatesListedMember,
StoredOutsideCabinet or PathHeldByDifferentFiles) beside its Reason.
Two entries at the same path, ignoring case, are listed once when one links to the other's data; the
other goes to SkippedFiles with a reason naming the listed entry. In a version 6 set, two entries
stored apart at one path with the same expanded size and header MD5 are taken as one file: the first
in table order is listed, and the other goes to SkippedFiles as its duplicate without its stored
bytes being read. Any other pair at one path holds different files, and so does every pair in a
version 5 set, which records no MD5 (see Different files at one path).
Names are read as ISO 8859-1. A malformed or truncated header or volume throws
InvalidDataException; a missing volume throws FileNotFoundException.
OpenRead decodes a member while it is read. The stream seeks: forward seeks decode the skipped bytes,
and backward seeks decode again from the start. Reading a member to its end checks that it expands to
exactly its declared size and, for version 6, that its bytes match the MD5 the header records; a failed
check throws InvalidDataException before the last bytes are returned, so AssetVerifier reports the
file as Unreadable. Version 5 headers carry no checksum the reader checks, so version 5 members are
checked by size only.
Compressed formats
The header does not record how a set's compressed members store their deflate data, so the caller
passes an InstallShieldCompressedFormat to OpenInstallShieldCabinet (as its third argument), and
the source reports it as CompressedFormat:
| Value | Stored bytes | Unshield |
|---|---|---|
LengthPrefixedChunks (default) |
Chunks, each a 16-bit little-endian length and raw deflate data that expands to at most 64 KiB. | Default extraction. |
MarkerDelimitedChunks |
Raw deflate data with no lengths. Each chunk ends with the empty stored block 00 00 FF FF that a deflate flush writes, and no block is final. |
-O ("old compression"). |
using var cabinet = OriginalContentSource.OpenInstallShieldCabinet(disc, "data1.hdr", null,
InstallShieldCompressedFormat.MarkerDelimitedChunks);
Every compressed member of the set is read in the chosen form. A member that does not decode in it
throws InvalidDataException from its read, and the reader never tries the other form. Under the
default, a chunk that does not read (a zero length, a length past the member's stored bytes, data
that does not inflate or expands past 64 KiB) says so and names MarkerDelimitedChunks, so a set
that reads under unshield -O and fails here is a sign to open it with that value.
Marker-delimited data is decoded as one deflate stream, so the reader does not search for the
markers: four marker bytes inside a chunk's data are read as data, and a chunk may expand to more
than 64 KiB. Reading such a member to its end checks that it expands to exactly its declared size,
that the decoder reaches the end of its stored bytes with no final block, and that they end with
00 00 FF FF; the version 6 MD5 check applies as for the default form.
Members stored outside the cabinet
A member is stored outside the cabinet when it has stored bytes and its data offset is exactly the
length of the volume where its data starts, split or not, as Unshield tells it. It is not listed: it
goes to SkippedFiles with the kind StoredOutsideCabinet and a reason giving the offset and the
volume, and the rest of the set opens. Entries that share its data, and version 6 copies of it that
are also stored outside, are skipped the same way; a version 6 copy whose own data is inside the
cabinet is listed. A different file at its path makes the path one that holds different files, and
PathConflicts names the entries stored outside there.
Each file stored outside is looked for where Unshield's -O looks for it: beside the header, at the
directory and name of the entry that holds its data (for a version 6 link, the entry the link ends
at), matching each component ignoring case. Nothing else is searched for. OutsideFiles lists each
such file in the table order of its first entry, as an InstallShieldOutsideFile: its Member
(entry, metadata with file groups, SharedBy), the LookupPath, its StoredSize (the compressed
size when Compressed, the expanded size otherwise), the FoundLength when exactly one file
matched, and a Status:
| Status | What was found | Read |
|---|---|---|
Available |
One file, exactly StoredSize bytes long, at a path that holds no other file of the set. |
Yes, by OpenEntry(index). |
Missing |
No file. | No. |
LengthDiffers |
One file of another length. | No: how such a file relates to the entry's data is not established. |
SeveralMatches |
More than one file matching ignoring case, which a case-sensitive file system can hold. | No. |
PathHeldByDifferentFiles |
The entry's path or the LookupPath holds other files of the set too (PathConflicts), so a file found cannot be told to be this one. FoundLength still gives its length. |
No. |
NoUsablePath |
The entry holding the data is a version 6 link target with no name. | No. |
LookupFailed |
Nothing known: a folder on the way could not be listed, or the length of the file found could not be read (access denied, or the file went away during the open). The set still opens. | No. |
OpenEntry reads an Available file as the entry's stored bytes, as Unshield -O reads it: decoded
in the set's CompressedFormat when the entry is compressed, deobfuscated when it is obfuscated, and
checked to its end as a member inside the cabinet is (size, the marker-delimited checks, and the MD5
in version 6). A file that does not decode fails its read, and so does one that is shorter or longer
than when the set was opened. An Available file's expanded size counts
toward MaximumExpandedBytes. Files never lists a file stored outside, found or not, and its
entries stay in SkippedFiles as StoredOutsideCabinet.
foreach (var outside in cabinet.OutsideFiles)
{
if (outside.Status != InstallShieldOutsideFileStatus.Available) continue; // report the status instead
await using var stream = cabinet.OpenEntry(outside.Member.Metadata.Index);
}
Any other extent past the end of a volume is damage: an offset past its length, or data that starts
inside it and runs past its end. It fails the open with InvalidDataException ("lies past the end of
volume N, which is shorter than the header claims"). The offset rule cannot tell a member stored
outside from a volume cut short exactly where its last member's data starts, so compare the volume
named in the reason with your source media when the skip is unexpected.
Different files at one path
A path, ignoring case, can hold two or more files the reader cannot show to be the same, for
example one per file group. The reader takes two entries to be one file only when one links to the
other's data, or, in version 6, when their expanded sizes and MD5s match; equal names, sizes or
bytes in a version 0 or 5 set do not count. The set still opens, and the path lists none of its
files, so TryGetFile, TryGetMember and OpenRead do not find it, and the reader never picks one:
PathConflictslists each such path, ordered by path, withFiles: each file the cabinet holds inside its volumes as anInstallShieldMember(Entry,Metadatawith its file groups, andSharedBy), in the table order of its first entry.StoredOutsidegives the metadata of the entries at the path stored outside the cabinet whose file it does not also hold inside; an entry stored outside with a matching version 6 copy inside is in that copy'sSharedBy.- Every entry at the path is in
SkippedFilesasPathHeldByDifferentFiles, with a reason naming the first entry of each file, except entries stored outside, which stayStoredOutsideCabinet. OpenEntry(index)reads a file by the file-table index of any of its entries, with the same checks asOpenRead. It also reads listed members by index, and throwsFileNotFoundExceptionfor an entry that holds no file the source reads.
The files' paths, extents and sizes are checked when the set opens, and their sizes count toward
MaximumExpandedBytes, as a listed member's do. An adapter that installs by file group handles
them alongside Members:
foreach (var conflict in cabinet.PathConflicts)
foreach (var file in conflict.Files)
{
// file.Metadata.FileGroups says which groups hold this file; decide which one installs where.
await using var stream = cabinet.OpenEntry(file.Metadata.Index);
}
InstallShieldArchiveSource reports a path that two entries name in the same shape: the format has
no links or checksums, so each entry is its own file, and StoredOutside is empty.
Format provenance
The reader is managed code in this package, under its MIT license, with no third-party parser. Its reading of the layout follows Unshield (MIT). No open tool writes the format, so the tests build their cabinets with a writer in the test project that follows the same layout; a restoration's own set, compared against another extractor, is the check against real media.
Member metadata and file groups
Files and OpenRead name a member by its directory and name joined, which is how the cabinet
stores it. An installer places files by file group, which the cabinet records only as ranges of
file-table indexes, so a restoration that needs installed paths builds them from Members, read
from the header the open already read:
Memberslists anInstallShieldMemberfor each entry ofFiles, in the same order, andTryGetMember(path)finds one by path asTryGetFiledoes. ItsMetadatagives the file-tableIndex,DirectoryIndex,Directory(with/separators, empty for the root) andName, soEntry.PathisDirectoryandNamejoined with/.SharedBygives the entries at the same path that are inSkippedFilesbecause they hold the same data (a link, or a version 6 copy with the same size and MD5), each with its own index, names and groups; reading the member gives their bytes.FileGroupslists the groups the cabinet descriptor lists, in Unshield's order, each once:Index,Name(ISO 8859-1),FirstFileandLastFile(inclusive, the header's unsigned values), and aProblemwhen the group's descriptor, name or range does not read or lies outside the file table.- Each entry's
FileGroupsmembership has aKind:NoFileGroups(the descriptor lists none),None,One,Several(the indexes of every group that holds it, none chosen) orUndetermined. An entry isUndeterminedwhen a group whose range is malformed may hold it (MalformedGroups): a range that reaches past the table may hold the entries from its first file on, and a range that did not read or is reversed may hold any. Every entry isUndeterminedwhen the group lists did not read whole:FileGroupProblemthen says why (a list entry that does not read, a list that returns to an entry it already read, a structure past the header limit, or more groups, or more (entry, group) pairs, thanMaximumFiles).
Malformed groups never fail the open and never change Files, SkippedFiles or what a member reads.
An I/O error from the stream a .cab that holds the header is read from still fails the open, as it
does for any other header structure. A group
name is data: the reader does not check it with PortableAssetPath.Relative, since an installer's group
name need not be a file name. A caller that builds a path from it checks the path it builds. An adapter that
installs each group below its own name reads:
foreach (var member in cabinet.Members)
foreach (var entry in member.SharedBy.Prepend(member.Metadata))
{
if (entry.FileGroups.Kind != InstallShieldFileGroupMembershipKind.One) continue; // decide these yourself
var group = cabinet.FileGroups[entry.FileGroups.Groups[0]].Name;
if (string.IsNullOrEmpty(group)) continue; // a name that did not read, or is empty: decide these too
var installed = PortableAssetPath.Relative(string.Join('/',
new[] { group, entry.Directory, entry.Name }.Where(part => part.Length > 0)));
// copy cabinet.OpenRead(member.Entry.Path) to installed
}
InstallShieldArchiveSource gives Members and TryGetMember in the same shape. An InstallShield 3
archive has no file groups, so every membership is NoFileGroups, and SharedBy is empty.
InstallShield 3 archives
InstallShield 3 keeps a whole installation in one archive file, often _SETUP.1 on the disc or a
.Z file. The format is unrelated to the cabinets above, so it is its own source kind,
installshield3-archive (ADR 0018).
OriginalContentSource.OpenInstallShieldArchive(path)opens an archive file, and opens it again whenever a member is read.OpenInstallShieldArchive(container, archivePath)opens an archive inside another source, such as the ISO 9660 volume of a disc image, and reads it through that source.OpenInstallShieldArchive(stream)opens an archive held in a readable, seekable stream whose position 0 is the archive's first byte, such as an archive carved out of a self-extracting patch at a known offset. The caller keeps the stream, as forOpenIso9660(stream).Open(path)opens a file as an archive when it starts with the archive signature (13 5D 65 8C), andOpen(path, "installshield3-archive")opens it by kind.
| Supported | Not supported |
|---|---|
| Archives with the 0x3A-byte header field block that hold all of their data: unsplit archives, and split archives of one part (a split flag, 0x1 or 0x2 at offset 10, with part 1 of 1 at offsets 31 and 30). Members stored as they are and members compressed with the PKWARE Data Compression Library (coded or plain literals, 1, 2 or 4 KiB dictionary), in any number of directories. | Any part of a split archive of more than one part (_SETUP.1, _SETUP.2 and so on), a split header that declares another part number or count, and an unsplit header that declares more than one part, which throw NotSupportedException with the header's flags, part number and part count. Entries marked as spanning parts, which throw NotSupportedException naming the entry. A header with a field block of another size, which throws NotSupportedException. Passwords, file dates and attributes are not read. |
Opening reads the header, the directory table and the file table and checks them before any member
is read: both tables lie inside the archive, their entries fill exactly the sizes the header declares,
each name ends with its NUL, and the directory a file entry names is the one the directory table's
file counts place it in. Every listed member's directory and name joined must pass
PortableAssetPath.Relative, its stored bytes must lie inside the archive after the header, a stored
member's two sizes must agree, a member of a split archive of one part must name part 1 as its first
and last part, and the archive must stay within
InstallShieldArchiveLimits (65,535 entries, 8 GiB expanded and 16 MiB of tables by default). A
failed check throws InvalidDataException. Entries the archive marks invalid are left out and listed
in SkippedFiles; their path is null when PortableAssetPath.Relative rejects it. A path that two
or more valid entries name, ignoring case, lists none of them; they are reported as
different files at one path. Names are read as ISO 8859-1.
Members and TryGetMember give each listed member's file-table index, directory index, directory and
name, in the shape of cabinet member metadata; the format has no file
groups, so every membership is NoFileGroups.
OpenRead decodes a member while it is read, and seeks as a cabinet member stream does. The archive
records no checksum, so a member is checked by size and framing only: reading a compressed member to
its end checks that it expands to exactly its declared size, that the end code follows, and that no
whole byte of its stored data is left after it. A failed check throws InvalidDataException before
the last bytes are returned, so AssetVerifier reports the file as Unreadable. A damaged member that
keeps its size and framing is not detected; pin the files you need by XXH3-128 in the manifest.
The reader, including its PKWARE DCL decoder, is managed code in this package under its MIT license.
Its reading of the layout follows unshieldv3 (Apache-2.0) and
idecomp (GPL-3.0), and the decoder follows the format
description implemented by zlib's contrib/blast; no code is taken from them. The tests build archives
with a writer in the test project, and also decode the format description's example and a stream an
independent decoder expanded. A restoration's own archive, compared entry by entry against another
extractor, is the check against real media.
Extracting a source into a stage
ContentSourceExtractor.ExtractAsync(source, root, options) copies the files of an
OriginalContentSource of any kind into root, usually StagedAssetPack.StagingDirectory, below
ContentExtractionOptions.Prefix when one is given. Include selects files, for example to leave
out executables the restoration does not need. It returns one InstalledAsset per file, in the
source's file order: the path relative to root with the prefix, the size, the XXH3-128 computed
while the file is copied, the file's path in the source as SourcePath, and Conversion from the
options (null by default, since the bytes are copied unchanged). The records go straight into an
InstalledAssetManifest for root, and through ContentOverlayResult.UpdateInstalledFiles when an
overlay follows.
Before it writes anything, the call checks the selection against MaximumFiles and
MaximumTotalBytes (100,000 files and 8 GiB by default), every source path with
PortableAssetPath.Relative, and that the prefix directory is absent or empty with no link on the
way to it. A prefix part that names an existing entry with different case is rejected, since
Windows would reuse that entry and a case-sensitive file system would create a second one beside it,
and so is a part that matches two entries ignoring case. A negative listed size is rejected.
Without a prefix the root itself must be empty. A file whose path is also another file's
directory, ignoring case, is rejected. A directory spelled two ways ignoring case is written once,
with the spelling of the first file under it, so a case-sensitive file system gets the same tree as
Windows. Each file must yield exactly the size the source lists; more or fewer bytes throw
InvalidDataException.
When the call throws, cancellation included, it returns no records and removes what it wrote: the directories it created for the prefix, or the contents of a prefix directory that already existed. Dispose the stage without committing it after any exception.
CD audio across read offsets
A drive's read offset shifts every sample of a ripped audio track by the same amount, so the exact
hash of a track differs between two rips of one disc. A CddaTrackFingerprint records, for one
track, its length in samples (16-bit stereo pairs, 588 to a sector), a tolerance, an anchor's offset,
length and XXH3-128, and the XXH3-128 of the central samples, which leave out the tolerance at each
end. Record one from a reference rip with CddaTrackFingerprints.RecordAsync, which refuses an
anchor whose samples repeat within twice the tolerance (the range a rip shifted by up to the
tolerance shows the verifier), and list it in a cue-bin or disc-image manifest's AudioTracks. To
record from an opened source, pass its OpenBin() stream and the track's Cue.TrackExtent, so the
samples come from the image the source checked. A disc-image source's OpenBin() and Cue give
the same extents and samples for every raw form of one disc, so a fingerprint recorded from a cue/bin
verifies against a CloneCD, Alcohol, Nero, CHD, ISO-plus-WAVE or ISO-plus-FLAC copy.
AssetVerifier checks each track after the files. A track starts at its INDEX 01 and ends at the
next track's INDEX 00, that track's INDEX 01 without one, or the end of the image. The checks
run in order, and each problem carries AudioTrack:
| Check | Problem when it fails |
|---|---|
The sheet has the track and marks it AUDIO |
Missing |
| The length differs from the fingerprint by at most the tolerance | WrongSize |
| The anchor matches at one shift within the tolerance | AudioOffsetOutOfRange at none, AudioAlignmentAmbiguous at several |
| The central samples at that shift hash to the fingerprint | AudioHashMismatch |
A shifted rip moves the end of a track into the sectors after it, so the checks read past the
track's extent into the rest of the image. When a check needs samples past the end of the image, the
track is reported as Unreadable, with the check that was not made. A source that holds no CD audio,
such as a directory or an .iso, reports each track as Unreadable, and so does a disc-image
source for a track in an audio file it does not read, with the reason. IdentifyAsync verifies a track once per source and
reports the outcome, a failed read included, for every edition that lists the same fingerprint.
The tolerance is at most 5880 samples and the anchor at most 44100 samples, since the anchor is
hashed once per shift.
Writing a CD audio track as WAVE
CddaWave.Write(source, output, startSector, sectorCount) and WriteAsync, which also takes a
CancellationToken, copy raw sectors of an image into a 16-bit stereo 44.1 kHz WAVE file. For a
track of a cue/bin image, pass the StartSector and Sectors of CueBinSheet.TrackExtent; for a
disc image of another form, pass the source's OpenBin() with the extent from its Cue.
WriteAsync checks the token before each read of up to 128 KiB, so a cancelled copy stops within a
read and leaves a partial file for the caller to delete.
A WAVE file holds at most CddaWave.MaximumSectors sectors (1,826,091, about 6.8 hours), since the
32-bit RIFF size counts the audio and 36 header bytes. A longer range, a negative value, or a range
that ends past the image's length throws before anything is written: ArgumentOutOfRangeException
for the first two, EndOfStreamException for the last.
Media packages
Namespaces match package names. Malformed bytes fail with InvalidDataException; unsupported
profiles fail with NotSupportedException, and invalid caller arguments fail with argument
exceptions. Surfaces are stateful and not thread-safe. Decode every dependent frame in order;
discard the surface after an exception. No decoder promises transactional recovery.
| Package | Public API and supported subset | Limits and exclusions |
|---|---|---|
Media.Smacker |
SmackerMovieDecoder, SmackerMovieStream, SmackerVideoDecoder, SmackerAudioDecoder; DecodePcm16 decodes Huffman-packed 8/16-bit mono/stereo to interleaved signed PCM16. The existing Decode returns unsigned 8-bit mono samples. |
Sources 256 MiB, dimensions 4096, a million physical frames; packed audio 16 MiB source samples per packet (8-bit widening can produce 32 MiB PCM). Uncompressed and Bink DCT/RDFT audio unsupported. Constant trees can decode without video bits; partial delta palettes keep unmentioned entries. Ring frames are indexed; omit the final ring frame from ordinary playback. |
Media.Avi |
AviReader.Decode reads classic RIFF AVI into compressed AviVideoFrame payloads, palette and AviAudioFormat/audio chunks. CinepakSurface and RleVideoSurface decode cumulative frames; MicrosoftAdpcmStream decodes format-tag-2 blocks to signed interleaved PCM16. |
Sources 256 MiB, dimensions 4096, 100,000 frames, 64 MiB compressed frame payload, 400,000 movi chunks; ADPCM output 64 MiB. One video and at most one audio stream, flat movi, 40-byte bitmap header, the complete palette biClrUsed declares (256 entries when 0) for 8-bit video. Empty video chunks (dropped frames) leave a surface unchanged. OpenDML/AVIX, nested record lists, palette-change chunks and 8-bit palettized Cinepak unsupported. Index/keyframe seeking is not exposed; always decode sequentially. ADPCM chunks must contain complete blocks. |
Media.Fli |
FliMovieStream indexes seekable AF11 sources and reads individual records; FliSurface decodes COLOR_64 (11), line delta (12), BLACK (13), BRUN (15), COPY (16), and ignores type 14. Exposes top-down indices and an RGB palette. |
Sources 256 MiB, dimensions 4096, frames 64 MiB. Strict header/record/chunk extents. FLC/AF12 and other chunk types unsupported. Optional trailing ring record is excluded from FrameCount. Header speed is optional; the host may override cadence. Malformed historical files need a downstream repair policy, never silent shared-reader truncation. |
Media.Audio |
Pcm16.FromUnsigned8 and Pcm16.Encode produce little-endian interleaved PCM16; AudioResourceCache<TKey, TResource> lazily creates and owns backend resources; AudioVoices<TVoice> owns admitted voices and disposes stopped ones on Reap. |
No resampling or remixing. Host-thread objects; capacity, eviction, stealing, routing, gain and fades stay with the caller. Dispose voices before resources. |
Media.Playback |
MoviePlayback(frameCount, frameDuration, initialDelay); Advance(elapsed, decodeFrame) visits every due frame in ascending order. Pause, Resume, Skip, FrameIndex, IsComplete. |
TimeSpan arithmetic is bounded; negative time and nonpositive cadence rejected. Frame zero appears at the initial delay; completion follows the final frame's full interval. A callback failure invalidates the clock. It owns no audio, GPU, stream or timer. |
using RefurbishedDinosaurs.Media.Fli;
using RefurbishedDinosaurs.Media.Playback;
using var movie = new FliMovieStream(File.OpenRead(path));
var surface = new FliSurface(movie.Width, movie.Height);
var frame = new byte[movie.MaximumFrameLength];
var playback = new MoviePlayback(movie.FrameCount, cadence, initialDelay);
playback.Advance(elapsed, index =>
{
int count = movie.ReadFrame(index, frame);
surface.DecodeFrame(frame.AsSpan(0, count));
});
// Upload surface.Indices and surface.Palette once, after all due frames decoded.
The host chooses track, volume, fit/scale, skip input, file selection, failure policy and audio buffering. Pause/resume/skip the audio backend alongside the clock. A fixed video cadence does not synchronize independent device clocks; reference captures and long-play drift checks remain downstream validation. A huge elapsed step still decodes every frame; hosts may pause admission or drive decoding on a worker when that cost is unacceptable.
Recoverable persistence
RecoverableFile.Write flushes a staged file, invokes the caller's validator, preserves a usable
primary as .bak and promotes the staged generation. Rejected primaries preserve existing backups.
Supply exception admission explicitly for your format and preserve incompatible generations when
appropriate. Read reports generation and primary failure and never repairs files during browsing.
When the primary fails with an admitted error and the backup is missing or fails too, it throws
FileGenerationsUnreadableException, an AggregateException whose PrimaryFailure and
BackupFailure hold the two errors; classify or rethrow PrimaryFailure, the file that was asked
for. ReadAndRepair reads the same way for play and, after a backup load, restores the primary from
the backup with Restore, which validates a durable copy, promotes it and keeps the rejected
primary as .corrupt. It repairs only a primary that isDamaged calls damaged or missing; by
default an access error or a Windows sharing or lock violation, which say another process holds a
file that may be the newest generation, returns the backup's value and leaves the primary alone. A
repair that fails is reported in RepairFailure and still returns the backup's value. A failed
promotion keeps the primary but can lose the previous backup or rejected file. ReadBounded checks file size before allocation. Serialize writers; these
operations are not a journal.
Promotion over an existing primary uses File.Replace, which renames the kept primary to the
backup (or the rejected file) in the same call, so the primary path always names a whole
generation and the previous generation is never copied. On Windows it fails while another handle
holds the primary or the kept file without FileShare.Delete; readers that share delete keep their
generation open and do not block it.
JsonSettingsStore<T>.MaximumBytes bounds reads and writes (set a small application limit; the compatibility default is Int32.MaxValue), and LoadResult
reports primary, backup or defaults. Whole-document validation and migration remain caller callbacks.
For partial settings recovery, parse bounded primary and backup documents with the game's version
admission, then use SettingsRecovery.Select for each nullable field. Defaults and clamps stay local.
FileWriteLock.Acquire provides a cooperative exclusive .lock sibling lease, timeout and
cancellation. Dispose the lease after each serialized operation; the lock file is intentionally
retained. Schedule and snapshot saves in the host, and never rely on timestamp-only trust for validation.
AtomicFile.WriteBytesAsync preserves cancellation before promotion while flushing the sibling
to disk. JsonSettingsStore.Save can also admit an older primary through its migration callback
before preserving it as the backup. Recoverable writers accept a backup suffix, which Read must
be given too, and an explicit trusted-primary fast path; use that only for a known exact
generation under serialized ownership.
Validation
All committed fixtures are synthetic. Smacker packed-audio seed ordering, channel interleaving,
16-bit byte order and wrapping were additionally compared with FFmpeg using generated packets.
Run python tools/media/smacker_audio_oracle.py with FFmpeg installed to repeat that optional
oracle check. FFmpeg is useful for inspection and comparisons, not a runtime requirement.
Build
From the repository root:
dotnet build packages/dotnet/RefurbishedDinosaurs.slnx
dotnet test --project packages/dotnet/RefurbishedDinosaurs.Core.Tests/RefurbishedDinosaurs.Core.Tests.csproj
Audio buffers and lifetimes
Media.Audio.Pcm16 converts unsigned eight-bit PCM and encodes signed samples in explicit
little-endian order. Channel layout remains interleaved; conversion does not resample or remix.
AudioResourceCache lazily owns backend resources and retries failed factories. AudioVoices
owns admitted instances and disposes stopped voices on Reap. Both are host-thread objects;
the caller controls limits, stealing, gain, routing and fades. Dispose voices before resources.
LegacyFormats.WavePcm16Writer writes canonical mono/stereo PCM16 with a positive rate and a representable byte rate.
WavePcm16Stream indexes RIFF chunks without allocating track data, admits mono/stereo PCM16
at 8–48 kHz and accepts a caller track-size bound. Buffers and seeks must align to whole frames.
Read stops at track end; ReadLooped wraps. Ownership includes constructor failure unless
leaveOpen is true. Admit game-specific CDDA rates and canonical layouts in the game adapter.
The eager WavePcm16Reader retains its 256 MiB data bound and leaves its input open.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 12.3.1 | 45 | 11/22/2026 |
| 12.3.0 | 128 | 11/9/2026 |
| 12.2.0 | 181 | 10/15/2026 |
| 12.1.0 | 101 | 10/15/2026 |
| 12.0.0 | 172 | 10/10/2026 |
| 11.4.0 | 93 | 10/10/2026 |
| 11.3.0 | 101 | 10/10/2026 |
| 11.2.0 | 238 | 10/8/2026 |
| 11.1.0 | 91 | 10/8/2026 |
| 11.0.0 | 312 | 10/7/2026 |
| 10.0.0 | 109 | 10/6/2026 |
| 9.0.0 | 104 | 10/5/2026 |
| 8.0.0 | 105 | 10/5/2026 |
| 7.1.0 | 104 | 10/5/2026 |
| 7.0.0 | 104 | 10/5/2026 |
| 6.8.0 | 103 | 10/5/2026 |
| 6.7.0 | 102 | 10/5/2026 |
| 6.6.0 | 99 | 10/5/2026 |
| 6.5.0 | 99 | 10/5/2026 |
| 6.4.0 | 96 | 10/5/2026 |