116 lines
8.0 KiB
Markdown
116 lines
8.0 KiB
Markdown
+++
|
|
title = 'XTHV1: A New Registry Hive Format for ExectOS'
|
|
author = 'Aiken Harris'
|
|
date = '2026-11-29T12:17:03+01:00'
|
|
+++
|
|
|
|
We would like to share some news about what we are working on right now: configuration management and the
|
|
registry. Like everything else in the kernel, the registry
|
|
follows the NT model. There is a hierarchical database of keys and values, security descriptors on keys, volatile
|
|
keys that disappear on reboot, symbolic links, and the familiar native API on top. One part of it, however, takes a
|
|
different road. ExectOS will not store its registry in the REGF hive files known from Windows. Instead, we are
|
|
deploying our own on-disk format, called **XTHV1**.
|
|
|
|
This article explains why we made that decision, what it buys us, what it costs, and what it means for NT
|
|
compatibility. The complete specification of the format, as it stands today, is available in our
|
|
[documentation](/documentation/xthv1).
|
|
|
|
### Why Not REGF?
|
|
REGF is the file format of Windows registry hives. It has served Windows well for three decades, but those three
|
|
decades show. The format accumulated revisions, compatibility rules, and fields whose meaning changed over time.
|
|
Its crash consistency depends on a header with sequence numbers and a simple checksum, combined with separate
|
|
transaction log files that are replayed when the primary file turns out to be inconsistent. The registry data
|
|
itself, the bins and cells that hold keys and values, carries no integrity protection at all. A torn write, a
|
|
flipped bit or a page written to the wrong place is only noticed if it happens to break the structure badly enough,
|
|
and a damaged hive is typically handled by repairing it in place: dropping whatever cannot be made consistent and
|
|
carrying on.
|
|
|
|
There is also the question of documentation. REGF has never been specified by its author. Everything known about it
|
|
comes from observation and reverse engineering, and every implementation outside Windows has to rediscover the same
|
|
corner cases. Implementing it for ExectOS would mean committing to a format we cannot fully specify, cannot change,
|
|
and whose most important guarantees live in a log replay protocol rather than in the file itself.
|
|
|
|
We wanted the opposite: a format we can describe completely in one document, whose consistency does not depend on
|
|
side files, and in which every byte on disk is verified before it is trusted.
|
|
|
|
### What XTHV1 Is
|
|
XTHV1 keeps the record model that registry implementations have relied on for decades. Keys, values, security
|
|
records and subkey indexes are stored as records in cells, and cells are grouped into bins. The configuration
|
|
manager above the file therefore works with familiar structures. What changes is everything around those records.
|
|
|
|
An XTHV1 file is a sequence of 4096-byte pages. Two of them hold superblocks, the roots of the two most recent
|
|
committed images. Every other page is either a data page carrying a piece of the registry image or a node of a
|
|
small three-level map tree that translates logical page numbers into physical ones. Every pointer in the file, from
|
|
the superblock down to each data page, carries a SHA-1 hash of the page it points to. The whole committed image is
|
|
thus covered by a hash tree whose root lives in the superblock, and the superblock is protected by its own hash.
|
|
|
|
Changes are never written in place. A commit writes modified data pages and the map nodes above them to free pages,
|
|
then publishes a new superblock in the slot that does not hold the current image. Until the second superblock write
|
|
is durable, the previous image is the committed one. Afterwards the new one is. There is no log to replay and no
|
|
intermediate state to repair.
|
|
|
|
### What We Gain
|
|
**Atomic commits without logs.** A crash at any point of a commit leaves the file with either the previous image or
|
|
the new one, both complete. Recovery after a power failure is the same procedure as a normal mount: pick the newest
|
|
valid superblock and follow it.
|
|
|
|
**Every byte is verified.** Torn pages, bit rot, misdirected writes and stale pages are detected by the hash tree
|
|
before any record is parsed. A hive that mounts successfully has been checked end to end.
|
|
|
|
**The previous image stays available.** Pages of the previous generation are not reused while it is still one of
|
|
the two live images. If the newest image fails verification, the reader can fall back to the previous one, which is
|
|
complete and consistent, instead of guessing which parts of a damaged image are still trustworthy.
|
|
|
|
**A canonical byte form.** Free space is zeroed, reserved fields are zero and runtime-only state never reaches the
|
|
disk. Two hives with the same content and history produce the same bytes. Images are reproducible and comparable,
|
|
and test fixtures can be generated from the specification alone.
|
|
|
|
**Strict structure.** The format defines exactly which records may appear and who may reference them. Every
|
|
allocated cell must be reachable from the root key, every cell except a security record has exactly one owner,
|
|
names are unique within a key, and indexes must be ordered and carry correct hints. There is no room for hidden
|
|
data, dangling references or ambiguous interpretations, which also makes crafted hives considerably less
|
|
interesting as an attack vector.
|
|
|
|
**64-bit physical addressing and a complete specification.** Physical page numbers are 64-bit, and the logical
|
|
image can be scattered across the file in any order. The format is [fully specified](/documentation/xthv1), including test vectors,
|
|
so it can be implemented independently of the ExectOS kernel.
|
|
|
|
### What We Give Up
|
|
**Compatibility at the file level.** Windows cannot read XTHV1 hives, and ExectOS will not read REGF hives. Existing
|
|
registry tools that operate on hive files will not work with ours.
|
|
|
|
**Write amplification.** Changing a single byte rewrites the whole data page, one map node on each of the three
|
|
levels and a superblock, separated by two durable flushes. REGF with its log can be cheaper for small, frequent
|
|
updates. We accept this because registry writes are batched and comparatively rare, and because the cost buys
|
|
atomicity.
|
|
|
|
**Space.** Two generations are live at the same time, so a file may temporarily hold close to twice the pages of the
|
|
logical image, plus about 1.2% for map nodes. Physical pages are also not kept in logical order.
|
|
|
|
**Verification cost.** Mounting a hive hashes every page and walks the entire record graph. For registry-sized data
|
|
this is a small price, but it is not free.
|
|
|
|
**No automatic repair.** A strict format rejects images that a lenient implementation would silently patch. XTHV1
|
|
1.0 can fall back to the previous generation, but it defines no procedure for rewriting damaged content. A
|
|
dedicated repair mechanism is planned, but it is not part of this version.
|
|
|
|
**SHA-1.** The hash tree uses SHA-1, whose collision resistance is no longer considered strong. The purpose of the
|
|
hashes is to detect accidental damage, not to authenticate the file. Anyone who can write the file can recompute
|
|
any hash in it, so a stronger function without a key would not change that.
|
|
|
|
### What This Means for NT Compatibility
|
|
Our compatibility target has always been the interface, not the files. Applications and drivers use the registry
|
|
through the native API and never parse hive files themselves. The semantics they depend on, such as keys, values and
|
|
value types, security descriptors, volatile keys and symbolic links, are preserved. From their point of view,
|
|
nothing changes.
|
|
|
|
What does change is everything that handles hive files directly. Offline registry editors, forensic tools and
|
|
anything that copies hives between systems will not understand XTHV1, and moving registry data between Windows and
|
|
ExectOS requires conversion. Our boot loader reads XTHV1 directly, so no REGF parser is needed anywhere in the boot
|
|
path.
|
|
|
|
### The XTHV1 Specification
|
|
The complete specification of XTHV1 version 1.0, cell format 1, covering the container, superblocks, hashes, the map
|
|
tree, bins and cells, the record catalog and the rules for commits and recovery, is published as a separate document:
|
|
[XTHV1 Registry Hive Format](/documentation/xthv1).
|