Ejemplo n.º 1
0
        /// <summary>
        ///     The main entrypoint of BepInEx, called from Doorstop.
        /// </summary>
        public static void Main()
        {
            // We set it to the current directory first as a fallback, but try to use the same location as the .exe file.
            string silentExceptionLog = $"preloader_{DateTime.Now:yyyyMMdd_HHmmss_fff}.log";

            try
            {
                EnvVars.LoadVars();

                string gamePath = Path.GetDirectoryName(EnvVars.DOORSTOP_PROCESS_PATH) ?? ".";
                silentExceptionLog = Path.Combine(gamePath, 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));

                AppDomain.CurrentDomain.AssemblyResolve += ResolveCurrentDirectory;

                // In some versions of Unity 4, Mono tries to resolve BepInEx.dll prematurely because of the call to Paths.SetExecutablePath
                // 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(Entrypoint).Assembly.GetType($"BepInEx.Preloader.{nameof(PreloaderRunner)}")
                ?.GetMethod(nameof(PreloaderRunner.PreloaderPreMain))
                ?.Invoke(null, null);
            }
            catch (Exception ex)
            {
                File.WriteAllText(silentExceptionLog, ex.ToString());
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyResolve -= ResolveCurrentDirectory;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     The main entrypoint of BepInEx, called from Doorstop.
        /// </summary>
        /// <param name="args">
        ///     The arguments passed in from Doorstop. First argument is the path of the currently executing
        ///     process.
        /// </param>
        public static void Main(string[] args)
        {
            EnvVars.LoadVars();

            string bepinPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH)));

            Paths.SetExecutablePath(args[0], bepinPath, EnvVars.DOORSTOP_MANAGED_FOLDER_DIR);
            AppDomain.CurrentDomain.AssemblyResolve += LocalResolve;

            Preloader.Run();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     The main entrypoint of BepInEx, called from Doorstop.
        /// </summary>
        /// <param name="args">
        ///     The arguments passed in from Doorstop. First argument is the path of the currently executing
        ///     process.
        /// </param>
        public static void Main(string[] args)
        {
            EnvVars.LoadVars();

            // 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));

            AppDomain.CurrentDomain.AssemblyResolve += ResolveCurrentDirectory;

            // In some versions of Unity 4, Mono tries to resolve BepInEx.dll prematurely because of the call to Paths.SetExecutablePath
            // 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(Entrypoint).Assembly.GetType($"BepInEx.Preloader.{nameof(PreloaderRunner)}")
            ?.GetMethod(nameof(PreloaderRunner.PreloaderMain))
            ?.Invoke(null, new object[] { args });

            AppDomain.CurrentDomain.AssemblyResolve -= ResolveCurrentDirectory;
        }