C++: Re-factor custom attribute generator signature handling

This commit is contained in:
Katy Coe
2020-07-18 03:33:33 +02:00
parent 2b1aff5bd1
commit 307cf29dcd
3 changed files with 14 additions and 23 deletions

View File

@@ -53,9 +53,6 @@ namespace Il2CppInspector.Model
// For il2cpp < 19, the key is the string literal ordinal instead of the address
public Dictionary<ulong, string> Strings = new Dictionary<ulong, string>();
// All of the custom attribute generator functions in the library
public Dictionary<CustomAttributeData, AppMethod> CustomAttributeGenerators = new Dictionary<CustomAttributeData, AppMethod>();
public bool StringIndexesAreOrdinals => Package.MetadataUsages == null;
// The .NET type model for the application
@@ -222,17 +219,6 @@ namespace Il2CppInspector.Model
}
}
// Add custom attribute generators to the model
foreach (var cppMethod in ILModel.AttributesByIndices.Values.Where(m => m.VirtualAddress.HasValue)) {
var cppMethodName = declarationGenerator.TypeNamer.GetName(cppMethod.AttributeType) + "_CustomAttributesCacheGenerator";
var fnPtrType = CppFnPtrType.FromSignature(CppTypeCollection, $"void (*{cppMethodName})(CustomAttributesCache *)");
fnPtrType.Name = cppMethodName;
fnPtrType.Group = "custom_attribute_generators";
var appMethod = new AppMethod(null, fnPtrType, cppMethod.VirtualAddress.Value.Start) {Group = fnPtrType.Group};
CustomAttributeGenerators.Add(cppMethod, appMethod);
}
// This is to allow this method to be chained after a new expression
return this;
}