Skip to main content

Module container

Module container 

Source
Expand description

The AssetBundle container (files/SerializedFile.py:316-324, classes/generated.py AssetBundle, environment.py:208-226).

A SerializedFile’s container is the m_Container of the first AssetBundle object in dict order, as (path, AssetInfo) pairs in file order, repeated paths kept (the dump’s L1 container rows). Each row points at its asset with asset.m_FileID/m_PathID; preload_index and preload_size index m_PreloadTable, which the environment’s container preload walks (plan section 3.13).

What the load needs. UnityPy’s load reads only m_PreloadTable (kept as it is), and each m_Container item’s key and value.asset.path_id (helpers/ContainerHelper.py:21-29): the asset must be a PPtr (a PPtr<...> node UnityPy could build one from), and nothing else is looked at until the preload or a caller does. So on a hostile tree an AssetInfo that lacks preloadIndex, a key that is not a string, an index of another type, a preload table that is not a list or holds something that is no pointer, all load: a row keeps None for each member UnityPy’s object does not hold as a string or an int (the dump’s null), and the preload raises where UnityPy’s would.

path_dict (helpers/ContainerHelper.py:28, :47, files/ObjectReader.py:199-204): what obj.container answers, through crate::env::Environment::container_path. Its initial entries map each row’s asset path id to the row’s path, the last row of a path id winning (a dict comprehension), keyed as Python compares the key with an object’s int path id (an integer, a bool, an integral float); a row whose asset names another file (m_FileID not 0) keys nothing here (PARITY.md section 19.2: UnityPy keys it by path id alone, in the container’s own file). The container preload then adds, for each object a row’s preload span reaches, the row’s path if the object’s file has none for it yet (setdefault); those entries live in the target file’s container, as UnityPy’s live in the target’s ContainerHelper. Each carries a stamp that orders the preload passes as UnityPy runs them one after another, and the least stamp wins, so two passes that run at once leave what one after the other would.

Memory. The rows and the preload table grow in crate::limits::MeteredVecs on the file’s input meter, and the Container keeps their charge (the AssetBundle’s value, read to get them, is dropped after). The tables are reached by reference only, so they cannot outlive the charge:

ⓘ
fn take(c: unityrs_core::container::Container) -> Box<[unityrs_core::container::ContainerRow]> {
    c.rows
}

Owner: package D. Container’s constructors are the scaffold’s.

Structs§

Container
A file’s container, with the charge for its tables.
ContainerRow
One container row. Each member is what UnityPy’s object holds there: None where it holds no string (the path) or no int (the others: a member the AssetInfo lacks, a bool, a float, a string, a class), which only a hostile tree makes (module docs).

Enums§

ContainerPath
What obj.container answers: the key of the container entry its file’s path_dict holds for its path id.

Functions§

read_container
Reads the container of the first AssetBundle in dict order with check_read. A file without one has an empty container; a failing read is an error (it already failed the file at load under crate::FileContext::eager_asset_bundle).