# Registry Reads, Writes, and Layers

_Peios / Using Peios / The Registry_

> Choose a live registry operation without confusing it with documentation or a backup.

`reg` reads and changes the live registry. `regman` explains the intended
meaning of a setting; it does not read the value configured on this machine.
Consult the documentation before changing a setting whose accepted values you
do not know.

## Keep the key and value name separate

The key path and the value name are separate arguments. A value name can
contain separators that are not allowed inside a key-path component. The
special value-name token `@` selects the empty-name default value.

Value literals have types. Numeric-looking input can be inferred as a number,
losing a textual spelling such as leading zeros. Use an explicit string type
when those characters are part of the value's meaning. Inspect the resolved
type reported after a successful write.

The empty-name default value is unrelated to a consumer's documented
fallback when an entry is absent. To preserve text such as `007`, use an
explicit literal such as `sz:007`. Quote backslash paths in a shell, or use
forward slashes. `reg(1)` owns the full type-prefix and encoding reference.

Names preserve display case and compare without locale-sensitive case rules.
They are not Unicode-normalized, so visually identical names can remain
distinct. Ordinary value data is opaque to the registry; its consumer checks
whether the bytes make sense for the type and setting. A link key's target
has additional interpretation by the kernel.

A volatile key describes storage lifetime, not when a setting applies. Check
`reg info` for volatility and the setting's manual for application timing.

## Choose a layer deliberately

An effective read resolves the visible value across layers. Deleting an entry
in one layer can reveal a lower entry. Masking hides lower values instead,
while hiding a key affects path visibility.

These are different operations, not interchangeable ways to remove data.
Select the layer and understand the lower state before changing either.
Security-descriptor changes affect the key object directly; removing a
configuration layer does not undo them.

The winner has the highest precedence, then the newest write sequence within
that precedence. A sequence is not a timestamp or a history of previous
values. Base and role layers can share precedence zero; writing to base does
not prevent a later role update from winning. `reg get KEY NAME -L` reports
only the effective winner, not every hidden entry.

See [Recovering a Registry Layer](/peios/using-peios/registry/recovering-a-layer.md)
before disabling or removing configuration, and [Removing Registry
Entries](/peios/using-peios/registry/removing-entries.md) before choosing between
withdrawal and masking.

## Separate exchange from exact backup

JSON export and apply provide a reviewable representation of keys and values.
A batch applies within one hive transaction. It is not a cross-hive
transaction. Export does not claim to preserve every security component.

Text export is useful for review, but the text import path is not implemented.
Use the supported JSON document when applying an export. Opaque backup and
restore use a different kernel mechanism and require the corresponding
privileges.

Use [Applying a Registry Batch](/peios/using-peios/registry/applying-a-batch.md) for
related edits and [Backing Up Registry
Configuration](/peios/using-peios/registry/backing-up-configuration.md) for recovery.

## Treat notifications as prompts to reread

A registry watch tells you that relevant state changed. Reread the state
needed by your application; do not treat the notification itself as the
complete new configuration.

For an operator watch, run this in a terminal and read the current values
from another:

```sh
reg watch Machine/System/KMES --subtree --filter value
reg get Machine/System/KMES BufferCapacity -L
```

The watch command remains running until interrupted; the second command is a
separate read. Watch permission does not grant permission to read descendant
values. The command reports changes without decoding every detailed record.

Watches describe effective-state changes, not every hidden layer write.
After overflow, an interruption, restore, or source reconnection, read the
required key or subtree again. A watch follows its opened key object; if a
replacement key takes the same path, reopen the path and arm a new watch.
Uncommitted transaction changes are not consumer notifications.

Operations use the caller's authority. Interactive confirmation protects
against mistakes but is not an access check, and redirected input can change
prompting behavior. `reg(1)` defines types, layers, batch syntax,
confirmation, and status codes.

## Inspect a link rather than its target

Normal opens follow registry links. To inspect a suspected link itself,
replace `KEY` with its path:

```sh
reg info KEY --no-follow
reg get KEY @ --no-follow -L
```

Check the link flag and the winning unnamed target value. A link flag is
fixed at creation; storing `REG_LINK` in an ordinary key does not create a
link. Conversely, a winning value of the wrong type can break resolution of
a flagged link. A target is literal: `CurrentUser` is not expanded inside it.

Targets are layered, so withdrawing a target entry can reveal a different
one. Check both the stored target and the resolved object after repair.
`reg(1)` defines which mutating commands support operating on a link itself;
do not assume every command accepts the inspection options above.

## Diagnose access to a key and a layer

A write needs the key's operation rights and access to its destination
layer. Use `reg sd` for the key's owner, group, and DACL; reading its SACL
needs `ACCESS_SYSTEM_SECURITY`. Values have no separate descriptors.

Inspect layer metadata permissions as well as the target key. Its `Owner`
value is informational, not an authorization grant. Creating or promoting a
layer above precedence zero needs `SeTcbPrivilege`. Merely being a local
administrator does not establish that privilege.

Do not create `Machine\System\Registry\Layers\base` as an exploratory
repair. Without that metadata key, a compiled descriptor allows
Authenticated Users to write into base, subject to target-key access.
Creating the key replaces that fallback with its real descriptor; inherited
read-only grants can unexpectedly prevent personal configuration writes.

A parent's readability does not establish a child's permissions, and LCS
does not apply filesystem-style traverse checks to each path component.
Inheritance applies when a key is created. Editing a parent's descriptor
does not rewrite existing descendants or revoke rights on existing handles.
Reopen the key when testing a changed descriptor. The kernel's
[access flow](/kernel/internals/lcs/security/the-access-flow.md) and
[layer authorization](/kernel/internals/lcs/layers/writing-into-a-layer.md)
references define the checks.

Related content:

- [Finding a Setting's Meaning](/peios/using-peios/registry/regman.md)
- [Registry Editor](/peios/using-peios/registry/registry-editor.md)
