2 * Copyright (c) 2018-2019, AuriStor, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _VERSIONSUPPORT_H_
33 #define _VERSIONSUPPORT_H_ 1
36 * IsWindowsVersionOrGreater() is provided by Windows SDK 8.1 or greater.
37 * As AuriStorFS supports building with SDK 7.0 and greater we must
38 * provide our own. VerifyVersionInfoW() is present on Windows XP and
42 #ifndef _WIN32_WINNT_WIN7
43 #define _WIN32_WINNT_WIN7 0x0601
46 #ifndef _WIN32_WINNT_WIN8
47 #define _WIN32_WINNT_WIN8 0x0602
50 #ifndef _WIN32_WINNT_WINBLUE
51 #define _WIN32_WINNT_WINBLUE 0x0603
54 /* Based upon VersionHelpers.h */
56 IsWindowsVersionOrGreater(WORD wMajorVersion
,
58 WORD wServicePackMajor
)
60 OSVERSIONINFOEXW osvi
;
61 DWORDLONG dwlConditionMask
= 0;
63 dwlConditionMask
= VerSetConditionMask(dwlConditionMask
,
66 dwlConditionMask
= VerSetConditionMask(dwlConditionMask
,
69 dwlConditionMask
= VerSetConditionMask(dwlConditionMask
,
73 memset(&osvi
, 0, sizeof(OSVERSIONINFOEXW
));
74 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
75 osvi
.dwMajorVersion
= wMajorVersion
;
76 osvi
.dwMinorVersion
= wMinorVersion
;
77 osvi
.wServicePackMajor
= wServicePackMajor
;
79 return VerifyVersionInfoW(&osvi
,
82 VER_SERVICEPACKMAJOR
),
87 IsWindowsXPOrGreater(VOID
)
89 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP
),
90 LOBYTE(_WIN32_WINNT_WINXP
),
95 IsWindows7OrGreater(VOID
)
97 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7
),
98 LOBYTE(_WIN32_WINNT_WIN7
),
103 IsWindows8OrGreater(VOID
)
105 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8
),
106 LOBYTE(_WIN32_WINNT_WIN8
),
111 IsWindows8Point1OrGreater(VOID
)
113 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE
),
114 LOBYTE(_WIN32_WINNT_WINBLUE
),
118 #define IS_WINDOWS_VERSION_OR_GREATER_CACHED(fn) \
123 static LONG lIsVersionOrGreater = -1; \
125 if (lIsVersionOrGreater == -1) { \
126 LONG lResult = fn(); \
127 InterlockedCompareExchangeRelease(&lIsVersionOrGreater, \
131 return lIsVersionOrGreater == 1; \
134 IS_WINDOWS_VERSION_OR_GREATER_CACHED(IsWindowsXPOrGreater
)
135 IS_WINDOWS_VERSION_OR_GREATER_CACHED(IsWindows7OrGreater
)
136 IS_WINDOWS_VERSION_OR_GREATER_CACHED(IsWindows8OrGreater
)
137 IS_WINDOWS_VERSION_OR_GREATER_CACHED(IsWindows8Point1OrGreater
)
139 #endif /* _VERSIONSUPPORT_H_ */