Plugins: Add IPostProcessTypeModel

This commit is contained in:
Katy Coe
2020-12-21 19:11:49 +01:00
parent b1d61f81f0
commit 5dc8e823c4
4 changed files with 21 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
using System; using System;
using System.IO; using System.IO;
using Il2CppInspector.Reflection;
namespace Il2CppInspector.PluginAPI.V100 namespace Il2CppInspector.PluginAPI.V100
{ {
@@ -25,4 +26,12 @@ namespace Il2CppInspector.PluginAPI.V100
{ {
void PostProcessMetadata(Metadata metadata, PluginPostProcessMetadataEventInfo data); void PostProcessMetadata(Metadata metadata, PluginPostProcessMetadataEventInfo data);
} }
/// <summary>
/// Post-process the .NET type model to make changes after it has been fully created
/// </summary>
public interface IPostProcessTypeModel
{
void PostProcessTypeModel(TypeModel model, PluginPostProcessTypeModelEventInfo data);
}
} }

View File

@@ -79,6 +79,11 @@ namespace Il2CppInspector.PluginAPI.V100
/// </summary> /// </summary>
public class PluginPostProcessMetadataEventInfo : PluginEventInfo { } public class PluginPostProcessMetadataEventInfo : PluginEventInfo { }
/// <summary>
/// Event info for PostProcessTypeModel
/// </summary>
public class PluginPostProcessTypeModelEventInfo : PluginEventInfo { }
/// <summary> /// <summary>
/// Additional data for PreProcessMetadata /// Additional data for PreProcessMetadata
/// </summary> /// </summary>

View File

@@ -7,6 +7,7 @@
// This is the ONLY line to update when the API version changes // This is the ONLY line to update when the API version changes
using System.IO; using System.IO;
using Il2CppInspector.PluginAPI.V100; using Il2CppInspector.PluginAPI.V100;
using Il2CppInspector.Reflection;
namespace Il2CppInspector namespace Il2CppInspector
{ {
@@ -21,5 +22,8 @@ namespace Il2CppInspector
stream.Position = 0; stream.Position = 0;
p.PreProcessMetadata(stream, e); p.PreProcessMetadata(stream, e);
}); });
public static PluginPostProcessTypeModelEventInfo PostProcessTypeModel(TypeModel typeModel)
=> PluginManager.Try<IPostProcessTypeModel, PluginPostProcessTypeModelEventInfo>((p, e) => p.PostProcessTypeModel(typeModel, e));
} }
} }

View File

@@ -166,6 +166,9 @@ namespace Il2CppInspector.Reflection
GenericMethods[spec].Invoker = MethodInvokers[index]; GenericMethods[spec].Invoker = MethodInvokers[index];
} }
} }
// Post-processing hook
PluginHooks.PostProcessTypeModel(this);
} }
// Get generic arguments from either a type or method instanceIndex from a MethodSpec // Get generic arguments from either a type or method instanceIndex from a MethodSpec