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
29 #define WIN32_NO_STATUS
31 #include "wine/debug.h"
32 #include "ntdll_misc.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
39 WIN20
, /* Windows 2.0 */
40 WIN30
, /* Windows 3.0 */
41 WIN31
, /* Windows 3.1 */
42 WIN95
, /* Windows 95 */
43 WIN98
, /* Windows 98 */
44 WINME
, /* Windows Me */
45 NT351
, /* Windows NT 3.51 */
46 NT40
, /* Windows NT 4.0 */
47 NT2K
, /* Windows 2000 */
48 WINXP
, /* Windows XP */
49 WINXP64
, /* Windows XP 64-bit */
50 WIN2K3
, /* Windows 2003 */
51 WINVISTA
,/* Windows Vista */
52 WIN2K8
, /* Windows 2008 */
53 WIN2K8R2
,/* Windows 2008 R2 */
56 WIN81
, /* Windows 8.1 */
57 WIN10
, /* Windows 10 */
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',' ','5',0},
116 5, 0, 0, VER_NT_WORKSTATION
, 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_WORKSTATION
, 0
144 sizeof(RTL_OSVERSIONINFOEXW
), 5, 2, 0xECE, 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_SERVER
, 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 2, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 0
156 sizeof(RTL_OSVERSIONINFOEXW
), 6, 0, 0x1772, VER_PLATFORM_WIN32_NT
,
157 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
158 2, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_SERVER
, 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_WORKSTATION
, 0
168 sizeof(RTL_OSVERSIONINFOEXW
), 6, 1, 0x1DB1, VER_PLATFORM_WIN32_NT
,
169 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','1',0},
170 1, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_SERVER
, 0
174 sizeof(RTL_OSVERSIONINFOEXW
), 6, 2, 0x23F0, VER_PLATFORM_WIN32_NT
,
175 {0}, 0, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 0
179 sizeof(RTL_OSVERSIONINFOEXW
), 6, 3, 0x2580, VER_PLATFORM_WIN32_NT
,
180 {0}, 0, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 0
184 sizeof(RTL_OSVERSIONINFOEXW
), 10, 0, 0x4563, VER_PLATFORM_WIN32_NT
,
185 {0}, 0, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 0
190 static const struct { WCHAR name
[12]; WINDOWS_VERSION ver
; } version_names
[] =
192 { {'w','i','n','2','0',0}, WIN20
},
193 { {'w','i','n','3','0',0}, WIN30
},
194 { {'w','i','n','3','1',0}, WIN31
},
195 { {'w','i','n','9','5',0}, WIN95
},
196 { {'w','i','n','9','8',0}, WIN98
},
197 { {'w','i','n','m','e',0}, WINME
},
198 { {'n','t','3','5','1',0}, NT351
},
199 { {'n','t','4','0',0}, NT40
},
200 { {'w','i','n','2','0','0','0',0}, NT2K
},
201 { {'w','i','n','2','k',0}, NT2K
},
202 { {'n','t','2','k',0}, NT2K
},
203 { {'n','t','2','0','0','0',0}, NT2K
},
204 { {'w','i','n','x','p',0}, WINXP
},
205 { {'w','i','n','x','p','6','4',0}, WINXP64
},
206 { {'w','i','n','2','0','0','3',0}, WIN2K3
},
207 { {'w','i','n','2','k','3',0}, WIN2K3
},
208 { {'v','i','s','t','a',0}, WINVISTA
},
209 { {'w','i','n','v','i','s','t','a',0}, WINVISTA
},
210 { {'w','i','n','2','0','0','8',0}, WIN2K8
},
211 { {'w','i','n','2','k','8',0}, WIN2K8
},
212 { {'w','i','n','2','0','0','8','r','2',0}, WIN2K8R2
},
213 { {'w','i','n','2','k','8','r','2',0}, WIN2K8R2
},
214 { {'w','i','n','7',0}, WIN7
},
215 { {'w','i','n','8',0}, WIN8
},
216 { {'w','i','n','8','1',0}, WIN81
},
217 { {'w','i','n','1','0',0}, WIN10
},
221 /* initialized to null so that we crash if we try to retrieve the version too early at startup */
222 static const RTL_OSVERSIONINFOEXW
*current_version
;
225 /**********************************************************************
226 * get_nt_registry_version
228 * Fetch the version information from the NT-style registry keys.
230 static BOOL
get_nt_registry_version( RTL_OSVERSIONINFOEXW
*version
)
232 static const WCHAR version_keyW
[] = {'M','a','c','h','i','n','e','\\',
233 'S','o','f','t','w','a','r','e','\\',
234 'M','i','c','r','o','s','o','f','t','\\',
235 'W','i','n','d','o','w','s',' ','N','T','\\',
236 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
237 static const WCHAR service_pack_keyW
[] = {'M','a','c','h','i','n','e','\\',
238 'S','y','s','t','e','m','\\',
239 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
240 'C','o','n','t','r','o','l','\\',
241 'W','i','n','d','o','w','s',0};
242 static const WCHAR product_keyW
[] = {'M','a','c','h','i','n','e','\\',
243 'S','y','s','t','e','m','\\',
244 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
245 'C','o','n','t','r','o','l','\\',
246 'P','r','o','d','u','c','t','O','p','t','i','o','n','s',0};
247 static const WCHAR CurrentBuildNumberW
[] = {'C','u','r','r','e','n','t','B','u','i','l','d','N','u','m','b','e','r',0};
248 static const WCHAR CSDVersionW
[] = {'C','S','D','V','e','r','s','i','o','n',0};
249 static const WCHAR CurrentVersionW
[] = {'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
250 static const WCHAR ProductTypeW
[] = {'P','r','o','d','u','c','t','T','y','p','e',0};
251 static const WCHAR WinNTW
[] = {'W','i','n','N','T',0};
252 static const WCHAR ServerNTW
[] = {'S','e','r','v','e','r','N','T',0};
253 static const WCHAR LanmanNTW
[] = {'L','a','n','m','a','n','N','T',0};
255 OBJECT_ATTRIBUTES attr
;
256 UNICODE_STRING nameW
, valueW
;
261 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
263 attr
.Length
= sizeof(attr
);
264 attr
.RootDirectory
= 0;
265 attr
.ObjectName
= &nameW
;
267 attr
.SecurityDescriptor
= NULL
;
268 attr
.SecurityQualityOfService
= NULL
;
269 RtlInitUnicodeString( &nameW
, version_keyW
);
271 if (NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
)) return FALSE
;
273 memset( version
, 0, sizeof(*version
) );
275 RtlInitUnicodeString( &valueW
, CurrentVersionW
);
276 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
278 WCHAR
*p
, *str
= (WCHAR
*)info
->Data
;
279 str
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
280 p
= wcschr( str
, '.' );
284 version
->dwMinorVersion
= wcstoul( p
, NULL
, 10 );
286 version
->dwMajorVersion
= wcstoul( str
, NULL
, 10 );
289 if (version
->dwMajorVersion
) /* we got the main version, now fetch the other fields */
292 version
->dwPlatformId
= VER_PLATFORM_WIN32_NT
;
294 /* get build number */
296 RtlInitUnicodeString( &valueW
, CurrentBuildNumberW
);
297 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
299 WCHAR
*str
= (WCHAR
*)info
->Data
;
300 str
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
301 version
->dwBuildNumber
= wcstoul( str
, NULL
, 10 );
304 /* get version description */
306 RtlInitUnicodeString( &valueW
, CSDVersionW
);
307 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
309 DWORD len
= min( info
->DataLength
, sizeof(version
->szCSDVersion
) - sizeof(WCHAR
) );
310 memcpy( version
->szCSDVersion
, info
->Data
, len
);
311 version
->szCSDVersion
[len
/ sizeof(WCHAR
)] = 0;
314 /* get service pack version */
316 RtlInitUnicodeString( &nameW
, service_pack_keyW
);
317 if (!NtOpenKey( &hkey2
, KEY_ALL_ACCESS
, &attr
))
319 RtlInitUnicodeString( &valueW
, CSDVersionW
);
320 if (!NtQueryValueKey( hkey2
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
322 if (info
->DataLength
>= sizeof(DWORD
))
324 DWORD dw
= *(DWORD
*)info
->Data
;
325 version
->wServicePackMajor
= LOWORD(dw
) >> 8;
326 version
->wServicePackMinor
= LOWORD(dw
) & 0xff;
332 /* get product type */
334 RtlInitUnicodeString( &nameW
, product_keyW
);
335 if (!NtOpenKey( &hkey2
, KEY_ALL_ACCESS
, &attr
))
337 RtlInitUnicodeString( &valueW
, ProductTypeW
);
338 if (!NtQueryValueKey( hkey2
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
340 WCHAR
*str
= (WCHAR
*)info
->Data
;
341 str
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
342 if (!wcsicmp( str
, WinNTW
)) version
->wProductType
= VER_NT_WORKSTATION
;
343 else if (!wcsicmp( str
, LanmanNTW
)) version
->wProductType
= VER_NT_DOMAIN_CONTROLLER
;
344 else if (!wcsicmp( str
, ServerNTW
)) version
->wProductType
= VER_NT_SERVER
;
349 /* FIXME: get wSuiteMask */
357 /**********************************************************************
358 * get_win9x_registry_version
360 * Fetch the version information from the Win9x-style registry keys.
362 static BOOL
get_win9x_registry_version( RTL_OSVERSIONINFOEXW
*version
)
364 static const WCHAR version_keyW
[] = {'M','a','c','h','i','n','e','\\',
365 'S','o','f','t','w','a','r','e','\\',
366 'M','i','c','r','o','s','o','f','t','\\',
367 'W','i','n','d','o','w','s','\\',
368 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
369 static const WCHAR VersionNumberW
[] = {'V','e','r','s','i','o','n','N','u','m','b','e','r',0};
370 static const WCHAR SubVersionNumberW
[] = {'S','u','b','V','e','r','s','i','o','n','N','u','m','b','e','r',0};
372 OBJECT_ATTRIBUTES attr
;
373 UNICODE_STRING nameW
, valueW
;
378 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
380 attr
.Length
= sizeof(attr
);
381 attr
.RootDirectory
= 0;
382 attr
.ObjectName
= &nameW
;
384 attr
.SecurityDescriptor
= NULL
;
385 attr
.SecurityQualityOfService
= NULL
;
386 RtlInitUnicodeString( &nameW
, version_keyW
);
388 if (NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
)) return FALSE
;
390 memset( version
, 0, sizeof(*version
) );
392 RtlInitUnicodeString( &valueW
, VersionNumberW
);
393 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
395 WCHAR
*p
, *str
= (WCHAR
*)info
->Data
;
396 str
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
397 p
= wcschr( str
, '.' );
399 version
->dwMajorVersion
= wcstoul( str
, NULL
, 10 );
403 p
= wcschr( str
, '.' );
407 version
->dwBuildNumber
= wcstoul( p
, NULL
, 10 );
409 version
->dwMinorVersion
= wcstoul( str
, NULL
, 10 );
411 /* build number contains version too on Win9x */
412 version
->dwBuildNumber
|= MAKEWORD( version
->dwMinorVersion
, version
->dwMajorVersion
) << 16;
415 if (version
->dwMajorVersion
) /* we got the main version, now fetch the other fields */
418 version
->dwPlatformId
= VER_PLATFORM_WIN32_WINDOWS
;
420 RtlInitUnicodeString( &valueW
, SubVersionNumberW
);
421 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
)-1, &count
))
423 DWORD len
= min( info
->DataLength
, sizeof(version
->szCSDVersion
) - sizeof(WCHAR
) );
424 memcpy( version
->szCSDVersion
, info
->Data
, len
);
425 version
->szCSDVersion
[len
/ sizeof(WCHAR
)] = 0;
434 /**********************************************************************
437 * Parse the contents of the Version key.
439 static BOOL
parse_win_version( HANDLE hkey
)
441 static const WCHAR VersionW
[] = {'V','e','r','s','i','o','n',0};
443 UNICODE_STRING valueW
;
444 WCHAR
*name
, tmp
[64];
445 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
448 RtlInitUnicodeString( &valueW
, VersionW
);
449 if (NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
) - sizeof(WCHAR
), &count
))
452 name
= (WCHAR
*)info
->Data
;
453 name
[info
->DataLength
/ sizeof(WCHAR
)] = 0;
455 for (i
= 0; i
< ARRAY_SIZE(version_names
); i
++)
457 if (wcscmp( version_names
[i
].name
, name
)) continue;
458 current_version
= &VersionData
[version_names
[i
].ver
];
459 TRACE( "got win version %s\n", debugstr_w(version_names
[i
].name
) );
463 ERR( "Invalid Windows version value %s specified in config file.\n", debugstr_w(name
) );
468 /**********************************************************************
471 void version_init(void)
473 static const WCHAR configW
[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
474 static const WCHAR appdefaultsW
[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
475 OBJECT_ATTRIBUTES attr
;
476 UNICODE_STRING nameW
;
477 HANDLE root
, hkey
, config_key
;
478 BOOL got_win_ver
= FALSE
;
479 const WCHAR
*p
, *appname
= NtCurrentTeb()->Peb
->ProcessParameters
->ImagePathName
.Buffer
;
480 WCHAR appversion
[MAX_PATH
+20];
482 current_version
= &VersionData
[WIN7
];
484 RtlOpenCurrentUser( KEY_ALL_ACCESS
, &root
);
485 attr
.Length
= sizeof(attr
);
486 attr
.RootDirectory
= root
;
487 attr
.ObjectName
= &nameW
;
489 attr
.SecurityDescriptor
= NULL
;
490 attr
.SecurityQualityOfService
= NULL
;
491 RtlInitUnicodeString( &nameW
, configW
);
493 /* @@ Wine registry key: HKCU\Software\Wine */
494 if (NtOpenKey( &config_key
, KEY_ALL_ACCESS
, &attr
)) config_key
= 0;
496 if (!config_key
) goto done
;
498 /* open AppDefaults\\appname key */
500 if ((p
= wcsrchr( appname
, '/' ))) appname
= p
+ 1;
501 if ((p
= wcsrchr( appname
, '\\' ))) appname
= p
+ 1;
503 wcscpy( appversion
, appdefaultsW
);
504 wcscat( appversion
, appname
);
505 RtlInitUnicodeString( &nameW
, appversion
);
506 attr
.RootDirectory
= config_key
;
508 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe */
509 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
511 TRACE( "getting version from %s\n", debugstr_w(appversion
) );
512 got_win_ver
= parse_win_version( hkey
);
518 TRACE( "getting default version\n" );
519 got_win_ver
= parse_win_version( config_key
);
521 NtClose( config_key
);
526 static RTL_OSVERSIONINFOEXW registry_version
;
528 TRACE( "getting registry version\n" );
529 if (get_nt_registry_version( ®istry_version
) ||
530 get_win9x_registry_version( ®istry_version
))
531 current_version
= ®istry_version
;
535 NtCurrentTeb()->Peb
->OSMajorVersion
= current_version
->dwMajorVersion
;
536 NtCurrentTeb()->Peb
->OSMinorVersion
= current_version
->dwMinorVersion
;
537 NtCurrentTeb()->Peb
->OSBuildNumber
= current_version
->dwBuildNumber
;
538 NtCurrentTeb()->Peb
->OSPlatformId
= current_version
->dwPlatformId
;
540 TRACE( "got %d.%d platform %d build %x name %s service pack %d.%d product %d\n",
541 current_version
->dwMajorVersion
, current_version
->dwMinorVersion
,
542 current_version
->dwPlatformId
, current_version
->dwBuildNumber
,
543 debugstr_w(current_version
->szCSDVersion
),
544 current_version
->wServicePackMajor
, current_version
->wServicePackMinor
,
545 current_version
->wProductType
);
548 /***********************************************************************
549 * RtlGetProductInfo (NTDLL.@)
551 * Gives info about the current Windows product type, in a format compatible
552 * with the given Windows version
554 * Returns TRUE if the input is valid, FALSE otherwise
556 BOOLEAN WINAPI
RtlGetProductInfo(DWORD dwOSMajorVersion
, DWORD dwOSMinorVersion
, DWORD dwSpMajorVersion
,
557 DWORD dwSpMinorVersion
, PDWORD pdwReturnedProductType
)
559 TRACE("(%d, %d, %d, %d, %p)\n", dwOSMajorVersion
, dwOSMinorVersion
,
560 dwSpMajorVersion
, dwSpMinorVersion
, pdwReturnedProductType
);
562 if (!pdwReturnedProductType
)
565 if (dwOSMajorVersion
< 6)
567 *pdwReturnedProductType
= PRODUCT_UNDEFINED
;
571 if (current_version
->wProductType
== VER_NT_WORKSTATION
)
572 *pdwReturnedProductType
= PRODUCT_ULTIMATE_N
;
574 *pdwReturnedProductType
= PRODUCT_STANDARD_SERVER
;
579 /***********************************************************************
580 * RtlGetVersion (NTDLL.@)
582 NTSTATUS WINAPI
RtlGetVersion( RTL_OSVERSIONINFOEXW
*info
)
584 info
->dwMajorVersion
= current_version
->dwMajorVersion
;
585 info
->dwMinorVersion
= current_version
->dwMinorVersion
;
586 info
->dwBuildNumber
= current_version
->dwBuildNumber
;
587 info
->dwPlatformId
= current_version
->dwPlatformId
;
588 wcscpy( info
->szCSDVersion
, current_version
->szCSDVersion
);
589 if(info
->dwOSVersionInfoSize
== sizeof(RTL_OSVERSIONINFOEXW
))
591 info
->wServicePackMajor
= current_version
->wServicePackMajor
;
592 info
->wServicePackMinor
= current_version
->wServicePackMinor
;
593 info
->wSuiteMask
= current_version
->wSuiteMask
;
594 info
->wProductType
= current_version
->wProductType
;
596 return STATUS_SUCCESS
;
600 /******************************************************************************
601 * RtlGetNtVersionNumbers (NTDLL.@)
603 * Get the version numbers of the run time library.
606 * major [O] Destination for the Major version
607 * minor [O] Destination for the Minor version
608 * build [O] Destination for the Build version
614 * Introduced in Windows XP (NT5.1)
616 void WINAPI
RtlGetNtVersionNumbers( LPDWORD major
, LPDWORD minor
, LPDWORD build
)
618 if (major
) *major
= current_version
->dwMajorVersion
;
619 if (minor
) *minor
= current_version
->dwMinorVersion
;
620 /* FIXME: Does anybody know the real formula? */
621 if (build
) *build
= (0xF0000000 | current_version
->dwBuildNumber
);
625 /******************************************************************************
626 * RtlGetNtProductType (NTDLL.@)
628 BOOLEAN WINAPI
RtlGetNtProductType( LPDWORD type
)
630 if (type
) *type
= current_version
->wProductType
;
634 static inline UCHAR
version_update_condition(UCHAR
*last_condition
, UCHAR condition
)
636 switch (*last_condition
)
639 *last_condition
= condition
;
642 if (condition
>= VER_EQUAL
&& condition
<= VER_LESS_EQUAL
)
644 *last_condition
= condition
;
649 case VER_GREATER_EQUAL
:
650 if (condition
>= VER_EQUAL
&& condition
<= VER_GREATER_EQUAL
)
655 if (condition
== VER_EQUAL
|| (condition
>= VER_LESS
&& condition
<= VER_LESS_EQUAL
))
659 if (!condition
) *last_condition
|= 0x10;
660 return *last_condition
& 0xf;
663 static inline NTSTATUS
version_compare_values(ULONG left
, ULONG right
, UCHAR condition
)
667 if (left
!= right
) return STATUS_REVISION_MISMATCH
;
670 if (left
<= right
) return STATUS_REVISION_MISMATCH
;
672 case VER_GREATER_EQUAL
:
673 if (left
< right
) return STATUS_REVISION_MISMATCH
;
676 if (left
>= right
) return STATUS_REVISION_MISMATCH
;
679 if (left
> right
) return STATUS_REVISION_MISMATCH
;
682 return STATUS_REVISION_MISMATCH
;
684 return STATUS_SUCCESS
;
687 /******************************************************************************
688 * RtlVerifyVersionInfo (NTDLL.@)
690 NTSTATUS WINAPI
RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW
*info
,
691 DWORD dwTypeMask
, DWORDLONG dwlConditionMask
)
693 RTL_OSVERSIONINFOEXW ver
;
696 TRACE("(%p,0x%x,0x%s)\n", info
, dwTypeMask
, wine_dbgstr_longlong(dwlConditionMask
));
698 ver
.dwOSVersionInfoSize
= sizeof(ver
);
699 if ((status
= RtlGetVersion( &ver
)) != STATUS_SUCCESS
) return status
;
701 if(!(dwTypeMask
&& dwlConditionMask
)) return STATUS_INVALID_PARAMETER
;
703 if(dwTypeMask
& VER_PRODUCT_TYPE
)
705 status
= version_compare_values(ver
.wProductType
, info
->wProductType
, dwlConditionMask
>> 7*3 & 0x07);
706 if (status
!= STATUS_SUCCESS
)
709 if(dwTypeMask
& VER_SUITENAME
)
710 switch(dwlConditionMask
>> 6*3 & 0x07)
713 if((info
->wSuiteMask
& ver
.wSuiteMask
) != info
->wSuiteMask
)
714 return STATUS_REVISION_MISMATCH
;
717 if(!(info
->wSuiteMask
& ver
.wSuiteMask
) && info
->wSuiteMask
)
718 return STATUS_REVISION_MISMATCH
;
721 return STATUS_INVALID_PARAMETER
;
723 if(dwTypeMask
& VER_PLATFORMID
)
725 status
= version_compare_values(ver
.dwPlatformId
, info
->dwPlatformId
, dwlConditionMask
>> 3*3 & 0x07);
726 if (status
!= STATUS_SUCCESS
)
729 if(dwTypeMask
& VER_BUILDNUMBER
)
731 status
= version_compare_values(ver
.dwBuildNumber
, info
->dwBuildNumber
, dwlConditionMask
>> 2*3 & 0x07);
732 if (status
!= STATUS_SUCCESS
)
736 if(dwTypeMask
& (VER_MAJORVERSION
|VER_MINORVERSION
|VER_SERVICEPACKMAJOR
|VER_SERVICEPACKMINOR
))
738 unsigned char condition
, last_condition
= 0;
739 BOOLEAN do_next_check
= TRUE
;
741 if(dwTypeMask
& VER_MAJORVERSION
)
743 condition
= version_update_condition(&last_condition
, dwlConditionMask
>> 1*3 & 0x07);
744 status
= version_compare_values(ver
.dwMajorVersion
, info
->dwMajorVersion
, condition
);
745 do_next_check
= (ver
.dwMajorVersion
== info
->dwMajorVersion
) &&
746 ((condition
>= VER_EQUAL
) && (condition
<= VER_LESS_EQUAL
));
748 if((dwTypeMask
& VER_MINORVERSION
) && do_next_check
)
750 condition
= version_update_condition(&last_condition
, dwlConditionMask
>> 0*3 & 0x07);
751 status
= version_compare_values(ver
.dwMinorVersion
, info
->dwMinorVersion
, condition
);
752 do_next_check
= (ver
.dwMinorVersion
== info
->dwMinorVersion
) &&
753 ((condition
>= VER_EQUAL
) && (condition
<= VER_LESS_EQUAL
));
755 if((dwTypeMask
& VER_SERVICEPACKMAJOR
) && do_next_check
)
757 condition
= version_update_condition(&last_condition
, dwlConditionMask
>> 5*3 & 0x07);
758 status
= version_compare_values(ver
.wServicePackMajor
, info
->wServicePackMajor
, condition
);
759 do_next_check
= (ver
.wServicePackMajor
== info
->wServicePackMajor
) &&
760 ((condition
>= VER_EQUAL
) && (condition
<= VER_LESS_EQUAL
));
762 if((dwTypeMask
& VER_SERVICEPACKMINOR
) && do_next_check
)
764 condition
= version_update_condition(&last_condition
, dwlConditionMask
>> 4*3 & 0x07);
765 status
= version_compare_values(ver
.wServicePackMinor
, info
->wServicePackMinor
, condition
);
768 if (status
!= STATUS_SUCCESS
)
772 return STATUS_SUCCESS
;