From a88e91451a3d72aac34ec45d3c233a93dff2826c Mon Sep 17 00:00:00 2001 From: LukeFZ <17146677+LukeFZ@users.noreply.github.com> Date: Fri, 22 Aug 2025 04:53:00 +0200 Subject: [PATCH] add (untested) support for metadata v38 --- .../IL2CPP/Il2CppInspector.cs | 2 +- Il2CppInspector.Common/IL2CPP/Metadata.cs | 167 ++++++++++---- .../Next/Metadata/GenericContainerIndex.cs | 76 ++++++ .../Next/Metadata/Il2CppAssemblyDefinition.cs | 4 + .../Next/Metadata/Il2CppEventDefinition.cs | 1 - .../Next/Metadata/Il2CppFieldDefaultValue.cs | 1 - .../Next/Metadata/Il2CppFieldDefinition.cs | 1 - .../Next/Metadata/Il2CppFieldMarshaledSize.cs | 1 - .../Next/Metadata/Il2CppFieldRef.cs | 1 - .../Next/Metadata/Il2CppGenericParameter.cs | 1 - .../Metadata/Il2CppGlobalMetadataHeader.cs | 217 ++++++++++++++++-- .../Next/Metadata/Il2CppImageDefinition.cs | 1 - .../Metadata/Il2CppInterfaceOffsetPair.cs | 2 - .../Next/Metadata/Il2CppMethodDefinition.cs | 3 - .../Metadata/Il2CppParameterDefaultValue.cs | 1 - .../Metadata/Il2CppParameterDefinition.cs | 1 - .../Next/Metadata/Il2CppSectionMetadata.cs | 11 + .../Next/Metadata/Il2CppTypeDefinition.cs | 4 +- .../Il2CppWindowsRuntimeTypeNamePair.cs | 1 - .../Next/Metadata/TypeDefinitionIndex.cs | 75 ++++++ .../Next/Metadata/TypeIndex.cs | 76 ++++++ .../Next/MetadataVersions.cs | 4 + .../Reflection/CustomAttributeData.cs | 4 +- README.md | 5 +- 24 files changed, 567 insertions(+), 93 deletions(-) create mode 100644 Il2CppInspector.Common/Next/Metadata/GenericContainerIndex.cs create mode 100644 Il2CppInspector.Common/Next/Metadata/Il2CppSectionMetadata.cs create mode 100644 Il2CppInspector.Common/Next/Metadata/TypeDefinitionIndex.cs create mode 100644 Il2CppInspector.Common/Next/Metadata/TypeIndex.cs diff --git a/Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs b/Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs index 24e52eb..c0edece 100644 --- a/Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs +++ b/Il2CppInspector.Common/IL2CPP/Il2CppInspector.cs @@ -85,7 +85,7 @@ namespace Il2CppInspector return (0ul, null); // Get pointer in binary to default value - var pValue = Metadata.Header.FieldAndParameterDefaultValueDataOffset + dataIndex; + var pValue = Metadata.FieldAndParameterDefaultValueDataOffset + dataIndex; var typeRef = TypeReferences[typeIndex]; // Default value is null diff --git a/Il2CppInspector.Common/IL2CPP/Metadata.cs b/Il2CppInspector.Common/IL2CPP/Metadata.cs index 839f053..32d61f2 100644 --- a/Il2CppInspector.Common/IL2CPP/Metadata.cs +++ b/Il2CppInspector.Common/IL2CPP/Metadata.cs @@ -5,15 +5,10 @@ All rights reserved. */ -using System; -using System.Collections.Generic; using System.Collections.Immutable; -using System.IO; -using System.Linq; -using System.Reflection; +using System.Runtime.CompilerServices; using Il2CppInspector.Next; using Il2CppInspector.Next.Metadata; -using NoisyCowStudios.Bin2Object; using VersionedSerialization; namespace Il2CppInspector @@ -48,7 +43,15 @@ namespace Il2CppInspector public ImmutableArray VTableMethodIndices { get; set; } public string[] StringLiterals { get; set; } - public Dictionary Strings { get; private set; } = new Dictionary(); + public int FieldAndParameterDefaultValueDataOffset => Version >= MetadataVersions.V380 + ? Header.FieldAndParameterDefaultValueData.Offset + : Header.FieldAndParameterDefaultValueDataOffset; + + public int AttributeDataOffset => Version >= MetadataVersions.V380 + ? Header.AttributeData.Offset + : Header.AttributeDataOffset; + + public Dictionary Strings { get; private set; } = []; // Set if something in the metadata has been modified / decrypted public bool IsModified { get; private set; } = false; @@ -92,13 +95,56 @@ namespace Il2CppInspector // Set object versioning for Bin2Object from metadata version Version = new StructVersion(Header.Version); - if (Version < MetadataVersions.V160 || Version > MetadataVersions.V350) { + if (Version < MetadataVersions.V160 || Version > MetadataVersions.V380) { throw new InvalidOperationException($"The supplied metadata file is not of a supported version ({Header.Version})."); } // Rewind and read metadata header with the correct version settings Header = ReadVersionedObject(0); + // Setup the proper index sizes for metadata v38+ + if (Version >= MetadataVersions.V380) + { + static int GetIndexSize(int elementCount) + { + return elementCount switch + { + <= byte.MaxValue => sizeof(byte), + <= ushort.MaxValue => sizeof(ushort), + _ => sizeof(int) + }; + } + + var typeDefinitionIndexSize = GetIndexSize(Header.TypeDefinitions.Count); + var genericContainerIndexSize = GetIndexSize(Header.GenericContainers.Count); + + var tag = $"{TypeDefinitionIndex.TagPrefix}{typeDefinitionIndexSize}" + + $"_{GenericContainerIndex.TagPrefix}{genericContainerIndexSize}"; + + var tempVersion = new StructVersion(Version.Major, Version.Minor, tag); + + // now we need to derive the size for TypeIndex. + // this is normally done through s_Il2CppMetadataRegistration->typesCount, but we don't want to use the binary for this + // as we do not have it available at this point. + // thankfully, we can just guess the size based off the three available options and the known total size of + // a type entry that uses TypeIndex. + var expectedEventDefinitionSize = Header.Events.SectionSize / Header.Events.Count; + var maxEventDefinitionSize = Il2CppEventDefinition.Size(tempVersion); + + int typeIndexSize; + if (expectedEventDefinitionSize == maxEventDefinitionSize) + typeIndexSize = sizeof(int); + else if (expectedEventDefinitionSize == maxEventDefinitionSize - 2) + typeIndexSize = sizeof(ushort); + else if (expectedEventDefinitionSize == maxEventDefinitionSize - 3) + typeIndexSize = sizeof(byte); + else + throw new InvalidOperationException("Could not determine TypeIndex size based on the metadata header"); + + var fullTag = $"{tag}_{TypeIndex.TagPrefix}{typeIndexSize}"; + Version = new StructVersion(Version.Major, Version.Minor, fullTag); + } + // Sanity checking // Unity.IL2CPP.MetadataCacheWriter.WriteLibIl2CppMetadata always writes the metadata information in the same order it appears in the header, // with each block always coming directly after the previous block, 4-byte aligned. We can use this to check the integrity of the data and @@ -122,10 +168,10 @@ namespace Il2CppInspector throw new InvalidOperationException("Could not verify the integrity of the metadata file or accurately identify the metadata sub-version"); } } - + // Load all the relevant metadata using offsets provided in the header if (Version >= MetadataVersions.V160) - Images = ReadVersionedObjectArray(Header.ImagesOffset, Header.ImagesSize / Sizeof()); + Images = ReadMetadataArray(Header.ImagesOffset, Header.ImagesSize, Header.Images); // As an additional sanity check, all images in the metadata should have Mono.Cecil.MetadataToken == 1 // In metadata v24.1, two extra fields were added which will cause the below test to fail. @@ -136,28 +182,29 @@ namespace Il2CppInspector Version = MetadataVersions.V241; // No need to re-read the header, it's the same for both sub-versions - Images = ReadVersionedObjectArray(Header.ImagesOffset, Header.ImagesSize / Sizeof()); + Images = ReadMetadataArray(Header.ImagesOffset, Header.ImagesSize, Header.Images); if (Images.Any(x => x.Token != 1)) throw new InvalidOperationException("Could not verify the integrity of the metadata file image list"); } - Types = ReadVersionedObjectArray(Header.TypeDefinitionsOffset, Header.TypeDefinitionsSize / Sizeof()); - Methods = ReadVersionedObjectArray(Header.MethodsOffset, Header.MethodsSize / Sizeof()); - Params = ReadVersionedObjectArray(Header.ParametersOffset, Header.ParametersSize / Sizeof()); - Fields = ReadVersionedObjectArray(Header.FieldsOffset, Header.FieldsSize / Sizeof()); - FieldDefaultValues = ReadVersionedObjectArray(Header.FieldDefaultValuesOffset, Header.FieldDefaultValuesSize / Sizeof()); - Properties = ReadVersionedObjectArray(Header.PropertiesOffset, Header.PropertiesSize / Sizeof()); - Events = ReadVersionedObjectArray(Header.EventsOffset, Header.EventsSize / Sizeof()); - InterfaceUsageIndices = ReadPrimitiveArray(Header.InterfacesOffset, Header.InterfacesSize / sizeof(int)); - NestedTypeIndices = ReadPrimitiveArray(Header.NestedTypesOffset, Header.NestedTypesSize / sizeof(int)); - GenericContainers = ReadVersionedObjectArray(Header.GenericContainersOffset, Header.GenericContainersSize / Sizeof()); - GenericParameters = ReadVersionedObjectArray(Header.GenericParametersOffset, Header.GenericParametersSize / Sizeof()); - GenericConstraintIndices = ReadPrimitiveArray(Header.GenericParameterConstraintsOffset, Header.GenericParameterConstraintsSize / sizeof(int)); - InterfaceOffsets = ReadVersionedObjectArray(Header.InterfaceOffsetsOffset, Header.InterfaceOffsetsSize / Sizeof()); - VTableMethodIndices = ReadPrimitiveArray(Header.VTableMethodsOffset, Header.VTableMethodsSize / sizeof(uint)); + Types = ReadMetadataArray(Header.TypeDefinitionsOffset, Header.TypeDefinitionsSize, Header.TypeDefinitions); + Methods = ReadMetadataArray(Header.MethodsOffset, Header.MethodsSize, Header.Methods); + Params = ReadMetadataArray(Header.ParametersOffset, Header.ParametersSize, Header.Parameters); + Fields = ReadMetadataArray(Header.FieldsOffset, Header.FieldsSize, Header.Fields); + FieldDefaultValues = ReadMetadataArray(Header.FieldDefaultValuesOffset, Header.FieldDefaultValuesSize, Header.FieldDefaultValues); + Properties = ReadMetadataArray(Header.PropertiesOffset, Header.PropertiesSize, Header.Properties); + Events = ReadMetadataArray(Header.EventsOffset, Header.EventsSize, Header.Events); + InterfaceUsageIndices = ReadMetadataPrimitiveArray(Header.InterfacesOffset, Header.InterfacesSize, Header.Interfaces); + NestedTypeIndices = ReadMetadataPrimitiveArray(Header.NestedTypesOffset, Header.NestedTypesSize, Header.NestedTypes); + GenericContainers = ReadMetadataArray(Header.GenericContainersOffset, Header.GenericContainersSize, Header.GenericContainers); + GenericParameters = ReadMetadataArray(Header.GenericParametersOffset, Header.GenericParametersSize, Header.GenericParameters); + GenericConstraintIndices = ReadMetadataPrimitiveArray(Header.GenericParameterConstraintsOffset, Header.GenericParameterConstraintsSize, Header.GenericParameterConstraints); + InterfaceOffsets = ReadMetadataArray(Header.InterfaceOffsetsOffset, Header.InterfaceOffsetsSize, Header.InterfaceOffsets); + VTableMethodIndices = ReadMetadataPrimitiveArray(Header.VTableMethodsOffset, Header.VTableMethodsSize, Header.VtableMethods); - if (Version >= MetadataVersions.V160) { + if (Version >= MetadataVersions.V160) + { // In v24.4 hashValueIndex was removed from Il2CppAssemblyNameDefinition, which is a field in Il2CppAssemblyDefinition // The number of images and assemblies should be the same. If they are not, we deduce that we are using v24.4 // Note the version comparison matches both 24.2 and 24.3 here since 24.3 is tested for during binary loading @@ -167,32 +214,39 @@ namespace Il2CppInspector { if (Version == MetadataVersions.V241) changedAssemblyDefStruct = true; + Version = MetadataVersions.V244; } - Assemblies = ReadVersionedObjectArray(Header.AssembliesOffset, Images.Length); + Assemblies = ReadMetadataArray(Header.AssembliesOffset, Header.AssembliesSize, Header.Assemblies); if (changedAssemblyDefStruct) Version = MetadataVersions.V241; - ParameterDefaultValues = ReadVersionedObjectArray(Header.ParameterDefaultValuesOffset, Header.ParameterDefaultValuesSize / Sizeof()); + ParameterDefaultValues = ReadMetadataArray(Header.ParameterDefaultValuesOffset, Header.ParameterDefaultValuesSize, Header.ParameterDefaultValues); } - if (Version >= MetadataVersions.V190 && Version < MetadataVersions.V270) { - MetadataUsageLists = ReadVersionedObjectArray(Header.MetadataUsageListsOffset, Header.MetadataUsageListsCount / Sizeof()); - MetadataUsagePairs = ReadVersionedObjectArray(Header.MetadataUsagePairsOffset, Header.MetadataUsagePairsCount / Sizeof()); + + if (Version >= MetadataVersions.V190 && Version < MetadataVersions.V270) + { + MetadataUsageLists = ReadMetadataArray(Header.MetadataUsageListsOffset, Header.MetadataUsageListsCount, default); + MetadataUsagePairs = ReadMetadataArray(Header.MetadataUsagePairsOffset, Header.MetadataUsagePairsCount, default); } - if (Version >= MetadataVersions.V190) { - FieldRefs = ReadVersionedObjectArray(Header.FieldRefsOffset, Header.FieldRefsSize / Sizeof()); + + if (Version >= MetadataVersions.V190) + { + FieldRefs = ReadMetadataArray(Header.FieldRefsOffset, Header.FieldRefsSize, Header.FieldRefs); } - if (Version >= MetadataVersions.V210 && Version < MetadataVersions.V290) { - AttributeTypeIndices = ReadPrimitiveArray(Header.AttributesTypesOffset, Header.AttributesTypesCount / sizeof(int)); - AttributeTypeRanges = ReadVersionedObjectArray(Header.AttributesInfoOffset, Header.AttributesInfoCount / Sizeof()); + + if (Version >= MetadataVersions.V210 && Version < MetadataVersions.V290) + { + AttributeTypeIndices = ReadMetadataPrimitiveArray(Header.AttributesTypesOffset, Header.AttributesTypesCount, default); + AttributeTypeRanges = ReadMetadataArray(Header.AttributesInfoOffset, Header.AttributesInfoCount, default); } if (Version >= MetadataVersions.V290) { - AttributeDataRanges = ReadVersionedObjectArray(Header.AttributeDataRangeOffset, - Header.AttributeDataRangeSize / Sizeof()); + AttributeDataRanges = ReadMetadataArray(Header.AttributeDataRangeOffset, + Header.AttributeDataRangeSize, Header.AttributeDataRanges); } // Get all metadata strings @@ -212,8 +266,14 @@ namespace Il2CppInspector if (pluginGetStringLiteralsResult.IsDataModified) StringLiterals = pluginGetStringLiteralsResult.StringLiterals.ToArray(); - else { - var stringLiteralList = ReadVersionedObjectArray(Header.StringLiteralOffset, Header.StringLiteralSize / Sizeof()); + else + { + var stringLiteralList = ReadMetadataArray(Header.StringLiteralOffset, + Header.StringLiteralSize, Header.StringLiterals); + + var dataOffset = Version >= MetadataVersions.V380 + ? Header.StringLiteralData.Offset + : Header.StringLiteralDataOffset; if (Version >= MetadataVersions.V350) { @@ -224,28 +284,45 @@ namespace Il2CppInspector var nextStringDataIndex = stringLiteralList[i + 1].DataIndex; var stringLength = nextStringDataIndex - currentStringDataIndex; - StringLiterals[i] = ReadFixedLengthString(Header.StringLiteralDataOffset + currentStringDataIndex, stringLength); + StringLiterals[i] = ReadFixedLengthString(dataOffset + currentStringDataIndex, stringLength); } - } else { StringLiterals = new string[stringLiteralList.Length]; for (var i = 0; i < stringLiteralList.Length; i++) - StringLiterals[i] = ReadFixedLengthString(Header.StringLiteralDataOffset + stringLiteralList[i].DataIndex, (int)stringLiteralList[i].Length); + StringLiterals[i] = ReadFixedLengthString(dataOffset + stringLiteralList[i].DataIndex, + (int)stringLiteralList[i].Length); } } // Post-processing hook IsModified |= PluginHooks.PostProcessMetadata(this).IsStreamModified; + return; + } + + public ImmutableArray ReadMetadataPrimitiveArray(int oldOffset, int oldSize, Il2CppSectionMetadata newMetadata) + where T : unmanaged + { + return Version >= MetadataVersions.V380 + ? ReadPrimitiveArray(newMetadata.Offset, newMetadata.Count) + : ReadPrimitiveArray(oldOffset, oldSize / Unsafe.SizeOf()); + } + + public ImmutableArray ReadMetadataArray(int oldOffset, int oldSize, Il2CppSectionMetadata newMetadata) + where T : IReadable, new() + { + return Version >= MetadataVersions.V380 + ? ReadVersionedObjectArray(newMetadata.Offset, newMetadata.Count) + : ReadVersionedObjectArray(oldOffset, oldSize / Sizeof()); } // Save metadata to file, overwriting if necessary public void SaveToFile(string pathname) { Position = 0; - using (var outFile = new FileStream(pathname, FileMode.Create, FileAccess.Write)) - CopyTo(outFile); + using var outFile = new FileStream(pathname, FileMode.Create, FileAccess.Write); + CopyTo(outFile); } public int Sizeof() where T : IReadable => T.Size(Version, Is32Bit); diff --git a/Il2CppInspector.Common/Next/Metadata/GenericContainerIndex.cs b/Il2CppInspector.Common/Next/Metadata/GenericContainerIndex.cs new file mode 100644 index 0000000..dc62b64 --- /dev/null +++ b/Il2CppInspector.Common/Next/Metadata/GenericContainerIndex.cs @@ -0,0 +1,76 @@ +using VersionedSerialization; + +namespace Il2CppInspector.Next.Metadata; + +public struct GenericContainerIndex(int value) : IReadable, IEquatable +{ + public const string TagPrefix = nameof(GenericContainerIndex); + + private int _value = value; + + public static implicit operator int(GenericContainerIndex idx) => idx._value; + public static implicit operator GenericContainerIndex(int idx) => new(idx); + + public static int Size(in StructVersion version = default, bool is32Bit = false) + { + if (version >= MetadataVersions.V380 + && version.Tag != null + && version.Tag.Contains(TagPrefix) + && !version.Tag.Contains($"{TagPrefix}4")) + { + if (version.Tag.Contains($"{TagPrefix}2")) + return sizeof(ushort); + + if (version.Tag.Contains($"{TagPrefix}1")) + return sizeof(byte); + } + + return sizeof(int); + } + + public void Read(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct + { + if (version >= MetadataVersions.V380 + && version.Tag != null + && version.Tag.Contains(TagPrefix) + && !version.Tag.Contains($"{TagPrefix}4")) + { + if (version.Tag.Contains($"{TagPrefix}2")) + { + _value = reader.ReadPrimitive(); + _value = _value == ushort.MaxValue ? -1 : _value; + return; + } + + if (version.Tag.Contains($"{TagPrefix}1")) + { + _value = reader.ReadPrimitive(); + _value = _value == byte.MaxValue ? -1 : _value; + return; + } + } + + _value = reader.ReadPrimitive(); + } + + #region Equality operators + ToString + + public static bool operator ==(GenericContainerIndex left, GenericContainerIndex right) + => left._value == right._value; + + public static bool operator !=(GenericContainerIndex left, GenericContainerIndex right) + => !(left == right); + + public readonly override bool Equals(object? obj) + => obj is GenericContainerIndex other && Equals(other); + + public readonly bool Equals(GenericContainerIndex other) + => this == other; + + public readonly override int GetHashCode() + => HashCode.Combine(_value); + + public readonly override string ToString() => _value.ToString(); + + #endregion +} \ No newline at end of file diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppAssemblyDefinition.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppAssemblyDefinition.cs index 40d55ee..23187d2 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppAssemblyDefinition.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppAssemblyDefinition.cs @@ -20,6 +20,10 @@ public partial record struct Il2CppAssemblyDefinition [VersionCondition(GreaterThan = "24.1")] public uint Token; + [FieldOffset(20 + 52)] + [VersionCondition(GreaterThan = "38.0")] + public uint ModuleToken; + [FieldOffset(8)] [VersionCondition(LessThan = "24.0")] public int CustomAttributeIndex; diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppEventDefinition.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppEventDefinition.cs index c763cbd..aea09fc 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppEventDefinition.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppEventDefinition.cs @@ -1,7 +1,6 @@ namespace Il2CppInspector.Next.Metadata; using StringIndex = int; -using TypeIndex = int; using MethodIndex = int; using VersionedSerialization.Attributes; diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppFieldDefaultValue.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppFieldDefaultValue.cs index 47c9fef..4e98bd6 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppFieldDefaultValue.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppFieldDefaultValue.cs @@ -3,7 +3,6 @@ namespace Il2CppInspector.Next.Metadata; using FieldIndex = int; -using TypeIndex = int; using DefaultValueDataIndex = int; [VersionedStruct] diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppFieldDefinition.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppFieldDefinition.cs index 91f81e9..753d889 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppFieldDefinition.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppFieldDefinition.cs @@ -2,7 +2,6 @@ using VersionedSerialization.Attributes; using StringIndex = int; -using TypeIndex = int; [VersionedStruct] public partial record struct Il2CppFieldDefinition diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppFieldMarshaledSize.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppFieldMarshaledSize.cs index 0cbb5ed..eee0110 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppFieldMarshaledSize.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppFieldMarshaledSize.cs @@ -2,7 +2,6 @@ using VersionedSerialization.Attributes; using FieldIndex = int; -using TypeIndex = int; [VersionedStruct] public partial record struct Il2CppFieldMarshaledSize diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppFieldRef.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppFieldRef.cs index aba478e..c83305b 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppFieldRef.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppFieldRef.cs @@ -3,7 +3,6 @@ namespace Il2CppInspector.Next.Metadata; using FieldIndex = int; -using TypeIndex = int; [VersionedStruct] public partial record struct Il2CppFieldRef diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppGenericParameter.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppGenericParameter.cs index b9f5a17..156b54d 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppGenericParameter.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppGenericParameter.cs @@ -3,7 +3,6 @@ using VersionedSerialization.Attributes; namespace Il2CppInspector.Next.Metadata; -using GenericContainerIndex = int; using StringIndex = int; using GenericParameterConstraintIndex = short; diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppGlobalMetadataHeader.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppGlobalMetadataHeader.cs index 1eefde9..cc0c992 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppGlobalMetadataHeader.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppGlobalMetadataHeader.cs @@ -29,55 +29,127 @@ public partial record struct Il2CppGlobalMetadataHeader { public int Sanity { get; private set; } public int Version { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int StringLiteralOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int StringLiteralSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int StringLiteralDataOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int StringLiteralDataSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int StringOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int StringSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int EventsOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int EventsSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int PropertiesOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int PropertiesSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int MethodsOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int MethodsSize { get; private set; } [VersionCondition(GreaterThan = "16.0")] [VersionCondition(EqualTo = "16.0")] public int ParameterDefaultValuesOffset { get; private set; } - [VersionCondition(GreaterThan = "16.0")] + [VersionCondition(GreaterThan = "16.0", LessThan = "35.0")] [VersionCondition(EqualTo = "16.0")] public int ParameterDefaultValuesSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int FieldDefaultValuesOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int FieldDefaultValuesSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int FieldAndParameterDefaultValueDataOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int FieldAndParameterDefaultValueDataSize { get; private set; } - [VersionCondition(GreaterThan = "16.0")] + [VersionCondition(GreaterThan = "16.0", LessThan = "35.0")] public int FieldMarshaledSizesOffset { get; private set; } - [VersionCondition(GreaterThan = "16.0")] + [VersionCondition(GreaterThan = "16.0", LessThan = "35.0")] public int FieldMarshaledSizesSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int ParametersOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int ParametersSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int FieldsOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int FieldsSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int GenericParametersOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int GenericParametersSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int GenericParameterConstraintsOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int GenericParameterConstraintsSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int GenericContainersOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int GenericContainersSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int NestedTypesOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int NestedTypesSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int InterfacesOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int InterfacesSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int VTableMethodsOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int VTableMethodsSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int InterfaceOffsetsOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int InterfaceOffsetsSize { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int TypeDefinitionsOffset { get; private set; } + + [VersionCondition(LessThan = "35.0")] public int TypeDefinitionsSize { get; private set; } [VersionCondition(LessThan = "24.1")] @@ -86,16 +158,16 @@ public partial record struct Il2CppGlobalMetadataHeader [VersionCondition(LessThan = "24.1")] public int RgctxEntriesCount { get; private set; } - [VersionCondition(GreaterThan = "16.0")] + [VersionCondition(GreaterThan = "16.0", LessThan = "35.0")] public int ImagesOffset { get; private set; } - [VersionCondition(GreaterThan = "16.0")] + [VersionCondition(GreaterThan = "16.0", LessThan = "35.0")] public int ImagesSize { get; private set; } - [VersionCondition(GreaterThan = "16.0")] + [VersionCondition(GreaterThan = "16.0", LessThan = "35.0")] public int AssembliesOffset { get; private set; } - [VersionCondition(GreaterThan = "16.0")] + [VersionCondition(GreaterThan = "16.0", LessThan = "35.0")] public int AssembliesSize { get; private set; } [VersionCondition(GreaterThan = "19.0", LessThan = "24.5")] @@ -110,16 +182,16 @@ public partial record struct Il2CppGlobalMetadataHeader [VersionCondition(GreaterThan = "19.0", LessThan = "24.5")] public int MetadataUsagePairsCount { get; private set; } - [VersionCondition(GreaterThan = "19.0")] + [VersionCondition(GreaterThan = "19.0", LessThan = "35.0")] public int FieldRefsOffset { get; private set; } - [VersionCondition(GreaterThan = "19.0")] + [VersionCondition(GreaterThan = "19.0", LessThan = "35.0")] public int FieldRefsSize { get; private set; } - [VersionCondition(GreaterThan = "20.0")] + [VersionCondition(GreaterThan = "20.0", LessThan = "35.0")] public int ReferencedAssembliesOffset { get; private set; } - [VersionCondition(GreaterThan = "20.0")] + [VersionCondition(GreaterThan = "20.0", LessThan = "35.0")] public int ReferencedAssembliesSize { get; private set; } [VersionCondition(GreaterThan = "21.0", LessThan = "27.2")] @@ -134,48 +206,143 @@ public partial record struct Il2CppGlobalMetadataHeader [VersionCondition(GreaterThan = "21.0", LessThan = "27.2")] public int AttributesTypesCount { get; private set; } - [VersionCondition(GreaterThan = "29.0")] + [VersionCondition(GreaterThan = "29.0", LessThan = "35.0")] public int AttributeDataOffset { get; private set; } - [VersionCondition(GreaterThan = "29.0")] + [VersionCondition(GreaterThan = "29.0", LessThan = "35.0")] public int AttributeDataSize { get; private set; } - [VersionCondition(GreaterThan = "29.0")] + [VersionCondition(GreaterThan = "29.0", LessThan = "35.0")] public int AttributeDataRangeOffset { get; private set; } - [VersionCondition(GreaterThan = "29.0")] + [VersionCondition(GreaterThan = "29.0", LessThan = "35.0")] public int AttributeDataRangeSize { get; private set; } - [VersionCondition(GreaterThan = "22.0")] + [VersionCondition(GreaterThan = "22.0", LessThan = "35.0")] public int UnresolvedIndirectCallParameterTypesOffset { get; private set; } - [VersionCondition(GreaterThan = "22.0")] + [VersionCondition(GreaterThan = "22.0", LessThan = "35.0")] public int UnresolvedIndirectCallParameterTypesSize { get; private set; } - [VersionCondition(GreaterThan = "22.0")] + [VersionCondition(GreaterThan = "22.0", LessThan = "35.0")] public int UnresolvedIndirectCallParameterRangesOffset { get; private set; } - [VersionCondition(GreaterThan = "22.0")] + [VersionCondition(GreaterThan = "22.0", LessThan = "35.0")] public int UnresolvedIndirectCallParameterRangesSize { get; private set; } - [VersionCondition(GreaterThan = "23.0")] + [VersionCondition(GreaterThan = "23.0", LessThan = "35.0")] public int WindowsRuntimeTypeNamesOffset { get; private set; } - [VersionCondition(GreaterThan = "23.0")] + [VersionCondition(GreaterThan = "23.0", LessThan = "35.0")] public int WindowsRuntimeTypeNamesSize { get; private set; } - [VersionCondition(GreaterThan = "27.0")] + [VersionCondition(GreaterThan = "27.0", LessThan = "35.0")] public int WindowsRuntimeStringsOffset { get; private set; } - [VersionCondition(GreaterThan = "27.0")] + [VersionCondition(GreaterThan = "27.0", LessThan = "35.0")] public int WindowsRuntimeStringsSize { get; private set; } - [VersionCondition(GreaterThan = "24.0")] + [VersionCondition(GreaterThan = "24.0", LessThan = "35.0")] public int ExportedTypeDefinitionsOffset { get; private set; } - [VersionCondition(GreaterThan = "24.0")] + [VersionCondition(GreaterThan = "24.0", LessThan = "35.0")] public int ExportedTypeDefinitionsSize { get; private set; } + // new, v38 metadata sections + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata StringLiterals { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata StringLiteralData { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Strings { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Events { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Properties { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Methods { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata ParameterDefaultValues { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata FieldDefaultValues { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata FieldAndParameterDefaultValueData { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata FieldMarshaledSizes { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Parameters { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Fields { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata GenericParameters { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata GenericParameterConstraints { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata GenericContainers { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata NestedTypes { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Interfaces { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata VtableMethods { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata InterfaceOffsets { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata TypeDefinitions { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Images { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata Assemblies { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata FieldRefs { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata ReferencedAssemblies { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata AttributeData { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata AttributeDataRanges { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata UnresolvedIndirectCallParameterTypes { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata UnresolvedIndirectCallParameterRanges { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata WindowsRuntimeTypeNames { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata WindowsRuntimeStrings { get; private set; } + + [VersionCondition(GreaterThan = "38.0")] + public Il2CppSectionMetadata ExportedTypeDefinitions { get; private set; } + public const int ExpectedSanity = unchecked((int)0xFAB11BAF); public readonly bool SanityValid => Sanity == ExpectedSanity; diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppImageDefinition.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppImageDefinition.cs index 0f50a2b..f1b7aef 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppImageDefinition.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppImageDefinition.cs @@ -2,7 +2,6 @@ using StringIndex = int; using AssemblyIndex = int; -using TypeDefinitionIndex = int; using MethodIndex = int; using CustomAttributeIndex = int; using VersionedSerialization.Attributes; diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppInterfaceOffsetPair.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppInterfaceOffsetPair.cs index 8ed5d41..14f380f 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppInterfaceOffsetPair.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppInterfaceOffsetPair.cs @@ -2,8 +2,6 @@ namespace Il2CppInspector.Next.Metadata; -using TypeIndex = int; - [VersionedStruct] public partial record struct Il2CppInterfaceOffsetPair { diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppMethodDefinition.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppMethodDefinition.cs index 0efa091..a73bda6 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppMethodDefinition.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppMethodDefinition.cs @@ -4,10 +4,7 @@ using VersionedSerialization.Attributes; namespace Il2CppInspector.Next.Metadata; using StringIndex = int; -using TypeDefinitionIndex = int; -using TypeIndex = int; using ParameterIndex = int; -using GenericContainerIndex = int; [VersionedStruct] public partial record struct Il2CppMethodDefinition diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppParameterDefaultValue.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppParameterDefaultValue.cs index 8451daa..8ae34f7 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppParameterDefaultValue.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppParameterDefaultValue.cs @@ -1,7 +1,6 @@ namespace Il2CppInspector.Next.Metadata; using ParameterIndex = int; -using TypeIndex = int; using DefaultValueDataIndex = int; using VersionedSerialization.Attributes; diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppParameterDefinition.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppParameterDefinition.cs index 2bca465..59aa693 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppParameterDefinition.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppParameterDefinition.cs @@ -2,7 +2,6 @@ using VersionedSerialization.Attributes; using StringIndex = int; -using TypeIndex = int; [VersionedStruct] public partial record struct Il2CppParameterDefinition diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppSectionMetadata.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppSectionMetadata.cs new file mode 100644 index 0000000..8ab043e --- /dev/null +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppSectionMetadata.cs @@ -0,0 +1,11 @@ +using VersionedSerialization.Attributes; + +namespace Il2CppInspector.Next.Metadata; + +[VersionedStruct] +public partial record struct Il2CppSectionMetadata +{ + public int Offset { get; private set; } + public int SectionSize { get; private set; } + public int Count { get; private set; } +} \ No newline at end of file diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppTypeDefinition.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppTypeDefinition.cs index e72002f..8f8835e 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppTypeDefinition.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppTypeDefinition.cs @@ -5,8 +5,6 @@ using VersionedSerialization.Attributes; namespace Il2CppInspector.Next.Metadata; using StringIndex = int; -using TypeIndex = int; -using GenericContainerIndex = int; using FieldIndex = int; using MethodIndex = int; using EventIndex = int; @@ -18,7 +16,7 @@ using VTableIndex = int; [VersionedStruct] public partial record struct Il2CppTypeDefinition { - public const TypeIndex InvalidTypeIndex = -1; + public static readonly TypeIndex InvalidTypeIndex = -1; public StringIndex NameIndex { get; private set; } public StringIndex NamespaceIndex { get; private set; } diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppWindowsRuntimeTypeNamePair.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppWindowsRuntimeTypeNamePair.cs index 6ac6357..e0444d2 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppWindowsRuntimeTypeNamePair.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppWindowsRuntimeTypeNamePair.cs @@ -2,7 +2,6 @@ using VersionedSerialization.Attributes; using StringIndex = int; -using TypeIndex = int; [VersionedStruct] public partial record struct Il2CppWindowsRuntimeTypeNamePair diff --git a/Il2CppInspector.Common/Next/Metadata/TypeDefinitionIndex.cs b/Il2CppInspector.Common/Next/Metadata/TypeDefinitionIndex.cs new file mode 100644 index 0000000..6b157a4 --- /dev/null +++ b/Il2CppInspector.Common/Next/Metadata/TypeDefinitionIndex.cs @@ -0,0 +1,75 @@ +using VersionedSerialization; + +namespace Il2CppInspector.Next.Metadata; + +public struct TypeDefinitionIndex(int value) : IReadable, IEquatable +{ + public const string TagPrefix = nameof(TypeDefinitionIndex); + + private int _value = value; + + public static implicit operator int(TypeDefinitionIndex idx) => idx._value; + public static implicit operator TypeDefinitionIndex(int idx) => new(idx); + + public static int Size(in StructVersion version = default, bool is32Bit = false) + { + if (version >= MetadataVersions.V380 + && version.Tag != null + && version.Tag.Contains(TagPrefix) + && !version.Tag.Contains($"{TagPrefix}4")) + { + if (version.Tag.Contains($"{TagPrefix}2")) + return sizeof(ushort); + + if (version.Tag.Contains($"{TagPrefix}1")) + return sizeof(byte); + } + + return sizeof(int); + } + + public void Read(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct + { + if (version >= MetadataVersions.V380 + && version.Tag != null + && version.Tag.Contains(TagPrefix) + && !version.Tag.Contains($"{TagPrefix}4")) + { + if (version.Tag.Contains($"{TagPrefix}2")) + { + _value = reader.ReadPrimitive(); + return; + } + + if (version.Tag.Contains($"{TagPrefix}1")) + { + _value = reader.ReadPrimitive(); + _value = _value == byte.MaxValue ? -1 : _value; + return; + } + } + + _value = reader.ReadPrimitive(); + } + + #region Equality operators + ToString + + public static bool operator ==(TypeDefinitionIndex left, TypeDefinitionIndex right) + => left._value == right._value; + + public static bool operator !=(TypeDefinitionIndex left, TypeDefinitionIndex right) + => !(left == right); + + public readonly override bool Equals(object? obj) + => obj is TypeDefinitionIndex other && Equals(other); + + public readonly bool Equals(TypeDefinitionIndex other) + => this == other; + + public readonly override int GetHashCode() + => HashCode.Combine(_value); + + public readonly override string ToString() => _value.ToString(); + + #endregion +} \ No newline at end of file diff --git a/Il2CppInspector.Common/Next/Metadata/TypeIndex.cs b/Il2CppInspector.Common/Next/Metadata/TypeIndex.cs new file mode 100644 index 0000000..b0b3991 --- /dev/null +++ b/Il2CppInspector.Common/Next/Metadata/TypeIndex.cs @@ -0,0 +1,76 @@ +using VersionedSerialization; + +namespace Il2CppInspector.Next.Metadata; + +public struct TypeIndex(int value) : IReadable, IEquatable +{ + public const string TagPrefix = nameof(TypeIndex); + + private int _value = value; + + public static implicit operator int(TypeIndex idx) => idx._value; + public static implicit operator TypeIndex(int idx) => new(idx); + + public static int Size(in StructVersion version = default, bool is32Bit = false) + { + if (version >= MetadataVersions.V380 + && version.Tag != null + && version.Tag.Contains(TagPrefix) + && !version.Tag.Contains($"{TagPrefix}4")) + { + if (version.Tag.Contains($"{TagPrefix}2")) + return sizeof(ushort); + + if (version.Tag.Contains($"{TagPrefix}1")) + return sizeof(byte); + } + + return sizeof(int); + } + + public void Read(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct + { + if (version >= MetadataVersions.V380 + && version.Tag != null + && version.Tag.Contains(TagPrefix) + && !version.Tag.Contains($"{TagPrefix}4")) + { + if (version.Tag.Contains($"{TagPrefix}2")) + { + _value = reader.ReadPrimitive(); + _value = _value == ushort.MaxValue ? -1 : _value; + return; + } + + if (version.Tag.Contains($"{TagPrefix}1")) + { + _value = reader.ReadPrimitive(); + _value = _value == byte.MaxValue ? -1 : _value; + return; + } + } + + _value = reader.ReadPrimitive(); + } + + #region Equality operators + ToString + + public static bool operator ==(TypeIndex left, TypeIndex right) + => left._value == right._value; + + public static bool operator !=(TypeIndex left, TypeIndex right) + => !(left == right); + + public readonly override bool Equals(object? obj) + => obj is TypeIndex other && Equals(other); + + public readonly bool Equals(TypeIndex other) + => this == other; + + public readonly override int GetHashCode() + => HashCode.Combine(_value); + + public readonly override string ToString() => _value.ToString(); + + #endregion +} \ No newline at end of file diff --git a/Il2CppInspector.Common/Next/MetadataVersions.cs b/Il2CppInspector.Common/Next/MetadataVersions.cs index 9a2a695..2202125 100644 --- a/Il2CppInspector.Common/Next/MetadataVersions.cs +++ b/Il2CppInspector.Common/Next/MetadataVersions.cs @@ -31,4 +31,8 @@ public static class MetadataVersions // Unity 6000.3.0a2 public static readonly StructVersion V350 = new(35); + + // Unity 6000.3.0a5 + public static readonly StructVersion V380 = new(38); + // NOTE: This version uses tags to specify the size of TypeIndex, TypeDefinitionIndex, and GenericContainerIndex. } \ No newline at end of file diff --git a/Il2CppInspector.Common/Reflection/CustomAttributeData.cs b/Il2CppInspector.Common/Reflection/CustomAttributeData.cs index 1220455..c45afcb 100644 --- a/Il2CppInspector.Common/Reflection/CustomAttributeData.cs +++ b/Il2CppInspector.Common/Reflection/CustomAttributeData.cs @@ -118,8 +118,8 @@ namespace Il2CppInspector.Reflection var range = pkg.Metadata.AttributeDataRanges[customAttributeIndex]; var next = pkg.Metadata.AttributeDataRanges[customAttributeIndex + 1]; - var startOffset = (uint)pkg.Metadata.Header.AttributeDataOffset + range.StartOffset; - var endOffset = (uint)pkg.Metadata.Header.AttributeDataOffset + next.StartOffset; + var startOffset = (uint)pkg.Metadata.AttributeDataOffset + range.StartOffset; + var endOffset = (uint)pkg.Metadata.AttributeDataOffset + next.StartOffset; var reader = new CustomAttributeDataReader(pkg, asm, pkg.Metadata, startOffset, endOffset); if (reader.Count == 0) diff --git a/README.md b/README.md index f5c8c39..6b5ac08 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This is a continuation of [Il2CppInspector, by djkaty](https://github.com/djkaty ### Redux only features -* Support for metadata version 29 and 29.1, with full reconstruction of custom attributes +* Support for metadata version 29/29.1/31/35/38, with full reconstruction of custom attributes * Proper extraction of static array initializer contents with their correct length * Proper support for v27.2+ Il2CppType * Fixed support for v24.5 @@ -767,7 +767,8 @@ Unity version | IL2CPP version | Support 2021.2.0-2021.2.x | 29 | Working 2021.3.0-??? | 29.1 | Working 2022.3.33-6000.2.x | 31(.1) | Working -6000.3.0a2+ | 35 | Working +6000.3.0a2 | 35 | Working +6000.3.0a5 | 38 | Working Please refer to the companion repository https://github.com/nneonneo/Il2CppVersions if you would like to track the changes between each IL2CPP release version.