Audience: engineers joining or reviewing the system. Scope: how the whole thing fits together, and how the hard parts are solved. Implementation detail lives in module docs; this is the map.
Companion documents, in this folder: wire.md (the wire contract a
director implements, byte by byte), shim-invariants.md
(the shim's invariants and the incidents behind them) and
escape-matrix.md. The crates it describes are this
repository's; its README says what is built and how.
The director is not here. It is whatever program speaks the wire contract. The sections on content, providers, the director, staging and the Linux host describe what a director does, as the design the shim and the injector are built against; the shim's tests run against their own fake director.
Aether makes a Windows game see a filesystem that does not exist on disk.
A game is installed as a 15 GB zip archive plus a set of mod folders. Instead of extracting and merging those onto disk, a director composes them into a single virtual tree and Aether serves that tree to one process, live, by intercepting the Windows NT file API inside it. Every other process on the machine sees the original, untouched directory.
The proof point is Skyrim Special Edition: it boots, loads its world, and plays from a Stored zip with no durable extract of game content. That runs on Windows natively, and on Linux under GE-Proton's Wine (§3.10): the game and the shim are Windows code either way, and only the host and the director differ.
The established approach to game modding is to copy mod files over the game install, or to use a kernel filter driver. Copying is destructive, slow, and makes "what am I actually running?" unanswerable. A driver is invasive, needs signing, and a bug takes the machine down rather than the game.
A userspace VFS keeps the install pristine, makes a mod list a piece of data rather than a mutation, and confines failure to one process.
┌─ Host process (a launcher, a binding, or a harness) ──────────────────────┐
│ │
│ Session roots, mounts, the ring, the launch │
│ Director userspace FUSE kernel: resolve, overlay, handle table │
│ Providers zip · disk · cache · compose · the host's own │
│ │
└───────────────────────────────┬───────────────────────────────────────────┘
│ shared memory:
│ control ring (slots) + bulk arena (banks)
┌───────────────────────────────▼───────────────────────────────────────────┐
│ Game process │
│ │
│ ntdll detours NtCreateFile / NtOpenFile / NtRead / stat×3 / enum×2 / … │
│ │ │
│ ├─ path under the managed root ──► director client ──► ring ──► director│
│ └─ anything else ────────────────► real ntdll, untouched │
│ │
│ synthetic handles · demand-paged sections · staged PE closure │
└───────────────────────────────────────────────────────────────────────────┘
Direction of authority. The director owns content; the shim owns interception and owns nothing else. The shim never opens a layer archive. That single rule keeps the trust boundary describable: archive bytes enter the game only through the ring.
Pure, OS-free, no I/O. Given enumerated layers, a director produces a merged
tree and answers resolve(vpath). It knows about:
- Layer precedence: later layers win.
- Tombstones: a first-class entry kind meaning "hide what is beneath". Deleting in an overlay must not reveal the file it was covering.
- Case folding: Windows is case-insensitive; the virtual tree must be too,
without being case-destructive (the original spelling is preserved for
enumeration). The fold is part of the wire:
aether-casefold'sfold, which the shim applies to every vpath before it is sent (wire.md). - Wildcards: enumeration filters (
*.esm) are not sent; the shim matches them over a listing (aether_redirect::wildcard_match).
Keeping this layer pure makes the merge semantics testable without a game, a driver, or even a filesystem.
Everything that can supply bytes implements a provider contract, addressed by
(RootId, relative path) rather than a bare string; RootId is the wire's
(aether-protocol). The root id lets one provider instance serve several
virtualized locations at once and still tell [1, "a"] from [0, "a"]
apart. A provider declares its capabilities once, at construction; a
read-only provider implements a small floor (capabilities, getattr, readdir,
open, close, and a positional or sequential read), and everything past that
answers ST_NOT_SUPPORTED.
immutable and slow look like they should be one flag; they are not, and
conflating them is the easiest way to get this model wrong. immutable says
caching a block is safe: the content never changes, so a cached copy is
good forever, even across process restarts. slow says caching is
warranted: reads are expensive enough that paying for a cache is worth
it. A local disk file is fast and mutable: no cache needed. A remote provider
serving content that can change underneath it might be slow but not
immutable: worth a RAM cache with invalidation, never a disk cache, because a
persisted block could go stale. A Stored zip entry is immutable but fast to
seek into: safe to cache, not obviously worth it on its own. Only a provider
that is both (a large, static, slow-to-fetch download) earns a cache that
survives across sessions. Getting the two backwards produces either a
correctness bug (stale bytes served from a disk cache for content that turns
out to be mutable) or a silent performance bug (content that never changes,
never cached).
- A zip provider parses the ZIP64 central directory and serves Stored (uncompressed) entries as byte windows into the container. Stored-only is a deliberate constraint: a Stored entry is a contiguous range, so a read at an arbitrary offset is a seek, not a decompress-from-the-start. That is what makes random access into a 15 GB archive viable.
- Combinators build providers out of other providers: layered (top-wins; listings union), a router (glob-pattern dispatch), an overlay (a writable upper over a base provider: reads fall through to the base, the first write to a base-only file copies it up into the upper, and removing a base-visible path writes a whiteout; the base is never mutated), a subdirectory view (a subtree exposed as a root), wrappers that add positional reads or demote write access, a disk directory served read-write, in-memory trees, and a mount graph (providers mounted at paths, a path resolved to the mount that serves it).
The userspace FUSE kernel. Holds the mount table, resolves a virtual path through it, owns the global file-handle table, and serves ring requests. It is the only component that touches archive containers.
It is a kernel, not the API a host embeds. A host's session (configure roots and mounts, stand up the ring, start the target) sits above it.
A shared memory segment holding a control ring of fixed slots plus a bulk arena of per-slot banks. Small requests and replies travel inline in the slot; large reads land in the arena so the ring never has to carry megabytes.
Slot ownership moves by compare_exchange, which makes it multi-producer safe
without a lock, which is necessary because a game issues file I/O from many threads at
once. aether-ipc imports no OS API at all; the mapping and the event objects live
in aether-win (a named section on Windows) and, on Unix, in the director (an mmap
of a real file, which a Windows shim inside Wine maps too). All unsafe is confined to
the segment accessor.
Concurrency. Each game thread claims its own slot and waits on that slot alone, so file operations on different threads do not wait for each other; the shim holds no lock across a round trip. A slot's life is
FREE → CLAIMED → SUBMITTED → PROCESSING → COMPLETED → FREE
└────→ ABANDONED → FREE
-
A director worker runs one request start to finish, so a read blocked in its provider (a block still coming from the network) holds its worker. The shim therefore counts reads, writes, truncates and write-opens against a gate (
aether_ipc::DataGate) sized at three quarters of the worker count the director publishes in the ring header. The remaining workers are always free for read-opens, stats, listings and closes, which are not counted. The gate is process-localstdsynchronisation; nothing about it crosses the ring. A permit stands for a worker a data request may be holding, which gives the gate three rules:- A permit outlives a timeout. A read the client gave up on is still inside its worker, so its permit stays out until the director has finished with the slot. A provider that stops answering can therefore hold at most the gate's share of the workers, however many reads time out.
- One call cannot take the gate. A pipelined read holds at most half the permits, and takes permits beyond its first only while more than a quarter stay free. With 16 workers (12 permits) two deep reads of slow content hold 6 and 3, and three permits remain for other threads' reads.
- First come, first served. A permit returned while callers are waiting is handed to the one at the front of the line, so a pipeline asking again for its next batch goes behind a caller already waiting.
A wait at the gate is bounded by the same deadline as a wait for a response, and fails the read when it runs out.
-
A client waits for its response by spinning, with no system call, for the first millisecond; every request the ring alone can answer is back long before that. After it, the shim yields, and after 20 ms sleeps a millisecond at a time (
Notifier::idle_client), so a thread waiting on a fetch does not hold a core. -
A full ring is waited for the same way, and for no longer. A pipelined batch has one deadline for all of its requests.
-
A client that gives up after
RESPONSE_DEADLINE(60 s) does not free a slot the director is still processing: it marks itABANDONED, and the worker frees it when it finishes. Until then nobody can claim the slot or its arena bank, so a late reply can never be read by a later request. The worker also echoes the request id it answered into the slot header, and the client checks it.
The ring's wire version (aether_ipc::layout::VERSION, 4) covers this state
machine as well as the payload layouts: a shim and a director built from
different versions refuse each other at attach. (The shim's bootstrap config
carries its own version first: §3.5.)
On Linux a director can keep the ring's pages off disk: when
$XDG_RUNTIME_DIR is a tmpfs owned by the user and closed to everyone else,
the ring file can live there (mode 0600, in a 0700 directory).
Detours on ntdll, installed inside the game. For each intercepted call it decides: is this path ours? If yes, serve it (from the director, or from a synthetic handle); if no, call the original function so the rest of the system is untouched.
The shim always runs with a director. Its client (FuseClient, in
aether-hooks/src/director.rs) owns the ring. There is no standalone engine and no
shim-local answer: the shim holds no tree and no write overlay of its own, and
without the director's client attached nothing is under a managed root. Writes,
copy-up and whiteouts are the director's overlay provider's (§3.2); the shim
forwards them. A call it cannot forward fails; it does not fall back to the real
disk under a root.
aether-redirect holds the pure path logic (which declared root, if any, a path
falls under, and its canonical spelling), so the policy is unit-testable away
from the hooks. aether-ntlayout holds the pure NT byte layouts the hooks fill in
(directory records, dispositions, object names), so they are tested on any host.
The hooks themselves live in aether-hooks/src/hook/, one module per concern
(open, attributes, I/O, mutation, directory queries, sections, registry, close);
the invariants each one keeps are in
shim-invariants.md.
Bootstrap config. The host hands the shim a small byte buffer: the managed
root and the static-import table. It is versioned (VFSC magic, layout version
2, in aether-protocol::shimcfg), and a host and shim from different builds fail
bootstrap with a named BootstrapError::Config rather than reading each other's
bytes. The ring VERSION check then rejects a stale shim at attach.
A game makes huge numbers of tiny reads (one launch of a 3,472-mod list read
Skyrim.esm 838,643 times in 4 KiB pieces, and plugins.txt a byte per
call), and over the ring each is a round trip. So the shim keeps a block
cache in front of the director for small reads of immutable files
(aether_ipc::readcache, OS-free so native tests run the same code; wired in
by aether-hooks's read_cache.rs):
- A synchronous
NtReadFileshorter than 64 KiB is served from aligned 64 KiB units; a miss fetches one unit with one bulk read through the sameread_fragmented, gate and deadline as any other read, and while a file's misses keep landing where its last fetch ended (a sequential reader) the run doubles, up to 1 MiB in one request. A unit never extends past the end of its file. Bytes are what a miss costs (a provider reading a compressed store spends about a millisecond a MiB, a hundred small round trips' worth), so units stay small. Larger reads, and reads asking for completion by APC or event, take the uncached path unchanged. Anything the cache does not serve falls back to that path, so the bytes, theIO_STATUS_BLOCKand the file position are always what it would give. - Blocks are per file (root and folded path), shared by every handle on
it, versioned by its size and the director's mount generation: 16 MiB
per file with LRU, 256 MiB process-wide (
VFS_SHIM_READ_CACHE_MIB) with global LRU. Per-file locks, none held across a fetch, one fetch per block however many threads miss it, and bytes reserved before a fetch starts, so memory stays bounded. - Coherence rule: only what cannot change is cached. The director's open reply says whether the handle is immutable (an overlay answers for the child holding the handle: a base file of an immutable base is, anything in the write layer is not). Only such handles are served. A write open, an open reported mutable, a write, a truncate, or a delete or rename (source and target, everything under them) through this process drops the file for the rest of the process. Because writable files are excluded rather than invalidated, another process writing the same write layer cannot make the cache stale: what it writes is never cached, and a file it copies up is reported mutable at its next open here.
- A file read at random across more units than it may hold goes cold: after 16 re-fetches of units its own LRU dropped, averaging under 8 hits each, it is read uncached for a while instead of turning every small read into a fetch. A file's first fetch of a unit, and a miss on a unit the process-wide cap evicted, are not held against it.
Replayed through the provider-side traces of real launches (every handle's reads, in order), the launch above needs 52,811 small round trips with the cache against 475,274 without it, and fetches 2.13 GiB where the program reads 2.03 GiB.
A provider that traces its reads sees the cache's unit fetches, not the program's own read pattern: capture an access trace with the cache off.
VFS_SHIM_READ_CACHE=0 turns it off, and the VFS_SHIM_STATS_LOG report has
a section for it (hits, misses, declined, fetches and bytes, evictions,
invalidations, misses the cap caused) with the twenty busiest files: their
small reads, hits, misses, bytes fetched, and whether they went cold and
why. A director that leaves the open reply's immutable flag clear is never
cached.
Getting the shim into the process before the process needs the VFS. This is the subtlest part of the system and gets its own section below.
Activation fails closed. The shim gets into a process one way only:
remote-thread injection. The target is held suspended until the shim has
bootstrapped inside its LoadLibrary and said so in the ready file, and a target
whose shim failed is terminated: if injection fails, the shim's bootstrap
reports a failure (config mismatch, director unreachable), the target dies
early, or the ready timeout passes, the launch returns an error and the process
is killed. The
same rule holds for every child the game creates (§4.3). The failure mode is a
launch that errors, never an unvirtualised game that writes to the real disk.
Almost all configuration crosses a process boundary: the host sets environment
variables, CreateProcessW inherits them, and the shim reads them inside the
game. That is the right mechanism for a boundary we do not otherwise control,
but spelling the names as literals at both ends would make drift free and
silent: a rename at the writer that misses the reader produces no error, just
a feature that quietly stops working.
aether-env holds one constant per name, a table describing all of them, and a
test that fails if any crate reads a VFS_* name absent from that table. It has
no dependencies, so even the shim can use it.
Two boolean forms: opt_in is off unless explicitly enabled (used for
anything that relaxes a guarantee: ALLOW_DISK_FALLTHROUGH un-seals the
managed root, and must not be enableable by accident), and opt_out is on
unless explicitly disabled.
aether_env::describe() prints the whole surface; the rustdoc on each constant is
the reference.
There is no control plane: a host composes each session in code, with the roots, the providers each root serves and the ring, and starts launches from it. A host that learns its sources one at a time installs them per root and keeps the root's write layer composed above them.
Injected processes see the real registry, but none of their registry writes reach it: they go to a per-profile registry layer that persists between runs.
- Switch. A host attaches a layer to its session; while one is attached,
launches set
VFS_REGISTRY=1. Without it the shim installs no registry detours at all, so a process with the overlay off carries none of them. - Director. The director holds the session's overlay tree
(
aether-registry::Overlay: values, value tombstones, present or tombstoned child entries, created-here or overlaying-real origin) and saves it in the layer (written beside and renamed into place) while dirty and at every flush. A save is an ordinary layer write, so under a deferred store it is durable only once the store syncs: at stop, at detach, and periodically while a save is not yet durable. - Ring. Opcodes 15–22:
REG_LOOKUP,REG_KEY,REG_SET_VALUE,REG_DELETE_VALUE,REG_CREATE_KEY,REG_DELETE_KEY,REG_RENAME_KEY,REG_CHANGED. The director publishes a registry generation in the ring header (reg_gen, ringVERSION4), bumped by every registry write and every attach or detach. - Shim. Hooks the NT registry calls (open/create, query, write, notify,
security, handle flags, and the out-of-scope hive and transaction calls). A
key the overlay does not touch is served by the real handle unchanged; one
it touches gets a synthetic handle whose queries merge the real key with the
overlay node in the exact NT layouts.
REG_LOOKUP/REG_KEYanswers are cached per path, tagged with the generation read before asking, and used only while the published generation still equals it; a cache hit is one atomic load. - All or nothing per process. If any registry detour cannot be installed, the process does not virtualise its registry at all (every hook passes through), because a missing write hook would let writes through a virtual view reach the real registry.
- Fail closed. Writes never fall back to the real registry: a director
failure, a key handle whose name cannot be read, or a real-modifying call
made while the hook is bypassed returns
STATUS_UNSUCCESSFUL. Reads fall back to the real registry, counted in the shim stats.
Linux is a supported host. The game is still a Windows program and so is the shim: both run inside GE-Proton's Wine, while the director, the providers and the host are native Linux. Only the transport and the launch differ from the Windows path.
- Ring. The director creates a file-backed ring, mapped by the director
natively and by the shim through Wine, tmpfs-backed when
$XDG_RUNTIME_DIRis private (§3.4). The wire protocol and the version are the same as on Windows. - Runtime. The director finds, downloads, verifies and extracts GE-Proton,
and refuses anything that is not GE, because an unset or wrong
PROTONPATHsilently falls back to stock Proton. - Prefix. A launch runs in a Wine prefix: an anonymous one deleted with the
session, or a named one that persists. A root's location (
C:\...) is a symlink into the prefix'sdrive_c, created at the first launch and removed with the session. The managed root is always empty on disk; content only ever arrives through the ring. - Windows half. The injector (
aether-injector.exe), the shim and the test probes are Windows binaries cross-built bybin/build-windows, whoseARTIFACTSarray is the one list of the natives it stages. - Launch. A launch lasts as long as anything runs in the prefix
(
wineserver -w), not only the program it started (a mod loader that starts the game and exits keeps it alive). The Windows path gives the same answer with a Job Object (§4.3); the injector itself uses no job under Wine, because the prefix watch already covers the tree.
A launch lifetime is the same on both targets. A launch runs until every
process it started has exited; the exit code reported is the first
process's; stopping a launch ends the whole tree. A session runs one launch at
a time. On Linux "the tree" is the session's Wine prefix (wineserver -w). On
Windows it is a Job Object per launch (aether_inject::spawn_target_with_shim,
ProcessTree) that no process can leave (§4.3).
Several of these show no error at all when they go wrong.
You cannot hook a process that does not exist, and by the time it exists the
Windows loader has already resolved the executable's static imports. A game EXE
sitting alone in an otherwise-virtual directory dies at STATUS_DLL_NOT_FOUND
before a single line of our code runs.
Two mechanisms:
- Staging the PE closure. Before launch, the director writes the target EXE and its non-system static imports (transitively, and nothing else) into a scratch directory. For Skyrim that is a 37 MB EXE and three DLLs against ~15 GB that stays virtual. The directory is deleted when the process exits. The loader resolves every static import from real files, so nothing needs to be hooked before it runs.
- The shim is injected, and bootstraps in its own
DllMain, synchronously, failing the load if it cannot. Injection is the only way it arrives, and works the way SKSE injects its DLL: create the target suspended, grow its primary stack to 16 MiB,LoadLibrarythe shim on a remote thread (which first runs process initialisation, then the shim's bootstrap), wait for that thread, and resume once the ready file says "ready". The primary thread never runs before the hooks are live. Nothing of the EXE, on disk or in memory, is edited, so a Steam DRM wrapper (SteamStub) that verifies its own headers starts as it would without the VFS. - The early layer covers what process initialisation reads. That
initialisation runs every static import's
DllMainbefore the shim, and a proxy DLL a mod ships as one (an ASI loader'sversion.dll, ReShade'sdxgi.dll, RED4ext'swinmm.dll) reads its settings and lists its plugins then, beside the program, where only the staged closure is. So before the target runs, the injector maps a small import-free DLL into it (crates/aether-inject/early/src/lib.rs, ano_stdRust DLL with no imports that the crate'sbuild.rscompiles withrustcalone) and points ntdll'sNtCreateFile,NtOpenFile,NtQuery(Full)AttributesFileandNtQueryDirectoryFile(Ex)at it. A name under a staged folder (the launch image's, each root's backing directory) waits while the injector asks the director for it over the ring (GETATTR, OPEN, READ, READDIR) and puts what it has there on disk: a file's bytes, a directory, a listing's matching entries. That covers only the loader's own probes, though: the first of these calls that comes once kernel32 has run itsDllMain(the loader starts it before any other DLL, and marks it so in the PEB's module list) puts ntdll's bytes back and loads the shim right there, on the thread initialising the process and under the loader lock, so every static import after kernel32 runs itsDllMainwith the hooks live: what it reads comes from the director, and what it writes (a proxy's log) goes to it, as any of the program's I/O does. The call that triggered the load goes on through the shim's hook. The remote thread starts in that DLL, after the initialisation; itsLoadLibraryof the shim then only returns the module already loaded (or, withVFS_EARLY_SHIM=0, puts ntdll's bytes back and loads the shim there, as before the early load: a static import's writes then reach the staged folder). What was put on disk stays in the staged folder, which the shim routes to the director from then on. Each injector carries the stub for its own architecture: x64, and x86 for a 32-bit target under WOW64, whose syscall thunks (mov eax, n; mov edx, transition; call edx) are as position-independent as x64's. A child the shim starts gets the stub too, loading only (aether_inject::inject_dll_early_exit_code): its image and import closure were staged before it was created, so its static imports run with its own shim live, as the launch's do. The layer is off when the launch stages nothing, andVFS_EARLY_LAYER=0turns it off (for a child too, which inherits it);VFS_EARLY_TRACE=1has the injector say whether the shim loaded during initialisation (crates/aether-inject/src/early.rs).
Windows will not create a process from a buffer. Staging writes the real EXE
and its import closure to a scratch directory, so there is a real file to
CreateProcess, and the loader maps, relocates and binds it properly. The
launch path is: stage → CreateProcess suspended → inject → resume.
The primary thread's stack is grown to 16 MiB on that path, because the
shim's extra frames overflow the stock 1 MiB stack (0xC00000FD).
What this does not cover is launching a child EXE that exists only
inside an archive, with no path to CreateProcess from. Staging the whole
launch closure (including a child that a loader will spawn) covers the real
cases (see §4.3).
A mod loader does not become the game; it launches it. skse64_loader.exe
starts, does its work, spawns SkyrimSE.exe, and exits. The virtualised view has
to survive that handover, or the process that actually plays the game sees the
real, nearly-empty directory. This is a known problem for any VFS in this
space.
Two halves solve it:
Stage the whole launch closure, not just the entry point. When the launch
executable is a loader, staging also places the game EXE beside it, because the
loader will CreateProcess it and that needs a real image for exactly the same
reason the top-level launch did. It also stages skse64_<runtime>.dll
explicitly: SKSE injects that at runtime rather than importing it, so a PE import
walk cannot discover it. For an SKSE launch the staged set is six files.
Follow the shim across CreateProcess. The shim detours
kernelbase!CreateProcessInternalW (the single funnel beneath every
CreateProcess* variant), forces the child to start suspended, injects it as
above (the child's primary thread is never resumed before the shim is up, so a
caller that asked for a suspended child, like skse64_loader, gets it still
suspended), then resumes it unless the caller asked otherwise. It fails
closed: a child whose injection fails, whose shim reports a bootstrap failure,
that dies early, or that is not ready within the launch's ready timeout is
terminated and its CreateProcess call returns FALSE (ERROR_PROCESS_ABORTED).
A child is never released without the shim, so the failure mode is a launch that
errors, not an unvirtualised game that writes to the real disk. The refusal
reaches the launcher: the shim lists the children it killed beside the ready
file, and the host reports them. The wait is the launch's own ready timeout
(180 s by default), which the injector passes down in
VFS_READY_TIMEOUT_SECS; every child is injected, none is skipped. The
child's image identity is scoped so the parent's does not leak into it.
Wait for the tree, not the loader. The handover also decides when the
launch is over: the loader exits while the game is still running. Under Wine
the launch watches the Wine prefix (§3.10). On Windows,
aether_inject::spawn_target_with_shim creates an unnamed Job Object per launch
and assigns the target to it while it is still suspended, before the remote
LoadLibrary thread and before ResumeThread, so no child can escape it by
racing the assignment; children inherit the job. The launch is over when the
job's ActiveProcesses count is zero. The completion port's
JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO is only a wake-up (job notifications are
not guaranteed), so the wait re-reads the count every 500 ms at most. Stopping
is TerminateJobObject. The job has KILL_ON_JOB_CLOSE (its handle lives only
in the host, so the game does not outlive the director it reads through) and
no breakaway limit (neither BREAKAWAY_OK nor SILENT_BREAKAWAY_OK): a process
that left the job would be neither waited for nor stopped, yet still do file
I/O through the VFS after the host saw the launch end. The shim's process hook
drops CREATE_BREAKAWAY_FROM_JOB from every child it creates
(child_creation_flags), so a child that asks to break away stays in the job
instead of failing with ERROR_ACCESS_DENIED. A child the shim refuses dies at once
and never holds the launch open. If the target cannot be put in a job (a host
job that forbids nesting), the launch falls back to tracking the first process
alone and says so. The injector's run_target_with_shim, used under Wine,
keeps first-process tracking.
Bethesda archives are opened with CreateFileMapping and read through slid
views. A naive implementation would have to materialise a whole BSA to back the
section: several GB, per archive.
Instead, NtCreateSection reserves address space without committing it, and
a vectored exception handler commits and streams 256 KiB chunks from the
director on first touch. Large archives are demand-paged; small ones take an
eager path.
The lifetime rule matters as much as the paging. The reservation belongs to the section, never to a view, because that is NT's model and the game depends on it: a BSA reader slides views across one archive, so unmapping one window must leave every other window, and any later remap of the still-open section, valid. The VA is released only once the section handle is closed and the last view is gone. Getting this wrong produces crashes far away from the cause.
This is the defect class that costs the most:
NT lets a caller name a file as (directory handle + relative name), not only
as an absolute path. CreateFileW("Data\\X") reaches ntdll as the process's
current-directory handle plus the relative string.
A hook that only understands absolute names does not fail on these. It decodes nothing, declines to act, and the call proceeds to whatever is really on disk behind the mount. No error, no log line, no counter: the file appears not to exist. Skyrim reaches its main menu with an empty load order for exactly this reason: every plugin lookup takes the relative form.
The resolution is one shared parent_dir_of_handle consulted by every hook that
decodes a name, covering three kinds of parent:
- our own synthetic directory handles,
- real directory handles the process opened (we record a path for every successful open),
- the current-directory handle, which the OS creates and publishes only in
RTL_USER_PROCESS_PARAMETERS.CurrentDirectory; there is no API that returns it, so it is read from the PEB.
Because every hook uses that one implementation, no hook can know about a parent the others cannot.
Windows offers multiple ways to ask "does this file exist, and how big is it", and callers choose between them for reasons of their own; the same program uses different ones in different code paths.
- Enumeration:
NtQueryDirectoryFileandNtQueryDirectoryFileEx. - Stat:
NtQueryAttributesFile,NtQueryFullAttributesFile, andNtQueryInformationByName, which Windows 11 prefers for existence checks.
Any hook that answers differently from its siblings produces a program that believes a file both exists and does not. Both failure directions are real: a false negative makes content silently invisible (Skyrim's intro video does not play), and a false positive leaks a file the sealed view deliberately hides.
Every one of these entry points is hooked, they share one implementation body where the shapes allow, and cross-API agreement is a test rather than a convention (§6).
The VFS's cost in a launch is not the number or size of reads: swapping the
content source (zip vs plain disk) changes nothing, and a launch involves only
hundreds of director operations. It is wake latency. Per-hook
instrumentation with max and >1 ms stall counts shows it: a stat hook can
average 819 µs/call while almost every call is fast and a few take up to
15.2 ms, the Windows timer quantum. Such an average describes no call that
ever happened.
Two mechanisms keep both ends awake:
- Server-side spin-then-wait: the director spins while the ring is hot instead of sleeping between bursts.
- The client wakes the server: the shim signals an event on submit and then spins for the reply, which arrives in 20–209 µs, far less than the cost of sleeping for it.
The lesson encoded in the tooling: report max and stall counts, never a bare mean, because the two shapes of "slow" want opposite fixes.
An enumeration must apply the caller's wildcard, honour case-insensitivity, and remain stable across the restart-scan and single-entry-at-a-time protocols NT allows. It is also stateful: a directory handle carries a cursor, so the listing is built once per scan and served in slices.
It must not show the union of real and virtual entries, for the reason
§4.9 gives. A directory listing is a spelling of the paths it names, so the
sealed root applies to it in full: under a managed root the director's
readdir is the whole answer, never merged with the real directory behind the
mount. If the director cannot be asked, the listing is empty rather than
drained from disk. See serve_dir_query in
aether-hooks/src/hook/dirquery.rs, and
escape-matrix.md for the test that holds it closed.
The managed root is sealed: under-root paths resolve through the director only, never falling through to whatever happens to be on disk there. This makes "the game cannot read anything we did not give it" a property rather than a hope, and it is why the runtime directory is nearly empty at rest.
Once a file is served from a synthetic handle, everything asked about that handle must answer consistently (name, size, position, volume information) or a caller that stats its own open file gets a contradiction. Handles carry their virtual identity so queries return the virtual answer, not the backing file's.
Time-to-window for Skyrim SE, three clean runs each:
| configuration | mean |
|---|---|
| native, no VFS | 1.0 s |
| VFS, staged launch | 2.81 s |
That is roughly 1.8 s over native. About 0.72 s of that is work native never does at all (staging, injection), and the rest is hook time. Content source is not a factor: zip and disk providers measure the same.
The system's characteristic failure is silence: work that is skipped rather than work that errors. Tests are shaped around that.
- Pure layers are unit-tested (
aether-casefold,aether-redirect,aether-ntlayout,aether-registry,aether-protocol,aether-ipc,aether-pe): case folding, path canonicalisation, wildcards, NT byte layouts, registry merges, wire codecs, ring state transitions. They build and test on Linux. - Hook behaviour is tested in-process. Integration binaries install the real
detours into the test process and then use ordinary
std::fsand raw NT calls against the fake director intests/fakedirector. One install per process, so every#[test]inaether-hooks/tests/re-executes itself in a fresh process (tests/common), and the scenarios are grouped into a few binaries by concern. These are Windows executables. A test whose prerequisite is missing printsSKIPand passes;VFS_TEST_REQUIRE_ALL=1makes a skip a failure (see the root README's Test section). - The fake director records, and can be told to misbehave. It is built
on
aether-refdirector'sharnessmodule:Recorderkeeps every request and reply that crossed the ring (so a test asserts what the shim sent, not only what the program saw),Faultsgives the reply a director should not (a status, a truncated or padded payload, an oversize reply, a bulk reply naming data outside its bank, a delay past the client's deadline) for the nth matching request, andOverridechanges the fields of a reply a director may legitimately vary (an OPEN's flags and size, a file's time). All three are taps onaether-rpc's serve loop. The fault table inwire.md3.7 is checked against the tests' own table, and generated sequences of faulted calls check that the program neither crashes nor hangs.tests/harness/also holds the counted costs of each hooked call (costs.txt), andaether-fuzzandfuzz/fuzz the decoders;benchmarks.mddescribes those and the timed tools. - Every naming form is covered, not just the convenient one. The
relative-name battery exercises each decoding hook through a real directory
handle, because Win32 decides on its own whether a relative path becomes an
absolute name or a handle pair; going through
std::fsalone cannot guarantee the second form was hit. - Cross-API agreement is asserted directly: both enumeration entry points must return one view; every stat API must agree about existence and size, in both directions.
- Byte-exactness is checked against ground truth, including against a native extract of the same archive when the corpus is present.
Two habits to keep:
Test the wiring, not only the unit. A predicate can be unit-tested and correct while a caller fails to consult it. A test of a predicate cannot catch a caller that does not call it; only a single shared implementation can.
Verify a regression test fails. The enumeration-parity test fails with the classic detour disabled, which is the defect it guards against.
Beyond the suite, behavioural changes are verified against the running game:
the window is driven headlessly with scancode-level input
(SendInput/KEYEVENTF_SCANCODE; the game ignores SendKeys and posted
messages), the console opened with the grave key, a command such as
coc riverwood typed key by key, a frame captured, and the run ended so the
game exits on its own path.
Because failures are silent, the shim carries instrumentation that can be turned
on with VFS_SHIM_STATS_LOG and answers questions counters normally cannot:
- per-hook calls, total and max time, and a
>1 msstall count; - what the read cache did (§3.5): hits, misses, block fetches, evictions and invalidations;
- open paths by frequency: a retry loop reopens one path thousands of times, and a deduplicated list hides exactly the path that matters;
- every directory enumeration with its filter, entry count, and which
mechanism answered it:
director,contained(under a root, but the director could not be asked: the listing is empty), orOS(outside every root). "ListedData, got nothing" and "never listedData" are different bugs with identical symptoms, and so are "the director listed it" and "something else did"; - every attribute query with its outcome, since a stat that wrongly says no never becomes an open;
- an ordered trace of under-root operations, because counts cannot show where a sequence stopped;
- undecodable opens, which is the only way an unnameable path becomes visible at all.
That last one is the general lesson: when a counter shows nothing, suspect the observer before concluding the process is idle.
| crate | role |
|---|---|
aether-casefold |
the case fold every name crosses the ring in, for file paths and registry keys; no dependencies |
aether-protocol |
ring wire codecs, opcodes, statuses, open flags and RootId; the shim bootstrap config (VFSC v2) |
aether-ipc |
control ring + bulk arena + read cache, OS-free |
aether-rpc |
typed ring ends over aether-protocol: the Client the shim calls the director with (compiled into the shim DLL) and the Director trait a director in Rust implements |
aether-refdirector |
the reference director (answers every file and registry opcode from memory, the server the shim's tests run against), a null one for measuring the ring, and the harness the shim's tests record and inject faults with; not shipped |
aether-conform |
the conformance tool: scenarios, malformed requests, generated cases and concurrent clients played against a director (docs/conformance.md) |
aether-fuzz |
the bodies of the fuzz targets over the decoders that read a director's output, and their replay on stable Rust; fuzz/ (outside the workspace) runs them under cargo-fuzz |
aether-shimbench |
times Win32 calls natively and under the shim, with the requests per call counted (docs/benchmarks.md); not shipped |
aether-filering |
a ring in a memory-mapped file on any OS (FileRing), the Linux-under-Wine backing of wire.md 2.10 for a native tool |
aether-win |
Windows shared memory, events and volume lookups |
aether-registry |
registry overlay tree, its file format, the merge with a real key, NT query layouts |
aether-env |
every VFS_* switch, defined once, with a drift test |
aether-redirect |
pure path core: root map, canonicalisation, vpath normalization, DOS wildcards, a handle's final name |
aether-ntlayout |
pure NT byte layouts and decisions for the shim's hooks |
aether-hooks / aether-shim |
NT detours, the director client, synthetic handles, sections, registry hooks |
aether-inject |
injection and process creation (aether-injector) |
aether-pe |
pure PE byte parsing, so any host can stage Windows executables |
aether-fixtures |
the test fixtures: Windows probe programs the tests run under the shim (aether-fixture-read, -writepath, -escape, -prefs, -registry, -steam, -nvapi) and the library they share |
aether-fixture-vproxy / aether-fixture-staticimp |
a proxy DLL (vproxy.dll) and a program that imports it statically, for injection before static imports initialise; built in that order, in two cargo invocations (cargo#6313) |
aether-testkit |
dev-only helpers shared by integration tests |
Dependency direction is enforced by the split: pure crates never learn about the OS.
- Windows guests only. The game and the shim are Windows code (x64 and x86). A Linux host runs them under GE-Proton's Wine (§3.10); there is no native Linux game support, and no macOS host.
- Anti-cheat. The techniques here are indistinguishable from those an anti-cheat system exists to detect. This is a single-player modding tool.