mirror of
https://github.com/LukeFZ/Il2CppInspectorRedux.git
synced 2025-12-10 05:19:44 +05:00
Compare commits
7 Commits
38aa333764
...
193395db29
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
193395db29 | ||
|
|
481d05668d | ||
|
|
ca6c958f9a | ||
|
|
7a621b40c6 | ||
|
|
1a418280fb | ||
|
|
f1a69cafe3 | ||
|
|
e5f2fa703d |
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
|||||||
[submodule "Bin2Object"]
|
[submodule "Bin2Object"]
|
||||||
path = Bin2Object
|
path = Bin2Object
|
||||||
url = https://github.com/djkaty/Bin2Object
|
url = https://github.com/LukeFZ/Bin2Object
|
||||||
|
|||||||
Submodule Bin2Object updated: 3b09026a0d...603021c8ee
2421
Il2CppInspector.Common/Cpp/UnityHeaders/35-6000.3.0a2.h
Normal file
2421
Il2CppInspector.Common/Cpp/UnityHeaders/35-6000.3.0a2.h
Normal file
File diff suppressed because it is too large
Load Diff
2421
Il2CppInspector.Common/Cpp/UnityHeaders/38-6000.3.0a5.h
Normal file
2421
Il2CppInspector.Common/Cpp/UnityHeaders/38-6000.3.0a5.h
Normal file
File diff suppressed because it is too large
Load Diff
2421
Il2CppInspector.Common/Cpp/UnityHeaders/39-6000.3.0b1.h
Normal file
2421
Il2CppInspector.Common/Cpp/UnityHeaders/39-6000.3.0b1.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -95,7 +95,7 @@ namespace Il2CppInspector
|
|||||||
// Set object versioning for Bin2Object from metadata version
|
// Set object versioning for Bin2Object from metadata version
|
||||||
Version = new StructVersion(Header.Version);
|
Version = new StructVersion(Header.Version);
|
||||||
|
|
||||||
if (Version < MetadataVersions.V160 || Version > MetadataVersions.V380) {
|
if (Version < MetadataVersions.V160 || Version > MetadataVersions.V390) {
|
||||||
throw new InvalidOperationException($"The supplied metadata file is not of a supported version ({Header.Version}).");
|
throw new InvalidOperationException($"The supplied metadata file is not of a supported version ({Header.Version}).");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,6 +142,13 @@ namespace Il2CppInspector
|
|||||||
throw new InvalidOperationException("Could not determine TypeIndex size based on the metadata header");
|
throw new InvalidOperationException("Could not determine TypeIndex size based on the metadata header");
|
||||||
|
|
||||||
var fullTag = $"{tag}_{TypeIndex.TagPrefix}{typeIndexSize}";
|
var fullTag = $"{tag}_{TypeIndex.TagPrefix}{typeIndexSize}";
|
||||||
|
|
||||||
|
if (Version >= MetadataVersions.V390)
|
||||||
|
{
|
||||||
|
var parameterIndexSize = GetIndexSize(Header.Parameters.Count);
|
||||||
|
fullTag += $"_{ParameterIndex.TagPrefix}{parameterIndexSize}";
|
||||||
|
}
|
||||||
|
|
||||||
Version = new StructVersion(Version.Major, Version.Minor, fullTag);
|
Version = new StructVersion(Version.Major, Version.Minor, fullTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +161,11 @@ namespace Il2CppInspector
|
|||||||
// in the header after the sanity and version fields, and since it will always point directly to the first byte after the end of the header,
|
// in the header after the sanity and version fields, and since it will always point directly to the first byte after the end of the header,
|
||||||
// we can use this value to determine the actual header length and therefore narrow down the metadata version to 24.0/24.1 or 24.2.
|
// we can use this value to determine the actual header length and therefore narrow down the metadata version to 24.0/24.1 or 24.2.
|
||||||
|
|
||||||
if (!pluginResult.SkipValidation) {
|
if (!pluginResult.SkipValidation)
|
||||||
var realHeaderLength = Header.StringLiteralOffset;
|
{
|
||||||
|
var realHeaderLength = Version >= MetadataVersions.V380
|
||||||
|
? Header.StringLiterals.Offset
|
||||||
|
: Header.StringLiteralOffset;
|
||||||
|
|
||||||
if (realHeaderLength != Sizeof<Il2CppGlobalMetadataHeader>()) {
|
if (realHeaderLength != Sizeof<Il2CppGlobalMetadataHeader>()) {
|
||||||
if (Version == MetadataVersions.V240) {
|
if (Version == MetadataVersions.V240) {
|
||||||
@@ -255,10 +265,17 @@ namespace Il2CppInspector
|
|||||||
Strings = pluginGetStringsResult.Strings;
|
Strings = pluginGetStringsResult.Strings;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
Position = Header.StringOffset;
|
var stringOffset = Version >= MetadataVersions.V380
|
||||||
|
? Header.Strings.Offset
|
||||||
|
: Header.StringOffset;
|
||||||
|
var stringLength = Version >= MetadataVersions.V380
|
||||||
|
? Header.Strings.SectionSize
|
||||||
|
: Header.StringSize;
|
||||||
|
|
||||||
while (Position < Header.StringOffset + Header.StringSize)
|
Position = stringOffset;
|
||||||
Strings.Add((int) Position - Header.StringOffset, ReadNullTerminatedString());
|
|
||||||
|
while (Position < stringOffset + stringLength)
|
||||||
|
Strings.Add((int)Position - stringOffset, ReadNullTerminatedString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all string literals
|
// Get all string literals
|
||||||
@@ -277,15 +294,17 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
if (Version >= MetadataVersions.V350)
|
if (Version >= MetadataVersions.V350)
|
||||||
{
|
{
|
||||||
StringLiterals = new string[stringLiteralList.Length - 1];
|
var literals = new string[stringLiteralList.Length - 1];
|
||||||
for (var i = 0; i < stringLiteralList.Length; i++)
|
for (var i = 0; i < literals.Length; i++)
|
||||||
{
|
{
|
||||||
var currentStringDataIndex = stringLiteralList[i].DataIndex;
|
var currentStringDataIndex = stringLiteralList[i].DataIndex;
|
||||||
var nextStringDataIndex = stringLiteralList[i + 1].DataIndex;
|
var nextStringDataIndex = stringLiteralList[i + 1].DataIndex;
|
||||||
var stringLength = nextStringDataIndex - currentStringDataIndex;
|
var stringLength = nextStringDataIndex - currentStringDataIndex;
|
||||||
|
|
||||||
StringLiterals[i] = ReadFixedLengthString(dataOffset + currentStringDataIndex, stringLength);
|
literals[i] = ReadFixedLengthString(dataOffset + currentStringDataIndex, stringLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringLiterals = literals;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,58 +2,27 @@
|
|||||||
|
|
||||||
namespace Il2CppInspector.Next.Metadata;
|
namespace Il2CppInspector.Next.Metadata;
|
||||||
|
|
||||||
public struct GenericContainerIndex(int value) : IReadable, IEquatable<GenericContainerIndex>
|
public struct GenericContainerIndex(int value) : IIndexType<GenericContainerIndex>, IReadable, IEquatable<GenericContainerIndex>
|
||||||
{
|
{
|
||||||
public const string TagPrefix = nameof(GenericContainerIndex);
|
public const string TagPrefix = nameof(GenericContainerIndex);
|
||||||
|
|
||||||
|
static string IIndexType<GenericContainerIndex>.TagPrefix => TagPrefix;
|
||||||
|
static StructVersion IIndexType<GenericContainerIndex>.AddedVersion => MetadataVersions.V390;
|
||||||
|
|
||||||
private int _value = value;
|
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)
|
public static int Size(in StructVersion version = default, bool is32Bit = false)
|
||||||
{
|
=> IIndexType<GenericContainerIndex>.IndexSize(version, is32Bit);
|
||||||
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
|
public void Read<TReader>(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct
|
||||||
{
|
{
|
||||||
if (version >= MetadataVersions.V380
|
_value = IIndexType<GenericContainerIndex>.ReadIndex(ref reader, in version);
|
||||||
&& 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"))
|
#region Operators + ToString
|
||||||
{
|
|
||||||
_value = reader.ReadPrimitive<byte>();
|
|
||||||
_value = _value == byte.MaxValue ? -1 : _value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_value = reader.ReadPrimitive<int>();
|
public static implicit operator int(GenericContainerIndex idx) => idx._value;
|
||||||
}
|
public static implicit operator GenericContainerIndex(int idx) => new(idx);
|
||||||
|
|
||||||
#region Equality operators + ToString
|
|
||||||
|
|
||||||
public static bool operator ==(GenericContainerIndex left, GenericContainerIndex right)
|
public static bool operator ==(GenericContainerIndex left, GenericContainerIndex right)
|
||||||
=> left._value == right._value;
|
=> left._value == right._value;
|
||||||
@@ -61,7 +30,7 @@ public struct GenericContainerIndex(int value) : IReadable, IEquatable<GenericCo
|
|||||||
public static bool operator !=(GenericContainerIndex left, GenericContainerIndex right)
|
public static bool operator !=(GenericContainerIndex left, GenericContainerIndex right)
|
||||||
=> !(left == right);
|
=> !(left == right);
|
||||||
|
|
||||||
public readonly override bool Equals(object? obj)
|
public readonly override bool Equals(object obj)
|
||||||
=> obj is GenericContainerIndex other && Equals(other);
|
=> obj is GenericContainerIndex other && Equals(other);
|
||||||
|
|
||||||
public readonly bool Equals(GenericContainerIndex other)
|
public readonly bool Equals(GenericContainerIndex other)
|
||||||
|
|||||||
55
Il2CppInspector.Common/Next/Metadata/IIndexType.cs
Normal file
55
Il2CppInspector.Common/Next/Metadata/IIndexType.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using VersionedSerialization;
|
||||||
|
|
||||||
|
namespace Il2CppInspector.Next.Metadata;
|
||||||
|
|
||||||
|
public interface IIndexType<T> where T
|
||||||
|
: IIndexType<T>, allows ref struct
|
||||||
|
{
|
||||||
|
public static abstract string TagPrefix { get; }
|
||||||
|
public static abstract StructVersion AddedVersion { get; }
|
||||||
|
|
||||||
|
private static string TagSize4 => $"{T.TagPrefix}4";
|
||||||
|
private static string TagSize2 => $"{T.TagPrefix}2";
|
||||||
|
private static string TagSize1 => $"{T.TagPrefix}1";
|
||||||
|
|
||||||
|
private static bool HasCustomSize(in StructVersion version)
|
||||||
|
=> version >= T.AddedVersion
|
||||||
|
&& version.Tag != null
|
||||||
|
&& version.Tag.Contains(T.TagPrefix)
|
||||||
|
&& !version.Tag.Contains(TagSize4);
|
||||||
|
|
||||||
|
public static int IndexSize(in StructVersion version = default, bool is32Bit = false)
|
||||||
|
{
|
||||||
|
if (version.Tag != null && HasCustomSize(version))
|
||||||
|
{
|
||||||
|
if (version.Tag.Contains(TagSize2))
|
||||||
|
return sizeof(ushort);
|
||||||
|
|
||||||
|
if (version.Tag.Contains(TagSize1))
|
||||||
|
return sizeof(byte);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sizeof(int);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int ReadIndex<TReader>(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct
|
||||||
|
{
|
||||||
|
if (version.Tag != null && HasCustomSize(version))
|
||||||
|
{
|
||||||
|
if (version.Tag.Contains(TagSize2))
|
||||||
|
{
|
||||||
|
var value = reader.ReadPrimitive<ushort>();
|
||||||
|
return value == ushort.MaxValue ? -1 : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version.Tag.Contains(TagSize1))
|
||||||
|
{
|
||||||
|
var value = reader.ReadPrimitive<byte>();
|
||||||
|
return value == byte.MaxValue ? -1 : value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return reader.ReadPrimitive<int>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,7 +66,7 @@ public partial record struct Il2CppGlobalMetadataHeader
|
|||||||
[VersionCondition(LessThan = "35.0")]
|
[VersionCondition(LessThan = "35.0")]
|
||||||
public int MethodsSize { get; private set; }
|
public int MethodsSize { get; private set; }
|
||||||
|
|
||||||
[VersionCondition(GreaterThan = "16.0")]
|
[VersionCondition(GreaterThan = "16.0", LessThan = "35.0")]
|
||||||
[VersionCondition(EqualTo = "16.0")]
|
[VersionCondition(EqualTo = "16.0")]
|
||||||
public int ParameterDefaultValuesOffset { get; private set; }
|
public int ParameterDefaultValuesOffset { get; private set; }
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using VersionedSerialization.Attributes;
|
|||||||
namespace Il2CppInspector.Next.Metadata;
|
namespace Il2CppInspector.Next.Metadata;
|
||||||
|
|
||||||
using StringIndex = int;
|
using StringIndex = int;
|
||||||
using ParameterIndex = int;
|
|
||||||
|
|
||||||
[VersionedStruct]
|
[VersionedStruct]
|
||||||
public partial record struct Il2CppMethodDefinition
|
public partial record struct Il2CppMethodDefinition
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
namespace Il2CppInspector.Next.Metadata;
|
namespace Il2CppInspector.Next.Metadata;
|
||||||
|
|
||||||
using ParameterIndex = int;
|
|
||||||
using DefaultValueDataIndex = int;
|
using DefaultValueDataIndex = int;
|
||||||
using VersionedSerialization.Attributes;
|
using VersionedSerialization.Attributes;
|
||||||
|
|
||||||
|
|||||||
46
Il2CppInspector.Common/Next/Metadata/ParameterIndex.cs
Normal file
46
Il2CppInspector.Common/Next/Metadata/ParameterIndex.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using NoisyCowStudios.Bin2Object;
|
||||||
|
using VersionedSerialization;
|
||||||
|
|
||||||
|
namespace Il2CppInspector.Next.Metadata;
|
||||||
|
|
||||||
|
public struct ParameterIndex(int value) : IIndexType<ParameterIndex>, IReadable, IEquatable<ParameterIndex>
|
||||||
|
{
|
||||||
|
public const string TagPrefix = nameof(ParameterIndex);
|
||||||
|
|
||||||
|
static string IIndexType<ParameterIndex>.TagPrefix => TagPrefix;
|
||||||
|
static StructVersion IIndexType<ParameterIndex>.AddedVersion => MetadataVersions.V390;
|
||||||
|
|
||||||
|
private int _value = value;
|
||||||
|
|
||||||
|
public static int Size(in StructVersion version = default, bool is32Bit = false)
|
||||||
|
=> IIndexType<ParameterIndex>.IndexSize(version, is32Bit);
|
||||||
|
|
||||||
|
public void Read<TReader>(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct
|
||||||
|
{
|
||||||
|
_value = IIndexType<ParameterIndex>.ReadIndex(ref reader, in version);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Operators + ToString
|
||||||
|
|
||||||
|
public static implicit operator int(ParameterIndex idx) => idx._value;
|
||||||
|
public static implicit operator ParameterIndex(int idx) => new(idx);
|
||||||
|
|
||||||
|
public static bool operator ==(ParameterIndex left, ParameterIndex right)
|
||||||
|
=> left._value == right._value;
|
||||||
|
|
||||||
|
public static bool operator !=(ParameterIndex left, ParameterIndex right)
|
||||||
|
=> !(left == right);
|
||||||
|
|
||||||
|
public readonly override bool Equals(object obj)
|
||||||
|
=> obj is ParameterIndex other && Equals(other);
|
||||||
|
|
||||||
|
public readonly bool Equals(ParameterIndex other)
|
||||||
|
=> this == other;
|
||||||
|
|
||||||
|
public readonly override int GetHashCode()
|
||||||
|
=> HashCode.Combine(_value);
|
||||||
|
|
||||||
|
public readonly override string ToString() => _value.ToString();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -2,57 +2,27 @@
|
|||||||
|
|
||||||
namespace Il2CppInspector.Next.Metadata;
|
namespace Il2CppInspector.Next.Metadata;
|
||||||
|
|
||||||
public struct TypeDefinitionIndex(int value) : IReadable, IEquatable<TypeDefinitionIndex>
|
public struct TypeDefinitionIndex(int value) : IIndexType<TypeDefinitionIndex>, IReadable, IEquatable<TypeDefinitionIndex>
|
||||||
{
|
{
|
||||||
public const string TagPrefix = nameof(TypeDefinitionIndex);
|
public const string TagPrefix = nameof(TypeDefinitionIndex);
|
||||||
|
|
||||||
|
static string IIndexType<TypeDefinitionIndex>.TagPrefix => TagPrefix;
|
||||||
|
static StructVersion IIndexType<TypeDefinitionIndex>.AddedVersion => MetadataVersions.V390;
|
||||||
|
|
||||||
private int _value = value;
|
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)
|
public static int Size(in StructVersion version = default, bool is32Bit = false)
|
||||||
{
|
=> IIndexType<TypeDefinitionIndex>.IndexSize(version, is32Bit);
|
||||||
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
|
public void Read<TReader>(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct
|
||||||
{
|
{
|
||||||
if (version >= MetadataVersions.V380
|
_value = IIndexType<TypeDefinitionIndex>.ReadIndex(ref reader, in version);
|
||||||
&& 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"))
|
#region Operators + ToString
|
||||||
{
|
|
||||||
_value = reader.ReadPrimitive<byte>();
|
|
||||||
_value = _value == byte.MaxValue ? -1 : _value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_value = reader.ReadPrimitive<int>();
|
public static implicit operator int(TypeDefinitionIndex idx) => idx._value;
|
||||||
}
|
public static implicit operator TypeDefinitionIndex(int idx) => new(idx);
|
||||||
|
|
||||||
#region Equality operators + ToString
|
|
||||||
|
|
||||||
public static bool operator ==(TypeDefinitionIndex left, TypeDefinitionIndex right)
|
public static bool operator ==(TypeDefinitionIndex left, TypeDefinitionIndex right)
|
||||||
=> left._value == right._value;
|
=> left._value == right._value;
|
||||||
@@ -60,7 +30,7 @@ public struct TypeDefinitionIndex(int value) : IReadable, IEquatable<TypeDefinit
|
|||||||
public static bool operator !=(TypeDefinitionIndex left, TypeDefinitionIndex right)
|
public static bool operator !=(TypeDefinitionIndex left, TypeDefinitionIndex right)
|
||||||
=> !(left == right);
|
=> !(left == right);
|
||||||
|
|
||||||
public readonly override bool Equals(object? obj)
|
public readonly override bool Equals(object obj)
|
||||||
=> obj is TypeDefinitionIndex other && Equals(other);
|
=> obj is TypeDefinitionIndex other && Equals(other);
|
||||||
|
|
||||||
public readonly bool Equals(TypeDefinitionIndex other)
|
public readonly bool Equals(TypeDefinitionIndex other)
|
||||||
|
|||||||
@@ -2,58 +2,27 @@
|
|||||||
|
|
||||||
namespace Il2CppInspector.Next.Metadata;
|
namespace Il2CppInspector.Next.Metadata;
|
||||||
|
|
||||||
public struct TypeIndex(int value) : IReadable, IEquatable<TypeIndex>
|
public struct TypeIndex(int value) : IIndexType<TypeIndex>, IReadable, IEquatable<TypeIndex>
|
||||||
{
|
{
|
||||||
public const string TagPrefix = nameof(TypeIndex);
|
public const string TagPrefix = nameof(TypeIndex);
|
||||||
|
|
||||||
|
static string IIndexType<TypeIndex>.TagPrefix => TagPrefix;
|
||||||
|
static StructVersion IIndexType<TypeIndex>.AddedVersion => MetadataVersions.V390;
|
||||||
|
|
||||||
private int _value = value;
|
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)
|
public static int Size(in StructVersion version = default, bool is32Bit = false)
|
||||||
{
|
=> IIndexType<TypeIndex>.IndexSize(version, is32Bit);
|
||||||
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
|
public void Read<TReader>(ref TReader reader, in StructVersion version = default) where TReader : IReader, allows ref struct
|
||||||
{
|
{
|
||||||
if (version >= MetadataVersions.V380
|
_value = IIndexType<TypeIndex>.ReadIndex(ref reader, in version);
|
||||||
&& 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"))
|
#region Operators + ToString
|
||||||
{
|
|
||||||
_value = reader.ReadPrimitive<byte>();
|
|
||||||
_value = _value == byte.MaxValue ? -1 : _value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_value = reader.ReadPrimitive<int>();
|
public static implicit operator int(TypeIndex idx) => idx._value;
|
||||||
}
|
public static implicit operator TypeIndex(int idx) => new(idx);
|
||||||
|
|
||||||
#region Equality operators + ToString
|
|
||||||
|
|
||||||
public static bool operator ==(TypeIndex left, TypeIndex right)
|
public static bool operator ==(TypeIndex left, TypeIndex right)
|
||||||
=> left._value == right._value;
|
=> left._value == right._value;
|
||||||
@@ -61,7 +30,7 @@ public struct TypeIndex(int value) : IReadable, IEquatable<TypeIndex>
|
|||||||
public static bool operator !=(TypeIndex left, TypeIndex right)
|
public static bool operator !=(TypeIndex left, TypeIndex right)
|
||||||
=> !(left == right);
|
=> !(left == right);
|
||||||
|
|
||||||
public readonly override bool Equals(object? obj)
|
public readonly override bool Equals(object obj)
|
||||||
=> obj is TypeIndex other && Equals(other);
|
=> obj is TypeIndex other && Equals(other);
|
||||||
|
|
||||||
public readonly bool Equals(TypeIndex other)
|
public readonly bool Equals(TypeIndex other)
|
||||||
|
|||||||
@@ -35,4 +35,8 @@ public static class MetadataVersions
|
|||||||
// Unity 6000.3.0a5
|
// Unity 6000.3.0a5
|
||||||
public static readonly StructVersion V380 = new(38);
|
public static readonly StructVersion V380 = new(38);
|
||||||
// NOTE: This version uses tags to specify the size of TypeIndex, TypeDefinitionIndex, and GenericContainerIndex.
|
// NOTE: This version uses tags to specify the size of TypeIndex, TypeDefinitionIndex, and GenericContainerIndex.
|
||||||
|
|
||||||
|
// Unity 6000.3.0b1
|
||||||
|
public static readonly StructVersion V390 = new(39);
|
||||||
|
// NOTE This version additionally uses a tag to specify the size of ParameterIndex.
|
||||||
}
|
}
|
||||||
@@ -298,6 +298,10 @@ namespace Il2CppInspector.Outputs
|
|||||||
private PropertyDef AddProperty(ModuleDef module, TypeDef mType, PropertyInfo prop) {
|
private PropertyDef AddProperty(ModuleDef module, TypeDef mType, PropertyInfo prop) {
|
||||||
PropertySig s;
|
PropertySig s;
|
||||||
|
|
||||||
|
// Example: ZstdSharp MEM_32Bit which gets inlined using weaving and all accessors removed
|
||||||
|
if (prop.GetMethod == null && prop.SetMethod == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
// Static or instance
|
// Static or instance
|
||||||
if (prop.GetMethod?.IsStatic ?? prop.SetMethod.IsStatic)
|
if (prop.GetMethod?.IsStatic ?? prop.SetMethod.IsStatic)
|
||||||
s = PropertySig.CreateStatic(GetTypeSig(module, prop.PropertyType));
|
s = PropertySig.CreateStatic(GetTypeSig(module, prop.PropertyType));
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class BinaryNinjaDisassemblerInterface(BaseDisassemblerInterface):
|
|||||||
self._type_cache[type] = parsed
|
self._type_cache[type] = parsed
|
||||||
return parsed
|
return parsed
|
||||||
|
|
||||||
def _parse_type_source(self, types: str, filename: str | None = None):
|
def _parse_type_source(self, types: str, filename: Union[str, None] = None):
|
||||||
parsed_types, errors = TypeParser.default.parse_types_from_source(
|
parsed_types, errors = TypeParser.default.parse_types_from_source(
|
||||||
types,
|
types,
|
||||||
filename if filename else "types.hpp",
|
filename if filename else "types.hpp",
|
||||||
@@ -127,7 +127,7 @@ class BinaryNinjaDisassemblerInterface(BaseDisassemblerInterface):
|
|||||||
self._view.set_analysis_hold(False)
|
self._view.set_analysis_hold(False)
|
||||||
self._view.update_analysis()
|
self._view.update_analysis()
|
||||||
|
|
||||||
def define_function(self, address: int, end: int | None = None):
|
def define_function(self, address: int, end: Union[int, None] = None):
|
||||||
if self._view.get_function_at(address) is not None:
|
if self._view.get_function_at(address) is not None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class GhidraDisassemblerInterface(BaseDisassemblerInterface):
|
|||||||
def on_finish(self):
|
def on_finish(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def define_function(self, address: int, end: int | None = None):
|
def define_function(self, address: int, end: Union[int, None] = None):
|
||||||
address = self._to_address(address)
|
address = self._to_address(address)
|
||||||
# Don't override existing functions
|
# Don't override existing functions
|
||||||
fn = getFunctionAt(address)
|
fn = getFunctionAt(address)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class IDADisassemblerInterface(BaseDisassemblerInterface):
|
|||||||
def on_finish(self):
|
def on_finish(self):
|
||||||
ida_ida.inf_set_genflags(self._cached_genflags)
|
ida_ida.inf_set_genflags(self._cached_genflags)
|
||||||
|
|
||||||
def define_function(self, address: int, end: int | None = None):
|
def define_function(self, address: int, end: Union[int, None] = None):
|
||||||
if self._skip_function_creation:
|
if self._skip_function_creation:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
|
#@runtime PyGhidra
|
||||||
|
# ^-- required for ghidra, ignored by all others
|
||||||
|
|
||||||
# Generated script file by Il2CppInspectorRedux - https://github.com/LukeFZ (Original Il2CppInspector by http://www.djkaty.com - https://github.com/djkaty)
|
# Generated script file by Il2CppInspectorRedux - https://github.com/LukeFZ (Original Il2CppInspector by http://www.djkaty.com - https://github.com/djkaty)
|
||||||
# Target Unity version: %TARGET_UNITY_VERSION%
|
# Target Unity version: %TARGET_UNITY_VERSION%
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Union
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
class BaseStatusHandler(abc.ABC):
|
class BaseStatusHandler(abc.ABC):
|
||||||
@@ -28,7 +32,7 @@ class BaseDisassemblerInterface(abc.ABC):
|
|||||||
def on_finish(self): pass
|
def on_finish(self): pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def define_function(self, address: int, end: int | None = None): pass
|
def define_function(self, address: int, end: Union[int, None] = None): pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def define_data_array(self, address: int, type: str, count: int): pass
|
def define_data_array(self, address: int, type: str, count: int): pass
|
||||||
@@ -108,7 +112,7 @@ class ScriptContext:
|
|||||||
self._backend.set_data_name(addr, definition['name'])
|
self._backend.set_data_name(addr, definition['name'])
|
||||||
self._backend.set_data_comment(addr, definition['string'])
|
self._backend.set_data_comment(addr, definition['string'])
|
||||||
|
|
||||||
def define_field(self, addr: str, name: str, type: str, il_type: str | None = None):
|
def define_field(self, addr: str, name: str, type: str, il_type: Union[str, None] = None):
|
||||||
address = self.from_hex(addr)
|
address = self.from_hex(addr)
|
||||||
self._backend.set_data_type(address, type)
|
self._backend.set_data_type(address, type)
|
||||||
self._backend.set_data_name(address, name)
|
self._backend.set_data_name(address, name)
|
||||||
|
|||||||
@@ -332,9 +332,9 @@ The `--seperate-attributes` switch directs Il2CppInspector to put assembly-level
|
|||||||
|
|
||||||
### Adding metadata to your IDA workflow
|
### Adding metadata to your IDA workflow
|
||||||
|
|
||||||
**NOTE:** IDA 7.6+ is required, but 7.7 is recommended.
|
**NOTE:** IDA 7.6+ is required, but 7.7 is recommended. You also need to use Python 3.8+ to be able to run the script.
|
||||||
|
|
||||||
**NOTE:** Run script as-soon-as-possible after IDA loads binary into database
|
**NOTE:** Run script as-soon-as-possible after IDA loads binary into database!
|
||||||
|
|
||||||
Simply run Il2CppInspector with the `-p` switch to choose the IDA script output file. Load your binary file into IDA, press Alt+F7 and select the generated script. Observe the Output Window while IDA analyzes the file - this may take a long time.
|
Simply run Il2CppInspector with the `-p` switch to choose the IDA script output file. Load your binary file into IDA, press Alt+F7 and select the generated script. Observe the Output Window while IDA analyzes the file - this may take a long time.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user