Expand description
SerializedFile metadata (files/SerializedFile.py:206-360,
files/ObjectReader.py:67-130), ported from UnityPy, bytes-native.
Rules ported exactly (plan section 3.7):
- the header (
SerializedFile.py:255-269): the endian byte at offset 16 from format 9, else atfile_size - metadata_size(absolute); the format-22 fields replace the legacyu32s; - gates (
SerializedFile.py:271-288): the version string from format 7, the target platform from 8,enable_type_treefrom 13 (else true),big_id_enabledat 7-13; - type records (
SerializedFile.py:112-149):is_stripped_typefrom 16,script_type_indexfrom 17 (else -1),script_idandold_type_hashfrom 13 under UnityPy’s condition, trees only whenenable_type_tree, blobs at format 10 and 12 and up; at 21 ref types read three names and plain types a dependency list; - objects (
ObjectReader.py:73-130): path id asi64under bigID,i32below 14, else alignedi64;byte_startu32(ori64from 22) plusdata_offset; below 16 the type is the first whoseclass_idequals the object’stype_id, from 16types[type_id]with Python indexing (a negative id counts from the end; out of range fails the file); at 11-16 the object’s script index is written back into its type, the last object winning; theobjectsdict keeps a repeated path id at its first position with its last entry; read_string_to_null’s 32,767-byte window for every metadata string;- the reader UnityPy reads the file with (
crate::stream::ReaderKind): the memory reader for bytes and every entry of a container, the stream reader for a file loaded from a path, whose rules the metadata’s reads and every object read follow (SerializedFile::reader_kind); - every table is built with
range(count)(SerializedFile.py:282-308): a negative count is zero records, and a table grows record by record, so no count sizes an allocation; - with
FileContext::eager_asset_bundle, the first AssetBundle in dict order is read at load withcheck_read, and a failure fails the file (SerializedFile.py:316-324). UnityPy reads it in object mode (parse_as_object); the core reads it in dict mode, and package D’s fixtures pin that the two agree (plan section 3.7).
Memory. Every table (types, their dependency lists and trees, objects,
the dict order, scripts, externals, ref types) is built in a
crate::limits::MeteredVec on the input’s meter, and the file keeps the
charges: two directory rows over the same bytes parse twice and pay twice.
Strings are zero-copy slices of the file.
Work. The container read (SerializedFile::container) builds the
whole AssetBundle value and keeps only its rows and preload table, so
two directory rows over the same bytes would repeat a read whose memory
is returned: what the meter granted the read on its own thread, beyond
what its Container keeps, counts as the open’s work
(crate::error::LimitKind::DecodeWork), and so does all it was
granted when it fails with an error its cell keeps. At load, a failure
fails the parse, whose grants its bundle counts instead
(files::bundle, “Memory and work”), so they count once (round 5).
Owner: package C. The accessors and SerializedType’s constructors and
SerializedType::tree are implemented by the scaffold, so package B can
build ref types for its tests before C lands.
Structs§
- External
- One external file reference.
- Object
Info - One row of the object table.
- Script
Ref - One script type reference (
LocalSerializedObjectIdentifier). - Serialized
File - A parsed
SerializedFile: metadata and object table. Values are read on demand throughObjectRef. - Serialized
Header - The header, as read.
- Serialized
Save Snapshot - Caller-owned metadata and object payload snapshot. All retained storage must be charged by the caller before constructing it. Object rows are emitted in supplied order, including repeated path ids; dictionary keys are irrelevant.
- Serialized
Type - A type record (
SerializedType), plain or ref type. NotClone: it lives in its file’s table, which paid for it.