Browse Source

Bump Doorstop to version 3.0.0.0 (for Unity mono)
Rebase of c830880

Bepis 3 years ago
parent
commit
437997b33b

+ 6 - 6
BepInEx.Preloader.Unity/DoorstopEntrypoint.cs

@@ -8,17 +8,17 @@ namespace BepInEx.Preloader.Unity
 {
 	internal static class UnityPreloaderRunner
 	{
-		public static void PreloaderPreMain(string[] args)
+		public static void PreloaderPreMain()
 		{
 			string bepinPath = Utility.ParentDirectory(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH), 2);
 
-			Paths.SetExecutablePath(args[0], bepinPath);
+			Paths.SetExecutablePath(EnvVars.DOORSTOP_MANAGED_FOLDER_DIR, bepinPath);
 			AppDomain.CurrentDomain.AssemblyResolve += LocalResolve;
 
-			PreloaderMain(args);
+			PreloaderMain();
 		}
 
-		private static void PreloaderMain(string[] args)
+		private static void PreloaderMain()
 		{
 			if (UnityPreloader.ConfigApplyRuntimePatches.Value)
 				XTermFix.Apply();
@@ -65,7 +65,7 @@ namespace BepInEx.Preloader.Unity
 			{
 				EnvVars.LoadVars();
 
-				silentExceptionLog = Path.Combine(Path.GetDirectoryName(args[0]), silentExceptionLog);
+				silentExceptionLog = Path.Combine(EnvVars.DOORSTOP_PROCESS_PATH, silentExceptionLog);
 
 				// Get the path of this DLL via Doorstop env var because Assembly.Location mangles non-ASCII characters on some versions of Mono for unknown reasons
 				preloaderPath = Path.GetDirectoryName(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH));
@@ -76,7 +76,7 @@ namespace BepInEx.Preloader.Unity
 				// To prevent that, we have to use reflection and a separate startup class so that we can install required assembly resolvers before the main code
 				typeof(DoorstopEntrypoint).Assembly.GetType($"BepInEx.Preloader.Unity.{nameof(UnityPreloaderRunner)}")
 								  ?.GetMethod(nameof(UnityPreloaderRunner.PreloaderPreMain))
-								  ?.Invoke(null, new object[] { args });
+								  ?.Invoke(null, null);
 
 				AppDomain.CurrentDomain.AssemblyResolve -= ResolveCurrentDirectory;
 			}

+ 6 - 0
BepInEx.Preloader.Unity/EnvVars.cs

@@ -18,10 +18,16 @@ namespace BepInEx.Preloader
 		/// </summary>
 		public static string DOORSTOP_MANAGED_FOLDER_DIR { get; private set; }
 
+		/// <summary>
+		/// Full path to the game executable currently running.
+		/// </summary>
+		public static string DOORSTOP_PROCESS_PATH { get; private set; }
+
 		internal static void LoadVars()
 		{
 			DOORSTOP_INVOKE_DLL_PATH = Environment.GetEnvironmentVariable("DOORSTOP_INVOKE_DLL_PATH");
 			DOORSTOP_MANAGED_FOLDER_DIR = Environment.GetEnvironmentVariable("DOORSTOP_MANAGED_FOLDER_DIR");
+			DOORSTOP_PROCESS_PATH = Environment.GetEnvironmentVariable("DOORSTOP_PROCESS_PATH");
 		}
 	}
 }