Inspector: Load Assembly and AssemblyName metadata
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Il2CppInspector
|
||||
{
|
||||
public Il2CppGlobalMetadataHeader Header;
|
||||
|
||||
public Il2CppAssemblyDefinition[] Assemblies { get; }
|
||||
public Il2CppImageDefinition[] Images { get; }
|
||||
public Il2CppTypeDefinition[] Types { get; }
|
||||
public Il2CppMethodDefinition[] Methods { get; }
|
||||
@@ -94,6 +95,7 @@ namespace Il2CppInspector
|
||||
throw new InvalidOperationException("ERROR: Could not verify the integrity of the metadata file image list");
|
||||
}
|
||||
|
||||
Assemblies = ReadArray<Il2CppAssemblyDefinition>(Header.assembliesOffset, Header.assembliesCount / Sizeof(typeof(Il2CppAssemblyDefinition)));
|
||||
Types = ReadArray<Il2CppTypeDefinition>(Header.typeDefinitionsOffset, Header.typeDefinitionsCount / Sizeof(typeof(Il2CppTypeDefinition)));
|
||||
Methods = ReadArray<Il2CppMethodDefinition>(Header.methodsOffset, Header.methodsCount / Sizeof(typeof(Il2CppMethodDefinition)));
|
||||
Params = ReadArray<Il2CppParameterDefinition>(Header.parametersOffset, Header.parametersCount / Sizeof(typeof(Il2CppParameterDefinition)));
|
||||
@@ -135,8 +137,19 @@ namespace Il2CppInspector
|
||||
|
||||
if (i.FieldType == typeof(int) || i.FieldType == typeof(uint))
|
||||
size += 4;
|
||||
if (i.FieldType == typeof(short) || i.FieldType == typeof(ushort))
|
||||
else if (i.FieldType == typeof(short) || i.FieldType == typeof(ushort))
|
||||
size += 2;
|
||||
|
||||
// Fixed-length array
|
||||
else if (i.FieldType.IsArray) {
|
||||
var attr = i.GetCustomAttribute<ArrayLengthAttribute>(false) ??
|
||||
throw new InvalidOperationException("Array field " + i.Name + " must have ArrayLength attribute");
|
||||
size += attr.FixedSize;
|
||||
}
|
||||
|
||||
// Embedded object
|
||||
else
|
||||
size += Sizeof(i.FieldType);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -9,11 +9,16 @@ using NoisyCowStudios.Bin2Object;
|
||||
|
||||
namespace Il2CppInspector
|
||||
{
|
||||
// Unity 4.6.1p5 - first release, no global-metadata.dat
|
||||
// Unity 5.2.0f3 -> v15
|
||||
// Unity 5.6.2p3 -> v23
|
||||
// Unity 5.6.4f1 -> v23
|
||||
// Unity 2017.2f3 -> v24
|
||||
// Unity 2018.2.0f2 -> v24
|
||||
// Unity 2018.3.0f2 -> v24.1
|
||||
// Unity 2019.2.8f1 -> v24.2
|
||||
// https://unity3d.com/get-unity/download/archive
|
||||
// Metadata version is written at the end of Unity.IL2CPP.MetadataCacheWriter.WriteLibIl2CppMetadata (Unity.IL2CPP.dll)
|
||||
|
||||
// From il2cpp-metadata.h
|
||||
#pragma warning disable CS0649
|
||||
@@ -33,14 +38,18 @@ namespace Il2CppInspector
|
||||
public int propertiesCount;
|
||||
public int methodsOffset; // Il2CppMethodDefinition
|
||||
public int methodsCount;
|
||||
|
||||
public int parameterDefaultValuesOffset; // Il2CppParameterDefaultValue
|
||||
public int parameterDefaultValuesCount;
|
||||
|
||||
public int fieldDefaultValuesOffset; // Il2CppFieldDefaultValue
|
||||
public int fieldDefaultValuesCount;
|
||||
public int fieldAndParameterDefaultValueDataOffset; // uint8_t
|
||||
public int fieldAndParameterDefaultValueDataCount;
|
||||
|
||||
public int fieldMarshaledSizesOffset; // Il2CppFieldMarshaledSize
|
||||
public int fieldMarshaledSizesCount;
|
||||
|
||||
public int parametersOffset; // Il2CppParameterDefinition
|
||||
public int parametersCount;
|
||||
public int fieldsOffset; // Il2CppFieldDefinition
|
||||
@@ -146,6 +155,34 @@ namespace Il2CppInspector
|
||||
}
|
||||
#pragma warning restore CS0649
|
||||
|
||||
// Renamed from Il2CppAssembly somewhere after Unity 2017.2f3 up to Unity 2018.2.0f2
|
||||
public class Il2CppAssemblyDefinition
|
||||
{
|
||||
public int imageIndex;
|
||||
public uint token;
|
||||
public int referencedAssemblyStart;
|
||||
public int referencedAssemblyCount;
|
||||
public Il2CppAssemblyNameDefinition aname;
|
||||
}
|
||||
|
||||
// Renamed from Il2CppAssemblyName somewhere after Unity 2017.2f3 up to Unity 2018.2.0f2
|
||||
public class Il2CppAssemblyNameDefinition
|
||||
{
|
||||
public uint nameIndex;
|
||||
public uint cultureIndex;
|
||||
public uint hashValueIndex;
|
||||
public uint publicKeyIndex;
|
||||
public uint hash_alg;
|
||||
public int hash_len;
|
||||
public uint flags;
|
||||
public int major;
|
||||
public int minor;
|
||||
public int build;
|
||||
public int revision;
|
||||
[ArrayLength(FixedSize = 8)]
|
||||
public byte[] publicKeyToken;
|
||||
}
|
||||
|
||||
public class Il2CppTypeDefinition
|
||||
{
|
||||
public int nameIndex;
|
||||
|
||||
Reference in New Issue
Block a user