public static void Run() { try { AllocateConsole(); PreloaderLog = new PreloaderLogWriter(Utility.SafeParseBool(Config.GetEntry("preloader-logconsole", "false", "BepInEx"))); PreloaderLog.Enabled = true; string consoleTile = $"BepInEx {Assembly.GetExecutingAssembly().GetName().Version} - {Process.GetCurrentProcess().ProcessName}"; ConsoleWindow.Title = consoleTile; Logger.SetLogger(PreloaderLog); PreloaderLog.WriteLine(consoleTile); #if DEBUG object[] attributes = typeof(DebugInfoAttribute).Assembly.GetCustomAttributes(typeof(DebugInfoAttribute), false); if (attributes.Length > 0) { var attribute = (DebugInfoAttribute)attributes[0]; PreloaderLog.WriteLine(attribute.Info); } #endif Logger.Log(LogLevel.Message, "Preloader started"); string entrypointAssembly = Config.GetEntry("entrypoint-assembly", "UnityEngine.dll", "Preloader"); AddPatcher(new[] { entrypointAssembly }, PatchEntrypoint); if (Directory.Exists(Paths.PatcherPluginPath)) { var sortedPatchers = new SortedDictionary <string, KeyValuePair <AssemblyPatcherDelegate, IEnumerable <string> > >(); foreach (string assemblyPath in Directory.GetFiles(Paths.PatcherPluginPath, "*.dll")) { try { var assembly = Assembly.LoadFrom(assemblyPath); foreach (KeyValuePair <AssemblyPatcherDelegate, IEnumerable <string> > kv in GetPatcherMethods(assembly)) { sortedPatchers.Add(assembly.GetName().Name, kv); } } catch (BadImageFormatException) { } //unmanaged DLL } catch (ReflectionTypeLoadException) { } //invalid references foreach (KeyValuePair <string, KeyValuePair <AssemblyPatcherDelegate, IEnumerable <string> > > kv in sortedPatchers) { AddPatcher(kv.Value.Value, kv.Value.Key); } }
public static void Run() { try { AllocateConsole(); PreloaderLog = new PreloaderLogWriter(SafeGetConfigBool("preloader-logconsole", "false")); PreloaderLog.Enabled = true; string consoleTile = $"BepInEx {Assembly.GetExecutingAssembly().GetName().Version} - {Process.GetCurrentProcess().ProcessName}"; ConsoleWindow.Title = consoleTile; Logger.SetLogger(PreloaderLog); PreloaderLog.WriteLine(consoleTile); Logger.Log(LogLevel.Message, "Preloader started"); AddPatcher(new[] { "UnityEngine.dll" }, PatchEntrypoint); if (Directory.Exists(Paths.PatcherPluginPath)) { var sortedPatchers = new SortedDictionary <string, KeyValuePair <AssemblyPatcherDelegate, IEnumerable <string> > >(); foreach (string assemblyPath in Directory.GetFiles(Paths.PatcherPluginPath, "*.dll")) { try { var assembly = Assembly.LoadFrom(assemblyPath); foreach (KeyValuePair <AssemblyPatcherDelegate, IEnumerable <string> > kv in GetPatcherMethods(assembly)) { sortedPatchers.Add(assembly.GetName().Name, kv); } } catch (BadImageFormatException) { } //unmanaged DLL } catch (ReflectionTypeLoadException) { } //invalid references foreach (KeyValuePair <string, KeyValuePair <AssemblyPatcherDelegate, IEnumerable <string> > > kv in sortedPatchers) { AddPatcher(kv.Value.Value, kv.Value.Key); } }