IL2CPP: Load metadata v27; mark broken areas with TODO
This commit is contained in:
@@ -267,7 +267,10 @@ namespace Il2CppInspector
|
||||
TypeReferences = Image.ReadMappedObjectPointerArray<Il2CppType>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount);
|
||||
|
||||
// Custom attribute constructors (function pointers)
|
||||
CustomAttributeGenerators = Image.ReadMappedArray<ulong>(CodeRegistration.customAttributeGenerators, (int) CodeRegistration.customAttributeCount);
|
||||
// TODO: Custom attribute generator load is broken in metadata v27 - this was moved to Il2CppCodeGenModule
|
||||
if (Image.Version < 27) {
|
||||
CustomAttributeGenerators = Image.ReadMappedArray<ulong>(CodeRegistration.customAttributeGenerators, (int) CodeRegistration.customAttributeCount);
|
||||
}
|
||||
|
||||
// Method.Invoke function pointers
|
||||
MethodInvokePointers = Image.ReadMappedArray<ulong>(CodeRegistration.invokerPointers, (int) CodeRegistration.invokerPointersCount);
|
||||
|
||||
@@ -127,6 +127,7 @@ namespace Il2CppInspector
|
||||
return ((ulong) pValue, value);
|
||||
}
|
||||
|
||||
// TODO: The resolution of metadata usages is broken for metadata v27 (MetadataUsageLists, MetadataUsagePairs no longer exist)
|
||||
private List<MetadataUsage> buildMetadataUsages()
|
||||
{
|
||||
var usages = new Dictionary<uint, MetadataUsage>();
|
||||
|
||||
@@ -148,6 +148,7 @@ namespace Il2CppInspector
|
||||
var mrSize = (ulong) Metadata.Sizeof(typeof(Il2CppMetadataRegistration), Image.Version, Image.Bits / 8);
|
||||
vas = FindAllMappedWords(imageBytes, (ulong) metadata.Types.Length).Select(a => a - mrSize + ptrSize * 4);
|
||||
|
||||
// TODO: The metadata usages heuristic no longer works in metadata v27
|
||||
foreach (var va in vas) {
|
||||
var mr = Image.ReadMappedObject<Il2CppMetadataRegistration>(va);
|
||||
if (mr.metadataUsagesCount == (ulong) metadata.MetadataUsageLists.Length)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Il2CppInspector
|
||||
|
||||
// Rewind and read metadata header in full
|
||||
Header = ReadObject<Il2CppGlobalMetadataHeader>(0);
|
||||
if (Version < 16 || Version > 24)
|
||||
if (Version < 16 || Version > 27)
|
||||
{
|
||||
throw new InvalidOperationException($"The supplied metadata file is not of a supported version ({Header.version}).");
|
||||
}
|
||||
@@ -122,9 +122,11 @@ namespace Il2CppInspector
|
||||
Assemblies = ReadArray<Il2CppAssemblyDefinition>(Header.assembliesOffset, Header.assembliesCount / Sizeof(typeof(Il2CppAssemblyDefinition)));
|
||||
ParameterDefaultValues = ReadArray<Il2CppParameterDefaultValue>(Header.parameterDefaultValuesOffset, Header.parameterDefaultValuesCount / Sizeof(typeof(Il2CppParameterDefaultValue)));
|
||||
}
|
||||
if (Version >= 19) {
|
||||
if (Version >= 19 && Version < 27) {
|
||||
MetadataUsageLists = ReadArray<Il2CppMetadataUsageList>(Header.metadataUsageListsOffset, Header.metadataUsageListsCount / Sizeof(typeof(Il2CppMetadataUsageList)));
|
||||
MetadataUsagePairs = ReadArray<Il2CppMetadataUsagePair>(Header.metadataUsagePairsOffset, Header.metadataUsagePairsCount / Sizeof(typeof(Il2CppMetadataUsagePair)));
|
||||
}
|
||||
if (Version >= 19) {
|
||||
FieldRefs = ReadArray<Il2CppFieldRef>(Header.fieldRefsOffset, Header.fieldRefsCount / Sizeof(typeof(Il2CppFieldRef)));
|
||||
}
|
||||
if (Version >= 21) {
|
||||
|
||||
@@ -803,7 +803,9 @@ namespace Il2CppInspector.Reflection
|
||||
|
||||
// Pass-by-reference type
|
||||
// NOTE: This should actually always evaluate to false in the current implementation
|
||||
IsByRef = Index == Definition.byrefTypeIndex;
|
||||
// This field is no longer present in metadata v27
|
||||
// IsByRef = Index == Definition.byrefTypeIndex;
|
||||
IsByRef = false;
|
||||
|
||||
// Add all implemented interfaces
|
||||
implementedInterfaceReferences = new TypeRef[Definition.interfaces_count];
|
||||
|
||||
@@ -198,6 +198,8 @@ namespace Il2CppInspector.Reflection
|
||||
// It appears that TypeRef can be -1 if the generic depth recursion limit
|
||||
// (--maximum-recursive-generic-depth=) is reached in Il2Cpp. In this case,
|
||||
// no generic instance type is generated, so we just produce a null TypeInfo here.
|
||||
|
||||
// TODO: Generic type definition index resolution is broken in metadata v27 (replaced with Il2CppType *type)
|
||||
if ((generic.typeDefinitionIndex & 0xffff_ffff) == 0x0000_0000_ffff_ffff)
|
||||
return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user