Skip to content

Instantly share code, notes, and snippets.

@klange
Created January 12, 2018 05:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klange/282e62fdd1c2cae6a210443ccbc5b12f to your computer and use it in GitHub Desktop.
Save klange/282e62fdd1c2cae6a210443ccbc5b12f to your computer and use it in GitHub Desktop.
wine detect
$ wine ./winedetect.exe
Running Wine 1.8.7 under Linux 4.9.0-4-amd64.
#include <windows.h>
#include <stdio.h>
int main(int argc, char * argv[]) {
static const char * (CDECL *pwine_get_version)(void);
static void (CDECL *pwine_get_host_version)(const char **sysname, const char **release);
HMODULE hntdll = GetModuleHandle("ntdll.dll");
if (!hntdll) {
fprintf(stdout, "Not running on NT.\n");
return 1;
}
pwine_get_version = (void *)GetProcAddress(hntdll, "wine_get_version");
pwine_get_host_version = (void *)GetProcAddress(hntdll, "wine_get_host_version");
if (pwine_get_version) {
char * sysname;
char * version;
pwine_get_host_version(&sysname, &version);
fprintf(stdout, "Running Wine %s under %s %s.\n", pwine_get_version(), sysname, version);
} else {
fprintf(stdout, "Running under Windows.\n");
return 2;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment