public static void Run() { try { ConsoleManager.Initialize(false); PreloaderLog = new PreloaderConsoleListener(); Logger.Listeners.Add(PreloaderLog); if (ConsoleManager.ConfigConsoleEnabled.Value) { ConsoleManager.CreateConsole(); Logger.Listeners.Add(new ConsoleLogListener()); } ChainloaderLogHelper.PrintLogInfo(Log); Log.LogInfo($"Running under Unity v{FileVersionInfo.GetVersionInfo(Paths.ExecutablePath).FileVersion}"); Log.LogDebug($"Game executable path: {Paths.ExecutablePath}"); Log.LogDebug($"Unhollowed assembly directory: {IL2CPPUnhollowedPath}"); Log.LogDebug($"BepInEx root path: {Paths.BepInExRootPath}"); UnhollowerLog = Logger.CreateLogSource("Unhollower"); UnhollowerBaseLib.LogSupport.InfoHandler += UnhollowerLog.LogInfo; UnhollowerBaseLib.LogSupport.WarningHandler += UnhollowerLog.LogWarning; UnhollowerBaseLib.LogSupport.TraceHandler += UnhollowerLog.LogDebug; UnhollowerBaseLib.LogSupport.ErrorHandler += UnhollowerLog.LogError; if (ProxyAssemblyGenerator.CheckIfGenerationRequired()) { ProxyAssemblyGenerator.GenerateAssemblies(); } Logger.Listeners.Remove(PreloaderLog); Chainloader = new IL2CPPChainloader(); Chainloader.Initialize(); } catch (Exception ex) { Log.LogFatal(ex); throw; } }
public override unsafe void Initialize(string gameExePath = null) { UnhollowerBaseLib.GeneratedDatabasesUtil.DatabasesLocationOverride = Preloader.IL2CPPUnhollowedPath; PatchManager.ResolvePatcher += IL2CPPDetourMethodPatcher.TryResolve; base.Initialize(gameExePath); Instance = this; var version = //Version.Parse(Application.unityVersion); Version.Parse(Process.GetCurrentProcess().MainModule.FileVersionInfo.FileVersion); UnityVersionHandler.Initialize(version.Major, version.Minor, version.Revision); // One or the other here for Unhollower to work correctly //ClassInjector.Detour = new DetourHandler(); ClassInjector.DoHook = (ptr, patchedFunctionPtr) => { IntPtr originalFunc = new IntPtr(*(void **)ptr); var detour = new FastNativeDetour(originalFunc, patchedFunctionPtr); detour.Apply(); *(void **)ptr = (void *)detour.TrampolinePtr; }; var gameAssemblyModule = Process.GetCurrentProcess().Modules.Cast <ProcessModule>().First(x => x.ModuleName.Contains("GameAssembly")); // TODO: Check that DynDll.GetFunction works fine now var runtimeInvokePtr = GetProcAddress(gameAssemblyModule.BaseAddress, "il2cpp_runtime_invoke"); //DynDll.GetFunction(gameAssemblyModule.BaseAddress, "il2cpp_runtime_invoke"); PreloaderLogger.Log.LogDebug($"Runtime invoke pointer: 0x{runtimeInvokePtr.ToInt64():X}"); RuntimeInvokeDetour = FastNativeDetour.CreateAndApply(runtimeInvokePtr, OnInvokeMethod, out originalInvoke, CallingConvention.Cdecl); var installTlsPtr = GetProcAddress(gameAssemblyModule.BaseAddress, "il2cpp_unity_install_unitytls_interface"); if (installTlsPtr != IntPtr.Zero) { InstallUnityTlsInterfaceDetour = FastNativeDetour.CreateAndApply(installTlsPtr, OnInstallUnityTlsInterface, out originalInstallUnityTlsInterface, CallingConvention.Cdecl); } Logger.LogDebug("Initializing TLS adapters"); Il2CppTlsAdapter.Initialize(); PreloaderLogger.Log.LogDebug("Runtime invoke patched"); }
public override unsafe void Initialize(string gameExePath = null) { UnhollowerBaseLib.GeneratedDatabasesUtil.DatabasesLocationOverride = Preloader.IL2CPPUnhollowedPath; PatchManager.ResolvePatcher += IL2CPPDetourMethodPatcher.TryResolve; base.Initialize(gameExePath); Instance = this; var version = //Version.Parse(Application.unityVersion); Version.Parse(Process.GetCurrentProcess().MainModule.FileVersionInfo.FileVersion); UnityVersionHandler.Initialize(version.Major, version.Minor, version.Revision); // One or the other here for Unhollower to work correctly //ClassInjector.Detour = new DetourHandler(); ClassInjector.DoHook = (ptr, patchedFunctionPtr) => { IntPtr originalFunc = new IntPtr(*(void **)ptr); var detour = new FastNativeDetour(originalFunc, patchedFunctionPtr); detour.Apply(); *(void **)ptr = (void *)detour.TrampolinePtr; }; var gameAssemblyModule = Process.GetCurrentProcess().Modules.Cast <ProcessModule>().First(x => x.ModuleName.Contains("GameAssembly")); var functionPtr = GetProcAddress(gameAssemblyModule.BaseAddress, "il2cpp_runtime_invoke"); //DynDll.GetFunction(gameAssemblyModule.BaseAddress, "il2cpp_runtime_invoke"); PreloaderLogger.Log.LogDebug($"Runtime invoke pointer: 0x{functionPtr.ToInt64():X}"); RuntimeInvokeDetour = new FastNativeDetour(functionPtr, MonoExtensions.GetFunctionPointerForDelegate(new RuntimeInvokeDetourDelegate(OnInvokeMethod), CallingConvention.Cdecl)); RuntimeInvokeDetour.Apply(); originalInvoke = RuntimeInvokeDetour.GenerateTrampoline <RuntimeInvokeDetourDelegate>(); PreloaderLogger.Log.LogDebug("Runtime invoke patched"); }
public override void Initialize(string gameExePath = null) { GeneratedDatabasesUtil.DatabasesLocationOverride = Preloader.IL2CPPUnhollowedPath; PatchManager.ResolvePatcher += IL2CPPDetourMethodPatcher.TryResolve; base.Initialize(gameExePath); Instance = this; ClassInjector.Detour = new UnhollowerDetourHandler(); var gameAssemblyModule = Process.GetCurrentProcess().Modules.Cast <ProcessModule>() .First(x => x.ModuleName.Contains("GameAssembly")); // TODO: Check that DynDll.GetFunction works fine now var runtimeInvokePtr = GetProcAddress(gameAssemblyModule.BaseAddress, "il2cpp_runtime_invoke"); //DynDll.GetFunction(gameAssemblyModule.BaseAddress, "il2cpp_runtime_invoke"); PreloaderLogger.Log.LogDebug($"Runtime invoke pointer: 0x{runtimeInvokePtr.ToInt64():X}"); RuntimeInvokeDetour = FastNativeDetour.CreateAndApply(runtimeInvokePtr, OnInvokeMethod, out originalInvoke, CallingConvention.Cdecl); var installTlsPtr = GetProcAddress(gameAssemblyModule.BaseAddress, "il2cpp_unity_install_unitytls_interface"); if (installTlsPtr != IntPtr.Zero) { InstallUnityTlsInterfaceDetour = FastNativeDetour.CreateAndApply(installTlsPtr, OnInstallUnityTlsInterface, out originalInstallUnityTlsInterface, CallingConvention.Cdecl); } Logger.LogDebug("Initializing TLS adapters"); Il2CppTlsAdapter.Initialize(); PreloaderLogger.Log.LogDebug("Runtime invoke patched"); }
public static void Run() { try { ConsoleManager.Initialize(false); PreloaderLog = new PreloaderConsoleListener(); Logger.Listeners.Add(PreloaderLog); if (ConsoleManager.ConfigConsoleEnabled.Value) { ConsoleManager.CreateConsole(); Logger.Listeners.Add(new ConsoleLogListener()); } ChainloaderLogHelper.PrintLogInfo(Log); Log.LogDebug($"Game executable path: {Paths.ExecutablePath}"); Log.LogDebug($"Unhollowed assembly directory: {IL2CPPUnhollowedPath}"); Log.LogDebug($"BepInEx root path: {Paths.BepInExRootPath}"); UnhollowerLog = Logger.CreateLogSource("Unhollower"); LogSupport.InfoHandler += UnhollowerLog.LogInfo; LogSupport.WarningHandler += UnhollowerLog.LogWarning; LogSupport.TraceHandler += UnhollowerLog.LogDebug; LogSupport.ErrorHandler += UnhollowerLog.LogError; if (ProxyAssemblyGenerator.CheckIfGenerationRequired()) { ProxyAssemblyGenerator.GenerateAssemblies(); } InitializeUnityVersion(); using (var assemblyPatcher = new AssemblyPatcher()) { assemblyPatcher.AddPatchersFromDirectory(Paths.PatcherPluginPath); Log.LogInfo($"{assemblyPatcher.PatcherPlugins.Count} patcher plugin{(assemblyPatcher.PatcherPlugins.Count == 1 ? "" : "s")} loaded"); assemblyPatcher.LoadAssemblyDirectories(IL2CPPUnhollowedPath); Log.LogInfo($"{assemblyPatcher.PatcherPlugins.Count} assemblies discovered"); assemblyPatcher.PatchAndLoad(); } Logger.Listeners.Remove(PreloaderLog); Chainloader = new IL2CPPChainloader(); Chainloader.Initialize(); } catch (Exception ex) { Log.LogFatal(ex); throw; } }