Skip to main content

Module raw

Module raw 

Source
Expand description

Raw strings: the bytes UnityPy holds as a str decoded with surrogateescape.

Every string unityrs reads from a file is kept as bytes, never as String: UnityPy decodes with surrogateescape (streams/EndianBinaryReader.py:144, :282), so its str can hold any bytes, and the canonical dump writes a name that is not valid UTF-8 as hex (docs/CANONICAL_DUMP.md section 4.2).

Zero-copy. An input RawStr borrows Bytes: a string read from a file is a slice of the file’s buffer (RawStr::from_shared), never a copy, so a typetree’s node names (each row naming an offset in one string buffer), metadata strings and Value::Str cost a handle each, whatever their length and however often a hostile file repeats them (plan section 3.15). Common strings are static. Only strings the core computes (a decimal common-string offset, py_lower, a registry key) allocate, and each is made with RawStr::charged, which charges the input’s meter for its buffer and its owner record and keeps the charge inside the buffer, so a clone of it that outlives its row still counts against the input.

Owner: the scaffold (implemented). Python string semantics on top of these bytes (str.lower, ntpath) are in crate::pystr.

Structs§

RawStr
Bytes UnityPy holds as a str. Valid UTF-8 or not; computed strings use fallible shared storage, while input strings borrow their Bytes.