mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 20:24:16 +01:00
Merge pull request #1351 from KazWolfe/wine-check-fix
This commit is contained in:
commit
dee48ec811
5 changed files with 60 additions and 34 deletions
|
|
@ -133,8 +133,8 @@ DWORD WINAPI InitializeImpl(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||||
// ============================== VEH ======================================== //
|
// ============================== VEH ======================================== //
|
||||||
|
|
||||||
logging::I("Initializing VEH...");
|
logging::I("Initializing VEH...");
|
||||||
if (utils::is_running_on_linux()) {
|
if (utils::is_running_on_wine()) {
|
||||||
logging::I("=> VEH was disabled, running on linux");
|
logging::I("=> VEH was disabled, running on wine");
|
||||||
} else if (g_startInfo.BootVehEnabled) {
|
} else if (g_startInfo.BootVehEnabled) {
|
||||||
if (veh::add_handler(g_startInfo.BootVehFull, g_startInfo.WorkingDirectory))
|
if (veh::add_handler(g_startInfo.BootVehFull, g_startInfo.WorkingDirectory))
|
||||||
logging::I("=> Done!");
|
logging::I("=> Done!");
|
||||||
|
|
|
||||||
|
|
@ -578,7 +578,7 @@ std::vector<std::string> utils::get_env_list(const wchar_t* pcszName) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool utils::is_running_on_linux() {
|
bool utils::is_running_on_wine() {
|
||||||
if (get_env<bool>(L"XL_WINEONLINUX"))
|
if (get_env<bool>(L"XL_WINEONLINUX"))
|
||||||
return true;
|
return true;
|
||||||
HMODULE hntdll = GetModuleHandleW(L"ntdll.dll");
|
HMODULE hntdll = GetModuleHandleW(L"ntdll.dll");
|
||||||
|
|
@ -588,6 +588,10 @@ bool utils::is_running_on_linux() {
|
||||||
return true;
|
return true;
|
||||||
if (GetProcAddress(hntdll, "wine_get_host_version"))
|
if (GetProcAddress(hntdll, "wine_get_host_version"))
|
||||||
return true;
|
return true;
|
||||||
|
if (GetProcAddress(hntdll, "wine_server_call"))
|
||||||
|
return true;
|
||||||
|
if (GetProcAddress(hntdll, "wine_unix_to_nt_file_name"))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ namespace utils {
|
||||||
return get_env_list<T>(unicode::convert<std::wstring>(pcszName).c_str());
|
return get_env_list<T>(unicode::convert<std::wstring>(pcszName).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_running_on_linux();
|
bool is_running_on_wine();
|
||||||
|
|
||||||
std::filesystem::path get_module_path(HMODULE hModule);
|
std::filesystem::path get_module_path(HMODULE hModule);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ public sealed class EntryPoint
|
||||||
// This is due to GitHub not supporting TLS 1.0, so we enable all TLS versions globally
|
// This is due to GitHub not supporting TLS 1.0, so we enable all TLS versions globally
|
||||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls;
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls;
|
||||||
|
|
||||||
if (!Util.IsLinux())
|
if (!Util.IsWine())
|
||||||
InitSymbolHandler(info);
|
InitSymbolHandler(info);
|
||||||
|
|
||||||
var dalamud = new Dalamud(info, configuration, mainThreadContinueEvent);
|
var dalamud = new Dalamud(info, configuration, mainThreadContinueEvent);
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
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;
|
||||||
|
|
@ -15,14 +14,12 @@ using Dalamud.Data;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Dalamud.Interface;
|
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Logging.Internal;
|
using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Networking.Http;
|
using Dalamud.Memory;
|
||||||
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 +488,57 @@ 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;
|
||||||
{
|
if (Environment.GetEnvironmentVariable("XL_PLATFORM") is not null and not "Windows") return true;
|
||||||
return EnvironmentConfiguration.XlWineOnLinux;
|
|
||||||
|
var ntdll = NativeFunctions.GetModuleHandleW("ntdll.dll");
|
||||||
|
|
||||||
|
// 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 AnyProcExists(nint handle, params string[] procs) =>
|
||||||
|
procs.Any(p => NativeFunctions.GetProcAddress(handle, p) != nint.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Check2()
|
/// <summary>
|
||||||
|
/// Gets the best guess for the current host's platform based on the <c>XL_PLATFORM</c> environment variable or
|
||||||
|
/// heuristics.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// macOS users running without <c>XL_PLATFORM</c> being set will be reported as Linux users. Due to the way our
|
||||||
|
/// Wines work, there isn't a great (consistent) way to split the two apart if we're not told.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Returns the <see cref="OSPlatform"/> that Dalamud is currently running on.</returns>
|
||||||
|
public static OSPlatform GetHostPlatform()
|
||||||
{
|
{
|
||||||
var hModule = NativeFunctions.GetModuleHandleW("ntdll.dll");
|
switch (Environment.GetEnvironmentVariable("XL_PLATFORM"))
|
||||||
var proc1 = NativeFunctions.GetProcAddress(hModule, "wine_get_version");
|
{
|
||||||
var proc2 = NativeFunctions.GetProcAddress(hModule, "wine_get_build_id");
|
case "Windows": return OSPlatform.Windows;
|
||||||
|
case "MacOS": return OSPlatform.OSX;
|
||||||
return proc1 != IntPtr.Zero || proc2 != IntPtr.Zero;
|
case "Linux": return OSPlatform.Linux;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Check3()
|
// n.b. we had some fancy code here to check if the Wine host version returned "Darwin" but apparently
|
||||||
{
|
// *all* our Wines report Darwin if exports aren't hidden. As such, it is effectively impossible (without some
|
||||||
return Registry.CurrentUser.OpenSubKey(@"Software\Wine") != null ||
|
// (very cursed and inaccurate heuristics) to determine if we're on macOS or Linux unless we're explicitly told
|
||||||
Registry.LocalMachine.OpenSubKey(@"Software\Wine") != null;
|
// by our launcher. See commit a7aacb15e4603a367e2f980578271a9a639d8852 for the old check.
|
||||||
}
|
|
||||||
|
|
||||||
return Check1() || Check2() || Check3();
|
return IsWine() ? OSPlatform.Linux : OSPlatform.Windows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue