diff --git a/Il2CppInspector.Common/Outputs/JSONMetadata.cs b/Il2CppInspector.Common/Outputs/JSONMetadata.cs index 41055db..b62cd55 100644 --- a/Il2CppInspector.Common/Outputs/JSONMetadata.cs +++ b/Il2CppInspector.Common/Outputs/JSONMetadata.cs @@ -52,9 +52,11 @@ namespace Il2CppInspector.Outputs writeArray("methodDefinitions", () => writeMethods(model.GetMethodGroup("types_from_methods")), "Method definitions"); writeArray("constructedGenericMethods", () => writeMethods(model.GetMethodGroup("types_from_generic_methods")), "Constructed generic methods"); + // We could use ILModel.CustomAttributeGenerators here to ensure uniqueness but then we lose function name information + // TODO: Merge CAG names that deal with multiple attribute types to reflect all of the attribute type names (solving the above) writeArray("customAttributesGenerators", () => { foreach (var method in model.ILModel.AttributesByIndices.Values) { - writeObject(() => writeTypedFunctionName(method.VirtualAddress.Value.Start, method.Signature, method.Name)); + writeObject(() => writeTypedFunctionName(method.VirtualAddress.Start, method.Signature, method.Name)); } }, "Custom attributes generators"); diff --git a/Il2CppInspector.Common/Reflection/CustomAttributeData.cs b/Il2CppInspector.Common/Reflection/CustomAttributeData.cs index 784c38e..6585248 100644 --- a/Il2CppInspector.Common/Reflection/CustomAttributeData.cs +++ b/Il2CppInspector.Common/Reflection/CustomAttributeData.cs @@ -21,7 +21,7 @@ namespace Il2CppInspector.Reflection // The type of the attribute public TypeInfo AttributeType { get; set; } - public (ulong Start, ulong End)? VirtualAddress => + public (ulong Start, ulong End) VirtualAddress => // The last one will be wrong but there is no way to calculate it (Model.Package.CustomAttributeGenerators[Index], Model.Package.FunctionAddresses[Model.Package.CustomAttributeGenerators[Index]]); diff --git a/Il2CppInspector.Common/Reflection/Extensions.cs b/Il2CppInspector.Common/Reflection/Extensions.cs index 5491f81..e4d3604 100644 --- a/Il2CppInspector.Common/Reflection/Extensions.cs +++ b/Il2CppInspector.Common/Reflection/Extensions.cs @@ -55,6 +55,8 @@ namespace Il2CppInspector.Reflection public static string ToAddressString(this (ulong start, ulong end)? address) => ToAddressString(address?.start ?? 0) + "-" + ToAddressString(address?.end ?? 0); + public static string ToAddressString(this (ulong start, ulong end) address) => ToAddressString(address.start) + "-" + ToAddressString(address.end); + // C# string literal escape characters // Taken from: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/#regular-and-verbatim-string-literals private static Dictionary escapeChars = new Dictionary { diff --git a/Il2CppInspector.Common/Reflection/TypeModel.cs b/Il2CppInspector.Common/Reflection/TypeModel.cs index 0d9e209..a6941fd 100644 --- a/Il2CppInspector.Common/Reflection/TypeModel.cs +++ b/Il2CppInspector.Common/Reflection/TypeModel.cs @@ -133,7 +133,7 @@ namespace Il2CppInspector.Reflection var allParameterAttributes = MethodsByDefinitionIndex.SelectMany(m => m.DeclaredParameters).Select(p => p.CustomAttributes).ToList(); // Populate list of unique custom attribute generators - CustomAttributeGenerators = AttributesByIndices.Values.GroupBy(a => a.VirtualAddress.Value.Start).Select(a => a.First()).ToList(); + CustomAttributeGenerators = AttributesByIndices.Values.GroupBy(a => a.VirtualAddress.Start).Select(a => a.First()).ToList(); // Create method invokers (one per signature, in invoker index order) foreach (var method in MethodsByDefinitionIndex) {