mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Fix Wine check not working on UnityMono version
DynDll relies on PlatformHelper in net35 version which can cause early loading
This commit is contained in:
1 parent
f658a4fbdf
commit
46d9dd4f62
2 files changed
+16
-6
No files matched your search
@@ -26,6 +26,12 @@ internal static class PlatformUtils
|
||||
[DllImport("ntdll.dll", SetLastError = true)]
|
||||
private static extern bool RtlGetVersion(ref WindowsOSVersionInfoExW versionInfo);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern IntPtr LoadLibrary(string libraryName);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
|
||||
|
||||
private static bool Is(this Platform current, Platform expected) => (current & expected) == expected;
|
||||
|
||||
/// <summary>
|
||||
@@ -67,12 +73,16 @@ internal static class PlatformUtils
|
||||
(int) windowsVersionInfo.dwMinorVersion, 0,
|
||||
(int) windowsVersionInfo.dwBuildNumber);
|
||||
|
||||
if (DynDll.TryOpenLibrary("ntdll.dll", out var ntdll) &&
|
||||
ntdll.TryGetFunction("wine_get_version", out var wineGetVersion))
|
||||
var ntDll = LoadLibrary("ntdll.dll");
|
||||
if (ntDll != IntPtr.Zero)
|
||||
{
|
||||
current |= Platform.Wine;
|
||||
var getVersion = wineGetVersion.AsDelegate<GetWineVersionDelegate>();
|
||||
WineVersion = new Version(getVersion());
|
||||
var wineGetVersion = GetProcAddress(ntDll, "wine_get_version");
|
||||
if (wineGetVersion != IntPtr.Zero)
|
||||
{
|
||||
current |= Platform.Wine;
|
||||
var getVersion = wineGetVersion.AsDelegate<GetWineVersionDelegate>();
|
||||
WineVersion = new Version(getVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user