Skip to content

Commit

Permalink
Merge pull request #477 from js6pak/wine-warning
Browse files Browse the repository at this point in the history
Warn about outdated wine
  • Loading branch information
ghorsington authored Aug 29, 2022
2 parents 8b32f63 + a77efac commit e8713f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 0 additions & 4 deletions Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,12 @@ private static List<AssemblyDefinition> RunCpp2Il()

private static void RunIl2CppInteropGenerator(List<AssemblyDefinition> 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,
Expand Down
10 changes: 10 additions & 0 deletions Runtimes/Unity/BepInEx.Unity.IL2CPP/Preloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using BepInEx.Preloader.Core.Patching;
using BepInEx.Preloader.RuntimeFixes;
using BepInEx.Unity.Common;
using MonoMod.Utils;

namespace BepInEx.Unity.IL2CPP;

Expand Down Expand Up @@ -51,6 +52,15 @@ public static void Run()
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();
Expand Down

0 comments on commit e8713f1

Please sign in to comment.