Files
reverse-engineering-anything/docs/guides/native
Ysopwnableandgensokyo-dev e1b66df5bc feat(native): recover UniFFI library interfaces from exports (#17215)
* feat(native): describe the UniFFI library report and its read budgets

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(native): recover UniFFI interfaces from a library's exports

Group a library's UniFFI scaffolding exports by namespace: objects named
by their free and clone functions with their constructors and methods,
functions, callback interfaces and runtime helpers. The contract version
and each item's checksum are read from function bodies that return only
that constant (x86, x86-64 with or without endbr, arm64), and NAMESPACE
and UDL_FILE metadata buffers are decoded. Nothing is called; a method
that two object names could own is listed under the longer and counted.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(native): read UniFFI libraries through an identity-checked provider

The provider reads one bounded PE or ELF file, maps its export addresses
through the image's own declarations and decodes the UniFFI interface. A
refusal at max_entries, max_text_bytes or max_file_bytes names the budget
to raise.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(analysis): summarize retained UniFFI library reports

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* refactor(analysis): bound the UniFFI summary's namespaces with boundedList

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(native): add the inspect_uniffi_library tool

CLI inspect-uniffi-library and MCP inspect_uniffi_library recover a
UniFFI library's namespaces, objects, methods, functions, callback
interfaces, contract version and checksums from its exports without
loading it. Large reports return the retained per-namespace summary
within the agent budget.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* docs(native): describe UniFFI interface recovery

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* docs(skill): route UniFFI libraries to inspect_uniffi_library

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* ci: scope the UniFFI reader with the native formats

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* chore(schemas): record the advertised inspect_uniffi_library catalog summary

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): keep UniFFI grouping linear and its omissions visible

- Namespaces, metadata owners and object owners are found by looking up
  each underscore-delimited prefix of a name, instead of scanning every
  namespace or object for every export.
- A body or metadata buffer reads the longest mapped prefix, so a constant
  that ends at its mapping's end is still decoded.
- A metadata buffer that cannot be read or decoded is counted apart from
  kinds this reader does not decode, and makes coverage partial.
- A partial export table carries its reasons into the report.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* feat(native): expose max_structure_bytes for UniFFI library inspection

The export reader's table-size limit is now a caller control, and its
refusal names it, as inspect_native_exports does.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(cli): honour delivery options for inspect-uniffi-library

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* docs(native): list the UniFFI structure budget and record its schema

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): match UniFFI namespaces and owners with a prefix trie

Namespaces, metadata owners and object owners are now found by walking
the name once through a trie of the known words, from the positions where
UniFFI spells them. The cost per name grows with its length, not with its
underscore count squared or with the number of known words.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): index UniFFI prefixes by hash instead of a character trie

A character trie allocated a node and a map for every distinct prefix, so
long crafted export names could exhaust the heap before the report's text
checks. The prefix index now keeps one entry per known word, keyed by two
polynomial hashes, and walks each name once computing the hashes of its
underscore-ended prefixes; only the longest matches are compared.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): map UniFFI reads through one index and check namespace shapes

- Constant and metadata reads use one file-mapping index built with the
  image's zero-filled ranges, so each read is a lookup and an ambiguous
  address reads as unknown instead of as definite bytes.
- The ELF container read honours max_structure_bytes, as the export read
  already did.
- 32-bit x86 images, which the shared readers name 386, decode their
  constants.
- A scaffolding symbol belongs to the longest namespace whose remainder
  has a scaffolding shape, so a namespace ending in _fn cannot take
  another namespace's functions.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): carry the export reader's issues into a partial UniFFI report

A partial export table now reports its first issues by code and message,
counting the rest, before falling back to its limitations.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

* fix(native): consider every shaped namespace match for UniFFI symbols

The scaffolding shape after a namespace is now checked while the name is
walked, so every span followed by _fn_ or _checksum_ is a candidate, not
only the longest four matches; only the chosen word is compared.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>

---------

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-12-06 06:30:31 +08:00
..