Skip to content

Remove static mutable state from LibCpp2IL 2: Electric Boogaloo#542

Merged
SamboyCoding merged 1 commit into
SamboyCoding:developmentfrom
Xpl0itR:instanced-state
Jun 7, 2026
Merged

Remove static mutable state from LibCpp2IL 2: Electric Boogaloo#542
SamboyCoding merged 1 commit into
SamboyCoding:developmentfrom
Xpl0itR:instanced-state

Conversation

@Xpl0itR

@Xpl0itR Xpl0itR commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Refactor: Remove Static State

Overview

Eliminated static/global state across the codebase by moving state into LibCpp2IlContext. This enables multiple concurrent analysis sessions and improves testability.

What Changed

Deleted:

  • LibCpp2IlGlobalMapper.cs — static mapper moved to context

Refactored:

  • LibCpp2IlContext now owns all global mapper state (TypeRefs, MethodRefs, FieldRefs, Literals)
  • Legacy static API on LibCpp2IlMain marked [Obsolete] for backwards compatibility
  • 95 files updated to pass context explicitly instead of relying on static state

@coveralls

coveralls commented Apr 9, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 25641285720

Coverage decreased (-0.2%) to 35.104%

Details

  • Coverage decreased (-0.2%) from the base build.
  • Patch coverage: 266 uncovered changes across 45 files (303 of 569 lines covered, 53.25%).
  • 12 coverage regressions across 11 files.

Uncovered Changes

Top 10 Files by Coverage Impact Changed Covered %
Cpp2IL.Core/Il2CppClassUsefulOffsets.cs 23 0 0.0%
LibCpp2IL/LibCpp2IlMain.cs 24 1 4.17%
LibCpp2IL/LibCpp2IlUtils.cs 71 49 69.01%
Cpp2IL.Core/Utils/Arm64Utils.cs 14 0 0.0%
Cpp2IL.Core/Utils/X86Utils.cs 21 8 38.1%
LibCpp2IL/LibCpp2IlContext.cs 50 37 74.0%
LibCpp2IL/Reflection/LibCpp2IlReflection.cs 13 0 0.0%
Cpp2IL.Core/Il2CppApiFunctions/NewArm64KeyFunctionAddresses.cs 12 0 0.0%
Cpp2IL.Core/Il2CppApiFunctions/X86KeyFunctionAddresses.cs 12 0 0.0%
Cpp2IL.Core/Utils/ArmV7Utils.cs 12 0 0.0%

Coverage Regressions

12 previously-covered lines in 11 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
LibCpp2IL/LibCpp2IlUtils.cs 2 47.94%
Cpp2IL.Core/Cpp2IlApi.cs 1 56.41%
Cpp2IL.Core/Il2CppApiFunctions/BaseKeyFunctionAddresses.cs 1 0.0%
Cpp2IL.Core/Il2CppClassUsefulOffsets.cs 1 0.0%
Cpp2IL.Core/Utils/Arm64Utils.cs 1 0.0%
Cpp2IL.Core/Utils/ArmV7Utils.cs 1 0.0%
LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs 1 65.79%
LibCpp2IL/Il2CppBinary.cs 1 79.09%
LibCpp2IL/LibCpp2IlMain.cs 1 23.0%
LibCpp2IL/Metadata/Il2CppEventDefinition.cs 1 54.17%

Coverage Stats

Coverage Status
Relevant Lines: 11171
Covered Lines: 4394
Line Coverage: 39.33%
Relevant Branches: 6693
Covered Branches: 1877
Branch Coverage: 28.04%
Branches in Coverage %: Yes
Coverage Strength: 268486.35 hits per line

💛 - Coveralls

@Xpl0itR Xpl0itR marked this pull request as ready for review April 13, 2026 18:42
@Xpl0itR Xpl0itR force-pushed the instanced-state branch from 32624b1 to d54f7de Compare May 10, 2026 22:12
@Xpl0itR Xpl0itR force-pushed the instanced-state branch from d54f7de to 9249bcb Compare May 10, 2026 22:18
Comment thread Cpp2IL.Core/Cpp2IlApi.cs

ConfigureLib(allowUserToInputAddresses);

#if !DEBUG

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These got dropped, need to bring them back

@SamboyCoding SamboyCoding merged commit 9f6b2f6 into SamboyCoding:development Jun 7, 2026
9 checks passed
@Xpl0itR Xpl0itR deleted the instanced-state branch June 7, 2026 13:49
SamboyCoding added a commit that referenced this pull request Jun 7, 2026
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