From 735dc2824b07bea1013046b5b0bd0058008d307c Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 19 Dec 2020 20:50:37 +0100 Subject: [PATCH] Plugins: Add PostProcessMetadata hook --- Il2CppInspector.Common/IL2CPP/Metadata.cs | 5 ++++- Il2CppInspector.Common/Plugins/PluginHooks.cs | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Il2CppInspector.Common/Plugins/PluginHooks.cs diff --git a/Il2CppInspector.Common/IL2CPP/Metadata.cs b/Il2CppInspector.Common/IL2CPP/Metadata.cs index 1b6fa46..c119de5 100644 --- a/Il2CppInspector.Common/IL2CPP/Metadata.cs +++ b/Il2CppInspector.Common/IL2CPP/Metadata.cs @@ -16,7 +16,7 @@ namespace Il2CppInspector { public class Metadata : BinaryObjectReader { - public Il2CppGlobalMetadataHeader Header; + public Il2CppGlobalMetadataHeader Header { get; set; } public Il2CppAssemblyDefinition[] Assemblies { get; } public Il2CppImageDefinition[] Images { get; } @@ -217,6 +217,9 @@ namespace Il2CppInspector StringLiterals = new string[stringLiteralList.Length]; for (var i = 0; i < stringLiteralList.Length; i++) StringLiterals[i] = ReadFixedLengthString(Header.stringLiteralDataOffset + stringLiteralList[i].dataIndex, stringLiteralList[i].length); + + // Post-processing hook + PluginHooks.PostProcessMetadata(this); } // Save metadata to file, overwriting if necessary diff --git a/Il2CppInspector.Common/Plugins/PluginHooks.cs b/Il2CppInspector.Common/Plugins/PluginHooks.cs new file mode 100644 index 0000000..7175b20 --- /dev/null +++ b/Il2CppInspector.Common/Plugins/PluginHooks.cs @@ -0,0 +1,17 @@ +/* + Copyright 2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty + + All rights reserved. +*/ + +// This is the ONLY line to update when the API version changes +using Il2CppInspector.PluginAPI.V100; + +namespace Il2CppInspector +{ + // Hooks we provide to plugins which can choose whether or not to provide implementations + internal static class PluginHooks + { + public static void PostProcessMetadata(Metadata metadata) => PluginManager.Try(p => p.PostProcessMetadata(metadata)); + } +}