From 0f22443e24f704a961cab8e54854fc8b72710b70 Mon Sep 17 00:00:00 2001 From: hazre Date: Thu, 29 Jan 2026 16:33:36 +0100 Subject: [PATCH] Merge remote-tracking branch 'upstream/master' --- BepInEx.Core/PlatformUtils.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BepInEx.Core/PlatformUtils.cs b/BepInEx.Core/PlatformUtils.cs index 7e251d8e..908645eb 100644 --- a/BepInEx.Core/PlatformUtils.cs +++ b/BepInEx.Core/PlatformUtils.cs @@ -151,7 +151,12 @@ public static void SetPlatform() if (wineGetVersion != IntPtr.Zero) { current |= Platform.Wine; - var getVersion = wineGetVersion.AsDelegate(); + // It's not safe to use the AsDelegate() extension method here because: + // - It comes from the MonoMod.Utils.DynDll class, defined in MonoMod.Common. + // - The DynDll class has a static constructor that reads PlatformHelper.Current. + // - Reading from that property freezes it: subsequent writes will throw an exception. + // - This method only sets PlatformHelper.Current at the very end. + var getVersion = Marshal.GetDelegateForFunctionPointer(wineGetVersion, typeof(GetWineVersionDelegate)) as GetWineVersionDelegate; WineVersion = getVersion(); } }