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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/port.h"
32 #define WIN32_NO_STATUS
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
36 #include "ntdll_misc.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
43 WIN20
, /* Windows 2.0 */
44 WIN30
, /* Windows 3.0 */
45 WIN31
, /* Windows 3.1 */
46 WIN95
, /* Windows 95 */
47 WIN98
, /* Windows 98 */
48 WINME
, /* Windows Me */
49 NT351
, /* Windows NT 3.51 */
50 NT40
, /* Windows NT 4.0 */
51 NT2K
, /* Windows 2000 */
52 WINXP
, /* Windows XP */
53 WIN2K3
, /* Windows 2003 */
54 WINVISTA
,/* Windows Vista */
55 WIN2K8
, /* Windows 2008 */
56 WIN2K8R2
,/* Windows 2008 R2 */
61 /* FIXME: compare values below with original and fix.
62 * An *excellent* win9x version page (ALL versions !)
63 * can be found at www.mdgx.com/ver.htm */
64 static const RTL_OSVERSIONINFOEXW VersionData
[NB_WINDOWS_VERSIONS
] =
66 /* WIN20 FIXME: verify values */
68 sizeof(RTL_OSVERSIONINFOEXW
), 2, 0, 0, VER_PLATFORM_WIN32s
,
69 {'W','i','n','3','2','s',' ','1','.','3',0},
72 /* WIN30 FIXME: verify values */
74 sizeof(RTL_OSVERSIONINFOEXW
), 3, 0, 0, VER_PLATFORM_WIN32s
,
75 {'W','i','n','3','2','s',' ','1','.','3',0},
80 sizeof(RTL_OSVERSIONINFOEXW
), 3, 10, 0, VER_PLATFORM_WIN32s
,
81 {'W','i','n','3','2','s',' ','1','.','3',0},
86 /* Win95: 4, 0, 0x40003B6, ""
87 * Win95sp1: 4, 0, 0x40003B6, " A " (according to doc)
88 * Win95osr2: 4, 0, 0x4000457, " B " (according to doc)
89 * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
90 * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
91 * Win95a/b can be discerned via regkey SubVersionNumber
93 sizeof(RTL_OSVERSIONINFOEXW
), 4, 0, 0x40003B6, VER_PLATFORM_WIN32_WINDOWS
,
97 /* WIN98 (second edition) */
99 /* Win98: 4, 10, 0x40A07CE, " " 4.10.1998
100 * Win98SE: 4, 10, 0x40A08AE, " A " 4.10.2222
102 sizeof(RTL_OSVERSIONINFOEXW
), 4, 10, 0x40A08AE, VER_PLATFORM_WIN32_WINDOWS
,
108 sizeof(RTL_OSVERSIONINFOEXW
), 4, 90, 0x45A0BB8, VER_PLATFORM_WIN32_WINDOWS
,
114 sizeof(RTL_OSVERSIONINFOEXW
), 3, 51, 0x421, VER_PLATFORM_WIN32_NT
,
115 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
120 sizeof(RTL_OSVERSIONINFOEXW
), 4, 0, 0x565, VER_PLATFORM_WIN32_NT
,
121 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','6','a',0},
122 6, 0, 0, VER_NT_WORKSTATION
, 0
126 sizeof(RTL_OSVERSIONINFOEXW
), 5, 0, 0x893, VER_PLATFORM_WIN32_NT
,
127 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','4',0},
128 4, 0, 0, VER_NT_WORKSTATION
, 30 /* FIXME: Great, a reserved field with a value! */
132 sizeof(RTL_OSVERSIONINFOEXW
), 5, 1, 0xA28, VER_PLATFORM_WIN32_NT
,
133 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0},
134 3, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 30 /* FIXME: Great, a reserved field with a value! */
138 sizeof(RTL_OSVERSIONINFOEXW
), 5, 2, 0xECE, VER_PLATFORM_WIN32_NT
,
139 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
140 2, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_SERVER
, 0
144 sizeof(RTL_OSVERSIONINFOEXW
), 6, 0, 0x1772, VER_PLATFORM_WIN32_NT
,
145 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
146 2, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 0
150 sizeof(RTL_OSVERSIONINFOEXW
), 6, 0, 0x1772, VER_PLATFORM_WIN32_NT
,
151 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
152 0, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_SERVER
, 0
156 sizeof(RTL_OSVERSIONINFOEXW
), 6, 1, 0x1DB1, VER_PLATFORM_WIN32_NT
,
157 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','1',0},
158 1, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 0
162 sizeof(RTL_OSVERSIONINFOEXW
), 6, 1, 0x1DB1, VER_PLATFORM_WIN32_NT
,
163 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','1',0},
164 1, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_SERVER
, 0
169 static const char * const WinVersionNames
[NB_WINDOWS_VERSIONS
] =
170 { /* no spaces in here ! */
179 "win2000,win2k,nt2k,nt2000", /* NT2K */
181 "win2003,win2k3", /* WIN2K3 */
182 "vista,winvista", /* WINVISTA*/
183 "win2008,win2k8", /* WIN2K8 */
184 "win2008r2,win2k8r2", /* WIN2K8R2 */
189 /* initialized to null so that we crash if we try to retrieve the version too early at startup */
190 static const RTL_OSVERSIONINFOEXW
*current_version
;
193 /**********************************************************************
194 * get_nt_registry_version
196 * Fetch the version information from the NT-style registry keys.
198 static BOOL
get_nt_registry_version( RTL_OSVERSIONINFOEXW
*version
)
200 static const WCHAR version_keyW
[] = {'M','a','c','h','i','n','e','\\',
201 'S','o','f','t','w','a','r','e','\\',
202 'M','i','c','r','o','s','o','f','t','\\',
203 'W','i','n','d','o','w','s',' ','N','T','\\',
204 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
205 static const WCHAR service_pack_keyW
[] = {'M','a','c','h','i','n','e','\\',
206 'S','y','s','t','e','m','\\',
207 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
208 'C','o','n','t','r','o','l','\\',
209 'W','i','n','d','o','w','s',0};
210 static const WCHAR product_keyW
[] = {'M','a','c','h','i','n','e','\\',
211 'S','y','s','t','e','m','\\',
212 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
213 'C','o','n','t','r','o','l','\\',
214 'P','r','o','d','u','c','t','O','p','t','i','o','n','s',0};
215 static const WCHAR CurrentBuildNumberW
[] = {'C','u','r','r','e','n','t','B','u','i','l','d','N','u','m','b','e','r',0};
216 static const WCHAR CSDVersionW
[] = {'C','S','D','V','e','r','s','i','o','n',0};
217 static const WCHAR CurrentVersionW
[] = {'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
218 static const WCHAR ProductTypeW
[] = {'P','r','o','d','u','c','t','T','y','p','e',0};
219 static const WCHAR WinNTW
[] = {'W','i','n','N','T',0};
220 static const WCHAR ServerNTW
[] = {'S','e','r','v','e','r','N','T',0};
221 static const WCHAR LanmanNTW
[] = {'L','a','n','m','a','n','N','T',0};
223 OBJECT_ATTRIBUTES attr
;
224 UNICODE_STRING nameW
, valueW
;
229 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
231 attr
.Length
= sizeof(attr
);
232 attr
.RootDirectory
= 0;
233 attr
.ObjectName
= &nameW
;
235 attr
.SecurityDescriptor
= NULL
;
236 attr
.SecurityQualityOfService
= NULL
;
237 RtlInitUnicodeString( &nameW
, version_keyW
);
239 if (NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
)) return FALSE
;
241 memset( version
, 0, sizeof(*version
) );
243 RtlInitUnicodeString( &valueW
, CurrentVersionW
);
244 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
246 WCHAR
*p
, *str
= (WCHAR
*)info
->Data
;
247 str
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
248 p
= strchrW( str
, '.' );
252 version
->dwMinorVersion
= atoiW( p
);
254 version
->dwMajorVersion
= atoiW( str
);
257 if (version
->dwMajorVersion
) /* we got the main version, now fetch the other fields */
260 version
->dwPlatformId
= VER_PLATFORM_WIN32_NT
;
262 /* get build number */
264 RtlInitUnicodeString( &valueW
, CurrentBuildNumberW
);
265 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
267 WCHAR
*str
= (WCHAR
*)info
->Data
;
268 str
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
269 version
->dwBuildNumber
= atoiW( str
);
272 /* get version description */
274 RtlInitUnicodeString( &valueW
, CSDVersionW
);
275 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
277 DWORD len
= min( info
->DataLength
, sizeof(version
->szCSDVersion
) - sizeof(WCHAR
) );
278 memcpy( version
->szCSDVersion
, info
->Data
, len
);
279 version
->szCSDVersion
[len
/ sizeof(WCHAR
)] = 0;
282 /* get service pack version */
284 RtlInitUnicodeString( &nameW
, service_pack_keyW
);
285 if (!NtOpenKey( &hkey2
, KEY_ALL_ACCESS
, &attr
))
287 RtlInitUnicodeString( &valueW
, CSDVersionW
);
288 if (!NtQueryValueKey( hkey2
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
290 if (info
->DataLength
>= sizeof(DWORD
))
292 DWORD dw
= *(DWORD
*)info
->Data
;
293 version
->wServicePackMajor
= LOWORD(dw
) >> 8;
294 version
->wServicePackMinor
= LOWORD(dw
) & 0xff;
300 /* get product type */
302 RtlInitUnicodeString( &nameW
, product_keyW
);
303 if (!NtOpenKey( &hkey2
, KEY_ALL_ACCESS
, &attr
))
305 RtlInitUnicodeString( &valueW
, ProductTypeW
);
306 if (!NtQueryValueKey( hkey2
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
308 WCHAR
*str
= (WCHAR
*)info
->Data
;
309 str
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
310 if (!strcmpiW( str
, WinNTW
)) version
->wProductType
= VER_NT_WORKSTATION
;
311 else if (!strcmpiW( str
, LanmanNTW
)) version
->wProductType
= VER_NT_DOMAIN_CONTROLLER
;
312 else if (!strcmpiW( str
, ServerNTW
)) version
->wProductType
= VER_NT_SERVER
;
317 /* FIXME: get wSuiteMask */
325 /**********************************************************************
326 * get_win9x_registry_version
328 * Fetch the version information from the Win9x-style registry keys.
330 static BOOL
get_win9x_registry_version( RTL_OSVERSIONINFOEXW
*version
)
332 static const WCHAR version_keyW
[] = {'M','a','c','h','i','n','e','\\',
333 'S','o','f','t','w','a','r','e','\\',
334 'M','i','c','r','o','s','o','f','t','\\',
335 'W','i','n','d','o','w','s','\\',
336 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
337 static const WCHAR VersionNumberW
[] = {'V','e','r','s','i','o','n','N','u','m','b','e','r',0};
338 static const WCHAR SubVersionNumberW
[] = {'S','u','b','V','e','r','s','i','o','n','N','u','m','b','e','r',0};
340 OBJECT_ATTRIBUTES attr
;
341 UNICODE_STRING nameW
, valueW
;
346 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
348 attr
.Length
= sizeof(attr
);
349 attr
.RootDirectory
= 0;
350 attr
.ObjectName
= &nameW
;
352 attr
.SecurityDescriptor
= NULL
;
353 attr
.SecurityQualityOfService
= NULL
;
354 RtlInitUnicodeString( &nameW
, version_keyW
);
356 if (NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
)) return FALSE
;
358 memset( version
, 0, sizeof(*version
) );
360 RtlInitUnicodeString( &valueW
, VersionNumberW
);
361 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
363 WCHAR
*p
, *str
= (WCHAR
*)info
->Data
;
364 str
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
365 p
= strchrW( str
, '.' );
367 version
->dwMajorVersion
= atoiW( str
);
371 p
= strchrW( str
, '.' );
375 version
->dwBuildNumber
= atoiW( p
);
377 version
->dwMinorVersion
= atoiW( str
);
379 /* build number contains version too on Win9x */
380 version
->dwBuildNumber
|= MAKEWORD( version
->dwMinorVersion
, version
->dwMajorVersion
) << 16;
383 if (version
->dwMajorVersion
) /* we got the main version, now fetch the other fields */
386 version
->dwPlatformId
= VER_PLATFORM_WIN32_WINDOWS
;
388 RtlInitUnicodeString( &valueW
, SubVersionNumberW
);
389 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
391 DWORD len
= min( info
->DataLength
, sizeof(version
->szCSDVersion
) - sizeof(WCHAR
) );
392 memcpy( version
->szCSDVersion
, info
->Data
, len
);
393 version
->szCSDVersion
[len
/ sizeof(WCHAR
)] = 0;
402 /**********************************************************************
405 * Parse the contents of the Version key.
407 static BOOL
parse_win_version( HANDLE hkey
)
409 static const WCHAR VersionW
[] = {'V','e','r','s','i','o','n',0};
411 UNICODE_STRING valueW
;
412 char tmp
[64], buffer
[50];
413 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
417 RtlInitUnicodeString( &valueW
, VersionW
);
418 if (NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
421 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
, (WCHAR
*)info
->Data
, info
->DataLength
);
424 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
426 const char *p
, *pCurr
= WinVersionNames
[i
];
427 /* iterate through all winver aliases separated by comma */
429 p
= strchr(pCurr
, ',');
430 len
= p
? p
- pCurr
: strlen(pCurr
);
431 if ( (!strncmp( pCurr
, buffer
, len
)) && (buffer
[len
] == 0) )
433 current_version
= &VersionData
[i
];
434 TRACE( "got win version %s\n", WinVersionNames
[i
] );
441 MESSAGE("Invalid Windows version value '%s' specified in config file.\n", buffer
);
442 MESSAGE("Valid versions are:" );
443 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
445 /* only list the first, "official" alias in case of aliases */
446 const char *pCurr
= WinVersionNames
[i
];
447 const char *p
= strchr(pCurr
, ',');
448 len
= (p
) ? p
- pCurr
: strlen(pCurr
);
450 MESSAGE(" '%.*s'%c", (int)len
, pCurr
, (i
== NB_WINDOWS_VERSIONS
- 1) ? '\n' : ',' );
456 /**********************************************************************
459 void version_init( const WCHAR
*appname
)
461 static const WCHAR configW
[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
462 static const WCHAR appdefaultsW
[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
464 OBJECT_ATTRIBUTES attr
;
465 UNICODE_STRING nameW
;
466 HANDLE root
, hkey
, config_key
;
467 BOOL got_win_ver
= FALSE
;
469 current_version
= &VersionData
[WINXP
]; /* default if nothing else is specified */
471 RtlOpenCurrentUser( KEY_ALL_ACCESS
, &root
);
472 attr
.Length
= sizeof(attr
);
473 attr
.RootDirectory
= root
;
474 attr
.ObjectName
= &nameW
;
476 attr
.SecurityDescriptor
= NULL
;
477 attr
.SecurityQualityOfService
= NULL
;
478 RtlInitUnicodeString( &nameW
, configW
);
480 /* @@ Wine registry key: HKCU\Software\Wine */
481 if (NtOpenKey( &config_key
, KEY_ALL_ACCESS
, &attr
)) config_key
= 0;
483 if (!config_key
) goto done
;
485 /* open AppDefaults\\appname key */
486 if (appname
&& *appname
)
489 WCHAR appversion
[MAX_PATH
+20];
491 if ((p
= strrchrW( appname
, '/' ))) appname
= p
+ 1;
492 if ((p
= strrchrW( appname
, '\\' ))) appname
= p
+ 1;
494 strcpyW( appversion
, appdefaultsW
);
495 strcatW( appversion
, appname
);
496 RtlInitUnicodeString( &nameW
, appversion
);
497 attr
.RootDirectory
= config_key
;
499 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe */
500 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
502 TRACE( "getting version from %s\n", debugstr_w(appversion
) );
503 got_win_ver
= parse_win_version( hkey
);
510 TRACE( "getting default version\n" );
511 got_win_ver
= parse_win_version( config_key
);
513 NtClose( config_key
);
518 static RTL_OSVERSIONINFOEXW registry_version
;
520 TRACE( "getting registry version\n" );
521 if (get_nt_registry_version( ®istry_version
) ||
522 get_win9x_registry_version( ®istry_version
))
523 current_version
= ®istry_version
;
527 NtCurrentTeb()->Peb
->OSMajorVersion
= current_version
->dwMajorVersion
;
528 NtCurrentTeb()->Peb
->OSMinorVersion
= current_version
->dwMinorVersion
;
529 NtCurrentTeb()->Peb
->OSBuildNumber
= current_version
->dwBuildNumber
;
530 NtCurrentTeb()->Peb
->OSPlatformId
= current_version
->dwPlatformId
;
532 user_shared_data
->NtProductType
= current_version
->wProductType
;
533 user_shared_data
->ProductTypeIsValid
= TRUE
;
534 user_shared_data
->NtMajorVersion
= current_version
->dwMajorVersion
;
535 user_shared_data
->NtMinorVersion
= current_version
->dwMinorVersion
;
536 user_shared_data
->SuiteMask
= current_version
->wSuiteMask
;
538 TRACE( "got %d.%d platform %d build %x name %s service pack %d.%d product %d\n",
539 current_version
->dwMajorVersion
, current_version
->dwMinorVersion
,
540 current_version
->dwPlatformId
, current_version
->dwBuildNumber
,
541 debugstr_w(current_version
->szCSDVersion
),
542 current_version
->wServicePackMajor
, current_version
->wServicePackMinor
,
543 current_version
->wProductType
);
546 /***********************************************************************
547 * GetProductInfo (NTDLL.@)
549 * Gives info about the current Windows product type, in a format compatible
550 * with the given Windows version
552 * Returns TRUE if the input is valid, FALSE otherwise
554 BOOLEAN WINAPI
RtlGetProductInfo(DWORD dwOSMajorVersion
, DWORD dwOSMinorVersion
, DWORD dwSpMajorVersion
,
555 DWORD dwSpMinorVersion
, PDWORD pdwReturnedProductType
)
557 FIXME("(%d,%d,%d,%d,%p): stub\n", dwOSMajorVersion
, dwOSMinorVersion
,
558 dwSpMajorVersion
, dwSpMinorVersion
, pdwReturnedProductType
);
560 *pdwReturnedProductType
= PRODUCT_ULTIMATE_N
;
565 /***********************************************************************
566 * RtlGetVersion (NTDLL.@)
568 NTSTATUS WINAPI
RtlGetVersion( RTL_OSVERSIONINFOEXW
*info
)
570 info
->dwMajorVersion
= current_version
->dwMajorVersion
;
571 info
->dwMinorVersion
= current_version
->dwMinorVersion
;
572 info
->dwBuildNumber
= current_version
->dwBuildNumber
;
573 info
->dwPlatformId
= current_version
->dwPlatformId
;
574 strcpyW( info
->szCSDVersion
, current_version
->szCSDVersion
);
575 if(info
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
))
577 info
->wServicePackMajor
= current_version
->wServicePackMajor
;
578 info
->wServicePackMinor
= current_version
->wServicePackMinor
;
579 info
->wSuiteMask
= current_version
->wSuiteMask
;
580 info
->wProductType
= current_version
->wProductType
;
582 return STATUS_SUCCESS
;
586 /******************************************************************************
587 * RtlGetNtVersionNumbers (NTDLL.@)
589 * Get the version numbers of the run time library.
592 * major [O] Destination for the Major version
593 * minor [O] Destination for the Minor version
594 * build [O] Destination for the Build version
600 * Introduced in Windows XP (NT5.1)
602 void WINAPI
RtlGetNtVersionNumbers( LPDWORD major
, LPDWORD minor
, LPDWORD build
)
604 if (major
) *major
= current_version
->dwMajorVersion
;
605 if (minor
) *minor
= current_version
->dwMinorVersion
;
606 /* FIXME: Does anybody know the real formula? */
607 if (build
) *build
= (0xF0000000 | current_version
->dwBuildNumber
);
611 /******************************************************************************
612 * RtlGetNtProductType (NTDLL.@)
614 BOOLEAN WINAPI
RtlGetNtProductType( LPDWORD type
)
616 if (type
) *type
= current_version
->wProductType
;
621 static inline NTSTATUS
version_compare_values(ULONG left
, ULONG right
, UCHAR condition
)
625 if (left
!= right
) return STATUS_REVISION_MISMATCH
;
628 if (left
<= right
) return STATUS_REVISION_MISMATCH
;
630 case VER_GREATER_EQUAL
:
631 if (left
< right
) return STATUS_REVISION_MISMATCH
;
634 if (left
>= right
) return STATUS_REVISION_MISMATCH
;
637 if (left
> right
) return STATUS_REVISION_MISMATCH
;
640 return STATUS_REVISION_MISMATCH
;
642 return STATUS_SUCCESS
;
645 /******************************************************************************
646 * RtlVerifyVersionInfo (NTDLL.@)
648 NTSTATUS WINAPI
RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW
*info
,
649 DWORD dwTypeMask
, DWORDLONG dwlConditionMask
)
651 RTL_OSVERSIONINFOEXW ver
;
654 TRACE("(%p,0x%x,0x%s)\n", info
, dwTypeMask
, wine_dbgstr_longlong(dwlConditionMask
));
656 ver
.dwOSVersionInfoSize
= sizeof(ver
);
657 if ((status
= RtlGetVersion( &ver
)) != STATUS_SUCCESS
) return status
;
659 if(!(dwTypeMask
&& dwlConditionMask
)) return STATUS_INVALID_PARAMETER
;
661 if(dwTypeMask
& VER_PRODUCT_TYPE
)
663 status
= version_compare_values(ver
.wProductType
, info
->wProductType
, dwlConditionMask
>> 7*3 & 0x07);
664 if (status
!= STATUS_SUCCESS
)
667 if(dwTypeMask
& VER_SUITENAME
)
668 switch(dwlConditionMask
>> 6*3 & 0x07)
671 if((info
->wSuiteMask
& ver
.wSuiteMask
) != info
->wSuiteMask
)
672 return STATUS_REVISION_MISMATCH
;
675 if(!(info
->wSuiteMask
& ver
.wSuiteMask
) && info
->wSuiteMask
)
676 return STATUS_REVISION_MISMATCH
;
679 return STATUS_INVALID_PARAMETER
;
681 if(dwTypeMask
& VER_PLATFORMID
)
683 status
= version_compare_values(ver
.dwPlatformId
, info
->dwPlatformId
, dwlConditionMask
>> 3*3 & 0x07);
684 if (status
!= STATUS_SUCCESS
)
687 if(dwTypeMask
& VER_BUILDNUMBER
)
689 status
= version_compare_values(ver
.dwBuildNumber
, info
->dwBuildNumber
, dwlConditionMask
>> 2*3 & 0x07);
690 if (status
!= STATUS_SUCCESS
)
694 if(dwTypeMask
& (VER_MAJORVERSION
|VER_MINORVERSION
|VER_SERVICEPACKMAJOR
|VER_SERVICEPACKMINOR
))
696 unsigned char condition
= 0;
697 BOOLEAN do_next_check
= TRUE
;
699 if(dwTypeMask
& VER_MAJORVERSION
)
700 condition
= dwlConditionMask
>> 1*3 & 0x07;
701 else if(dwTypeMask
& VER_MINORVERSION
)
702 condition
= dwlConditionMask
>> 0*3 & 0x07;
703 else if(dwTypeMask
& VER_SERVICEPACKMAJOR
)
704 condition
= dwlConditionMask
>> 5*3 & 0x07;
705 else if(dwTypeMask
& VER_SERVICEPACKMINOR
)
706 condition
= dwlConditionMask
>> 4*3 & 0x07;
708 if(dwTypeMask
& VER_MAJORVERSION
)
710 status
= version_compare_values(ver
.dwMajorVersion
, info
->dwMajorVersion
, condition
);
711 do_next_check
= (ver
.dwMajorVersion
== info
->dwMajorVersion
) &&
712 ((condition
!= VER_EQUAL
) || (status
== STATUS_SUCCESS
));
714 if((dwTypeMask
& VER_MINORVERSION
) && do_next_check
)
716 status
= version_compare_values(ver
.dwMinorVersion
, info
->dwMinorVersion
, condition
);
717 do_next_check
= (ver
.dwMinorVersion
== info
->dwMinorVersion
) &&
718 ((condition
!= VER_EQUAL
) || (status
== STATUS_SUCCESS
));
720 if((dwTypeMask
& VER_SERVICEPACKMAJOR
) && do_next_check
)
722 status
= version_compare_values(ver
.wServicePackMajor
, info
->wServicePackMajor
, condition
);
723 do_next_check
= (ver
.wServicePackMajor
== info
->wServicePackMajor
) &&
724 ((condition
!= VER_EQUAL
) || (status
== STATUS_SUCCESS
));
726 if((dwTypeMask
& VER_SERVICEPACKMINOR
) && do_next_check
)
728 status
= version_compare_values(ver
.wServicePackMinor
, info
->wServicePackMinor
, condition
);
731 if (status
!= STATUS_SUCCESS
)
735 return STATUS_SUCCESS
;