Skip to content

Commit

Permalink
add additonoal windows version check fucntions
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyFr3sh committed May 6, 2024
1 parent e18eb93 commit 57a98d6
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
67 changes: 67 additions & 0 deletions inc/versionhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ VERSIONHELPERAPI IsWindowsVersionOrGreater(DWORD major, DWORD minor, DWORD build
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL));
}

VERSIONHELPERAPI IsWindowsVersion(DWORD major, DWORD minor, DWORD build, WORD servpack)
{
RTL_OSVERSIONINFOEXW vi = { sizeof(vi),major,minor,build,0,{0},servpack };
return verhelp_verify_version(&vi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER | VER_SERVICEPACKMAJOR,
VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
VER_MAJORVERSION, VER_EQUAL),
VER_MINORVERSION, VER_EQUAL),
VER_BUILDNUMBER, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_EQUAL));
}

VERSIONHELPERAPI IsWindowsXPOrGreater(void) {
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 0);
}
Expand Down Expand Up @@ -106,6 +117,62 @@ VERSIONHELPERAPI IsWindowsServer(void) {
return !verhelp_verify_version(&vi, VER_PRODUCT_TYPE, VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL));
}

VERSIONHELPERAPI IsWindowsXP(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 0);
}

VERSIONHELPERAPI IsWindowsXPSP1(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 1);
}

VERSIONHELPERAPI IsWindowsXPSP2(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 2);
}

VERSIONHELPERAPI IsWindowsXPSP3(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 3);
}

VERSIONHELPERAPI IsWindowsVista(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0, 0);
}

VERSIONHELPERAPI IsWindowsVistaSP1(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0, 1);
}

VERSIONHELPERAPI IsWindowsVistaSP2(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0, 2);
}

VERSIONHELPERAPI IsWindows7(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0, 0);
}

VERSIONHELPERAPI IsWindows7SP1(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0, 1);
}

VERSIONHELPERAPI IsWindows8(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0, 0);
}

VERSIONHELPERAPI IsWindows8Point1(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0, 0);
}

VERSIONHELPERAPI IsWindowsThreshold(void) {
return IsWindows10OrGreater() && !IsWindows11OrGreater();
}

VERSIONHELPERAPI IsWindows10(void) {
return IsWindowsThreshold();
}

VERSIONHELPERAPI IsWindows11(void) {
return IsWindowsVersion(HIBYTE(_WIN32_WINNT_WIN11), LOBYTE(_WIN32_WINNT_WIN11), 22000, 0);
}

VERSIONHELPERAPI IsWine(void) {
return verhelp_wine_get_version() != NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/versionhelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static RTLVERIFYVERSIONINFOPROC RtlVerifyVersionInfo;
static WINE_GET_VERSIONPROC wine_get_version;
static WINE_GET_HOST_VERSIONPROC wine_get_host_version;

/* GetProcAddress is rather slow so we use a function to inizialize it once on startup */
/* GetProcAddress is rather slow so we use a function to initialize it once on startup */
void verhelp_init()
{
HMODULE mod = GetModuleHandleA("ntdll.dll");
Expand Down

0 comments on commit 57a98d6

Please sign in to comment.