Skip to main content

Module mutate

Module mutate 

Source
Expand description

G3b’s seeded mutator (plan section 6): every builder output, mutated by three operators, and both dumpers read every mutant.

  • Fields. Every field the build of an output writes into it (each 4- and 8-byte integer, crate::writer: every count, length, size and offset, zero-valued ones included, and every other integer of those widths) becomes two mutants: the field set negative (-1 or the type’s minimum) and set huge (the type’s maximum, or 2^30 or 2^40). The output is built again with that one field replaced as it is written (crate::writer::with_fields), so a field inside a compressed block, or in a file a bundle holds, is changed before the block is compressed and the bundle’s sizes are computed. A field belongs to the outputs whose bytes change when it alone is replaced; one that changes no output (a build kept only for its length) is no output’s.
  • Bit flips. One to eight random bits.
  • Truncation. The input cut at a random length below its own.

Each output’s field mutants come first, in write order, then RANDOM_PER_INPUT mutants alternate bit flips and truncations. Each output’s generator is SEED mixed with the FNV-1a hash of its name, and picks each field’s value from its pair; a mutant’s label says what was done (f<field>.<le|be><4|8><n|h>, the field’s number among the output’s own, b<bits>, t<length>). The mutants depend only on the builders’ code, never on how many threads made them.

Structs§

Mutant
One mutant: what was done, and the bytes.

Constants§

RANDOM_PER_INPUT
Bit flips and truncations per output, after its field mutants.
SEED
The master seed (recorded in the gate’s report).

Functions§

builder_outputs
G3b’s inputs: every builder output the gate mutates, (name, bytes): the format matrix (crate::bundle::matrix) and every file of every Environment scene, those some of whose loads are dependencies, those find_file is recorded on and those whose walk races another load (its file among the scene’s) included (crate::env::scenes, crate::env::dependency_scenes, crate::env::find_scenes, crate::env::race_scenes; named scene-<scene>-<file>), but a WebFile (is_web_file): P1 refuses one (plan section 1), so the dump writes no record of the entries UnityPy reads from it.
gate_mutants
G3b’s mutants: mutants_of the builder_outputs.
is_web_file
Whether bytes are a WebFile by UnityPy’s detection: a signature that starts UnityWebData or TuanjieWebData (docs/CANONICAL_DUMP.md section 4.2, l0’s rule 4).
mutants_of
Every output of build with its mutants (module docs), the work spread over threads threads. build must give the same outputs, under names that do not repeat, each time it runs.

Type Aliases§

Outputs
Named outputs, in build order.