mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
fix: Don't check for Wine Registry anymore
- Renames `IsLinux` to `IsWine` to better reflect that this will return true for macOS as well. - Fixes a bug caused by misbehaving apps wanting to be helpful to Linux users - Also makes Wine checking far more resilient in cases where XL_WINEONLINUX isn't set.
This commit is contained in:
parent
3e613cffd0
commit
fd518f8e3f
1 changed files with 20 additions and 22 deletions
|
|
@ -8,6 +8,7 @@ using System.Net.Http;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
|
|
@ -22,7 +23,6 @@ using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Networking.Http;
|
using Dalamud.Networking.Http;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
using Microsoft.Win32;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Utility;
|
namespace Dalamud.Utility;
|
||||||
|
|
@ -491,32 +491,30 @@ public static class Util
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Heuristically determine if Dalamud is running on Linux/WINE.
|
/// Determine if Dalamud is currently running within a Wine context (e.g. either on macOS or Linux). This method
|
||||||
|
/// will not return information about the host operating system.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Whether or not Dalamud is running on Linux/WINE.</returns>
|
/// <returns>Returns true if Wine is detected, false otherwise.</returns>
|
||||||
public static bool IsLinux()
|
public static bool IsWine()
|
||||||
{
|
{
|
||||||
bool Check1()
|
if (EnvironmentConfiguration.XlWineOnLinux) return true;
|
||||||
{
|
|
||||||
return EnvironmentConfiguration.XlWineOnLinux;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Check2()
|
var ntdll = NativeFunctions.GetModuleHandleW("ntdll.dll");
|
||||||
{
|
|
||||||
var hModule = NativeFunctions.GetModuleHandleW("ntdll.dll");
|
|
||||||
var proc1 = NativeFunctions.GetProcAddress(hModule, "wine_get_version");
|
|
||||||
var proc2 = NativeFunctions.GetProcAddress(hModule, "wine_get_build_id");
|
|
||||||
|
|
||||||
return proc1 != IntPtr.Zero || proc2 != IntPtr.Zero;
|
// Test to see if any Wine specific exports exist. If they do, then we are running on Wine.
|
||||||
}
|
// The exports "wine_get_version", "wine_get_build_id", and "wine_get_host_version" will tend to be hidden
|
||||||
|
// by most Linux users (else FFXIV will want a macOS license), so we will additionally check some lesser-known
|
||||||
|
// exports as well.
|
||||||
|
return AnyProcExists(
|
||||||
|
ntdll,
|
||||||
|
"wine_get_version",
|
||||||
|
"wine_get_build_id",
|
||||||
|
"wine_get_host_version",
|
||||||
|
"wine_server_call",
|
||||||
|
"wine_unix_to_nt_file_name");
|
||||||
|
|
||||||
bool Check3()
|
bool AnyProcExists(nint handle, params string[] procs) =>
|
||||||
{
|
procs.Any(p => NativeFunctions.GetProcAddress(handle, p) != nint.Zero);
|
||||||
return Registry.CurrentUser.OpenSubKey(@"Software\Wine") != null ||
|
|
||||||
Registry.LocalMachine.OpenSubKey(@"Software\Wine") != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Check1() || Check2() || Check3();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue