benilla-re systems structs docs

source

System docs

One doc per system of the client: systems/<system>.md. A system that outgrows one doc splits by topic into systems/<system>/<topic>.md, and its rows link to the topic doc. A doc is a reference: it says what the client does, where, and how that was read from the bytes. History is in git; open work is in the issue tracker.

Shape of a doc

# <system>

<Overview>

Roots: `0x……`, `0x……`, …

## <Entry title>
…

Overview

What the system does and where it lives in the exe: its object files as address ranges, the structs and globals it owns, and which of its functions the rest of the client actually reaches. A system owns the functions of its object files (../symbols/README.md). At most 200 words, no addresses beyond what a reader needs to find the code.

Object files

Most object files include a shared maths header whose static initializers store +∞, 2π, 1/2π and a block of constants. The C runtime's initializer table, 0x827000, lists each file's initializers as one contiguous run in link order, and a file that includes the header opens its run with its +∞ copy: the table's first slot, 0x827004, is one, and its last three, from 0x82e024, are +∞, 2π and 1/2π. A run gives the file's initializers, not its extent. The file's code can start before its +∞ thunk, at a lower initializer of the same run or at a function with no initializer, and code past its last initializer can belong to a file with no run. A file without the header or without initializers has no run: it is bounded by the source paths its code passes and by its callers. One stretch of code between two runs can hold several files, as WardenClient.cpp (0x6c9f8e) and FFXEffects.cpp (0x6cbed2) share the stretch after slot 0x82cd78.

A row's system is its object file's, and a row stays unassigned until its file is proved. Four proofs settle it:

Two functions of one system with an unproved function between them settle nothing: the stretch can hold another system's file. The library code the client links is owned by its library (../symbols/README.md, "One row per address"): the community database names the C runtime's functions, and a function that passes a DBFilesClient\ file name is a DBC record file's. cargo xtask census --assign applies the rule to every row that has no system.

Roots

The functions through which anything outside the system enters it:

The closure of a system is every function reachable from its roots by calls, tail jumps, vtable slots and stored addresses, stopping at functions another system owns. Every function in the closure has a row with a class (../symbols/README.md), and every primitive in it has a bit-exact test. That is the definition of a complete system, and no system meets it yet: tests cover a few primitives, and the rest are open work (#87). A function the system owns that nothing live reaches is of class unreached: it keeps a row with its one-line meaning and owes no test. The doc gives the unreached functions one short entry that lists their addresses and the census that shows nothing reaches them.

Entries

One entry per mechanism: a ## heading (the title, at most six words, which is also the anchor rows link to), then this shape:

## State advance

<Claim: what the client does, in one to three sentences, with the inputs it holds for.>

Addresses: `0x4531e0`, `0x802700`
Confidence: verified
Proof: two
Test: none

<Derivation: the path from the bytes to the claim, in a few lines.>

An entry that settles a configuration another entry decided reconciles both in the same change. A correction rewrites the entry; the wrong version stays only in git.

Addresses in prose

An address is written 0x and six lowercase hex digits, in backticks: `0x514ae0`. Struct fields are written +0x14 with the struct named nearby. Every address in a system doc resolves to a row of the table. A pooled constant is cited by value (2π as f32, 0x40c90fdb) unless its address matters. A constant that would read as an address, six hex digits after 0x, is written in decimal or without backticks. A range is written by its first and last function, never by an end address that belongs to no row. A function's end, and the padding bytes after it, are written in backticks as any address is: the check accepts an address that lies less than 16 bytes past the end of the nearest row before it. A Mac client address is written mac: and six lowercase hex digits, in backticks, and resolves to a Mac row (../symbols/README.md, The Mac client); a Mac address is never written with 0x, even inside a quoted instruction.

Rules the check enforces

cargo xtask check enforces these. They apply to every doc under systems/ except this one.

rulevaluewhy
overview200 wordsa reader orients on one screen
entry title6 wordsit is an anchor and must stay stable
claim120 words, a table not counteda longer claim is two mechanisms
table in a claim12 rowsa longer table belongs in the symbol table
derivation200 wordsa derivation cites bytes; a longer one is a pasted dump
quoted instructions8 lines per blockfindings cite the bytes, they do not reproduce the exe
one doc4,000 wordspast that, split by topic
hedgesprobably, likely, seems, appears to, roughly, maybe, should be, TODO, FIXMEa guess is inferred, said once in the Confidence line
shoutingNOTE:, IMPORTANT, WARNING, CORRECTED, VERIFIED, INFERREDemphasis does not make a claim truer
historypreviously, used to, no longer, originally, corrected, was wrongthe doc states the current fact; git holds the past
first personwe, our, Ithe claim is about the client, not the reader
entry shapethe four lines Addresses, Confidence, Proof, Test with valid valuesthe table and the docs share one vocabulary
addressesevery address in a system doc resolves to a row; one in a spec doc (docs/METHOD.md, docs/CONTRIBUTING.md, the READMEs) lies inside the imagea citation without a row cannot be looked up; a spec doc's addresses are examples and pointers
anchorsno two headings in one doc share an anchora link must reach one entry