Skip to content

Commit 2aca385

Browse files
committed
Better code & detection
1 parent f56c949 commit 2aca385

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

Client/loader/Main.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,8 @@ MTAEXPORT int DoWinMain(HINSTANCE hLauncherInstance, MAYBE_UNUSED HINSTANCE hPre
259259
// Make sure GTA is not running
260260
HandleIfGTAIsAlreadyRunning();
261261

262-
// Maybe warn user if no anti-virus running (skip under Wine)
263-
HKEY hKey = nullptr;
264-
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine", 0, KEY_READ, &hKey) != ERROR_SUCCESS &&
265-
RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
266-
{
267-
CheckAntiVirusStatus();
268-
}
269-
else
270-
{
271-
RegCloseKey(hKey);
272-
}
262+
// Maybe warn user if no anti-virus running
263+
CheckAntiVirusStatus();
273264

274265
// Ensure logo is showing
275266
ShowSplash(hInstanceToUse);

Client/loader/MainFunctions.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <iterator>
2222
#include <optional>
2323
#include <locale.h>
24+
#include <windows.h>
25+
#include <stdio.h>
2426

2527
// Function must be at the start to fix odd compile error (Didn't happen locally but does in build server)
2628
namespace
@@ -938,6 +940,22 @@ void ValidateGTAPath()
938940
}
939941
}
940942

943+
int isUsingWine()
944+
{
945+
HMODULE ntdll = GetModuleHandleA("ntdll.dll");
946+
if (!ntdll)
947+
return 0; // Not ntdll? Not Wine.
948+
949+
// Check for Wine-specific function
950+
FARPROC wineVersion = GetProcAddress(ntdll, "wine_get_version");
951+
if (wineVersion)
952+
{
953+
return 1; // Is Wine.
954+
}
955+
956+
return 0; // Not Wine.
957+
}
958+
941959
//////////////////////////////////////////////////////////
942960
//
943961
// CheckAntiVirusStatus
@@ -947,6 +965,12 @@ void ValidateGTAPath()
947965
//////////////////////////////////////////////////////////
948966
void CheckAntiVirusStatus()
949967
{
968+
if (isUsingWine())
969+
{
970+
WriteDebugEvent("Skipping AV check under Wine");
971+
return;
972+
}
973+
950974
std::vector<SString> enabledList, disabledList;
951975
GetWMIAntiVirusStatus(enabledList, disabledList);
952976

0 commit comments

Comments
 (0)