|
@@ -5,16 +5,9 @@ using System.Reflection;
|
|
|
|
|
|
namespace BepInEx.Preloader
|
|
|
{
|
|
|
- internal static class Entrypoint
|
|
|
+ internal static class PreloaderRunner
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- public static void Main(string[] args)
|
|
|
+ public static void PreloaderMain(string[] args)
|
|
|
{
|
|
|
EnvVars.LoadVars();
|
|
|
|
|
@@ -22,21 +15,10 @@ namespace BepInEx.Preloader
|
|
|
|
|
|
Paths.SetExecutablePath(args[0], bepinPath, EnvVars.DOORSTOP_MANAGED_FOLDER_DIR);
|
|
|
AppDomain.CurrentDomain.AssemblyResolve += LocalResolve;
|
|
|
-
|
|
|
Preloader.Run();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- internal static Assembly LocalResolve(object sender, ResolveEventArgs args)
|
|
|
+ private static Assembly LocalResolve(object sender, ResolveEventArgs args)
|
|
|
{
|
|
|
var assemblyName = new AssemblyName(args.Name);
|
|
|
|
|
@@ -54,4 +36,45 @@ namespace BepInEx.Preloader
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ internal static class Entrypoint
|
|
|
+ {
|
|
|
+ private static string preloaderPath;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static void Main(string[] args)
|
|
|
+ {
|
|
|
+
|
|
|
+ preloaderPath = Path.GetDirectoryName(Path.GetFullPath(Environment.GetEnvironmentVariable("DOORSTOP_INVOKE_DLL_PATH")));
|
|
|
+
|
|
|
+ AppDomain.CurrentDomain.AssemblyResolve += ResolveCurrentDirectory;
|
|
|
+
|
|
|
+
|
|
|
+ typeof(Entrypoint).Assembly.GetType($"BepInEx.Preloader.{nameof(PreloaderRunner)}")
|
|
|
+ ?.GetMethod(nameof(PreloaderRunner.PreloaderMain))
|
|
|
+ ?.Invoke(null, new object[] { args });
|
|
|
+
|
|
|
+ AppDomain.CurrentDomain.AssemblyResolve -= ResolveCurrentDirectory;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static Assembly ResolveCurrentDirectory(object sender, ResolveEventArgs args)
|
|
|
+ {
|
|
|
+ var name = new AssemblyName(args.Name);
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return Assembly.LoadFile(Path.Combine(preloaderPath, $"{name.Name}.dll"));
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|