Skip to main content

Module provider

Module provider 

Source
Expand description

Typetree providers for stripped files, keyed by (class, version).

UnityPy’s order (files/ObjectReader.py:285-307): an explicit nodes= tree; else the type record’s own tree; else the class tree for (class_id, version) from the TPK (helpers/Tpk.py:42-55), and, only for that TPK tree (generate_monobehaviour_node is called inside if not node:, ObjectReader.py:296-304), the script generator’s tree when its root is MonoBehaviour and the generator answers. An embedded or explicit MonoBehaviour tree is never replaced. Only a ValueError is swallowed there; the script lookup dereferences m_Script through the Environment, so it lives in crate::env::Environment::object_tree, and runs only when a provider TypeTreeProvider::accepts_scripts. The cache key is the class and the packed version integer, as UnityPy’s CLASSES_CACHE is (Tpk.py:16, :44): rabex keys by class alone, so the first version to ask fixes a class’s tree for every later version (docs/spikes/rabex.md section 5). The TPK itself is not here: unityrs-tpk (package A) loads one from a path and implements TypeTreeProvider. With no provider, a stripped object is no_typetree. Where no provider has a class’s tree, which of UnityPy’s exceptions that is (NoTree: the TPK’s KeyError, ValueError or AssertionError, or the comparison’s NotImplementedError for a file with no version) is ProviderChain::why_none’s answer (review round 11: nothing public told them apart, and a binding must raise UnityPy’s). The cache. ProviderChain caches answers only, as UnityPy does (Tpk.py:42-54 raises before CLASSES_CACHE[key] = node on a miss): a miss is asked again next time, so input-chosen keys that find nothing leave nothing behind. The key’s class and version are still the input’s choice, and one context’s chain outlives every input it reads, so the cache is bounded in entries and bytes (ProviderChain::with_cache_bound); when full it stops adding, which changes no answer. A lookup reads the cache with a key borrowed from the request, so a hit (or a miss) copies nothing, however long the request’s script names are. An answer is kept only when the cache has room for it, and that is decided from the borrowed request (its key’s size, whether it is already cached, whether the cache is full) before anything is copied: only an answer that is kept copies its key’s strings, so a key over the byte bound, or any key once the cache is full, costs no copy, a cached key never keeps an input’s buffer alive, and the copies count against the cache’s byte bound. Each entry is counted at four buckets of the table, which covers the table at rest and while it doubles (limits::HASH_TABLE_SHARES). A provider is caller code: the chain calls it with no lock held, so a provider may itself call ProviderChain::lookup.

Modules§

generator
External script schemas, not an IL2CPP/Mono generator. Callers decode their own TypeTreeGeneratorAPI or Il2CppDumper output, normalize its rows with generator_node_list, compile during registration, and supply the trees. No dump, generated schema, or native generator is bundled with the library.

Structs§

ProviderChain
Providers in order, with a bounded cache of their answers keyed by (class, packed version, script) (module docs).
ProviderError
A provider failure.
PythonException
A generator exception preserved for a dynamic-language boundary. Classification is supplied separately from its name: custom subclasses of ValueError follow the same fallback as ValueError itself.
ScriptIdent
A MonoBehaviour’s script, for script-tree providers.
TreeRef
A resolved tree.
TreeRequest
What a provider is asked for.

Enums§

NoTree
Why no tree answers a class: the exception UnityPy raises there, the TPK’s (helpers/Tpk.py:42-55, :58-64, :472-481), which a binding raises where the core reports no tree (crate::walk::ParseError::NoTypeTree).
TreeSource
Where an object’s tree came from.

Traits§

TypeTreeProvider
A source of class (or script) trees.