Preloader.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Diagnostics;
  3. using BepInEx.Logging;
  4. using BepInEx.Preloader.Core;
  5. using BepInEx.Preloader.Core.Logging;
  6. namespace BepInEx.IL2CPP
  7. {
  8. public static class Preloader
  9. {
  10. public static string IL2CPPUnhollowedPath { get; internal set; }
  11. private static PreloaderConsoleListener PreloaderLog { get; set; }
  12. private static ManualLogSource Log => PreloaderLogger.Log;
  13. public static IL2CPPChainloader Chainloader { get; private set; }
  14. public static void Run()
  15. {
  16. try
  17. {
  18. PreloaderLog = new PreloaderConsoleListener(false);
  19. Logger.Listeners.Add(PreloaderLog);
  20. BasicLogInfo.PrintLogInfo(Log);
  21. Log.LogInfo($"Running under Unity v{FileVersionInfo.GetVersionInfo(Paths.ExecutablePath).FileVersion}");
  22. //Log.LogInfo($"CLR runtime version: {Environment.Version}");
  23. //Log.LogInfo($"Supports SRE: {Utility.CLRSupportsDynamicAssemblies}");
  24. Log.LogDebug($"Game executable path: {Paths.ExecutablePath}");
  25. Log.LogDebug($"Unhollowed assembly directory: {IL2CPPUnhollowedPath}");
  26. Log.LogDebug($"BepInEx root path: {Paths.BepInExRootPath}");
  27. Logger.Listeners.Remove(PreloaderLog);
  28. Chainloader = new IL2CPPChainloader();
  29. Chainloader.Initialize();
  30. Chainloader.Execute();
  31. }
  32. catch (Exception ex)
  33. {
  34. Log.LogFatal(ex);
  35. throw;
  36. }
  37. }
  38. }
  39. }