diff --git a/Il2CppInspector.Common/Plugins/API/V100/ILoadPipeline.cs b/Il2CppInspector.Common/Plugins/API/V100/ILoadPipeline.cs index f16768c..3a1faa6 100644 --- a/Il2CppInspector.Common/Plugins/API/V100/ILoadPipeline.cs +++ b/Il2CppInspector.Common/Plugins/API/V100/ILoadPipeline.cs @@ -4,9 +4,11 @@ All rights reserved. */ -using NoisyCowStudios.Bin2Object; -using Il2CppInspector.Reflection; using System.Collections.Generic; +using System.IO; +using Il2CppInspector.Model; +using Il2CppInspector.Reflection; +using NoisyCowStudios.Bin2Object; namespace Il2CppInspector.PluginAPI.V100 { @@ -43,6 +45,38 @@ namespace Il2CppInspector.PluginAPI.V100 /// void PostProcessMetadata(Metadata metadata, PluginPostProcessMetadataEventInfo data) { } + /// + /// 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 + /// + void PreProcessImage(BinaryObjectStream stream, PluginPreProcessImageEventInfo data) { } + + /// + /// 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 + /// + void PostProcessImage(FileFormatStream stream, PluginPostProcessImageEventInfo data) where T : FileFormatStream { } + + /// + /// Process the IL2CPP binary after Il2CppCodeRegistration and Il2CppMetadataRegistration have been found + /// but before any other structures are loaded + /// Called once per IL2CPP binary image + /// + void PreProcessBinary(Il2CppBinary binary, PluginPreProcessBinaryEventInfo data) { } + + /// + /// Process the IL2CPP binary after all structures have been loaded + /// Called once per IL2CPP binary image + /// + void PostProcessBinary(Il2CppBinary binary, PluginPostProcessBinaryEventInfo data) { } + /// /// Post-process the entire IL2CPP application package after the metadata and binary have been loaded and merged /// @@ -59,5 +93,10 @@ namespace Il2CppInspector.PluginAPI.V100 /// Post-process the .NET type model to make changes after it has been fully created /// void PostProcessTypeModel(TypeModel model, PluginPostProcessTypeModelEventInfo data) { } + + /// + /// Post-process a C++ application model to make changes after it has been fully created + /// + void PostProcessAppModel(AppModel appModel, PluginPostProcessAppModelEventInfo data) { } } } diff --git a/Il2CppInspector.Common/Plugins/API/V100/PluginEventInfo.cs b/Il2CppInspector.Common/Plugins/API/V100/PluginEventInfo.cs index 8b03d73..694e404 100644 --- a/Il2CppInspector.Common/Plugins/API/V100/PluginEventInfo.cs +++ b/Il2CppInspector.Common/Plugins/API/V100/PluginEventInfo.cs @@ -50,6 +50,11 @@ namespace Il2CppInspector.PluginAPI.V100 public PluginErrorEventArgs Error { get; set; } = null; } + /// + /// Event info for OptionsChanged + /// + public class PluginOptionsChangedEventInfo : PluginEventInfo { } + /// /// Event info for LoadPipelineStarting /// @@ -66,11 +71,6 @@ namespace Il2CppInspector.PluginAPI.V100 public bool SkipValidation { get; set; } } - /// - /// Event info for OptionsChanged - /// - public class PluginOptionsChangedEventInfo : PluginEventInfo { } - /// /// Event info for PostProcessMetadata /// @@ -98,6 +98,26 @@ namespace Il2CppInspector.PluginAPI.V100 public List StringLiterals { get; set; } = new List(); } + /// + /// Event info for PreProcessImage + /// + public class PluginPreProcessImageEventInfo : PluginEventInfo { } + + /// + /// Event info for PostProcessImage + /// + public class PluginPostProcessImageEventInfo : PluginEventInfo { } + + /// + /// Event info for PreProcessBinary + /// + public class PluginPreProcessBinaryEventInfo : PluginEventInfo { } + + /// + /// Event info for PostProcessBinary + /// + public class PluginPostProcessBinaryEventInfo : PluginEventInfo { } + /// /// Event info for PostProcessPackage /// @@ -112,4 +132,9 @@ namespace Il2CppInspector.PluginAPI.V100 /// Event info for LoadPipelineEnding /// public class PluginLoadPipelineEndingEventInfo : PluginEventInfo { } + + /// + /// Event info for PostProcessAppModel + /// + public class PluginPostProcessAppModelEventInfo : PluginEventInfo { } } diff --git a/Il2CppInspector.Common/Plugins/Internal/PluginHooks.cs b/Il2CppInspector.Common/Plugins/Internal/PluginHooks.cs index 0a3aec5..6079ff4 100644 --- a/Il2CppInspector.Common/Plugins/Internal/PluginHooks.cs +++ b/Il2CppInspector.Common/Plugins/Internal/PluginHooks.cs @@ -5,6 +5,8 @@ */ using System.Collections.Generic; +using System.IO; +using Il2CppInspector.Model; using Il2CppInspector.Reflection; using NoisyCowStudios.Bin2Object; @@ -36,6 +38,18 @@ namespace Il2CppInspector public static PluginGetStringLiteralsEventInfo GetStringLiterals(Metadata metadata) => PluginManager.Try((p, e) => p.GetStringLiterals(metadata, e)); + public static PluginPreProcessImageEventInfo PreProcessImage(BinaryObjectStream stream) + => PluginManager.Try((p, e) => p.PreProcessImage(stream, e)); + + public static PluginPostProcessImageEventInfo PostProcessImage(FileFormatStream stream) where T : FileFormatStream + => PluginManager.Try((p, e) => p.PostProcessImage(stream, e)); + + public static PluginPreProcessBinaryEventInfo PreProcessBinary(Il2CppBinary binary) + => PluginManager.Try((p, e) => p.PreProcessBinary(binary, e)); + + public static PluginPostProcessBinaryEventInfo PostProcessBinary(Il2CppBinary binary) + => PluginManager.Try((p, e) => p.PostProcessBinary(binary, e)); + public static PluginPostProcessPackageEventInfo PostProcessPackage(Il2CppInspector package) => PluginManager.Try((p, e) => p.PostProcessPackage(package, e)); @@ -44,5 +58,8 @@ namespace Il2CppInspector public static PluginPostProcessTypeModelEventInfo PostProcessTypeModel(TypeModel typeModel) => PluginManager.Try((p, e) => p.PostProcessTypeModel(typeModel, e)); + + public static PluginPostProcessAppModelEventInfo PostProcessAppModel(AppModel appModel) + => PluginManager.Try((p, e) => p.PostProcessAppModel(appModel, e)); } }