Model: Add Model.CustomAttributeGeneratorsByAddress

This commit is contained in:
Katy Coe
2020-08-09 21:35:55 +02:00
parent 84f82474eb
commit 87de370a3a

View File

@@ -51,6 +51,9 @@ namespace Il2CppInspector.Reflection
// List of unique custom attributes generators indexed by type (multiple indices above may refer to a single generator function) // List of unique custom attributes generators indexed by type (multiple indices above may refer to a single generator function)
public Dictionary<TypeInfo, List<CustomAttributeData>> CustomAttributeGenerators { get; } public Dictionary<TypeInfo, List<CustomAttributeData>> CustomAttributeGenerators { get; }
// List of unique custom attributes generators indexed by virtual address
public Dictionary<ulong, List<CustomAttributeData>> CustomAttributeGeneratorsByAddress { get; }
// Get an assembly by its image name // Get an assembly by its image name
public Assembly GetAssembly(string name) => Assemblies.FirstOrDefault(a => a.ShortName == name); public Assembly GetAssembly(string name) => Assemblies.FirstOrDefault(a => a.ShortName == name);
@@ -137,6 +140,11 @@ namespace Il2CppInspector.Reflection
.GroupBy(a => a.AttributeType) .GroupBy(a => a.AttributeType)
.ToDictionary(g => g.Key, g => g.GroupBy(a => a.VirtualAddress.Start).Select(g => g.First()).ToList()); .ToDictionary(g => g.Key, g => g.GroupBy(a => a.VirtualAddress.Start).Select(g => g.First()).ToList());
// Populate list of unique custom attribute generators for each address
CustomAttributeGeneratorsByAddress = AttributesByIndices.Values
.GroupBy(a => a.VirtualAddress.Start)
.ToDictionary(g => g.Key, g => g.GroupBy(a => a.AttributeType).Select(g => g.First()).ToList());
// Create method invokers (one per signature, in invoker index order) // Create method invokers (one per signature, in invoker index order)
foreach (var method in MethodsByDefinitionIndex) { foreach (var method in MethodsByDefinitionIndex) {
var index = package.GetInvokerIndex(method.DeclaringType.Assembly.ModuleDefinition, method.Definition); var index = package.GetInvokerIndex(method.DeclaringType.Assembly.ModuleDefinition, method.Definition);