Rework metadata struct loading to use new struct versioning
This commit is contained in:
@@ -3,16 +3,13 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppArrayType
|
||||
public partial record struct Il2CppArrayType
|
||||
{
|
||||
public Pointer<Il2CppType> ElementType;
|
||||
public byte Rank;
|
||||
public byte NumSizes;
|
||||
public byte NumLowerBound;
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong Sizes; // int*
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong LoBounds; // int*
|
||||
public PrimitivePointer<int> Sizes;
|
||||
public PrimitivePointer<int> LoBounds;
|
||||
}
|
||||
@@ -3,17 +3,16 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppCodeGenModule
|
||||
public partial record struct Il2CppCodeGenModule
|
||||
{
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong ModuleName; // const char*
|
||||
public PrimitivePointer<byte> ModuleName; // const char*
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint MethodPointerCount;
|
||||
|
||||
public Pointer<Il2CppMethodPointer> MethodPointers;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(EqualTo = "24.5")]
|
||||
[VersionCondition(GreaterThan = "27.1")]
|
||||
public uint AdjustorThunksCount;
|
||||
@@ -22,24 +21,22 @@ public partial struct Il2CppCodeGenModule
|
||||
[VersionCondition(GreaterThan = "27.1")]
|
||||
public Pointer<Il2CppTokenAdjustorThunkPair> AdjustorThunks;
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong InvokerIndices; // int*
|
||||
public PrimitivePointer<int> InvokerIndices; // int*
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint ReversePInvokeWrapperCount;
|
||||
|
||||
public Pointer<Il2CppTokenIndexMethodTuple> ReversePInvokeWrapperIndices;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint RgctxRangesCount;
|
||||
public Pointer<Il2CppTokenRangePair> RgctxRanges;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint RgctxsCount;
|
||||
public Pointer<Il2CppRgctxDefinition> Rgctxs;
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong DebuggerMetadata; // Pointer<Il2CppDebuggerMetadataRegistration> DebuggerMetadata;
|
||||
public PrimitivePointer<byte> DebuggerMetadata; // Pointer<Il2CppDebuggerMetadataRegistration> DebuggerMetadata;
|
||||
|
||||
[VersionCondition(GreaterThan = "27.0", LessThan = "27.2")]
|
||||
public Pointer<Il2CppMethodPointer> CustomAttributeCacheGenerator;
|
||||
@@ -48,14 +45,11 @@ public partial struct Il2CppCodeGenModule
|
||||
public Il2CppMethodPointer ModuleInitializer;
|
||||
|
||||
[VersionCondition(GreaterThan = "27.0")]
|
||||
[Aligned(0)]
|
||||
public ulong StaticConstructorTypeIndices; // TypeDefinitionIndex*
|
||||
public PrimitivePointer<int> StaticConstructorTypeIndices; // TypeDefinitionIndex*
|
||||
|
||||
[VersionCondition(GreaterThan = "27.0")]
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong MetadataRegistration; // Pointer<Il2CppMetadataRegistration>
|
||||
public PrimitivePointer<byte> MetadataRegistration; // Pointer<Il2CppMetadataRegistration>
|
||||
|
||||
[VersionCondition(GreaterThan = "27.0")]
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong CodeRegistration; // Pointer<Il2CppCodeRegistration>
|
||||
public PrimitivePointer<byte> CodeRegistration; // Pointer<Il2CppCodeRegistration>
|
||||
}
|
||||
@@ -5,38 +5,42 @@ namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
using InvokerMethod = Il2CppMethodPointer;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppCodeRegistration
|
||||
public partial record struct Il2CppCodeRegistration
|
||||
{
|
||||
[VersionCondition(LessThan = "24.1"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(LessThan = "24.1")]
|
||||
public uint MethodPointersCount;
|
||||
|
||||
[VersionCondition(LessThan = "24.1")]
|
||||
public Pointer<Il2CppMethodPointer> MethodPointers;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint ReversePInvokeWrapperCount;
|
||||
|
||||
public Pointer<Il2CppMethodPointer> ReversePInvokeWrappers;
|
||||
|
||||
[VersionCondition(LessThan = "22.0"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(LessThan = "22.0")]
|
||||
public uint DelegateWrappersFromManagedToNativeCount;
|
||||
|
||||
[VersionCondition(LessThan = "22.0")]
|
||||
public Pointer<Il2CppMethodPointer> DelegateWrappersFromManagedToNative;
|
||||
|
||||
[VersionCondition(LessThan = "22.0"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(LessThan = "22.0")]
|
||||
public uint MarshalingFunctionsCount;
|
||||
|
||||
[VersionCondition(LessThan = "22.0")]
|
||||
public Pointer<Il2CppMethodPointer> MarshalingFunctions;
|
||||
|
||||
[VersionCondition(GreaterThan = "21.0", LessThan = "22.0"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(GreaterThan = "21.0", LessThan = "22.0")]
|
||||
public uint CcwMarshalingFunctionsCount;
|
||||
|
||||
[VersionCondition(GreaterThan = "21.0", LessThan = "22.0")]
|
||||
public Pointer<Il2CppMethodPointer> CcwMarshalingFunctions;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint GenericMethodPointersCount;
|
||||
|
||||
public Pointer<Il2CppMethodPointer> GenericMethodPointers;
|
||||
@@ -45,29 +49,32 @@ public partial struct Il2CppCodeRegistration
|
||||
[VersionCondition(GreaterThan = "27.1")]
|
||||
public Pointer<Il2CppMethodPointer> GenericAdjustorThunks;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint InvokerPointersCount;
|
||||
|
||||
public Pointer<InvokerMethod> InvokerPointers;
|
||||
|
||||
[VersionCondition(LessThan = "24.5"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(LessThan = "24.5")]
|
||||
public int CustomAttributeCount;
|
||||
|
||||
[VersionCondition(LessThan = "24.5")]
|
||||
public Pointer<Il2CppMethodPointer> CustomAttributeGenerators;
|
||||
|
||||
[VersionCondition(GreaterThan = "21.0", LessThan = "22.0"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(GreaterThan = "21.0", LessThan = "22.0")]
|
||||
public int GuidCount;
|
||||
|
||||
[VersionCondition(GreaterThan = "21.0", LessThan = "22.0")]
|
||||
public Pointer<Il2CppGuid> Guids;
|
||||
|
||||
[NativeInteger]
|
||||
[VersionCondition(GreaterThan = "22.0", LessThan = "29.0")]
|
||||
public int UnresolvedVirtualCallCount;
|
||||
|
||||
[NativeInteger]
|
||||
[VersionCondition(EqualTo = "29.1"), VersionCondition(EqualTo = "31.1")]
|
||||
[VersionCondition(EqualTo = "29.2"), VersionCondition(EqualTo = "31.2")]
|
||||
[Aligned(0)]
|
||||
public uint UnresolvedIndirectCallCount; // UnresolvedVirtualCallCount pre 29.1
|
||||
|
||||
[VersionCondition(GreaterThan = "22.0")]
|
||||
@@ -81,19 +88,22 @@ public partial struct Il2CppCodeRegistration
|
||||
[VersionCondition(EqualTo = "29.2"), VersionCondition(EqualTo = "31.2")]
|
||||
public Pointer<Il2CppMethodPointer> UnresolvedStaticCallPointers;
|
||||
|
||||
[VersionCondition(GreaterThan = "23.0"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(GreaterThan = "23.0")]
|
||||
public uint InteropDataCount;
|
||||
|
||||
[VersionCondition(GreaterThan = "23.0")]
|
||||
public Pointer<Il2CppInteropData> InteropData;
|
||||
|
||||
[VersionCondition(GreaterThan = "24.3"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(GreaterThan = "24.3")]
|
||||
public uint WindowsRuntimeFactoryCount;
|
||||
|
||||
[VersionCondition(GreaterThan = "24.3")]
|
||||
public Pointer<Il2CppWindowsRuntimeFactoryTableEntry> WindowsRuntimeFactoryTable;
|
||||
|
||||
[VersionCondition(GreaterThan = "24.2"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(GreaterThan = "24.2")]
|
||||
public uint CodeGenModulesCount;
|
||||
|
||||
[VersionCondition(GreaterThan = "24.2")]
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppGenericClass
|
||||
public partial record struct Il2CppGenericClass
|
||||
{
|
||||
[VersionCondition(LessThan = "24.5"), Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(LessThan = "24.5")]
|
||||
public int TypeDefinitionIndex;
|
||||
|
||||
[VersionCondition(GreaterThan = "27.0")]
|
||||
@@ -13,6 +14,5 @@ public partial struct Il2CppGenericClass
|
||||
|
||||
public Il2CppGenericContext Context;
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong CachedClass; // Il2CppClass*, optional
|
||||
public PrimitivePointer<byte> CachedClass; // Il2CppClass*, optional
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppGenericContext
|
||||
public partial record struct Il2CppGenericContext
|
||||
{
|
||||
public Pointer<Il2CppGenericInst> ClassInst;
|
||||
public Pointer<Il2CppGenericInst> MethodInst;
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppGenericInst
|
||||
public partial record struct Il2CppGenericInst
|
||||
{
|
||||
public readonly bool Valid => TypeArgc > 0;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint TypeArgc;
|
||||
|
||||
public Pointer<Pointer<Il2CppType>> TypeArgv;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
using GenericMethodIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppGenericMethodFunctionsDefinitions
|
||||
public partial record struct Il2CppGenericMethodFunctionsDefinitions
|
||||
{
|
||||
public GenericMethodIndex GenericMethodIndex;
|
||||
public Il2CppGenericMethodIndices Indices;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
using MethodIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppGenericMethodIndices
|
||||
public partial record struct Il2CppGenericMethodIndices
|
||||
{
|
||||
public MethodIndex MethodIndex;
|
||||
public MethodIndex InvokerIndex;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
|
||||
public struct Il2CppGuid : IReadable
|
||||
public record struct Il2CppGuid : IReadable
|
||||
{
|
||||
public Guid Value;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using PInvokeMarshalCleanupFunc = Il2CppMethodPointer;
|
||||
using CreateCCWFunc = Il2CppMethodPointer;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppInteropData
|
||||
public partial record struct Il2CppInteropData
|
||||
{
|
||||
public Il2CppMethodPointer DelegatePInvokeWrapperFunction;
|
||||
public PInvokeMarshalToNativeFunc PInvokeMarshalToNativeFunction;
|
||||
|
||||
@@ -7,51 +7,50 @@ using FieldIndex = int;
|
||||
using TypeDefinitionIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppMetadataRegistration
|
||||
public partial record struct Il2CppMetadataRegistration
|
||||
{
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public int GenericClassesCount;
|
||||
|
||||
public Pointer<Pointer<Il2CppGenericClass>> GenericClasses;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public int GenericInstsCount;
|
||||
|
||||
public Pointer<Pointer<Il2CppGenericInst>> GenericInsts;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public int GenericMethodTableCount;
|
||||
|
||||
public Pointer<Il2CppGenericMethodFunctionsDefinitions> GenericMethodTable;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public int TypesCount;
|
||||
|
||||
public Pointer<Pointer<Il2CppType>> Types;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public int MethodSpecsCount;
|
||||
|
||||
public Pointer<Il2CppMethodSpec> MethodSpecs;
|
||||
|
||||
[NativeInteger]
|
||||
[VersionCondition(LessThan = "16.0")]
|
||||
public int MethodReferencesCount;
|
||||
|
||||
[VersionCondition(LessThan = "16.0")]
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong MethodReferences; // uint**
|
||||
public PrimitivePointer<PrimitivePointer<uint>> MethodReferences; // uint**
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public FieldIndex FieldOffsetsCount;
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong FieldOffsets; // int**
|
||||
public PrimitivePointer<PrimitivePointer<int>> FieldOffsets; // int**
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public TypeDefinitionIndex TypeDefinitionsSizesCount;
|
||||
public Pointer<Pointer<Il2CppTypeDefinitionSizes>> TypeDefinitionsSizes;
|
||||
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
[VersionCondition(GreaterThan = "19.0")]
|
||||
public ulong MetadataUsagesCount;
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppMethodPointer(ulong addr = 0)
|
||||
public partial record struct Il2CppMethodPointer(ulong addr = 0)
|
||||
{
|
||||
public static readonly Il2CppMethodPointer Null = new();
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
[NativeInteger]
|
||||
public ulong Value { get; set; } = addr;
|
||||
|
||||
public readonly bool IsNull => Value == 0;
|
||||
|
||||
@@ -6,7 +6,7 @@ using MethodIndex = int;
|
||||
using GenericInstIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppMethodSpec
|
||||
public partial record struct Il2CppMethodSpec
|
||||
{
|
||||
public MethodIndex MethodDefinitionIndex;
|
||||
public GenericInstIndex ClassIndexIndex;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppRange
|
||||
public partial record struct Il2CppRange
|
||||
{
|
||||
public int Start;
|
||||
public int Length;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppRgctxConstrainedData
|
||||
public partial record struct Il2CppRgctxConstrainedData
|
||||
{
|
||||
public TypeIndex TypeIndex;
|
||||
public Il2CppMetadataUsage EncodedMethodIndex;
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppRgctxDefinition
|
||||
public partial record struct Il2CppRgctxDefinition
|
||||
{
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public Il2CppRgctxDataType Type;
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong Data; // void*
|
||||
public PrimitivePointer<byte> Data; // void*
|
||||
|
||||
public readonly Pointer<Il2CppRgctxDefinitionData> Definition => Data;
|
||||
public readonly Pointer<Il2CppRgctxConstrainedData> Constrained => Data;
|
||||
public readonly Pointer<Il2CppRgctxDefinitionData> Definition => Data.PointerValue;
|
||||
public readonly Pointer<Il2CppRgctxConstrainedData> Constrained => Data.PointerValue;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using MethodIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppRgctxDefinitionData
|
||||
public partial record struct Il2CppRgctxDefinitionData
|
||||
{
|
||||
public int Value;
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppTokenAdjustorThunkPair
|
||||
public partial record struct Il2CppTokenAdjustorThunkPair
|
||||
{
|
||||
[Aligned(0)]
|
||||
[NativeInteger]
|
||||
public uint Token;
|
||||
|
||||
public Il2CppMethodPointer AdjustorThunk;
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppTokenIndexMethodTuple
|
||||
public partial record struct Il2CppTokenIndexMethodTuple
|
||||
{
|
||||
public uint Token;
|
||||
public int Index;
|
||||
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
public ulong Method; // void**
|
||||
public PrimitivePointer<Il2CppMethodPointer> Method; // void**
|
||||
|
||||
public uint GenericMethodIndex;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppTokenRangePair
|
||||
public partial record struct Il2CppTokenRangePair
|
||||
{
|
||||
public uint Token;
|
||||
public Il2CppRange Range;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppTypeDefinitionSizes
|
||||
public partial record struct Il2CppTypeDefinitionSizes
|
||||
{
|
||||
public uint InstanceSize;
|
||||
public int NativeSize;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.BinaryMetadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppWindowsRuntimeFactoryTableEntry
|
||||
public partial record struct Il2CppWindowsRuntimeFactoryTableEntry
|
||||
{
|
||||
public Pointer<Il2CppType> Type;
|
||||
public Il2CppMethodPointer CreateFactoryFunction;
|
||||
|
||||
@@ -8,6 +8,18 @@ namespace Il2CppInspector.Next;
|
||||
|
||||
public class BinaryObjectStreamReader : BinaryObjectStream, IReader
|
||||
{
|
||||
public new StructVersion Version
|
||||
{
|
||||
get => _version;
|
||||
set
|
||||
{
|
||||
_version = value;
|
||||
base.Version = _version.AsDouble;
|
||||
}
|
||||
}
|
||||
|
||||
private StructVersion _version;
|
||||
|
||||
public virtual int Bits { get; set; }
|
||||
public bool Is32Bit => Bits == 32;
|
||||
|
||||
@@ -127,4 +139,9 @@ public class BinaryObjectStreamReader : BinaryObjectStream, IReader
|
||||
Position = addr;
|
||||
return ReadVersionedObjectArray<TType>(count, Version);
|
||||
}
|
||||
|
||||
public void Skip(int count)
|
||||
{
|
||||
Position += count;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using ImageIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public partial struct Il2CppAssemblyDefinition
|
||||
public partial record struct Il2CppAssemblyDefinition
|
||||
{
|
||||
[FieldOffset(20)]
|
||||
[VersionCondition(LessThan = "15.0")]
|
||||
|
||||
@@ -17,7 +17,7 @@ public struct PublicKeyToken
|
||||
|
||||
[VersionedStruct]
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public partial struct Il2CppAssemblyNameDefinition
|
||||
public partial record struct Il2CppAssemblyNameDefinition
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public StringIndex NameIndex;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppCustomAttributeDataRange
|
||||
public partial record struct Il2CppCustomAttributeDataRange
|
||||
{
|
||||
public uint Token { get; private set; }
|
||||
public uint StartOffset { get; private set; }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppCustomAttributeTypeRange
|
||||
public partial record struct Il2CppCustomAttributeTypeRange
|
||||
{
|
||||
[VersionCondition(GreaterThan = "24.1")]
|
||||
public uint Token { get; private set; }
|
||||
|
||||
@@ -6,7 +6,7 @@ using MethodIndex = int;
|
||||
using VersionedSerialization.Attributes;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppEventDefinition
|
||||
public partial record struct Il2CppEventDefinition
|
||||
{
|
||||
public StringIndex NameIndex { get; private set; }
|
||||
public TypeIndex TypeIndex { get; private set; }
|
||||
|
||||
@@ -7,7 +7,7 @@ using TypeIndex = int;
|
||||
using DefaultValueDataIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppFieldDefaultValue
|
||||
public partial record struct Il2CppFieldDefaultValue
|
||||
{
|
||||
public FieldIndex FieldIndex { get; private set; }
|
||||
public TypeIndex TypeIndex { get; private set; }
|
||||
|
||||
@@ -5,7 +5,7 @@ using StringIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppFieldDefinition
|
||||
public partial record struct Il2CppFieldDefinition
|
||||
{
|
||||
public StringIndex NameIndex { get; private set; }
|
||||
public TypeIndex TypeIndex { get; private set; }
|
||||
|
||||
@@ -5,7 +5,7 @@ using FieldIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppFieldMarshaledSize
|
||||
public partial record struct Il2CppFieldMarshaledSize
|
||||
{
|
||||
public FieldIndex FieldIndex { get; private set; }
|
||||
public TypeIndex TypeIndex { get; private set; }
|
||||
|
||||
@@ -6,7 +6,7 @@ using FieldIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppFieldRef
|
||||
public partial record struct Il2CppFieldRef
|
||||
{
|
||||
public TypeIndex TypeIndex { get; private set; }
|
||||
public FieldIndex FieldIndex { get; private set; }
|
||||
|
||||
@@ -4,7 +4,7 @@ using VersionedSerialization.Attributes;
|
||||
using GenericParameterIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppGenericContainer
|
||||
public partial record struct Il2CppGenericContainer
|
||||
{
|
||||
public int OwnerIndex { get; private set; }
|
||||
public int TypeArgc { get; private set; }
|
||||
|
||||
@@ -8,7 +8,7 @@ using StringIndex = int;
|
||||
using GenericParameterConstraintIndex = short;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppGenericParameter
|
||||
public partial record struct Il2CppGenericParameter
|
||||
{
|
||||
public GenericContainerIndex OwnerIndex { get; private set; }
|
||||
public StringIndex NameIndex { get; private set; }
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Il2CppInspector.Next.Metadata;
|
||||
// Metadata version is written at the end of Unity.IL2CPP.MetadataCacheWriter.WriteLibIl2CppMetadata or WriteMetadata (Unity.IL2CPP.dll)
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppGlobalMetadataHeader
|
||||
public partial record struct Il2CppGlobalMetadataHeader
|
||||
{
|
||||
public int Sanity { get; private set; }
|
||||
public int Version { get; private set; }
|
||||
|
||||
@@ -8,7 +8,7 @@ using CustomAttributeIndex = int;
|
||||
using VersionedSerialization.Attributes;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppImageDefinition
|
||||
public partial record struct Il2CppImageDefinition
|
||||
{
|
||||
public StringIndex NameIndex { get; private set; }
|
||||
public AssemblyIndex AssemblyIndex { get; private set; }
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Il2CppInspector.Next.Metadata;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppInterfaceOffsetPair
|
||||
public partial record struct Il2CppInterfaceOffsetPair
|
||||
{
|
||||
public TypeIndex InterfaceTypeIndex { get; private set; }
|
||||
public int Offset { get; private set; }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppMetadataRange
|
||||
public partial record struct Il2CppMetadataRange
|
||||
{
|
||||
public int Start { get; private set; }
|
||||
public int Length { get; private set; }
|
||||
|
||||
@@ -7,7 +7,7 @@ using VersionedSerialization.Attributes;
|
||||
using EncodedMethodIndex = uint;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppMetadataUsage
|
||||
public partial record struct Il2CppMetadataUsage
|
||||
{
|
||||
private const uint TypeMask = 0b111u << 29;
|
||||
private const uint InflatedMask = 0b1;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppMetadataUsageList
|
||||
public partial record struct Il2CppMetadataUsageList
|
||||
{
|
||||
public int Start { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppMetadataUsagePair
|
||||
public partial record struct Il2CppMetadataUsagePair
|
||||
{
|
||||
public uint DestinationIndex { get; private set; }
|
||||
public uint EncodedSourceIndex { get; private set; }
|
||||
|
||||
@@ -10,7 +10,7 @@ using ParameterIndex = int;
|
||||
using GenericContainerIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppMethodDefinition
|
||||
public partial record struct Il2CppMethodDefinition
|
||||
{
|
||||
public StringIndex NameIndex { get; private set; }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using DefaultValueDataIndex = int;
|
||||
using VersionedSerialization.Attributes;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppParameterDefaultValue
|
||||
public partial record struct Il2CppParameterDefaultValue
|
||||
{
|
||||
public ParameterIndex ParameterIndex { get; private set; }
|
||||
public TypeIndex TypeIndex { get; private set; }
|
||||
|
||||
@@ -5,7 +5,7 @@ using StringIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppParameterDefinition
|
||||
public partial record struct Il2CppParameterDefinition
|
||||
{
|
||||
public StringIndex NameIndex { get; private set; }
|
||||
public uint Token { get; private set; }
|
||||
|
||||
@@ -7,7 +7,7 @@ using StringIndex = int;
|
||||
using MethodIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppPropertyDefinition
|
||||
public partial record struct Il2CppPropertyDefinition
|
||||
{
|
||||
public StringIndex NameIndex { get; private set; }
|
||||
public MethodIndex Get { get; private set; }
|
||||
|
||||
@@ -4,7 +4,7 @@ using VersionedSerialization.Attributes;
|
||||
using StringLiteralIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppStringLiteral
|
||||
public partial record struct Il2CppStringLiteral
|
||||
{
|
||||
public uint Length { get; private set; }
|
||||
public StringLiteralIndex DataIndex { get; private set; }
|
||||
|
||||
@@ -15,7 +15,7 @@ using InterfacesIndex = int;
|
||||
using VTableIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppTypeDefinition
|
||||
public partial record struct Il2CppTypeDefinition
|
||||
{
|
||||
public const TypeIndex InvalidTypeIndex = -1;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Il2CppInspector.Next.Metadata;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppTypeDefinitionBitfield
|
||||
public partial record struct Il2CppTypeDefinitionBitfield
|
||||
{
|
||||
private uint _value;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using StringIndex = int;
|
||||
using TypeIndex = int;
|
||||
|
||||
[VersionedStruct]
|
||||
public partial struct Il2CppWindowsRuntimeTypeNamePair
|
||||
public partial record struct Il2CppWindowsRuntimeTypeNamePair
|
||||
{
|
||||
public StringIndex NameIndex { get; private set; }
|
||||
public TypeIndex TypeIndex { get; private set; }
|
||||
|
||||
@@ -4,9 +4,9 @@ using VersionedSerialization.Attributes;
|
||||
|
||||
namespace Il2CppInspector.Next;
|
||||
|
||||
public struct Pointer<T>(ulong value = 0) : IReadable, IEquatable<Pointer<T>> where T : IReadable, new()
|
||||
public struct Pointer<T>(ulong value = 0) : IReadable, IEquatable<Pointer<T>> where T : struct, IReadable
|
||||
{
|
||||
[CustomSerialization("reader.ReadNUInt();", "is32Bit ? 4 : 8")]
|
||||
[NativeInteger]
|
||||
private ulong _value = value;
|
||||
|
||||
public readonly ulong PointerValue => _value;
|
||||
|
||||
60
Il2CppInspector.Common/Next/PrimitivePointer.cs
Normal file
60
Il2CppInspector.Common/Next/PrimitivePointer.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Collections.Immutable;
|
||||
using VersionedSerialization;
|
||||
using VersionedSerialization.Attributes;
|
||||
|
||||
namespace Il2CppInspector.Next;
|
||||
|
||||
public struct PrimitivePointer<T>(ulong value = 0) : IReadable, IEquatable<PrimitivePointer<T>> where T : unmanaged
|
||||
{
|
||||
[NativeInteger]
|
||||
private ulong _value = value;
|
||||
|
||||
public readonly ulong PointerValue => _value;
|
||||
public readonly bool Null => _value == 0;
|
||||
|
||||
public void Read<TReader>(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct
|
||||
{
|
||||
_value = reader.ReadNUInt();
|
||||
}
|
||||
|
||||
public static int Size(in StructVersion version = default, bool is32Bit = false)
|
||||
{
|
||||
return is32Bit ? 4 : 8;
|
||||
}
|
||||
|
||||
public readonly T Read(ref SpanReader reader)
|
||||
{
|
||||
reader.Offset = (int)PointerValue;
|
||||
return reader.ReadPrimitive<T>();
|
||||
}
|
||||
|
||||
public readonly ImmutableArray<T> ReadArray(ref SpanReader reader, long count)
|
||||
{
|
||||
reader.Offset = (int)PointerValue;
|
||||
return reader.ReadPrimitiveArray<T>(count);
|
||||
}
|
||||
|
||||
public static implicit operator PrimitivePointer<T>(ulong value) => new(value);
|
||||
public static implicit operator ulong(PrimitivePointer<T> ptr) => ptr.PointerValue;
|
||||
|
||||
#region Equality operators + ToString
|
||||
|
||||
public static bool operator ==(PrimitivePointer<T> left, PrimitivePointer<T> right)
|
||||
=> left._value == right._value;
|
||||
|
||||
public static bool operator !=(PrimitivePointer<T> left, PrimitivePointer<T> right)
|
||||
=> !(left == right);
|
||||
|
||||
public readonly override bool Equals(object? obj)
|
||||
=> obj is PrimitivePointer<T> other && Equals(other);
|
||||
|
||||
public readonly bool Equals(PrimitivePointer<T> other)
|
||||
=> this == other;
|
||||
|
||||
public readonly override int GetHashCode()
|
||||
=> HashCode.Combine(_value);
|
||||
|
||||
public readonly override string ToString() => $"0x{_value:X} <{typeof(T).Name}>";
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user