IL2CPP: Reconstruct CustomAttributesGenerators for metadata v27
This commit is contained in:
@@ -48,6 +48,7 @@ namespace Il2CppInspector
|
|||||||
public long[] FieldOffsetPointers { get; private set; }
|
public long[] FieldOffsetPointers { get; private set; }
|
||||||
|
|
||||||
// Generated functions which call constructors on custom attributes
|
// Generated functions which call constructors on custom attributes
|
||||||
|
// Only for <=24.3
|
||||||
public ulong[] CustomAttributeGenerators { get; private set; }
|
public ulong[] CustomAttributeGenerators { get; private set; }
|
||||||
|
|
||||||
// IL2CPP-generated functions which implement MethodBase.Invoke with a unique signature per invoker, defined in Il2CppInvokerTable.cpp
|
// IL2CPP-generated functions which implement MethodBase.Invoke with a unique signature per invoker, defined in Il2CppInvokerTable.cpp
|
||||||
@@ -267,7 +268,7 @@ namespace Il2CppInspector
|
|||||||
TypeReferences = Image.ReadMappedObjectPointerArray<Il2CppType>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount);
|
TypeReferences = Image.ReadMappedObjectPointerArray<Il2CppType>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount);
|
||||||
|
|
||||||
// Custom attribute constructors (function pointers)
|
// Custom attribute constructors (function pointers)
|
||||||
// TODO: Custom attribute generator load is broken in metadata v27 - this was moved to Il2CppCodeGenModule
|
// This is managed in Il2CppInspector for metadata >= 27
|
||||||
if (Image.Version < 27) {
|
if (Image.Version < 27) {
|
||||||
CustomAttributeGenerators = Image.ReadMappedArray<ulong>(CodeRegistration.customAttributeGenerators, (int) CodeRegistration.customAttributeCount);
|
CustomAttributeGenerators = Image.ReadMappedArray<ulong>(CodeRegistration.customAttributeGenerators, (int) CodeRegistration.customAttributeCount);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace Il2CppInspector
|
|||||||
public Dictionary<ulong, int> TypeReferenceIndicesByAddress => Binary.TypeReferenceIndicesByAddress;
|
public Dictionary<ulong, int> TypeReferenceIndicesByAddress => Binary.TypeReferenceIndicesByAddress;
|
||||||
public List<Il2CppGenericInst> GenericInstances => Binary.GenericInstances;
|
public List<Il2CppGenericInst> GenericInstances => Binary.GenericInstances;
|
||||||
public Dictionary<string, Il2CppCodeGenModule> Modules => Binary.Modules;
|
public Dictionary<string, Il2CppCodeGenModule> Modules => Binary.Modules;
|
||||||
public ulong[] CustomAttributeGenerators => Binary.CustomAttributeGenerators;
|
public ulong[] CustomAttributeGenerators { get; }
|
||||||
public ulong[] MethodInvokePointers => Binary.MethodInvokePointers;
|
public ulong[] MethodInvokePointers => Binary.MethodInvokePointers;
|
||||||
public Il2CppMethodSpec[] MethodSpecs => Binary.MethodSpecs;
|
public Il2CppMethodSpec[] MethodSpecs => Binary.MethodSpecs;
|
||||||
public Dictionary<Il2CppMethodSpec, ulong> GenericMethodPointers => Binary.GenericMethodPointers;
|
public Dictionary<Il2CppMethodSpec, ulong> GenericMethodPointers => Binary.GenericMethodPointers;
|
||||||
@@ -193,10 +193,26 @@ namespace Il2CppInspector
|
|||||||
FieldOffsets = offsets.OrderBy(x => x.Key).Select(x => x.Value).ToList();
|
FieldOffsets = offsets.OrderBy(x => x.Key).Select(x => x.Value).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build list of custom attribute generators
|
||||||
|
if (Version < 27)
|
||||||
|
CustomAttributeGenerators = Binary.CustomAttributeGenerators;
|
||||||
|
|
||||||
|
else {
|
||||||
|
var cagCount = Images.Sum(i => i.customAttributeCount);
|
||||||
|
CustomAttributeGenerators = new ulong[cagCount];
|
||||||
|
|
||||||
|
foreach (var image in Images) {
|
||||||
|
// Get CodeGenModule for this image
|
||||||
|
var codeGenModule = Binary.Modules[Strings[image.nameIndex]];
|
||||||
|
var cags = BinaryImage.ReadMappedWordArray(codeGenModule.customAttributeCacheGenerator, (int) image.customAttributeCount);
|
||||||
|
cags.CopyTo(CustomAttributeGenerators, image.customAttributeStart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get sorted list of function pointers from all sources
|
// Get sorted list of function pointers from all sources
|
||||||
var sortedFunctionPointers = (Version <= 24.1)?
|
var sortedFunctionPointers = (Version <= 24.1)?
|
||||||
Binary.GlobalMethodPointers.ToList() :
|
Binary.GlobalMethodPointers.ToList() :
|
||||||
Binary.ModuleMethodPointers.SelectMany(module => module.Value).ToList();
|
Binary.ModuleMethodPointers.SelectMany(module => module.Value).ToList();
|
||||||
|
|
||||||
sortedFunctionPointers.AddRange(CustomAttributeGenerators);
|
sortedFunctionPointers.AddRange(CustomAttributeGenerators);
|
||||||
sortedFunctionPointers.AddRange(MethodInvokePointers);
|
sortedFunctionPointers.AddRange(MethodInvokePointers);
|
||||||
|
|||||||
Reference in New Issue
Block a user