Skip to content

Commit

Permalink
Wine Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
marcussacana committed Jun 6, 2018
1 parent befce09 commit d165d7b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion SRL/SRL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TrimChars= ,<,(,[,“,[,《,«,「,『,【,],”,],》,»,」,』,】,),>,
NoTrim=false
BreakLine=
DenyChars=@,§,$,_,<,>,/,[,]
Multithread=false
Multithread=true
WindowHook=false
Invalidate=false
CachePointer=false
Expand Down
7 changes: 7 additions & 0 deletions SRL/Unmanaged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
20 changes: 18 additions & 2 deletions SRL/Variables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit d165d7b

Please sign in to comment.