Skip to content

Fix metadata version not populated, breaking all past versions#515

Merged
SamboyCoding merged 1 commit intoSamboyCoding:developmentfrom
ViRb3:development
Feb 14, 2026
Merged

Fix metadata version not populated, breaking all past versions#515
SamboyCoding merged 1 commit intoSamboyCoding:developmentfrom
ViRb3:development

Conversation

@ViRb3
Copy link
Contributor

@ViRb3 ViRb3 commented Feb 14, 2026

I noticed a regression in CPP2IL 2022.1.0 #20 where it can't find the codereg address for my Nintendo Switch binary with Unity 2019.4.27, while the previous milestone 2022.1.0 #19 did.

I further narrowed down the regression to AssetRipper/AssetRipper@1.1.8...1.1.9.

When I diffed the code, I came across this issue:

Commit c91170a changed ReadableClass version checking from using the global static LibCpp2IlMain.MetadataVersion to using an instance property MetadataVersion. The instance property is set from the binary reader's MetadataVersion when the struct is created in InternalReadReadableClass<T>().

However, Il2CppBinary._metadataVersion is only set in Init(), which runs after FindCodeAndMetadataReg(). So during code registration search, the binary's MetadataVersion is 0 (default), causing all version-gated fields to be read incorrectly. This likely breaks all past (non-current) metadata versions.

To fix, I added the missing setter call, and reworked FindCodeAndMetadataReg() to raise an exception in case this ever happens again.

@ds5678 tagging for visibility as this probably has a pretty big impact on AssetRipper.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 22017229224

Details

  • 4 of 5 (80.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.008%) to 34.379%

Changes Missing Coverage Covered Lines Changed/Added Lines %
LibCpp2IL/Il2CppBinary.cs 3 4 75.0%
Totals Coverage Status
Change from base Build 21104268457: 0.008%
Covered Lines: 4211
Relevant Lines: 10902

💛 - Coveralls

@SamboyCoding SamboyCoding merged commit 07cc02c into SamboyCoding:development Feb 14, 2026
9 checks passed
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.

3 participants