|
@@ -15,12 +15,34 @@ namespace BepInEx.Bootstrap
|
|
|
|
|
|
public delegate void AssemblyPatcherDelegate(ref AssemblyDefinition assembly);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public class AssemblyPatcher
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public IEnumerable<string> TargetDLLs { get; set; } = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public Action Initializer { get; set; } = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public Action Finalizer { get; set; } = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public AssemblyPatcherDelegate Patcher { get; set; } = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
}
|
|
|
|
|
@@ -36,11 +58,20 @@ namespace BepInEx.Bootstrap
|
|
|
|
|
|
private static bool DumpingEnabled => Utility.SafeParseBool(Config.GetEntry("dump-assemblies", "false", "Preloader"));
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public static void AddPatcher(AssemblyPatcher patcher)
|
|
|
{
|
|
|
patchers.Add(patcher);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public static void AddPatchersFromDirectory(string directory, Func<Assembly, List<AssemblyPatcher>> patcherLocator)
|
|
|
{
|
|
|
if (!Directory.Exists(directory))
|
|
@@ -75,11 +106,18 @@ namespace BepInEx.Bootstrap
|
|
|
assemblyPatcher.Finalizer?.Invoke();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public static void DisposePatchers()
|
|
|
{
|
|
|
patchers.Clear();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public static void PatchAndLoad(string directory)
|
|
|
{
|
|
|
|