Fix gcc 4 warnings.
[wine/multimedia.git] / dlls / ntdll / version.c
blob5a2b1f2147941a4de7ca3f31c10c91070ed06a3e
1 /*
2 * Windows and DOS version functions
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Patrik Stridvall
6 * Copyright 1998, 2003 Andreas Mohr
7 * Copyright 1997, 2003 Alexandre Julliard
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include <string.h>
28 #include <stdlib.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include "ntstatus.h"
32 #include "windef.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
35 #include "ntdll_misc.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(ver);
39 typedef enum
41 WIN20, /* Windows 2.0 */
42 WIN30, /* Windows 3.0 */
43 WIN31, /* Windows 3.1 */
44 WIN95, /* Windows 95 */
45 WIN98, /* Windows 98 */
46 WINME, /* Windows Me */
47 NT351, /* Windows NT 3.51 */
48 NT40, /* Windows NT 4.0 */
49 NT2K, /* Windows 2000 */
50 WINXP, /* Windows XP */
51 WIN2K3, /* Windows 2003 */
52 NB_WINDOWS_VERSIONS
53 } WINDOWS_VERSION;
55 /* FIXME: compare values below with original and fix.
56 * An *excellent* win9x version page (ALL versions !)
57 * can be found at members.aol.com/axcel216/ver.htm */
58 static const RTL_OSVERSIONINFOEXW VersionData[NB_WINDOWS_VERSIONS] =
60 /* WIN20 FIXME: verify values */
62 sizeof(RTL_OSVERSIONINFOEXW), 2, 0, 0, VER_PLATFORM_WIN32s,
63 {'W','i','n','3','2','s',' ','1','.','3',0},
64 0, 0, 0, 0, 0
66 /* WIN30 FIXME: verify values */
68 sizeof(RTL_OSVERSIONINFOEXW), 3, 0, 0, VER_PLATFORM_WIN32s,
69 {'W','i','n','3','2','s',' ','1','.','3',0},
70 0, 0, 0, 0, 0
72 /* WIN31 */
74 sizeof(RTL_OSVERSIONINFOEXW), 3, 10, 0, VER_PLATFORM_WIN32s,
75 {'W','i','n','3','2','s',' ','1','.','3',0},
76 0, 0, 0, 0, 0
78 /* WIN95 */
80 /* Win95: 4, 0, 0x40003B6, ""
81 * Win95sp1: 4, 0, 0x40003B6, " A " (according to doc)
82 * Win95osr2: 4, 0, 0x4000457, " B " (according to doc)
83 * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
84 * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
85 * Win95a/b can be discerned via regkey SubVersionNumber
86 * See also:
87 * http://support.microsoft.com/support/kb/articles/q158/2/38.asp
89 sizeof(RTL_OSVERSIONINFOEXW), 4, 0, 0x40003B6, VER_PLATFORM_WIN32_WINDOWS,
90 {0},
91 0, 0, 0, 0, 0
93 /* WIN98 (second edition) */
95 /* Win98: 4, 10, 0x40A07CE, " " 4.10.1998
96 * Win98SE: 4, 10, 0x40A08AE, " A " 4.10.2222
98 sizeof(RTL_OSVERSIONINFOEXW), 4, 10, 0x40A08AE, VER_PLATFORM_WIN32_WINDOWS,
99 {' ','A',' ',0},
100 0, 0, 0, 0, 0
102 /* WINME */
104 sizeof(RTL_OSVERSIONINFOEXW), 4, 90, 0x45A0BB8, VER_PLATFORM_WIN32_WINDOWS,
105 {' ',0},
106 0, 0, 0, 0, 0
108 /* NT351 */
110 sizeof(RTL_OSVERSIONINFOEXW), 3, 51, 0x421, VER_PLATFORM_WIN32_NT,
111 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
112 0, 0, 0, 0, 0
114 /* NT40 */
116 sizeof(RTL_OSVERSIONINFOEXW), 4, 0, 0x565, VER_PLATFORM_WIN32_NT,
117 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','6','a',0},
118 6, 0, 0, VER_NT_WORKSTATION, 0
120 /* NT2K */
122 sizeof(RTL_OSVERSIONINFOEXW), 5, 0, 0x893, VER_PLATFORM_WIN32_NT,
123 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','4',0},
124 4, 0, 0, VER_NT_WORKSTATION, 30 /* FIXME: Great, a reserved field with a value! */
126 /* WINXP */
128 sizeof(RTL_OSVERSIONINFOEXW), 5, 1, 0xA28, VER_PLATFORM_WIN32_NT,
129 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
130 2, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 30 /* FIXME: Great, a reserved field with a value! */
132 /* WIN2K3 */
134 sizeof(RTL_OSVERSIONINFOEXW), 5, 2, 0xECE, VER_PLATFORM_WIN32_NT,
135 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','1',0},
136 1, 0, VER_SUITE_SINGLEUSERTS, VER_NT_SERVER, 0
140 static const char * const WinVersionNames[NB_WINDOWS_VERSIONS] =
141 { /* no spaces in here ! */
142 "win20", /* WIN20 */
143 "win30", /* WIN30 */
144 "win31", /* WIN31 */
145 "win95", /* WIN95 */
146 "win98", /* WIN98 */
147 "winme", /* WINME */
148 "nt351", /* NT351 */
149 "nt40", /* NT40 */
150 "win2000,win2k,nt2k,nt2000", /* NT2K */
151 "winxp", /* WINXP */
152 "win2003,win2k3" /* WIN2K3 */
156 /* initialized to null so that we crash if we try to retrieve the version too early at startup */
157 static const RTL_OSVERSIONINFOEXW *current_version;
160 /**********************************************************************
161 * get_nt_registry_version
163 * Fetch the version information from the NT-style registry keys.
165 static BOOL get_nt_registry_version( RTL_OSVERSIONINFOEXW *version )
167 static const WCHAR version_keyW[] = {'M','a','c','h','i','n','e','\\',
168 'S','o','f','t','w','a','r','e','\\',
169 'M','i','c','r','o','s','o','f','t','\\',
170 'W','i','n','d','o','w','s',' ','N','T','\\',
171 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
172 static const WCHAR service_pack_keyW[] = {'M','a','c','h','i','n','e','\\',
173 'S','y','s','t','e','m','\\',
174 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
175 'C','o','n','t','r','o','l','\\',
176 'W','i','n','d','o','w','s',0};
177 static const WCHAR product_keyW[] = {'M','a','c','h','i','n','e','\\',
178 'S','y','s','t','e','m','\\',
179 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
180 'C','o','n','t','r','o','l','\\',
181 'P','r','o','d','u','c','t','O','p','t','i','o','n','s',0};
182 static const WCHAR CurrentBuildNumberW[] = {'C','u','r','r','e','n','t','B','u','i','l','d','N','u','m','b','e','r',0};
183 static const WCHAR CSDVersionW[] = {'C','S','D','V','e','r','s','i','o','n',0};
184 static const WCHAR CurrentVersionW[] = {'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
185 static const WCHAR ProductTypeW[] = {'P','r','o','d','u','c','t','T','y','p','e',0};
186 static const WCHAR WinNTW[] = {'W','i','n','N','T',0};
187 static const WCHAR ServerNTW[] = {'S','e','r','v','e','r','N','T',0};
188 static const WCHAR LanmanNTW[] = {'L','a','n','m','a','n','N','T',0};
190 OBJECT_ATTRIBUTES attr;
191 UNICODE_STRING nameW, valueW;
192 HANDLE hkey, hkey2;
193 char tmp[64];
194 DWORD count;
195 BOOL ret = FALSE;
196 KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)tmp;
198 attr.Length = sizeof(attr);
199 attr.RootDirectory = 0;
200 attr.ObjectName = &nameW;
201 attr.Attributes = 0;
202 attr.SecurityDescriptor = NULL;
203 attr.SecurityQualityOfService = NULL;
204 RtlInitUnicodeString( &nameW, version_keyW );
206 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) return FALSE;
208 memset( version, 0, sizeof(*version) );
210 RtlInitUnicodeString( &valueW, CurrentVersionW );
211 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
213 WCHAR *p, *str = (WCHAR *)info->Data;
214 str[info->DataLength / sizeof(WCHAR)] = 0;
215 p = strchrW( str, '.' );
216 if (p)
218 *p++ = 0;
219 version->dwMinorVersion = atoiW( p );
221 version->dwMajorVersion = atoiW( str );
224 if (version->dwMajorVersion) /* we got the main version, now fetch the other fields */
226 ret = TRUE;
227 version->dwPlatformId = VER_PLATFORM_WIN32_NT;
229 /* get build number */
231 RtlInitUnicodeString( &valueW, CurrentBuildNumberW );
232 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
234 WCHAR *str = (WCHAR *)info->Data;
235 str[info->DataLength / sizeof(WCHAR)] = 0;
236 version->dwBuildNumber = atoiW( str );
239 /* get version description */
241 RtlInitUnicodeString( &valueW, CSDVersionW );
242 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
244 DWORD len = min( info->DataLength, sizeof(version->szCSDVersion) - sizeof(WCHAR) );
245 memcpy( version->szCSDVersion, info->Data, len );
246 version->szCSDVersion[len / sizeof(WCHAR)] = 0;
249 /* get service pack version */
251 RtlInitUnicodeString( &nameW, service_pack_keyW );
252 if (!NtOpenKey( &hkey2, KEY_ALL_ACCESS, &attr ))
254 RtlInitUnicodeString( &valueW, CSDVersionW );
255 if (!NtQueryValueKey( hkey2, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp), &count ))
257 if (info->DataLength >= sizeof(DWORD))
259 DWORD dw = *(DWORD *)info->Data;
260 version->wServicePackMajor = LOWORD(dw) >> 8;
261 version->wServicePackMinor = LOWORD(dw) & 0xff;
264 NtClose( hkey2 );
267 /* get product type */
269 RtlInitUnicodeString( &nameW, product_keyW );
270 if (!NtOpenKey( &hkey2, KEY_ALL_ACCESS, &attr ))
272 RtlInitUnicodeString( &valueW, ProductTypeW );
273 if (!NtQueryValueKey( hkey2, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
275 WCHAR *str = (WCHAR *)info->Data;
276 str[info->DataLength / sizeof(WCHAR)] = 0;
277 if (!strcmpiW( str, WinNTW )) version->wProductType = VER_NT_WORKSTATION;
278 else if (!strcmpiW( str, LanmanNTW )) version->wProductType = VER_NT_DOMAIN_CONTROLLER;
279 else if (!strcmpiW( str, ServerNTW )) version->wProductType = VER_NT_SERVER;
281 NtClose( hkey2 );
284 /* FIXME: get wSuiteMask */
287 NtClose( hkey );
288 return ret;
292 /**********************************************************************
293 * get_win9x_registry_version
295 * Fetch the version information from the Win9x-style registry keys.
297 static BOOL get_win9x_registry_version( RTL_OSVERSIONINFOEXW *version )
299 static const WCHAR version_keyW[] = {'M','a','c','h','i','n','e','\\',
300 'S','o','f','t','w','a','r','e','\\',
301 'M','i','c','r','o','s','o','f','t','\\',
302 'W','i','n','d','o','w','s','\\',
303 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
304 static const WCHAR VersionNumberW[] = {'V','e','r','s','i','o','n','N','u','m','b','e','r',0};
305 static const WCHAR SubVersionNumberW[] = {'S','u','b','V','e','r','s','i','o','n','N','u','m','b','e','r',0};
307 OBJECT_ATTRIBUTES attr;
308 UNICODE_STRING nameW, valueW;
309 HANDLE hkey;
310 char tmp[64];
311 DWORD count;
312 BOOL ret = FALSE;
313 KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)tmp;
315 attr.Length = sizeof(attr);
316 attr.RootDirectory = 0;
317 attr.ObjectName = &nameW;
318 attr.Attributes = 0;
319 attr.SecurityDescriptor = NULL;
320 attr.SecurityQualityOfService = NULL;
321 RtlInitUnicodeString( &nameW, version_keyW );
323 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) return FALSE;
325 memset( version, 0, sizeof(*version) );
327 RtlInitUnicodeString( &valueW, VersionNumberW );
328 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
330 WCHAR *p, *str = (WCHAR *)info->Data;
331 str[info->DataLength / sizeof(WCHAR)] = 0;
332 p = strchrW( str, '.' );
333 if (p) *p++ = 0;
334 version->dwMajorVersion = atoiW( str );
335 if (p)
337 str = p;
338 p = strchrW( str, '.' );
339 if (p)
341 *p++ = 0;
342 version->dwBuildNumber = atoiW( p );
344 version->dwMinorVersion = atoiW( str );
346 /* build number contains version too on Win9x */
347 version->dwBuildNumber |= MAKEWORD( version->dwMinorVersion, version->dwMajorVersion ) << 16;
350 if (version->dwMajorVersion) /* we got the main version, now fetch the other fields */
352 ret = TRUE;
353 version->dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
355 RtlInitUnicodeString( &valueW, SubVersionNumberW );
356 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
358 DWORD len = min( info->DataLength, sizeof(version->szCSDVersion) - sizeof(WCHAR) );
359 memcpy( version->szCSDVersion, info->Data, len );
360 version->szCSDVersion[len / sizeof(WCHAR)] = 0;
364 NtClose( hkey );
365 return ret;
369 /**********************************************************************
370 * parse_win_version
372 * Parse the contents of the Version key.
374 static BOOL parse_win_version( HANDLE hkey )
376 static const WCHAR VersionW[] = {'V','e','r','s','i','o','n',0};
378 UNICODE_STRING valueW;
379 char tmp[64], buffer[50];
380 KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)tmp;
381 DWORD count, len;
382 int i;
384 RtlInitUnicodeString( &valueW, VersionW );
385 if (NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp), &count ))
386 return FALSE;
388 RtlUnicodeToMultiByteN( buffer, sizeof(buffer)-1, &len, (WCHAR *)info->Data, info->DataLength );
389 buffer[len] = 0;
391 for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
393 const char *p, *pCurr = WinVersionNames[i];
394 /* iterate through all winver aliases separated by comma */
395 do {
396 p = strchr(pCurr, ',');
397 len = p ? p - pCurr : strlen(pCurr);
398 if ( (!strncmp( pCurr, buffer, len )) && (buffer[len] == 0) )
400 current_version = &VersionData[i];
401 TRACE( "got win version %s\n", WinVersionNames[i] );
402 return TRUE;
404 pCurr = p+1;
405 } while (p);
408 MESSAGE("Invalid Windows version value '%s' specified in config file.\n", buffer );
409 MESSAGE("Valid versions are:" );
410 for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
412 /* only list the first, "official" alias in case of aliases */
413 const char *pCurr = WinVersionNames[i];
414 const char *p = strchr(pCurr, ',');
415 len = (p) ? p - pCurr : strlen(pCurr);
417 MESSAGE(" '%.*s'%c", (int)len, pCurr, (i == NB_WINDOWS_VERSIONS - 1) ? '\n' : ',' );
419 return FALSE;
423 /**********************************************************************
424 * version_init
426 void version_init( const WCHAR *appname )
428 static const WCHAR configW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
429 static const WCHAR appdefaultsW[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
431 OBJECT_ATTRIBUTES attr;
432 UNICODE_STRING nameW;
433 HANDLE root, hkey, config_key;
434 BOOL got_win_ver = FALSE;
436 current_version = &VersionData[NT2K]; /* default if nothing else is specified */
438 RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
439 attr.Length = sizeof(attr);
440 attr.RootDirectory = root;
441 attr.ObjectName = &nameW;
442 attr.Attributes = 0;
443 attr.SecurityDescriptor = NULL;
444 attr.SecurityQualityOfService = NULL;
445 RtlInitUnicodeString( &nameW, configW );
447 /* @@ Wine registry key: HKCU\Software\Wine */
448 if (NtOpenKey( &config_key, KEY_ALL_ACCESS, &attr )) config_key = 0;
449 NtClose( root );
450 if (!config_key) goto done;
452 /* open AppDefaults\\appname key */
453 if (appname && *appname)
455 const WCHAR *p;
456 WCHAR appversion[MAX_PATH+20];
458 if ((p = strrchrW( appname, '/' ))) appname = p + 1;
459 if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
461 strcpyW( appversion, appdefaultsW );
462 strcatW( appversion, appname );
463 RtlInitUnicodeString( &nameW, appversion );
464 attr.RootDirectory = config_key;
466 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe */
467 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
469 TRACE( "getting version from %s\n", debugstr_w(appversion) );
470 got_win_ver = parse_win_version( hkey );
471 NtClose( hkey );
475 if (!got_win_ver)
477 TRACE( "getting default version\n" );
478 got_win_ver = parse_win_version( config_key );
480 NtClose( config_key );
482 done:
483 if (!got_win_ver)
485 static RTL_OSVERSIONINFOEXW registry_version;
487 TRACE( "getting registry version\n" );
488 if (get_nt_registry_version( &registry_version ) ||
489 get_win9x_registry_version( &registry_version ))
490 current_version = &registry_version;
494 NtCurrentTeb()->Peb->OSMajorVersion = current_version->dwMajorVersion;
495 NtCurrentTeb()->Peb->OSMinorVersion = current_version->dwMinorVersion;
496 NtCurrentTeb()->Peb->OSBuildNumber = current_version->dwBuildNumber;
497 NtCurrentTeb()->Peb->OSPlatformId = current_version->dwPlatformId;
499 TRACE( "got %ld.%ld plaform %ld build %lx name %s service pack %d.%d product %d\n",
500 current_version->dwMajorVersion, current_version->dwMinorVersion,
501 current_version->dwPlatformId, current_version->dwBuildNumber,
502 debugstr_w(current_version->szCSDVersion),
503 current_version->wServicePackMajor, current_version->wServicePackMinor,
504 current_version->wProductType );
508 /***********************************************************************
509 * RtlGetVersion (NTDLL.@)
511 NTSTATUS WINAPI RtlGetVersion( RTL_OSVERSIONINFOEXW *info )
513 info->dwMajorVersion = current_version->dwMajorVersion;
514 info->dwMinorVersion = current_version->dwMinorVersion;
515 info->dwBuildNumber = current_version->dwBuildNumber;
516 info->dwPlatformId = current_version->dwPlatformId;
517 strcpyW( info->szCSDVersion, current_version->szCSDVersion );
518 if(info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
520 info->wServicePackMajor = current_version->wServicePackMajor;
521 info->wServicePackMinor = current_version->wServicePackMinor;
522 info->wSuiteMask = current_version->wSuiteMask;
523 info->wProductType = current_version->wProductType;
525 return STATUS_SUCCESS;
529 /******************************************************************************
530 * RtlGetNtVersionNumbers (NTDLL.@)
532 * Get the version numbers of the run time library.
534 * PARAMS
535 * major [O] Destination for the Major version
536 * minor [O] Destination for the Minor version
537 * build [O] Destination for the Build version
539 * RETURNS
540 * Nothing.
542 * NOTES
543 * Introduced in Windows XP (NT5.1)
545 void WINAPI RtlGetNtVersionNumbers( LPDWORD major, LPDWORD minor, LPDWORD build )
547 if (major) *major = current_version->dwMajorVersion;
548 if (minor) *minor = current_version->dwMinorVersion;
549 /* FIXME: Does anybody know the real formula? */
550 if (build) *build = (0xF0000000 | current_version->dwBuildNumber);
554 /******************************************************************************
555 * RtlGetNtProductType (NTDLL.@)
557 BOOLEAN WINAPI RtlGetNtProductType( LPDWORD type )
559 if (type) *type = current_version->wProductType;
560 return TRUE;
564 /******************************************************************************
565 * RtlVerifyVersionInfo (NTDLL.@)
567 NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
568 DWORD dwTypeMask, DWORDLONG dwlConditionMask )
570 RTL_OSVERSIONINFOEXW ver;
571 NTSTATUS status;
573 FIXME("(%p,%lu,%llx): Not all cases correctly implemented yet\n",
574 info, dwTypeMask, dwlConditionMask);
576 /* FIXME:
577 - Check the following special case on Windows (various versions):
578 o lp->wSuiteMask == 0 and ver.wSuiteMask != 0 and VER_AND/VER_OR
579 o lp->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)
580 - MSDN talks about some tests being impossible. Check what really happens.
583 ver.dwOSVersionInfoSize = sizeof(ver);
584 if ((status = RtlGetVersion( &ver )) != STATUS_SUCCESS) return status;
586 if(!(dwTypeMask && dwlConditionMask)) return STATUS_INVALID_PARAMETER;
588 if(dwTypeMask & VER_PRODUCT_TYPE)
589 switch(dwlConditionMask >> 7*3 & 0x07) {
590 case VER_EQUAL:
591 if(ver.wProductType != info->wProductType) return STATUS_REVISION_MISMATCH;
592 break;
593 case VER_GREATER:
594 if(ver.wProductType <= info->wProductType) return STATUS_REVISION_MISMATCH;
595 break;
596 case VER_GREATER_EQUAL:
597 if(ver.wProductType < info->wProductType) return STATUS_REVISION_MISMATCH;
598 break;
599 case VER_LESS:
600 if(ver.wProductType >= info->wProductType) return STATUS_REVISION_MISMATCH;
601 break;
602 case VER_LESS_EQUAL:
603 if(ver.wProductType > info->wProductType) return STATUS_REVISION_MISMATCH;
604 break;
605 default:
606 return STATUS_INVALID_PARAMETER;
608 if(dwTypeMask & VER_SUITENAME)
609 switch(dwlConditionMask >> 6*3 & 0x07)
611 case VER_AND:
612 if((info->wSuiteMask & ver.wSuiteMask) != info->wSuiteMask)
613 return STATUS_REVISION_MISMATCH;
614 break;
615 case VER_OR:
616 if(!(info->wSuiteMask & ver.wSuiteMask) && info->wSuiteMask)
617 return STATUS_REVISION_MISMATCH;
618 break;
619 default:
620 return STATUS_INVALID_PARAMETER;
622 if(dwTypeMask & VER_PLATFORMID)
623 switch(dwlConditionMask >> 3*3 & 0x07)
625 case VER_EQUAL:
626 if(ver.dwPlatformId != info->dwPlatformId) return STATUS_REVISION_MISMATCH;
627 break;
628 case VER_GREATER:
629 if(ver.dwPlatformId <= info->dwPlatformId) return STATUS_REVISION_MISMATCH;
630 break;
631 case VER_GREATER_EQUAL:
632 if(ver.dwPlatformId < info->dwPlatformId) return STATUS_REVISION_MISMATCH;
633 break;
634 case VER_LESS:
635 if(ver.dwPlatformId >= info->dwPlatformId) return STATUS_REVISION_MISMATCH;
636 break;
637 case VER_LESS_EQUAL:
638 if(ver.dwPlatformId > info->dwPlatformId) return STATUS_REVISION_MISMATCH;
639 break;
640 default:
641 return STATUS_INVALID_PARAMETER;
643 if(dwTypeMask & VER_BUILDNUMBER)
644 switch(dwlConditionMask >> 2*3 & 0x07)
646 case VER_EQUAL:
647 if(ver.dwBuildNumber != info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
648 break;
649 case VER_GREATER:
650 if(ver.dwBuildNumber <= info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
651 break;
652 case VER_GREATER_EQUAL:
653 if(ver.dwBuildNumber < info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
654 break;
655 case VER_LESS:
656 if(ver.dwBuildNumber >= info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
657 break;
658 case VER_LESS_EQUAL:
659 if(ver.dwBuildNumber > info->dwBuildNumber) return STATUS_REVISION_MISMATCH;
660 break;
661 default:
662 return STATUS_INVALID_PARAMETER;
664 if(dwTypeMask & VER_MAJORVERSION)
665 switch(dwlConditionMask >> 1*3 & 0x07)
667 case VER_EQUAL:
668 if(ver.dwMajorVersion != info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
669 break;
670 case VER_GREATER:
671 if(ver.dwMajorVersion <= info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
672 break;
673 case VER_GREATER_EQUAL:
674 if(ver.dwMajorVersion < info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
675 break;
676 case VER_LESS:
677 if(ver.dwMajorVersion >= info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
678 break;
679 case VER_LESS_EQUAL:
680 if(ver.dwMajorVersion > info->dwMajorVersion) return STATUS_REVISION_MISMATCH;
681 break;
682 default:
683 return STATUS_INVALID_PARAMETER;
685 if(dwTypeMask & VER_MINORVERSION)
686 switch(dwlConditionMask >> 0*3 & 0x07)
688 case VER_EQUAL:
689 if(ver.dwMinorVersion != info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
690 break;
691 case VER_GREATER:
692 if(ver.dwMinorVersion <= info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
693 break;
694 case VER_GREATER_EQUAL:
695 if(ver.dwMinorVersion < info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
696 break;
697 case VER_LESS:
698 if(ver.dwMinorVersion >= info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
699 break;
700 case VER_LESS_EQUAL:
701 if(ver.dwMinorVersion > info->dwMinorVersion) return STATUS_REVISION_MISMATCH;
702 break;
703 default:
704 return STATUS_INVALID_PARAMETER;
706 if(dwTypeMask & VER_SERVICEPACKMAJOR)
707 switch(dwlConditionMask >> 5*3 & 0x07)
709 case VER_EQUAL:
710 if(ver.wServicePackMajor != info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
711 break;
712 case VER_GREATER:
713 if(ver.wServicePackMajor <= info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
714 break;
715 case VER_GREATER_EQUAL:
716 if(ver.wServicePackMajor < info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
717 break;
718 case VER_LESS:
719 if(ver.wServicePackMajor >= info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
720 break;
721 case VER_LESS_EQUAL:
722 if(ver.wServicePackMajor > info->wServicePackMajor) return STATUS_REVISION_MISMATCH;
723 break;
724 default:
725 return STATUS_INVALID_PARAMETER;
727 if(dwTypeMask & VER_SERVICEPACKMINOR)
728 switch(dwlConditionMask >> 4*3 & 0x07)
730 case VER_EQUAL:
731 if(ver.wServicePackMinor != info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
732 break;
733 case VER_GREATER:
734 if(ver.wServicePackMinor <= info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
735 break;
736 case VER_GREATER_EQUAL:
737 if(ver.wServicePackMinor < info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
738 break;
739 case VER_LESS:
740 if(ver.wServicePackMinor >= info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
741 break;
742 case VER_LESS_EQUAL:
743 if(ver.wServicePackMinor > info->wServicePackMinor) return STATUS_REVISION_MISMATCH;
744 break;
745 default:
746 return STATUS_INVALID_PARAMETER;
749 return STATUS_SUCCESS;