Preloader.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.LogDebug($"Game executable path: {Paths.ExecutablePath}");
  23. Log.LogDebug($"Unhollowed assembly directory: {IL2CPPUnhollowedPath}");
  24. Log.LogDebug($"BepInEx root path: {Paths.BepInExRootPath}");
  25. Logger.Listeners.Remove(PreloaderLog);
  26. Chainloader = new IL2CPPChainloader();
  27. Chainloader.Initialize();
  28. }
  29. catch (Exception ex)
  30. {
  31. Log.LogFatal(ex);
  32. throw;
  33. }
  34. }
  35. }
  36. }