Plugins: Add more hooks boilerplate

This commit is contained in:
Katy Coe
2020-12-29 01:31:04 +01:00
parent 0c25465c31
commit 964d845fd4
3 changed files with 88 additions and 7 deletions

View File

@@ -4,9 +4,11 @@
All rights reserved. All rights reserved.
*/ */
using NoisyCowStudios.Bin2Object;
using Il2CppInspector.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using Il2CppInspector.Model;
using Il2CppInspector.Reflection;
using NoisyCowStudios.Bin2Object;
namespace Il2CppInspector.PluginAPI.V100 namespace Il2CppInspector.PluginAPI.V100
{ {
@@ -43,6 +45,38 @@ namespace Il2CppInspector.PluginAPI.V100
/// </summary> /// </summary>
void PostProcessMetadata(Metadata metadata, PluginPostProcessMetadataEventInfo data) { } void PostProcessMetadata(Metadata metadata, PluginPostProcessMetadataEventInfo data) { }
/// <summary>
/// Process the binary image before its format is detected or analyzed
/// For AAB, APK, split APK and ZIP files, this will be a generated zip file with just the IL2CPP binaries in their original paths
/// For Fat Mach-O (UB) files with multiple images, this will be the entire file
/// For Linux process maps (eg. GameGuardian dumps), this will be the maps.txt file
/// For all other files, this will be the IL2CPP binary image itself
/// The file is copied to memory before calling this function so you can make modifications without changing the original file(s)
/// This will be called once per load pipeline
/// </summary>
void PreProcessImage(BinaryObjectStream stream, PluginPreProcessImageEventInfo data) { }
/// <summary>
/// Process the binary image after format detection and loading but before it is analyzed
/// This will be one of the classes from the FileFormatStreams folder, ie. ElfReader32, PEReader etc.
/// This will be called once per IL2CPP binary image, so for multi-architecture images such as multi-targeting APKs and Fat Mach-Os,
/// you will receive multiple calls
/// </summary>
void PostProcessImage<T>(FileFormatStream<T> stream, PluginPostProcessImageEventInfo data) where T : FileFormatStream<T> { }
/// <summary>
/// Process the IL2CPP binary after Il2CppCodeRegistration and Il2CppMetadataRegistration have been found
/// but before any other structures are loaded
/// Called once per IL2CPP binary image
/// </summary>
void PreProcessBinary(Il2CppBinary binary, PluginPreProcessBinaryEventInfo data) { }
/// <summary>
/// Process the IL2CPP binary after all structures have been loaded
/// Called once per IL2CPP binary image
/// </summary>
void PostProcessBinary(Il2CppBinary binary, PluginPostProcessBinaryEventInfo data) { }
/// <summary> /// <summary>
/// Post-process the entire IL2CPP application package after the metadata and binary have been loaded and merged /// Post-process the entire IL2CPP application package after the metadata and binary have been loaded and merged
/// </summary> /// </summary>
@@ -59,5 +93,10 @@ namespace Il2CppInspector.PluginAPI.V100
/// Post-process the .NET type model to make changes after it has been fully created /// Post-process the .NET type model to make changes after it has been fully created
/// </summary> /// </summary>
void PostProcessTypeModel(TypeModel model, PluginPostProcessTypeModelEventInfo data) { } void PostProcessTypeModel(TypeModel model, PluginPostProcessTypeModelEventInfo data) { }
/// <summary>
/// Post-process a C++ application model to make changes after it has been fully created
/// </summary>
void PostProcessAppModel(AppModel appModel, PluginPostProcessAppModelEventInfo data) { }
} }
} }

View File

@@ -50,6 +50,11 @@ namespace Il2CppInspector.PluginAPI.V100
public PluginErrorEventArgs Error { get; set; } = null; public PluginErrorEventArgs Error { get; set; } = null;
} }
/// <summary>
/// Event info for OptionsChanged
/// </summary>
public class PluginOptionsChangedEventInfo : PluginEventInfo { }
/// <summary> /// <summary>
/// Event info for LoadPipelineStarting /// Event info for LoadPipelineStarting
/// </summary> /// </summary>
@@ -66,11 +71,6 @@ namespace Il2CppInspector.PluginAPI.V100
public bool SkipValidation { get; set; } public bool SkipValidation { get; set; }
} }
/// <summary>
/// Event info for OptionsChanged
/// </summary>
public class PluginOptionsChangedEventInfo : PluginEventInfo { }
/// <summary> /// <summary>
/// Event info for PostProcessMetadata /// Event info for PostProcessMetadata
/// </summary> /// </summary>
@@ -98,6 +98,26 @@ namespace Il2CppInspector.PluginAPI.V100
public List<string> StringLiterals { get; set; } = new List<string>(); public List<string> StringLiterals { get; set; } = new List<string>();
} }
/// <summary>
/// Event info for PreProcessImage
/// </summary>
public class PluginPreProcessImageEventInfo : PluginEventInfo { }
/// <summary>
/// Event info for PostProcessImage
/// </summary>
public class PluginPostProcessImageEventInfo : PluginEventInfo { }
/// <summary>
/// Event info for PreProcessBinary
/// </summary>
public class PluginPreProcessBinaryEventInfo : PluginEventInfo { }
/// <summary>
/// Event info for PostProcessBinary
/// </summary>
public class PluginPostProcessBinaryEventInfo : PluginEventInfo { }
/// <summary> /// <summary>
/// Event info for PostProcessPackage /// Event info for PostProcessPackage
/// </summary> /// </summary>
@@ -112,4 +132,9 @@ namespace Il2CppInspector.PluginAPI.V100
/// Event info for LoadPipelineEnding /// Event info for LoadPipelineEnding
/// </summary> /// </summary>
public class PluginLoadPipelineEndingEventInfo : PluginEventInfo { } public class PluginLoadPipelineEndingEventInfo : PluginEventInfo { }
/// <summary>
/// Event info for PostProcessAppModel
/// </summary>
public class PluginPostProcessAppModelEventInfo : PluginEventInfo { }
} }

View File

@@ -5,6 +5,8 @@
*/ */
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using Il2CppInspector.Model;
using Il2CppInspector.Reflection; using Il2CppInspector.Reflection;
using NoisyCowStudios.Bin2Object; using NoisyCowStudios.Bin2Object;
@@ -36,6 +38,18 @@ namespace Il2CppInspector
public static PluginGetStringLiteralsEventInfo GetStringLiterals(Metadata metadata) public static PluginGetStringLiteralsEventInfo GetStringLiterals(Metadata metadata)
=> PluginManager.Try<ILoadPipeline, PluginGetStringLiteralsEventInfo>((p, e) => p.GetStringLiterals(metadata, e)); => PluginManager.Try<ILoadPipeline, PluginGetStringLiteralsEventInfo>((p, e) => p.GetStringLiterals(metadata, e));
public static PluginPreProcessImageEventInfo PreProcessImage(BinaryObjectStream stream)
=> PluginManager.Try<ILoadPipeline, PluginPreProcessImageEventInfo>((p, e) => p.PreProcessImage(stream, e));
public static PluginPostProcessImageEventInfo PostProcessImage<T>(FileFormatStream<T> stream) where T : FileFormatStream<T>
=> PluginManager.Try<ILoadPipeline, PluginPostProcessImageEventInfo>((p, e) => p.PostProcessImage(stream, e));
public static PluginPreProcessBinaryEventInfo PreProcessBinary(Il2CppBinary binary)
=> PluginManager.Try<ILoadPipeline, PluginPreProcessBinaryEventInfo>((p, e) => p.PreProcessBinary(binary, e));
public static PluginPostProcessBinaryEventInfo PostProcessBinary(Il2CppBinary binary)
=> PluginManager.Try<ILoadPipeline, PluginPostProcessBinaryEventInfo>((p, e) => p.PostProcessBinary(binary, e));
public static PluginPostProcessPackageEventInfo PostProcessPackage(Il2CppInspector package) public static PluginPostProcessPackageEventInfo PostProcessPackage(Il2CppInspector package)
=> PluginManager.Try<ILoadPipeline, PluginPostProcessPackageEventInfo>((p, e) => p.PostProcessPackage(package, e)); => PluginManager.Try<ILoadPipeline, PluginPostProcessPackageEventInfo>((p, e) => p.PostProcessPackage(package, e));
@@ -44,5 +58,8 @@ namespace Il2CppInspector
public static PluginPostProcessTypeModelEventInfo PostProcessTypeModel(TypeModel typeModel) public static PluginPostProcessTypeModelEventInfo PostProcessTypeModel(TypeModel typeModel)
=> PluginManager.Try<ILoadPipeline, PluginPostProcessTypeModelEventInfo>((p, e) => p.PostProcessTypeModel(typeModel, e)); => PluginManager.Try<ILoadPipeline, PluginPostProcessTypeModelEventInfo>((p, e) => p.PostProcessTypeModel(typeModel, e));
public static PluginPostProcessAppModelEventInfo PostProcessAppModel(AppModel appModel)
=> PluginManager.Try<ILoadPipeline, PluginPostProcessAppModelEventInfo>((p, e) => p.PostProcessAppModel(appModel, e));
} }
} }