Ver código fonte

Add ability to break before patched assemblies are loaded

ghorsington 6 anos atrás
pai
commit
150f812ece
1 arquivos alterados com 14 adições e 0 exclusões
  1. 14 0
      BepInEx.Preloader/Patching/AssemblyPatcher.cs

+ 14 - 0
BepInEx.Preloader/Patching/AssemblyPatcher.cs

@@ -153,6 +153,14 @@ namespace BepInEx.Preloader.Patching
 				}
 				}
             }
             }
 
 
+			if (ConfigBreakBeforeLoadAssemblies.Value)
+			{
+				Logger.LogInfo($"BepInEx is about load the following assemblies:\n{string.Join("\n", patchedAssemblies.ToArray())}");
+				Logger.LogInfo($"The assemblies were dumped into {DumpedAssembliesPath}");
+				Logger.LogInfo("Load any assemblies into the debugger, set breakpoints and continue execution.");
+				Debugger.Break();
+			}
+
 			foreach (var kv in assemblies)
 			foreach (var kv in assemblies)
 			{
 			{
 				string filename = kv.Key;
 				string filename = kv.Key;
@@ -202,6 +210,12 @@ namespace BepInEx.Preloader.Patching
             "If enabled, BepInEx will load patched assemblies from BepInEx/DumpedAssemblies instead of memory.\nThis can be used to be able to load patched assemblies into debuggers like dnSpy.\nIf set to true, will override DumpAssemblies.",
             "If enabled, BepInEx will load patched assemblies from BepInEx/DumpedAssemblies instead of memory.\nThis can be used to be able to load patched assemblies into debuggers like dnSpy.\nIf set to true, will override DumpAssemblies.",
 			false);
 			false);
 
 
+		private static readonly ConfigWrapper<bool> ConfigBreakBeforeLoadAssemblies = ConfigFile.CoreConfig.Wrap(
+			"Preloader",
+			"BreakBeforeLoadAssemblies",
+			"If enabled, BepInEx will call Debugger.Break() once before loading patched assemblies.\nThis can be used with debuggers like dnSpy to install breakpoints into patched assemblies before they are loaded.",
+			false);
+
         #endregion
         #endregion
     }
     }
 }
 }