From d165d7b9545c1bce582a9aed4b8d08a563210ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Andr=C3=A9?= Date: Wed, 6 Jun 2018 01:11:09 -0300 Subject: [PATCH] Wine Fix #1 --- SRL/SRL.ini | 2 +- SRL/Unmanaged.cs | 7 +++++++ SRL/Variables.cs | 20 ++++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/SRL/SRL.ini b/SRL/SRL.ini index a4cd7f9..65d8b1d 100644 --- a/SRL/SRL.ini +++ b/SRL/SRL.ini @@ -22,7 +22,7 @@ TrimChars= ,<,(,[,“,[,《,«,「,『,【,],”,],》,»,」,』,】,),>, NoTrim=false BreakLine= DenyChars=@,§,$,_,<,>,/,[,] -Multithread=false +Multithread=true WindowHook=false Invalidate=false CachePointer=false diff --git a/SRL/Unmanaged.cs b/SRL/Unmanaged.cs index 8aeadbe..2446218 100644 --- a/SRL/Unmanaged.cs +++ b/SRL/Unmanaged.cs @@ -40,6 +40,13 @@ partial class StringReloader { public static extern IntPtr GetMenu(IntPtr hWnd); + [DllImport(@"kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] + internal static extern IntPtr GetProcAddress(IntPtr hModule, string procName); + + [DllImport(@"kernel32.dll", CharSet = CharSet.Auto)] + public static extern IntPtr GetModuleHandle(string lpModuleName); + + [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern bool GetMenuItemInfo(IntPtr hMenu, int uItem, bool fByPosition, ref MENUITEMINFO lpmii); diff --git a/SRL/Variables.cs b/SRL/Variables.cs index 782076b..2f21bb8 100644 --- a/SRL/Variables.cs +++ b/SRL/Variables.cs @@ -258,7 +258,7 @@ private static TextWriter LogWriter { private static DateTime LastTry = DateTime.Now; private static bool Online { get { - if (_netstas == 1) + if (_netstas == 1 || IsWine) return true; if (_netstas == -1 || (DateTime.Now - LastTry).TotalMinutes > 10) { Ping myPing = new Ping(); @@ -276,7 +276,23 @@ private static bool Online { _netstas = value ? 1 : 0; } } - + + static bool? isWine; + internal static bool IsWine { + get { + if (isWine.HasValue) return isWine.Value; + + IntPtr hModule = GetModuleHandle(@"ntdll.dll"); + if (hModule == IntPtr.Zero) + isWine = false; + else { + IntPtr fptr = GetProcAddress(hModule, @"wine_get_version"); + isWine = fptr != IntPtr.Zero; + } + + return isWine.Value; + } + } private static bool GameStarted() { try { return !string.IsNullOrWhiteSpace(System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle);