-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWineDetect.cpp
More file actions
71 lines (56 loc) · 1.56 KB
/
Copy pathWineDetect.cpp
File metadata and controls
71 lines (56 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <OsintgramCXX/App/WineDetect.hpp>
#include <string>
#ifdef _WIN32
#include <windows.h>
typedef void (CDECL *wine_get_host_version_t)(const char **sysname, const char **release);
#endif
using namespace OsintgramCXX;
bool Wine::WineExecution() {
bool result = false;
#ifdef _WIN32
HMODULE hMod = GetModuleHandleA("ntdll.dll");
if (!hMod)
return result;
FARPROC wine_get_version = GetProcAddress(hMod, "wine_get_version");
if (wine_get_version)
result = true;
#endif
return result;
}
Wine::Host Wine::WineHost() {
Host result{NONE, ""};
#ifdef _WIN32
HMODULE hMod = GetModuleHandleA("ntdll.dll");
if (!hMod)
return result;
auto hostVer = (wine_get_host_version_t) GetProcAddress(hMod, "wine_get_host_version");
if (hostVer) {
const char* sysName = nullptr;
const char* release = nullptr;
hostVer(&sysName, &release);
std::string sys(sysName);
if (sys == "Linux")
result.platform = LINUX;
else if (sys == "Darwin")
result.platform = MAC_OS;
else
result.platform = UNKNOWN;
result.version = std::string(release);
}
#endif
return result;
}
std::string Wine::HostPlatformToString(Wine::HostPlatform platform) {
switch (platform) {
case Wine::LINUX:
return "Linux";
case Wine::MAC_OS:
return "macOS";
case Wine::NONE:
return "None";
case Wine::UNKNOWN:
return "Unknown";
default:
return "what";
}
}