From a77efac44b8a94bf953b544b0508248894212d12 Mon Sep 17 00:00:00 2001 From: js6pak Date: Mon, 29 Aug 2022 00:55:10 +0200 Subject: [PATCH] Warn about outdated wine --- .../Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs | 4 ---- Runtimes/Unity/BepInEx.Unity.IL2CPP/Preloader.cs | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs index c4b4314..d88e7d9 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs @@ -285,16 +285,12 @@ internal static class Il2CppInteropManager private static void RunIl2CppInteropGenerator(List sourceAssemblies) { - // Wine doesn't seem to support parallelism properly - var canRunParallel = !PlatformHelper.Is(Platform.Wine); - var opts = new GeneratorOptions { GameAssemblyPath = GameAssemblyPath, Source = sourceAssemblies, OutputDir = IL2CPPInteropAssemblyPath, UnityBaseLibsDir = Directory.Exists(UnityBaseLibsDirectory) ? UnityBaseLibsDirectory : null, - Parallel = canRunParallel, ObfuscatedNamesRegex = !string.IsNullOrEmpty(ConfigUnhollowerDeobfuscationRegex.Value) ? new Regex(ConfigUnhollowerDeobfuscationRegex.Value) : null, diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Preloader.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Preloader.cs index 2694f6f..690d4ef 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Preloader.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Preloader.cs @@ -8,6 +8,7 @@ using BepInEx.Preloader.Core.Logging; using BepInEx.Preloader.Core.Patching; using BepInEx.Preloader.RuntimeFixes; using BepInEx.Unity.Common; +using MonoMod.Utils; namespace BepInEx.Unity.IL2CPP; @@ -51,6 +52,15 @@ public static class Preloader Logger.Log(LogLevel.Debug, $"Interop assembly directory: {Il2CppInteropManager.IL2CPPInteropAssemblyPath}"); Logger.Log(LogLevel.Debug, $"BepInEx root path: {Paths.BepInExRootPath}"); + if (PlatformHelper.Is(Platform.Wine) && !Environment.Is64BitProcess) + { + if (!NativeLibrary.TryGetExport(NativeLibrary.Load("ntdll"), "RtlRestoreContext", out var _)) + { + Logger.Log(LogLevel.Warning, + "Your wine version doesn't support CoreCLR properly, expect crashes! Upgrade to wine 7.16 or higher."); + } + } + NativeLibrary.SetDllImportResolver(typeof(Il2CppInterop.Runtime.IL2CPP).Assembly, DllImportResolver); Il2CppInteropManager.Initialize();