diff --git a/Il2CppDumper/Il2Cpp/Metadata.cs b/Il2CppDumper/Il2Cpp/Metadata.cs index 53c9b96..3ed4fe7 100644 --- a/Il2CppDumper/Il2Cpp/Metadata.cs +++ b/Il2CppDumper/Il2Cpp/Metadata.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; using System.Text; namespace Il2CppDumper @@ -10,6 +11,7 @@ namespace Il2CppDumper { public Il2CppGlobalMetadataHeader header; public Il2CppImageDefinition[] imageDefs; + public Il2CppAssemblyDefinition[] assemblyDefs; public Il2CppTypeDefinition[] typeDefs; public Il2CppMethodDefinition[] methodDefs; public Il2CppParameterDefinition[] parameterDefs; @@ -73,6 +75,7 @@ namespace Il2CppDumper { Version = 24.4; } + assemblyDefs = ReadMetadataClassArray(header.assembliesOffset, header.assembliesCount); typeDefs = ReadMetadataClassArray(header.typeDefinitionsOffset, header.typeDefinitionsCount); methodDefs = ReadMetadataClassArray(header.methodsOffset, header.methodsCount); parameterDefs = ReadMetadataClassArray(header.parametersOffset, header.parametersCount); @@ -238,6 +241,11 @@ namespace Il2CppDumper var e = fieldType.GetField("value__").FieldType; size += GetPrimitiveTypeSize(e.Name); } + else if (fieldType.IsArray) + { + var arrayLengthAttribute = i.GetCustomAttribute(); + size += arrayLengthAttribute.Length; + } else { size += SizeOf(fieldType); diff --git a/Il2CppDumper/Il2Cpp/MetadataClass.cs b/Il2CppDumper/Il2Cpp/MetadataClass.cs index f5e57f6..8985061 100644 --- a/Il2CppDumper/Il2Cpp/MetadataClass.cs +++ b/Il2CppDumper/Il2Cpp/MetadataClass.cs @@ -52,7 +52,7 @@ namespace Il2CppDumper public int rgctxEntriesCount; public uint imagesOffset; // Il2CppImageDefinition public int imagesCount; - public int assembliesOffset; // Il2CppAssemblyDefinition + public uint assembliesOffset; // Il2CppAssemblyDefinition public int assembliesCount; [Version(Min = 19, Max = 24.5)] public uint metadataUsageListsOffset; // Il2CppMetadataUsageList @@ -100,6 +100,38 @@ namespace Il2CppDumper public int exportedTypeDefinitionsCount; } + public class Il2CppAssemblyDefinition + { + public int imageIndex; + [Version(Min = 24.1)] + public uint token; + [Version(Max = 24)] + public int customAttributeIndex; + [Version(Min = 20)] + public int referencedAssemblyStart; + [Version(Min = 20)] + public int referencedAssemblyCount; + public Il2CppAssemblyNameDefinition aname; + } + + public class Il2CppAssemblyNameDefinition + { + public uint nameIndex; + public uint cultureIndex; + [Version(Max = 24.3)] + public int hashValueIndex; + public uint publicKeyIndex; + public uint hash_alg; + public int hash_len; + public uint flags; + public int major; + public int minor; + public int build; + public int revision; + [ArrayLength(Length = 8)] + public byte[] public_key_token; + } + public class Il2CppImageDefinition { public uint nameIndex; diff --git a/Il2CppDumper/Utils/DummyAssemblyGenerator.cs b/Il2CppDumper/Utils/DummyAssemblyGenerator.cs index 7560ad3..8c5474a 100644 --- a/Il2CppDumper/Utils/DummyAssemblyGenerator.cs +++ b/Il2CppDumper/Utils/DummyAssemblyGenerator.cs @@ -54,8 +54,15 @@ namespace Il2CppDumper foreach (var imageDef in metadata.imageDefs) { var imageName = metadata.GetStringFromIndex(imageDef.nameIndex); - var assemblyName = new AssemblyNameDefinition(imageName.Replace(".dll", ""), new Version("3.7.1.6")); - var assemblyDefinition = AssemblyDefinition.CreateAssembly(assemblyName, imageName, moduleParameters); + var aname = metadata.assemblyDefs[imageDef.assemblyIndex].aname; + var assemblyName = metadata.GetStringFromIndex(aname.nameIndex); + var assemblyNameDef = new AssemblyNameDefinition(assemblyName, new Version(aname.major, aname.minor, aname.build, aname.revision)); + /*assemblyNameDef.Culture = metadata.GetStringFromIndex(aname.cultureIndex); + assemblyNameDef.PublicKey = Encoding.UTF8.GetBytes(metadata.GetStringFromIndex(aname.publicKeyIndex)); + assemblyNameDef.HashAlgorithm = (AssemblyHashAlgorithm)aname.hash_alg; + assemblyNameDef.Attributes = (AssemblyAttributes)aname.flags; + assemblyNameDef.PublicKeyToken = aname.public_key_token;*/ + var assemblyDefinition = AssemblyDefinition.CreateAssembly(assemblyNameDef, imageName, moduleParameters); resolver.Register(assemblyDefinition); Assemblies.Add(assemblyDefinition); var moduleDefinition = assemblyDefinition.MainModule;