add support for metadata
This commit is contained in:
@@ -92,7 +92,7 @@ namespace Il2CppInspector
|
||||
// Set object versioning for Bin2Object from metadata version
|
||||
Version = new StructVersion(Header.Version);
|
||||
|
||||
if (Version < MetadataVersions.V160 || Version > MetadataVersions.V310) {
|
||||
if (Version < MetadataVersions.V160 || Version > MetadataVersions.V350) {
|
||||
throw new InvalidOperationException($"The supplied metadata file is not of a supported version ({Header.Version}).");
|
||||
}
|
||||
|
||||
@@ -215,9 +215,26 @@ namespace Il2CppInspector
|
||||
else {
|
||||
var stringLiteralList = ReadVersionedObjectArray<Il2CppStringLiteral>(Header.StringLiteralOffset, Header.StringLiteralSize / Sizeof<Il2CppStringLiteral>());
|
||||
|
||||
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);
|
||||
if (Version >= MetadataVersions.V350)
|
||||
{
|
||||
StringLiterals = new string[stringLiteralList.Length - 1];
|
||||
for (var i = 0; i < stringLiteralList.Length; i++)
|
||||
{
|
||||
var currentStringDataIndex = stringLiteralList[i].DataIndex;
|
||||
var nextStringDataIndex = stringLiteralList[i + 1].DataIndex;
|
||||
var stringLength = nextStringDataIndex - currentStringDataIndex;
|
||||
|
||||
StringLiterals[i] = ReadFixedLengthString(Header.StringLiteralDataOffset + 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Post-processing hook
|
||||
|
||||
@@ -77,6 +77,7 @@ public partial record struct Il2CppCodeRegistration
|
||||
[NativeInteger]
|
||||
[VersionCondition(EqualTo = "29.0", IncludingTag = "2022"), VersionCondition(EqualTo = "31.0", IncludingTag = "2022")]
|
||||
[VersionCondition(EqualTo = "29.0", IncludingTag = "2023"), VersionCondition(EqualTo = "31.0", IncludingTag = "2023")]
|
||||
[VersionCondition(GreaterThan = "35.0")]
|
||||
public uint UnresolvedIndirectCallCount; // UnresolvedVirtualCallCount pre 29.1
|
||||
|
||||
[VersionCondition(GreaterThan = "22.0")]
|
||||
@@ -84,10 +85,12 @@ public partial record struct Il2CppCodeRegistration
|
||||
|
||||
[VersionCondition(EqualTo = "29.0", IncludingTag = "2022"), VersionCondition(EqualTo = "31.0", IncludingTag = "2022")]
|
||||
[VersionCondition(EqualTo = "29.0", IncludingTag = "2023"), VersionCondition(EqualTo = "31.0", IncludingTag = "2023")]
|
||||
[VersionCondition(GreaterThan = "35.0")]
|
||||
public Pointer<Il2CppMethodPointer> UnresolvedInstanceCallWrappers;
|
||||
|
||||
[VersionCondition(EqualTo = "29.0", IncludingTag = "2022"), VersionCondition(EqualTo = "31.0", IncludingTag = "2022")]
|
||||
[VersionCondition(EqualTo = "29.0", IncludingTag = "2023"), VersionCondition(EqualTo = "31.0", IncludingTag = "2023")]
|
||||
[VersionCondition(GreaterThan = "35.0")]
|
||||
public Pointer<Il2CppMethodPointer> UnresolvedStaticCallPointers;
|
||||
|
||||
[NativeInteger]
|
||||
|
||||
@@ -18,7 +18,7 @@ public partial record struct Il2CppMethodDefinition
|
||||
public TypeDefinitionIndex DeclaringType { get; private set; }
|
||||
public TypeIndex ReturnType { get; private set; }
|
||||
|
||||
[VersionCondition(EqualTo = "31.0")]
|
||||
[VersionCondition(GreaterThan = "31.0")]
|
||||
public uint ReturnParameterToken { get; private set; }
|
||||
|
||||
public ParameterIndex ParameterStart { get; private set; }
|
||||
|
||||
@@ -6,6 +6,7 @@ using StringLiteralIndex = int;
|
||||
[VersionedStruct]
|
||||
public partial record struct Il2CppStringLiteral
|
||||
{
|
||||
[VersionCondition(LessThan = "31.0")]
|
||||
public uint Length { get; private set; }
|
||||
public StringLiteralIndex DataIndex { get; private set; }
|
||||
}
|
||||
@@ -32,6 +32,8 @@ public partial record struct Il2CppTypeDefinition
|
||||
|
||||
public TypeIndex DeclaringTypeIndex { get; private set; }
|
||||
public TypeIndex ParentIndex { get; private set; }
|
||||
|
||||
[VersionCondition(LessThan = "31.0")]
|
||||
public TypeIndex ElementTypeIndex { get; private set; }
|
||||
|
||||
[VersionCondition(LessThan = "24.1")]
|
||||
|
||||
@@ -28,4 +28,7 @@ public static class MetadataVersions
|
||||
|
||||
// No tag - 29.0/31.0
|
||||
public static readonly string Tag2022 = "2022"; // 29.1/31.1
|
||||
|
||||
// Unity 6000.3.0a2
|
||||
public static readonly StructVersion V350 = new(35);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Il2CppInspector.Next;
|
||||
using Il2CppInspector.Next.BinaryMetadata;
|
||||
using Il2CppInspector.Next.Metadata;
|
||||
|
||||
@@ -784,7 +785,12 @@ namespace Il2CppInspector.Reflection
|
||||
// Enumerations - bit 1 of bitfield indicates this (also the baseTypeReference will be System.Enum)
|
||||
if (Definition.Bitfield.EnumType) {
|
||||
IsEnum = true;
|
||||
enumUnderlyingTypeReference = TypeRef.FromReferenceIndex(Assembly.Model, Definition.ElementTypeIndex);
|
||||
|
||||
var enumUnderlyingTypeIndex = Assembly.Model.Package.Version >= MetadataVersions.V350
|
||||
? Definition.ParentIndex
|
||||
: Definition.ElementTypeIndex;
|
||||
|
||||
enumUnderlyingTypeReference = TypeRef.FromReferenceIndex(Assembly.Model, enumUnderlyingTypeIndex);
|
||||
}
|
||||
|
||||
// Pass-by-reference type
|
||||
|
||||
@@ -163,7 +163,11 @@ public static class BlobReader
|
||||
var typeHandle = inspector.TypeReferences[typeIndex].Data.KlassIndex;
|
||||
enumType = inspector.TypeDefinitions[typeHandle];
|
||||
|
||||
var elementTypeHandle = inspector.TypeReferences[enumType.ElementTypeIndex].Data.KlassIndex;
|
||||
var elementTypeIndex = inspector.Version >= MetadataVersions.V350
|
||||
? enumType.ParentIndex
|
||||
: enumType.ElementTypeIndex;
|
||||
|
||||
var elementTypeHandle = inspector.TypeReferences[elementTypeIndex].Data.KlassIndex;
|
||||
var elementType = inspector.TypeDefinitions[elementTypeHandle];
|
||||
typeEnum = inspector.TypeReferences[elementType.ByValTypeIndex].Type;
|
||||
}
|
||||
|
||||
@@ -754,8 +754,9 @@ Unity version | IL2CPP version | Support
|
||||
2020.2.4-2020.3.x | 27.1 | Working
|
||||
2021.1.0-2021.1.x | 27.2 | Working
|
||||
2021.2.0-2021.2.x | 29 | Working
|
||||
2021.3.0+ | 29.1 | Working
|
||||
2022.3.33+ | 31(.1) | Working
|
||||
2021.3.0-??? | 29.1 | Working
|
||||
2022.3.33-6000.2.x | 31(.1) | Working
|
||||
6000.3.0a2+ | 35 | 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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user