diff --git a/Il2CppDumper/Il2CppCSharpDumper.cs b/Il2CppDumper/Il2CppCSharpDumper.cs index 89507ba..f38645b 100644 --- a/Il2CppDumper/Il2CppCSharpDumper.cs +++ b/Il2CppDumper/Il2CppCSharpDumper.cs @@ -33,7 +33,7 @@ namespace Il2CppInspector public void WriteFile(string outFile) { using (writer = new StreamWriter(new FileStream(outFile, FileMode.Create), Encoding.UTF8)) { foreach (var asm in model.Assemblies) { - writer.Write($"// Image {asm.Index}: {asm.FullName} - {asm.Definition.typeStart}\n"); + writer.Write($"// Image {asm.Index}: {asm.FullName} - {asm.ImageDefinition.typeStart}\n"); // Assembly-level attributes writer.Write(asm.CustomAttributes.ToString(attributePrefix: "assembly: ")); diff --git a/Il2CppInspector/Il2CppInspector.cs b/Il2CppInspector/Il2CppInspector.cs index 08c746a..baecff0 100644 --- a/Il2CppInspector/Il2CppInspector.cs +++ b/Il2CppInspector/Il2CppInspector.cs @@ -24,6 +24,7 @@ namespace Il2CppInspector public Dictionary Strings => Metadata.Strings; public Il2CppTypeDefinition[] TypeDefinitions => Metadata.Types; + public Il2CppAssemblyDefinition[] Assemblies => Metadata.Assemblies; public Il2CppImageDefinition[] Images => Metadata.Images; public Il2CppMethodDefinition[] Methods => Metadata.Methods; public Il2CppParameterDefinition[] Params => Metadata.Params; diff --git a/Il2CppInspector/Il2CppModel.cs b/Il2CppInspector/Il2CppModel.cs index 3034355..75e7301 100644 --- a/Il2CppInspector/Il2CppModel.cs +++ b/Il2CppInspector/Il2CppModel.cs @@ -113,7 +113,7 @@ namespace Il2CppInspector.Reflection if (Package.Version <= 24.0) return customAttributeIndex; - var image = asm.Definition; + var image = asm.ImageDefinition; var imageRange = image.customAttributeStart..(int)(image.customAttributeStart + image.customAttributeCount); // From v24.1 onwards, token was added to Il2CppCustomAttributeTypeRange and each Il2CppImageDefinition noted the CustomAttributeTypeRanges for the image diff --git a/Il2CppInspector/Reflection/Assembly.cs b/Il2CppInspector/Reflection/Assembly.cs index ca43205..5b1c431 100644 --- a/Il2CppInspector/Reflection/Assembly.cs +++ b/Il2CppInspector/Reflection/Assembly.cs @@ -13,8 +13,9 @@ namespace Il2CppInspector.Reflection { { // IL2CPP-specific data public Il2CppModel Model { get; } - public Il2CppImageDefinition Definition { get; } - public Il2CppCodeGenModule Module { get; } + public Il2CppImageDefinition ImageDefinition { get; } + public Il2CppAssemblyDefinition AssemblyDefinition { get; } + public Il2CppCodeGenModule ModuleDefinition { get; } public int Index { get; } // Custom attributes for this assembly @@ -35,19 +36,24 @@ namespace Il2CppInspector.Reflection { // Initialize from specified assembly index in package public Assembly(Il2CppModel model, int imageIndex) { Model = model; - Definition = Model.Package.Images[imageIndex]; - Index = Definition.assemblyIndex; - FullName = Model.Package.Strings[Definition.nameIndex]; + ImageDefinition = Model.Package.Images[imageIndex]; + AssemblyDefinition = Model.Package.Assemblies[ImageDefinition.assemblyIndex]; - if (Definition.entryPointIndex != -1) { + if (AssemblyDefinition.imageIndex != imageIndex) + throw new InvalidOperationException("Assembly/image index mismatch"); + + Index = ImageDefinition.assemblyIndex; + FullName = Model.Package.Strings[ImageDefinition.nameIndex]; + + if (ImageDefinition.entryPointIndex != -1) { // TODO: Generate EntryPoint method from entryPointIndex } // Find corresponding module (we'll need this for method pointers) - Module = Model.Package.Modules?[FullName]; + ModuleDefinition = Model.Package.Modules?[FullName]; // Generate types in DefinedTypes from typeStart to typeStart+typeCount-1 - for (var t = Definition.typeStart; t < Definition.typeStart + Definition.typeCount; t++) { + for (var t = ImageDefinition.typeStart; t < ImageDefinition.typeStart + ImageDefinition.typeCount; t++) { var type = new TypeInfo(t, this); // Don't add empty module definitions diff --git a/Il2CppInspector/Reflection/MethodBase.cs b/Il2CppInspector/Reflection/MethodBase.cs index 80f6d52..73df973 100644 --- a/Il2CppInspector/Reflection/MethodBase.cs +++ b/Il2CppInspector/Reflection/MethodBase.cs @@ -61,7 +61,7 @@ namespace Il2CppInspector.Reflection Name = pkg.Strings[Definition.nameIndex]; // Find method pointer - VirtualAddress = pkg.GetMethodPointer(Assembly.Module, Definition); + VirtualAddress = pkg.GetMethodPointer(Assembly.ModuleDefinition, Definition); // Add to global method definition list Assembly.Model.MethodsByDefinitionIndex[Index] = this;