light refactor of binary and metadata initialization#533
Open
Xpl0itR wants to merge 1 commit intoSamboyCoding:developmentfrom
Open
light refactor of binary and metadata initialization#533Xpl0itR wants to merge 1 commit intoSamboyCoding:developmentfrom
Xpl0itR wants to merge 1 commit intoSamboyCoding:developmentfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors LibCpp2IL initialization to split metadata and binary initialization steps, aiming to provide callers finer-grained control over the init process.
Changes:
- Added
LibCpp2IlMain.InitializeMetadata(...)andLibCpp2IlMain.Initialize(Il2CppMetadata, Il2CppBinary)to separate initialization phases. - Made
LibCpp2IlBinaryRegistry.CreateAndInit(...)public and moved “find regs + init” orchestration intoIl2CppBinary.Init(Il2CppMetadata). - Exposed PE image base/sections via public members and updated tests to call
LibCpp2IlMain.Reset().
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| LibCpp2ILTests/Tests.cs | Ensures test runs reset LibCpp2IL state before initialization. |
| LibCpp2IL/PE/PE.cs | Renames/exposes PE section headers and image base for external access. |
| LibCpp2IL/LibCpp2IlMain.cs | Splits init into metadata init + binary init + post-init mapping/caches. |
| LibCpp2IL/LibCpp2IlBinaryRegistry.cs | Makes binary creation/init publicly callable and delegates init to Il2CppBinary. |
| LibCpp2IL/Il2CppBinary.cs | Adds a convenience Init(Il2CppMetadata) wrapper around reg discovery + initialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
LibCpp2IL/PE/PE.cs
Outdated
| internal readonly SectionHeader[] peSectionHeaders; //Internal for the one use in PlusSearch | ||
| internal readonly ulong peImageBase; //Internal for the one use in PlusSearch | ||
| public readonly SectionHeader[] PeSectionHeaders; | ||
| public ulong PeImageBase; |
LibCpp2IL/LibCpp2IlBinaryRegistry.cs
Outdated
Comment on lines
52
to
70
| @@ -64,22 +64,9 @@ internal static Il2CppBinary CreateAndInit(byte[] buffer, Il2CppMetadata metadat | |||
| var memStream = new MemoryStream(buffer, 0, buffer.Length, true, true); | |||
|
|
|||
| LibLogger.InfoNewline("Searching Binary for Required Data..."); | |||
| var start = DateTime.Now; | |||
|
|
|||
| var binary = match.FactoryFunc(memStream); | |||
| binary.SetMetadataVersion(metadata.MetadataVersion); | |||
|
|
|||
| LibCpp2IlMain.Binary = binary; | |||
|
|
|||
| var (codereg, metareg) = binary.FindCodeAndMetadataReg(metadata); | |||
|
|
|||
| LibLogger.InfoNewline($"Got Binary codereg: 0x{codereg:X}, metareg: 0x{metareg:X} in {(DateTime.Now - start).TotalMilliseconds:F0}ms."); | |||
| LibLogger.InfoNewline("Initializing Binary..."); | |||
| start = DateTime.Now; | |||
|
|
|||
| binary.Init(codereg, metareg, metadata); | |||
|
|
|||
| LibLogger.InfoNewline($"Initialized Binary in {(DateTime.Now - start).TotalMilliseconds:F0}ms"); | |||
|
|
|||
| var binary = LibCpp2IlMain.Binary = match.FactoryFunc(memStream); | |||
| binary.Init(metadata); | |||
|
|
|||
LibCpp2IL/LibCpp2IlMain.cs
Outdated
Comment on lines
175
to
204
| @@ -187,8 +201,6 @@ public static bool Initialize(byte[] binaryBytes, byte[] metadataBytes, UnityVer | |||
| } | |||
|
|
|||
| LibCpp2IlReflection.InitCaches(); | |||
|
|
|||
| return true; | |||
| } | |||
Owner
|
Rebase and fix conflicts, also some of this copilot feedback seems valid, there's some footguns introduced here. |
Pull Request Test Coverage Report for Build 23216409431Details
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For the purpose of having greater control over the init process