UnityPy icon indicating copy to clipboard operation
UnityPy copied to clipboard

ManagedReferencesRegistry version 1

Open shimamura-sakura opened this issue 4 months ago • 1 comments

Not handling this results in segfault (with boost on) or "Expected to read xxx bytes, but only read yyy bytes" error (with boost off).

Its typetree from one of my files (int vesion = 1)

ManagedReferencesRegistry references // typeFlag=4 metaFlag=8001
	int version // typeFlag=0 metaFlag=1
	ReferencedObject 00000000 // typeFlag=0 metaFlag=8001
		ReferencedManagedType type // typeFlag=0 metaFlag=208001
			string class // typeFlag=0 metaFlag=208001
				Array Array // typeFlag=1 metaFlag=204001
					int size // typeFlag=0 metaFlag=200001
					char data // typeFlag=0 metaFlag=200001
			string ns // typeFlag=0 metaFlag=208001
				Array Array // typeFlag=1 metaFlag=204001
					int size // typeFlag=0 metaFlag=200001
					char data // typeFlag=0 metaFlag=200001
			string asm // typeFlag=0 metaFlag=208001
				Array Array // typeFlag=1 metaFlag=204001
					int size // typeFlag=0 metaFlag=200001
					char data // typeFlag=0 metaFlag=200001
		ReferencedObjectData data // typeFlag=0 metaFlag=1

Only one ReferencedObject is listed in the tree, however there are more ReferencedObject's after that. Specifically, only stop when you get a ReferencedManagedType of ("Terminus", "UnityEngine.DMAT", "FAKE_ASM"). And in this case, managedRefArrayItem.id seems to be an index into this ReferencedObject array.

See also: https://github.com/Unity-Technologies/UnityDataTools/blob/main/TextDumper/TextDumperTool.cs#L308

shimamura-sakura avatar Sep 19 '25 12:09 shimamura-sakura

Thanks for reporting the issue, and especially so for pointing to that tool - I didn't know that Unity published the source for it by now.

K0lb3 avatar Oct 17 '25 21:10 K0lb3