Skip to content

Add support for versions v35-v39#903

Open
roytu wants to merge 3 commits into
Perfare:masterfrom
roytu:v39
Open

Add support for versions v35-v39#903
roytu wants to merge 3 commits into
Perfare:masterfrom
roytu:v39

Conversation

@roytu
Copy link
Copy Markdown

@roytu roytu commented Feb 26, 2026

This is mostly working except for DummyAssemblyGenerator.cs, where custom attribute-related code is disabled. I also make some assumptions in StructGenerator.cs regarding how IL2CPP_TYPE_VAR and IL2CPP_TYPE_MVAR are treated.

Version 35

Metadata changes:

  • [REMOVED] Il2CppTypeDefinition.elementTypeIndex
  • [REMOVED] Il2CppStringLiteral.length

Version 38

Metadata changes:

  • [REMOVED] Metadata.interfaceIndices replaced with interfaceOffsetPairs
  • [CHANGED] Metadata.constraintIndices is a uint16_t, not a uint32_t

Instead of having separate offset/size fields in Metadata, we now have Il2CppSectionMetadata objects which hold an offset/size/count triplet. Additionally, this version introduced three variable-sized types:

  • TypeIndex
  • TypeDefinitionIndex
  • GenericContainerIndex

which can be 1, 2, or 4 bytes depending on the number of each object type we need to store.

Version 39

Introduced ParamIndex. No other changes.

@roytu
Copy link
Copy Markdown
Author

roytu commented Feb 26, 2026

#887 #891 #892 #894 #898 #900

Mentioning issues where this may be relevant.

@Madiha1441nora
Copy link
Copy Markdown

I just tested your fork, got this error :

Initializing metadata...
Metadata Version: 39
Initializing il2cpp file...
Il2Cpp Version: 39
Searching...
CodeRegistration : x
MetadataRegistration : x
Dumping...
Done!
Generate struct...
Done!
Generate dummy dll...
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Il2CppDumper.DummyAssemblyGenerator.CreateGenericParameter(Il2CppGenericParameter param, IGenericParameterProvider iGenericParameterProvider) in C:\Users\x\Desktop\Il2CppDumper-39\Il2CppDumper\Utils\DummyAssemblyGenerator.cs:line 655
at Il2CppDumper.DummyAssemblyGenerator..ctor(Il2CppExecutor il2CppExecutor, Boolean addToken) in C:\Users\x\Desktop\Il2CppDumper-39\Il2CppDumper\Utils\DummyAssemblyGenerator.cs:line 139
at Il2CppDumper.DummyAssemblyExporter.Export(Il2CppExecutor il2CppExecutor, String outputDir, Boolean addToken) in C:\Users\x\Desktop\Il2CppDumper-39\Il2CppDumper\Outputs\DummyAssemblyExporter.cs:line 14
at Il2CppDumper.Program.Dump(Metadata metadata, Il2Cpp il2Cpp, String outputDir) in C:\Users\x\Desktop\Il2CppDumper-39\Il2CppDumper\Program.cs:line 271
at Il2CppDumper.Program.Main(String[] args) in C:\Users\x\Desktop\Il2CppDumper-39\Il2CppDumper\Program.cs:line 99

I can send you the game assembly + metadata, do you have Discord ?

@roytu
Copy link
Copy Markdown
Author

roytu commented Feb 28, 2026

Hey @Madiha1441nora , thanks for testing. I actually managed to recreate the bug with another sample, I pushed a fix.

The critical change is that constraintIndices was also changed to be a TypeIndex instead of an int32_t, so we deserialize it as such below:

constraintIndices = Version < 38
    ? ReadMetadataClassArray<Il2CppConstraintIndex>(header.genericParameterConstraintsOffset, header.genericParameterConstraintsSize)
   : ReadMetadataClassArray<Il2CppConstraintIndex>(header.genericParameterConstraints.offset, (int)header.genericParameterConstraints.size);

This fixed my sample, let me know if it fixes yours.

@Zepp7289
Copy link
Copy Markdown

Zepp7289 commented Mar 2, 2026

could you please provide prebuilt binary in your fork, thx

@danielhm96
Copy link
Copy Markdown

is this work fine and can do it automatic ?

@bsskk7
Copy link
Copy Markdown

bsskk7 commented Mar 8, 2026

saved my day, tysm

@qaqFei
Copy link
Copy Markdown

qaqFei commented Mar 9, 2026

image

unitypy cannot read typetree using the dummydll
libil2cpp.zip
global-metadata.zip

metadata wasn't protected

@ghostwwwwrr
Copy link
Copy Markdown

how 2 run?

@johmarjac
Copy link
Copy Markdown

Awesome it worked
i hope @Perfare will merge at some point

@Cheve-Chelios
Copy link
Copy Markdown

Thank you very much! Very helpful! It's working!

@johmarjac
Copy link
Copy Markdown

@roytu Can you check whether Enums get disassembled correctly? Idk if its the game that changed a specific enum to be a class now, but before it switched to a later unity version now with v39 dumper the same enum is now put as a class in the dummy dll, missing the values of each enum member ... :(

@vjshah7
Copy link
Copy Markdown

vjshah7 commented May 4, 2026

this change worked great for me, appreciate your work!

@govno2222
Copy link
Copy Markdown

Initializing metadata...
System.ArgumentOutOfRangeException: Stream length must be non-negative and less than 2^31 - 1 - origin. (Parameter 'value')
at System.IO.MemoryStream.set_Position(Int64 value)
at Il2CppDumper.BinaryStream.set_Position(UInt64 value) in C:\Users\niley\Downloads\Il2CppDumper-39\Il2CppDumper-39\Il2CppDumper\IO\BinaryStream.cs:line 89
at Il2CppDumper.BinaryStream.ReadClassArray[T](UInt64 addr, Int64 count) in C:\Users\niley\Downloads\Il2CppDumper-39\Il2CppDumper-39\Il2CppDumper\IO\BinaryStream.cs:line 360
at Il2CppDumper.Metadata.ReadMetadataClassArray[T](UInt32 addr, Int32 count) in C:\Users\niley\Downloads\Il2CppDumper-39\Il2CppDumper-39\Il2CppDumper\Il2Cpp\Metadata.cs:line 247
at Il2CppDumper.Metadata..ctor(Stream stream) in C:\Users\niley\Downloads\Il2CppDumper-39\Il2CppDumper-39\Il2CppDumper\Il2Cpp\Metadata.cs:line 117
at Il2CppDumper.Program.Init(String il2cppPath, String metadataPath, Metadata& metadata, Il2Cpp& il2Cpp) in C:\Users\niley\Downloads\Il2CppDumper-39\Il2CppDumper-39\Il2CppDumper\Program.cs:line 123
at Il2CppDumper.Program.Main(String[] args) in C:\Users\niley\Downloads\Il2CppDumper-39\Il2CppDumper-39\Il2CppDumper\Program.cs:line 97
Press any key to exit...

#global-metadata.dat

#libil2cpp.so

lxraa added a commit to lxraa/Il2CppDumper that referenced this pull request May 20, 2026
Cherry-picks from roytu/Il2CppDumper:v39 (Perfare PR Perfare#903, unmerged upstream).
Adds parser support for global-metadata.dat versions 32 through 39, including
Unity 6000 family. Source PR is mergeable-clean against upstream master
(4741d46, last upstream commit 2024-07-06).

Adopted in lxraa fork because upstream Il2CppDumper has been inactive since
2024-08; PR sat unreviewed for >2 months. Verified locally as part of the
reverse-engineering pipeline (Il2CppDumper consumer in stage5 unity handler).
lxraa added a commit to lxraa/Il2CppDumper that referenced this pull request May 20, 2026
…sion)

PR Perfare#903 conflated the `interfaces` and `interfaceOffsets` metadata
sections, reading the per-type flat TypeIndex[] as if it were a
VTable-style InterfaceOffsetPair[]. It also dropped the
`+ typeDef.interfacesStart` offset, so every type read interfaces from
global index 0.

Restore upstream Perfare/master behaviour:
- Re-introduce Metadata.interfaceIndices as flat int[].
- v38+: ReadClassArray<TypeIndex> using Metadata.typeIndexSize, cast
  to int[] (PR's variable-width TypeIndex still respected).
- DummyAssemblyGenerator + Il2CppDecompiler: use
  interfaceIndices[typeDef.interfacesStart + i].

Empirically reverted-fix: on com.Garawell.BridgeRace (v31),
System.String previously emitted as `String : IDisposable,
SmallXmlParser.IContentHandler, …` — should now produce the correct
`String : IComparable, IEnumerable, IEnumerable<char>, IComparable<string>,
IEquatable<string>, IConvertible, ICloneable`.
lxraa added a commit to lxraa/Il2CppDumper that referenced this pull request May 20, 2026
PR Perfare#903 commented out the entire third pass of
DummyAssemblyGenerator.GenerateAssemblies (lines 384-447 in the merge)
that writes CustomAttributes to type/field/method/parameter/property/
event entries on the generated DummyDll .dll files. Without it, dnSpy/
ILSpy/UABE consumers see no attributes.

The block is uncommented as-is; CreateCustomAttribute and the
VisitCustomAttributeData iterator API both still exist with compatible
signatures, and customAttributeIndex (Max=24) being default-0 for v25+
is handled inside GetCustomAttributeIndex via token-based lookup.

The companion Il2CppDecompiler dump.cs attribute path was unaffected
(uses GetStringCustomAttributeData() - different code path).
Copy link
Copy Markdown

@alshauzbek alshauzbek left a comment

Choose a reason for hiding this comment

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

топчик

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.