add (untested) support for metadata v38
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user