fix Il2CppType definition for 27.2+ (better)
This commit is contained in:
@@ -382,7 +382,13 @@ namespace Il2CppInspector
|
|||||||
// Type references (pointer array)
|
// Type references (pointer array)
|
||||||
var typeRefPointers = Image.ReadMappedArray<ulong>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount);
|
var typeRefPointers = Image.ReadMappedArray<ulong>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount);
|
||||||
TypeReferenceIndicesByAddress = typeRefPointers.Zip(Enumerable.Range(0, typeRefPointers.Length), (a, i) => new { a, i }).ToDictionary(x => x.a, x => x.i);
|
TypeReferenceIndicesByAddress = typeRefPointers.Zip(Enumerable.Range(0, typeRefPointers.Length), (a, i) => new { a, i }).ToDictionary(x => x.a, x => x.i);
|
||||||
TypeReferences = Image.ReadMappedObjectPointerArray<Il2CppType>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount);
|
|
||||||
|
TypeReferences =
|
||||||
|
Image.Version >= 27.2
|
||||||
|
? Image.ReadMappedObjectPointerArray<Il2CppTypeV272>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount)
|
||||||
|
.Cast<Il2CppType>()
|
||||||
|
.ToList()
|
||||||
|
: Image.ReadMappedObjectPointerArray<Il2CppType>(MetadataRegistration.ptypes, (int)MetadataRegistration.typesCount);
|
||||||
|
|
||||||
// Custom attribute constructors (function pointers)
|
// Custom attribute constructors (function pointers)
|
||||||
// This is managed in Il2CppInspector for metadata >= 27
|
// This is managed in Il2CppInspector for metadata >= 27
|
||||||
|
|||||||
@@ -200,6 +200,18 @@ namespace Il2CppInspector
|
|||||||
// From metadata.h / il2cpp-runtime-metadata.h
|
// From metadata.h / il2cpp-runtime-metadata.h
|
||||||
public class Il2CppType
|
public class Il2CppType
|
||||||
{
|
{
|
||||||
|
public ulong datapoint;
|
||||||
|
public ulong bits; // this should be private but we need it to be public for BinaryObjectReader to work
|
||||||
|
//public Union data { get; set; }
|
||||||
|
|
||||||
|
public virtual uint attrs => (uint) bits & 0xffff;
|
||||||
|
public virtual Il2CppTypeEnum type => (Il2CppTypeEnum)((bits >> 16) & 0xff);
|
||||||
|
|
||||||
|
public virtual uint num_mods => (uint) (bits >> 24) & 0x3f;
|
||||||
|
public virtual bool byref => ((bits >> 30) & 1) == 1;
|
||||||
|
public virtual bool pinned => ((bits >> 31) & 1) == 1;
|
||||||
|
public virtual bool valuetype => false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
@@ -212,51 +224,15 @@ namespace Il2CppInspector
|
|||||||
Il2CppGenericClass* generic_class; // for GENERICINST
|
Il2CppGenericClass* generic_class; // for GENERICINST
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public ulong datapoint;
|
}
|
||||||
public ulong bits; // this should be private but we need it to be public for BinaryObjectReader to work
|
|
||||||
//public Union data { get; set; }
|
|
||||||
|
|
||||||
public uint attrs => (uint) bits & 0xffff; /* param attributes or field flags */
|
// Unity 2021.1 (v27.2): num_mods becomes 1 bit shorter, shifting byref and pinned left 1 bit, valuetype bit added
|
||||||
public Il2CppTypeEnum type => (Il2CppTypeEnum)((bits >> 16) & 0xff);
|
public class Il2CppTypeV272 : Il2CppType
|
||||||
// Unity 2021.1 (v27.2): num_mods becomes 1 bit shorter, shifting byref and pinned left 1 bit, valuetype bit added
|
{
|
||||||
|
public override uint num_mods => (uint) (bits >> 24) & 0x1f;
|
||||||
public uint NumMods(double version) => (uint) (bits >> 24) & (version >= 27.2 ? 0x1fu : 0x3fu);
|
public override bool byref => ((bits >> 29) & 1) == 1;
|
||||||
public bool ByRef(double version) => (bits >> (version >= 27.2 ? 29 : 30) & 1) == 1;
|
public override bool pinned => ((bits >> 30) & 1) == 1;
|
||||||
public bool Pinned(double version) => (bits >> (version >= 27.2 ? 30 : 31) & 1) == 1;
|
public override bool valuetype => ((bits >> 31) & 1) == 1;
|
||||||
public bool ValueType(double version) => version >= 27.2 && ((bits >> 31) & 1) == 1; // Was only added in 27.2
|
|
||||||
|
|
||||||
/*public class Union
|
|
||||||
{
|
|
||||||
public ulong dummy;
|
|
||||||
/// <summary>
|
|
||||||
/// for VALUETYPE and CLASS
|
|
||||||
/// </summary>
|
|
||||||
public long klassIndex => (long)dummy;
|
|
||||||
/// <summary>
|
|
||||||
/// for VALUETYPE and CLASS at runtime
|
|
||||||
/// </summary>
|
|
||||||
public ulong typeHandle => dummy;
|
|
||||||
/// <summary>
|
|
||||||
/// for PTR and SZARRAY
|
|
||||||
/// </summary>
|
|
||||||
public ulong type => dummy;
|
|
||||||
/// <summary>
|
|
||||||
/// for ARRAY
|
|
||||||
/// </summary>
|
|
||||||
public ulong array => dummy;
|
|
||||||
/// <summary>
|
|
||||||
/// for VAR and MVAR
|
|
||||||
/// </summary>
|
|
||||||
public long genericParameterIndex => (long)dummy;
|
|
||||||
/// <summary>
|
|
||||||
/// for VAR and MVAR at runtime
|
|
||||||
/// </summary>
|
|
||||||
public ulong genericParameterHandle => dummy;
|
|
||||||
/// <summary>
|
|
||||||
/// for GENERICINST
|
|
||||||
/// </summary>
|
|
||||||
public ulong generic_class => dummy;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Il2CppGenericClass
|
public class Il2CppGenericClass
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ namespace Il2CppInspector.Reflection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a reference type if necessary
|
// Create a reference type if necessary
|
||||||
return typeRef.ByRef(Package.Version) ? underlyingType.MakeByRefType() : underlyingType;
|
return typeRef.byref ? underlyingType.MakeByRefType() : underlyingType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basic primitive types are specified via a flag value
|
// Basic primitive types are specified via a flag value
|
||||||
|
|||||||
Reference in New Issue
Block a user