add (untested) support for metadata v38
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<uint> VTableMethodIndices { get; set; }
|
||||
public string[] StringLiterals { get; set; }
|
||||
|
||||
public Dictionary<int, string> Strings { get; private set; } = new Dictionary<int, string>();
|
||||
public int FieldAndParameterDefaultValueDataOffset => Version >= MetadataVersions.V380
|
||||
? Header.FieldAndParameterDefaultValueData.Offset
|
||||
: Header.FieldAndParameterDefaultValueDataOffset;
|
||||
|
||||
public int AttributeDataOffset => Version >= MetadataVersions.V380
|
||||
? Header.AttributeData.Offset
|
||||
: Header.AttributeDataOffset;
|
||||
|
||||
public Dictionary<int, string> 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<Il2CppGlobalMetadataHeader>(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
|
||||
@@ -125,7 +171,7 @@ namespace Il2CppInspector
|
||||
|
||||
// Load all the relevant metadata using offsets provided in the header
|
||||
if (Version >= MetadataVersions.V160)
|
||||
Images = ReadVersionedObjectArray<Il2CppImageDefinition>(Header.ImagesOffset, Header.ImagesSize / Sizeof<Il2CppImageDefinition>());
|
||||
Images = ReadMetadataArray<Il2CppImageDefinition>(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<Il2CppImageDefinition>(Header.ImagesOffset, Header.ImagesSize / Sizeof<Il2CppImageDefinition>());
|
||||
Images = ReadMetadataArray<Il2CppImageDefinition>(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<Il2CppTypeDefinition>(Header.TypeDefinitionsOffset, Header.TypeDefinitionsSize / Sizeof<Il2CppTypeDefinition>());
|
||||
Methods = ReadVersionedObjectArray<Il2CppMethodDefinition>(Header.MethodsOffset, Header.MethodsSize / Sizeof<Il2CppMethodDefinition>());
|
||||
Params = ReadVersionedObjectArray<Il2CppParameterDefinition>(Header.ParametersOffset, Header.ParametersSize / Sizeof<Il2CppParameterDefinition>());
|
||||
Fields = ReadVersionedObjectArray<Il2CppFieldDefinition>(Header.FieldsOffset, Header.FieldsSize / Sizeof<Il2CppFieldDefinition>());
|
||||
FieldDefaultValues = ReadVersionedObjectArray<Il2CppFieldDefaultValue>(Header.FieldDefaultValuesOffset, Header.FieldDefaultValuesSize / Sizeof<Il2CppFieldDefaultValue>());
|
||||
Properties = ReadVersionedObjectArray<Il2CppPropertyDefinition>(Header.PropertiesOffset, Header.PropertiesSize / Sizeof<Il2CppPropertyDefinition>());
|
||||
Events = ReadVersionedObjectArray<Il2CppEventDefinition>(Header.EventsOffset, Header.EventsSize / Sizeof<Il2CppEventDefinition>());
|
||||
InterfaceUsageIndices = ReadPrimitiveArray<int>(Header.InterfacesOffset, Header.InterfacesSize / sizeof(int));
|
||||
NestedTypeIndices = ReadPrimitiveArray<int>(Header.NestedTypesOffset, Header.NestedTypesSize / sizeof(int));
|
||||
GenericContainers = ReadVersionedObjectArray<Il2CppGenericContainer>(Header.GenericContainersOffset, Header.GenericContainersSize / Sizeof<Il2CppGenericContainer>());
|
||||
GenericParameters = ReadVersionedObjectArray<Il2CppGenericParameter>(Header.GenericParametersOffset, Header.GenericParametersSize / Sizeof<Il2CppGenericParameter>());
|
||||
GenericConstraintIndices = ReadPrimitiveArray<int>(Header.GenericParameterConstraintsOffset, Header.GenericParameterConstraintsSize / sizeof(int));
|
||||
InterfaceOffsets = ReadVersionedObjectArray<Il2CppInterfaceOffsetPair>(Header.InterfaceOffsetsOffset, Header.InterfaceOffsetsSize / Sizeof<Il2CppInterfaceOffsetPair>());
|
||||
VTableMethodIndices = ReadPrimitiveArray<uint>(Header.VTableMethodsOffset, Header.VTableMethodsSize / sizeof(uint));
|
||||
Types = ReadMetadataArray<Il2CppTypeDefinition>(Header.TypeDefinitionsOffset, Header.TypeDefinitionsSize, Header.TypeDefinitions);
|
||||
Methods = ReadMetadataArray<Il2CppMethodDefinition>(Header.MethodsOffset, Header.MethodsSize, Header.Methods);
|
||||
Params = ReadMetadataArray<Il2CppParameterDefinition>(Header.ParametersOffset, Header.ParametersSize, Header.Parameters);
|
||||
Fields = ReadMetadataArray<Il2CppFieldDefinition>(Header.FieldsOffset, Header.FieldsSize, Header.Fields);
|
||||
FieldDefaultValues = ReadMetadataArray<Il2CppFieldDefaultValue>(Header.FieldDefaultValuesOffset, Header.FieldDefaultValuesSize, Header.FieldDefaultValues);
|
||||
Properties = ReadMetadataArray<Il2CppPropertyDefinition>(Header.PropertiesOffset, Header.PropertiesSize, Header.Properties);
|
||||
Events = ReadMetadataArray<Il2CppEventDefinition>(Header.EventsOffset, Header.EventsSize, Header.Events);
|
||||
InterfaceUsageIndices = ReadMetadataPrimitiveArray<int>(Header.InterfacesOffset, Header.InterfacesSize, Header.Interfaces);
|
||||
NestedTypeIndices = ReadMetadataPrimitiveArray<int>(Header.NestedTypesOffset, Header.NestedTypesSize, Header.NestedTypes);
|
||||
GenericContainers = ReadMetadataArray<Il2CppGenericContainer>(Header.GenericContainersOffset, Header.GenericContainersSize, Header.GenericContainers);
|
||||
GenericParameters = ReadMetadataArray<Il2CppGenericParameter>(Header.GenericParametersOffset, Header.GenericParametersSize, Header.GenericParameters);
|
||||
GenericConstraintIndices = ReadMetadataPrimitiveArray<int>(Header.GenericParameterConstraintsOffset, Header.GenericParameterConstraintsSize, Header.GenericParameterConstraints);
|
||||
InterfaceOffsets = ReadMetadataArray<Il2CppInterfaceOffsetPair>(Header.InterfaceOffsetsOffset, Header.InterfaceOffsetsSize, Header.InterfaceOffsets);
|
||||
VTableMethodIndices = ReadMetadataPrimitiveArray<uint>(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<Il2CppAssemblyDefinition>(Header.AssembliesOffset, Images.Length);
|
||||
Assemblies = ReadMetadataArray<Il2CppAssemblyDefinition>(Header.AssembliesOffset, Header.AssembliesSize, Header.Assemblies);
|
||||
|
||||
if (changedAssemblyDefStruct)
|
||||
Version = MetadataVersions.V241;
|
||||
|
||||
ParameterDefaultValues = ReadVersionedObjectArray<Il2CppParameterDefaultValue>(Header.ParameterDefaultValuesOffset, Header.ParameterDefaultValuesSize / Sizeof<Il2CppParameterDefaultValue>());
|
||||
ParameterDefaultValues = ReadMetadataArray<Il2CppParameterDefaultValue>(Header.ParameterDefaultValuesOffset, Header.ParameterDefaultValuesSize, Header.ParameterDefaultValues);
|
||||
}
|
||||
if (Version >= MetadataVersions.V190 && Version < MetadataVersions.V270) {
|
||||
MetadataUsageLists = ReadVersionedObjectArray<Il2CppMetadataUsageList>(Header.MetadataUsageListsOffset, Header.MetadataUsageListsCount / Sizeof<Il2CppMetadataUsageList>());
|
||||
MetadataUsagePairs = ReadVersionedObjectArray<Il2CppMetadataUsagePair>(Header.MetadataUsagePairsOffset, Header.MetadataUsagePairsCount / Sizeof<Il2CppMetadataUsagePair>());
|
||||
|
||||
if (Version >= MetadataVersions.V190 && Version < MetadataVersions.V270)
|
||||
{
|
||||
MetadataUsageLists = ReadMetadataArray<Il2CppMetadataUsageList>(Header.MetadataUsageListsOffset, Header.MetadataUsageListsCount, default);
|
||||
MetadataUsagePairs = ReadMetadataArray<Il2CppMetadataUsagePair>(Header.MetadataUsagePairsOffset, Header.MetadataUsagePairsCount, default);
|
||||
}
|
||||
if (Version >= MetadataVersions.V190) {
|
||||
FieldRefs = ReadVersionedObjectArray<Il2CppFieldRef>(Header.FieldRefsOffset, Header.FieldRefsSize / Sizeof<Il2CppFieldRef>());
|
||||
|
||||
if (Version >= MetadataVersions.V190)
|
||||
{
|
||||
FieldRefs = ReadMetadataArray<Il2CppFieldRef>(Header.FieldRefsOffset, Header.FieldRefsSize, Header.FieldRefs);
|
||||
}
|
||||
if (Version >= MetadataVersions.V210 && Version < MetadataVersions.V290) {
|
||||
AttributeTypeIndices = ReadPrimitiveArray<int>(Header.AttributesTypesOffset, Header.AttributesTypesCount / sizeof(int));
|
||||
AttributeTypeRanges = ReadVersionedObjectArray<Il2CppCustomAttributeTypeRange>(Header.AttributesInfoOffset, Header.AttributesInfoCount / Sizeof<Il2CppCustomAttributeTypeRange>());
|
||||
|
||||
if (Version >= MetadataVersions.V210 && Version < MetadataVersions.V290)
|
||||
{
|
||||
AttributeTypeIndices = ReadMetadataPrimitiveArray<int>(Header.AttributesTypesOffset, Header.AttributesTypesCount, default);
|
||||
AttributeTypeRanges = ReadMetadataArray<Il2CppCustomAttributeTypeRange>(Header.AttributesInfoOffset, Header.AttributesInfoCount, default);
|
||||
}
|
||||
|
||||
if (Version >= MetadataVersions.V290)
|
||||
{
|
||||
AttributeDataRanges = ReadVersionedObjectArray<Il2CppCustomAttributeDataRange>(Header.AttributeDataRangeOffset,
|
||||
Header.AttributeDataRangeSize / Sizeof<Il2CppCustomAttributeDataRange>());
|
||||
AttributeDataRanges = ReadMetadataArray<Il2CppCustomAttributeDataRange>(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<Il2CppStringLiteral>(Header.StringLiteralOffset, Header.StringLiteralSize / Sizeof<Il2CppStringLiteral>());
|
||||
else
|
||||
{
|
||||
var stringLiteralList = ReadMetadataArray<Il2CppStringLiteral>(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<T> ReadMetadataPrimitiveArray<T>(int oldOffset, int oldSize, Il2CppSectionMetadata newMetadata)
|
||||
where T : unmanaged
|
||||
{
|
||||
return Version >= MetadataVersions.V380
|
||||
? ReadPrimitiveArray<T>(newMetadata.Offset, newMetadata.Count)
|
||||
: ReadPrimitiveArray<T>(oldOffset, oldSize / Unsafe.SizeOf<T>());
|
||||
}
|
||||
|
||||
public ImmutableArray<T> ReadMetadataArray<T>(int oldOffset, int oldSize, Il2CppSectionMetadata newMetadata)
|
||||
where T : IReadable, new()
|
||||
{
|
||||
return Version >= MetadataVersions.V380
|
||||
? ReadVersionedObjectArray<T>(newMetadata.Offset, newMetadata.Count)
|
||||
: ReadVersionedObjectArray<T>(oldOffset, oldSize / Sizeof<T>());
|
||||
}
|
||||
|
||||
// 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<T>() where T : IReadable => T.Size(Version, Is32Bit);
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using VersionedSerialization;
|
||||
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
public struct GenericContainerIndex(int value) : IReadable, IEquatable<GenericContainerIndex>
|
||||
{
|
||||
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<TReader>(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<short>();
|
||||
_value = _value == ushort.MaxValue ? -1 : _value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (version.Tag.Contains($"{TagPrefix}1"))
|
||||
{
|
||||
_value = reader.ReadPrimitive<byte>();
|
||||
_value = _value == byte.MaxValue ? -1 : _value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_value = reader.ReadPrimitive<int>();
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
using StringIndex = int;
|
||||
using TypeIndex = int;
|
||||
using MethodIndex = int;
|
||||
using VersionedSerialization.Attributes;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
using FieldIndex = int;
|
||||
using TypeIndex = int;
|
||||
using DefaultValueDataIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
using VersionedSerialization.Attributes;
|
||||
using StringIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial record struct Il2CppFieldDefinition
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
using VersionedSerialization.Attributes;
|
||||
using FieldIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial record struct Il2CppFieldMarshaledSize
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
using FieldIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial record struct Il2CppFieldRef
|
||||
|
||||
@@ -3,7 +3,6 @@ using VersionedSerialization.Attributes;
|
||||
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
using GenericContainerIndex = int;
|
||||
using StringIndex = int;
|
||||
using GenericParameterConstraintIndex = short;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
using StringIndex = int;
|
||||
using AssemblyIndex = int;
|
||||
using TypeDefinitionIndex = int;
|
||||
using MethodIndex = int;
|
||||
using CustomAttributeIndex = int;
|
||||
using VersionedSerialization.Attributes;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial record struct Il2CppInterfaceOffsetPair
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
using ParameterIndex = int;
|
||||
using TypeIndex = int;
|
||||
using DefaultValueDataIndex = int;
|
||||
using VersionedSerialization.Attributes;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
using VersionedSerialization.Attributes;
|
||||
using StringIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial record struct Il2CppParameterDefinition
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
using VersionedSerialization.Attributes;
|
||||
using StringIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial record struct Il2CppWindowsRuntimeTypeNamePair
|
||||
|
||||
75
Il2CppInspector.Common/Next/Metadata/TypeDefinitionIndex.cs
Normal file
75
Il2CppInspector.Common/Next/Metadata/TypeDefinitionIndex.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using VersionedSerialization;
|
||||
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
public struct TypeDefinitionIndex(int value) : IReadable, IEquatable<TypeDefinitionIndex>
|
||||
{
|
||||
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<TReader>(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<ushort>();
|
||||
return;
|
||||
}
|
||||
|
||||
if (version.Tag.Contains($"{TagPrefix}1"))
|
||||
{
|
||||
_value = reader.ReadPrimitive<byte>();
|
||||
_value = _value == byte.MaxValue ? -1 : _value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_value = reader.ReadPrimitive<int>();
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
76
Il2CppInspector.Common/Next/Metadata/TypeIndex.cs
Normal file
76
Il2CppInspector.Common/Next/Metadata/TypeIndex.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using VersionedSerialization;
|
||||
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
public struct TypeIndex(int value) : IReadable, IEquatable<TypeIndex>
|
||||
{
|
||||
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<TReader>(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<ushort>();
|
||||
_value = _value == ushort.MaxValue ? -1 : _value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (version.Tag.Contains($"{TagPrefix}1"))
|
||||
{
|
||||
_value = reader.ReadPrimitive<byte>();
|
||||
_value = _value == byte.MaxValue ? -1 : _value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_value = reader.ReadPrimitive<int>();
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user