Skip to content

fix(TypeTreeHelper): handle ManagedReferencesRegistry version 1 - #406

Open
1915rising wants to merge 3 commits into
K0lb3:masterfrom
1915rising:fix/347-registry-version-1
Open

1915rising wants to merge 3 commits into
K0lb3:masterfrom
1915rising:fix/347-registry-version-1

Conversation

@1915rising

Copy link
Copy Markdown

Fixes #347.

A version 1 registry has no count. The data holds ReferencedObjects one after another, ended by one with the type Terminus / UnityEngine.DMAT / FAKE_ASM, which has no data. UnityPy read only the first object, so reading failed with "Expected to read X bytes, but only read Y bytes".

This adds version 1 handling to the Python reader and writer and to the boost reader: read objects until the Terminus type, write them back out with the Terminus at the end. Version 2 goes through the existing code as before.

Repro: built a version 1 registry by hand with two objects plus the Terminus. Before: ValueError, Expected to read 144 bytes, but only read 52 bytes, in both the Python and boost readers. After: both objects read back, and writing gives the same bytes again.

Tests: new tests/test_managed_references_registry.py, 2 passed (version 1 read and write round trip, version 2 read). Full suite: 44 passed / 4 failed before, 46 passed / 4 failed after. The 4 failures are the pre-existing sample data ones in test_extractor and test_mesh_helper.

Comment thread UnityPy/helpers/TypeTreeHelper.py Resolved
Comment thread UnityPy/helpers/TypeTreeHelper.py Resolved
Comment thread UnityPy/helpers/TypeTreeHelper.py Resolved
Comment thread UnityPyBoost/TypeTreeHelper.cpp Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ManagedReferencesRegistry version 1

2 participants