Browse Source

Add check for patched BepInEx

Bepis 6 years ago
parent
commit
0800c8ef03
1 changed files with 6 additions and 1 deletions
  1. 6 1
      BepInEx/Bootstrap/Preloader.cs

+ 6 - 1
BepInEx/Bootstrap/Preloader.cs

@@ -217,9 +217,14 @@ namespace BepInEx.Bootstrap
 		/// <param name="assembly">The assembly that will be attempted to be patched.</param>
 		public static void PatchEntrypoint(ref AssemblyDefinition assembly)
 		{
+			if (assembly.MainModule.AssemblyReferences.Any(x => x.Name.Contains("BepInEx")))
+			{
+				throw new Exception("BepInEx has been detected to be patched! Please unpatch before using a patchless variant!");
+			}
+
 			string entrypointType = Config.GetEntry("entrypoint-type", "Application", "Preloader");
 			string entrypointMethod = Config.GetEntry("entrypoint-method", ".cctor", "Preloader");
-			
+
 			bool isCctor = entrypointMethod.IsNullOrWhiteSpace() || entrypointMethod == ".cctor";
 			
 			using (var injected = AssemblyDefinition.ReadAssembly(Paths.BepInExAssemblyPath))