ReactOS 0.4.15-dev-7934-g1dc8d80
version.c File Reference
#include <rtl.h>
#include <debug.h>
Include dependency graph for version.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI RtlGetVersion (OUT PRTL_OSVERSIONINFOW lpVersionInformation)
 
static UCHAR RtlpVerGetCondition (IN ULONGLONG ConditionMask, IN ULONG TypeMask)
 
static BOOLEAN RtlpVerCompare (ULONG left, ULONG right, UCHAR Condition)
 
NTSTATUS NTAPI RtlVerifyVersionInfo (IN PRTL_OSVERSIONINFOEXW VersionInfo, IN ULONG TypeMask, IN ULONGLONG ConditionMask)
 
ULONGLONG NTAPI VerSetConditionMask (IN ULONGLONG ConditionMask, IN ULONG TypeMask, IN UCHAR Condition)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file version.c.

Function Documentation

◆ RtlGetVersion()

NTSTATUS NTAPI RtlGetVersion ( OUT PRTL_OSVERSIONINFOW  lpVersionInformation)

◆ RtlpVerCompare()

static BOOLEAN RtlpVerCompare ( ULONG  left,
ULONG  right,
UCHAR  Condition 
)
static

Definition at line 30 of file version.c.

31{
32 switch (Condition)
33 {
34 case VER_EQUAL:
35 return (left == right);
36 case VER_GREATER:
37 return (left > right);
39 return (left >= right);
40 case VER_LESS:
41 return (left < right);
42 case VER_LESS_EQUAL:
43 return (left <= right);
44 default:
45 break;
46 }
47 return FALSE;
48}
#define FALSE
Definition: types.h:117
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
#define VER_LESS_EQUAL
Definition: rtltypes.h:243
#define VER_EQUAL
Definition: rtltypes.h:239
#define VER_LESS
Definition: rtltypes.h:242
#define VER_GREATER
Definition: rtltypes.h:240
#define VER_GREATER_EQUAL
Definition: rtltypes.h:241
IN ULONG IN UCHAR Condition

Referenced by RtlVerifyVersionInfo().

◆ RtlpVerGetCondition()

static UCHAR RtlpVerGetCondition ( IN ULONGLONG  ConditionMask,
IN ULONG  TypeMask 
)
static

Definition at line 224 of file version.c.

226{
227 UCHAR Condition = 0;
228
231 else if (TypeMask & VER_SUITENAME)
233 else if (TypeMask & VER_PLATFORMID)
235 else if (TypeMask & VER_BUILDNUMBER)
237 /*
238 * We choose here the lexicographical order on the 4D space
239 * {(Major ; Minor ; SP Major ; SP Minor)} to select the
240 * appropriate comparison operator.
241 * Therefore the following 'else if' instructions must be in this order.
242 */
243 else if (TypeMask & VER_MAJORVERSION)
245 else if (TypeMask & VER_MINORVERSION)
251
253
254 return Condition;
255}
_In_ ULONG TypeMask
Definition: rtlfuncs.h:4674
_In_ ULONG _In_ ULONGLONG ConditionMask
Definition: rtlfuncs.h:4676
#define VER_SERVICEPACKMINOR
Definition: rtltypes.h:232
#define VER_BUILDNUMBER
Definition: rtltypes.h:230
#define VER_SUITENAME
Definition: rtltypes.h:234
#define VER_MAJORVERSION
Definition: rtltypes.h:229
#define VER_PRODUCT_TYPE
Definition: rtltypes.h:235
#define VER_NUM_BITS_PER_CONDITION_MASK
Definition: rtltypes.h:247
#define VER_PLATFORMID
Definition: rtltypes.h:231
#define VER_CONDITION_MASK
Definition: rtltypes.h:246
#define VER_MINORVERSION
Definition: rtltypes.h:228
#define VER_SERVICEPACKMAJOR
Definition: rtltypes.h:233
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by RtlVerifyVersionInfo().

◆ RtlVerifyVersionInfo()

NTSTATUS NTAPI RtlVerifyVersionInfo ( IN PRTL_OSVERSIONINFOEXW  VersionInfo,
IN ULONG  TypeMask,
IN ULONGLONG  ConditionMask 
)

Definition at line 55 of file version.c.

58{
60 BOOLEAN Comparison;
61 BOOLEAN DoNextCheck;
64
65 /* FIXME:
66 - Check the following special case on Windows (various versions):
67 o lp->wSuiteMask == 0 and ver.wSuiteMask != 0 and VER_AND/VER_OR
68 o lp->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)
69 - MSDN talks about some tests being impossible. Check what really happens.
70 */
71
72 Version.dwOSVersionInfoSize = sizeof(Version);
73
76 {
77 return Status;
78 }
79
80 if (!TypeMask || !ConditionMask)
81 {
83 }
84
86 {
87 Comparison = RtlpVerCompare(Version.wProductType,
88 VersionInfo->wProductType,
90 if (!Comparison)
91 {
93 }
94 }
95
97 {
99 {
100 case VER_AND:
101 {
102 if ((VersionInfo->wSuiteMask & Version.wSuiteMask) != VersionInfo->wSuiteMask)
103 {
105 }
106 }
107 break;
108
109 case VER_OR:
110 {
111 if (!(VersionInfo->wSuiteMask & Version.wSuiteMask) && VersionInfo->wSuiteMask)
112 {
114 }
115 break;
116 }
117
118 default:
119 {
121 }
122 }
123 }
124
126 {
127 Comparison = RtlpVerCompare(Version.dwPlatformId,
130 if (!Comparison)
131 {
133 }
134 }
135
137 {
138 Comparison = RtlpVerCompare(Version.dwBuildNumber,
141 if (!Comparison)
142 {
144 }
145 }
146
147 DoNextCheck = TRUE;
149
151 {
153 DoNextCheck = (VersionInfo->dwMajorVersion == Version.dwMajorVersion);
154 Comparison = RtlpVerCompare(Version.dwMajorVersion,
156 Condition);
157
158 if (!Comparison && !DoNextCheck)
159 {
161 }
162 }
163
164 if (DoNextCheck)
165 {
167 {
168 if (Condition == VER_EQUAL)
169 {
171 }
172
173 DoNextCheck = (VersionInfo->dwMinorVersion == Version.dwMinorVersion);
174 Comparison = RtlpVerCompare(Version.dwMinorVersion,
176 Condition);
177
178 if (!Comparison && !DoNextCheck)
179 {
181 }
182 }
183
184 if (DoNextCheck && (TypeMask & VER_SERVICEPACKMAJOR))
185 {
186 if (Condition == VER_EQUAL)
187 {
189 }
190
191 DoNextCheck = (VersionInfo->wServicePackMajor == Version.wServicePackMajor);
192 Comparison = RtlpVerCompare(Version.wServicePackMajor,
193 VersionInfo->wServicePackMajor,
194 Condition);
195
196 if (!Comparison && !DoNextCheck)
197 {
199 }
200
201 if (DoNextCheck && (TypeMask & VER_SERVICEPACKMINOR))
202 {
203 if (Condition == VER_EQUAL)
204 {
206 }
207
208 Comparison = RtlpVerCompare(Version.wServicePackMinor,
209 VersionInfo->wServicePackMinor,
210 Condition);
211
212 if (!Comparison)
213 {
215 }
216 }
217 }
218 }
219
220 return STATUS_SUCCESS;
221}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
Status
Definition: gdiplustypes.h:25
#define VER_AND
Definition: rtltypes.h:244
#define VER_OR
Definition: rtltypes.h:245
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
static BOOLEAN RtlpVerCompare(ULONG left, ULONG right, UCHAR Condition)
Definition: version.c:30
static UCHAR RtlpVerGetCondition(IN ULONGLONG ConditionMask, IN ULONG TypeMask)
Definition: version.c:224
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwPlatformId
Definition: rtltypes.h:250
ULONG dwMajorVersion
Definition: rtltypes.h:247
ULONG dwBuildNumber
Definition: rtltypes.h:249
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

◆ VerSetConditionMask()

ULONGLONG NTAPI VerSetConditionMask ( IN ULONGLONG  ConditionMask,
IN ULONG  TypeMask,
IN UCHAR  Condition 
)

Definition at line 262 of file version.c.

265{
266 ULONGLONG ullCondMask;
267
268 if (TypeMask == 0)
269 return ConditionMask;
270
272
273 if (Condition == 0)
274 return ConditionMask;
275
276 ullCondMask = Condition;
278 ConditionMask |= ullCondMask << (7 * VER_NUM_BITS_PER_CONDITION_MASK);
279 else if (TypeMask & VER_SUITENAME)
280 ConditionMask |= ullCondMask << (6 * VER_NUM_BITS_PER_CONDITION_MASK);
282 ConditionMask |= ullCondMask << (5 * VER_NUM_BITS_PER_CONDITION_MASK);
284 ConditionMask |= ullCondMask << (4 * VER_NUM_BITS_PER_CONDITION_MASK);
285 else if (TypeMask & VER_PLATFORMID)
286 ConditionMask |= ullCondMask << (3 * VER_NUM_BITS_PER_CONDITION_MASK);
287 else if (TypeMask & VER_BUILDNUMBER)
288 ConditionMask |= ullCondMask << (2 * VER_NUM_BITS_PER_CONDITION_MASK);
289 else if (TypeMask & VER_MAJORVERSION)
290 ConditionMask |= ullCondMask << (1 * VER_NUM_BITS_PER_CONDITION_MASK);
291 else if (TypeMask & VER_MINORVERSION)
292 ConditionMask |= ullCondMask << (0 * VER_NUM_BITS_PER_CONDITION_MASK);
293
294 return ConditionMask;
295}
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by IsActiveSessionCountLimited(), IsWindows8OrGreater(), IsWindowsServer(), IsWindowsVersionOrGreater(), and test_VerifyVersionInfo().