2 * Windows and DOS version functions
4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998 Patrik Stridvall
7 * Copyright 1998 Andreas Mohr
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
25 #include "wine/port.h"
36 #include "wine/winbase16.h"
38 #include "wine/unicode.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
45 WIN20
, /* Windows 2.0 */
46 WIN30
, /* Windows 3.0 */
47 WIN31
, /* Windows 3.1 */
48 WIN95
, /* Windows 95 */
49 WIN98
, /* Windows 98 */
50 WINME
, /* Windows Me */
51 NT351
, /* Windows NT 3.51 */
52 NT40
, /* Windows NT 4.0 */
53 NT2K
, /* Windows 2000 */
54 WINXP
, /* Windows XP */
62 OSVERSIONINFOEXA getVersionEx
;
65 /* FIXME: compare values below with original and fix.
66 * An *excellent* win9x version page (ALL versions !)
67 * can be found at members.aol.com/axcel216/ver.htm */
68 static VERSION_DATA VersionData
[NB_WINDOWS_VERSIONS
] =
70 /* WIN20 FIXME: verify values */
72 MAKELONG( 0x0002, 0x0303 ), /* assume DOS 3.3 */
73 MAKELONG( 0x0002, 0x8000 ),
75 sizeof(OSVERSIONINFOA
), 2, 0, 0,
76 VER_PLATFORM_WIN32s
, "Win32s 1.3",
80 /* WIN30 FIXME: verify values */
82 MAKELONG( 0x0003, 0x0500 ), /* assume DOS 5.00 */
83 MAKELONG( 0x0003, 0x8000 ),
85 sizeof(OSVERSIONINFOA
), 3, 0, 0,
86 VER_PLATFORM_WIN32s
, "Win32s 1.3",
92 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
93 MAKELONG( 0x0a03, 0x8000 ),
95 sizeof(OSVERSIONINFOA
), 3, 10, 0,
96 VER_PLATFORM_WIN32s
, "Win32s 1.3",
105 /* Win95: 4, 0, 0x40003B6, ""
106 * Win95sp1: 4, 0, 0x40003B6, " A " (according to doc)
107 * Win95osr2: 4, 0, 0x4000457, " B " (according to doc)
108 * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
109 * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
110 * Win95a/b can be discerned via regkey SubVersionNumber
112 * http://support.microsoft.com/support/kb/articles/q158/2/38.asp
114 sizeof(OSVERSIONINFOA
), 4, 0, 0x40003B6,
115 VER_PLATFORM_WIN32_WINDOWS
, "",
119 /* WIN98 (second edition) */
124 /* Win98: 4, 10, 0x40A07CE, " " 4.10.1998
125 * Win98SE: 4, 10, 0x40A08AE, " A " 4.10.2222
127 sizeof(OSVERSIONINFOA
), 4, 10, 0x40A08AE,
128 VER_PLATFORM_WIN32_WINDOWS
, " A ",
137 sizeof(OSVERSIONINFOA
), 4, 90, 0x45A0BB8,
138 VER_PLATFORM_WIN32_WINDOWS
, " ",
147 sizeof(OSVERSIONINFOA
), 3, 51, 0x421,
148 VER_PLATFORM_WIN32_NT
, "Service Pack 2",
157 sizeof(OSVERSIONINFOA
), 4, 0, 0x565,
158 VER_PLATFORM_WIN32_NT
, "Service Pack 6",
159 6, 0, 0, VER_NT_WORKSTATION
, 0
167 sizeof(OSVERSIONINFOA
), 5, 0, 0x893,
168 VER_PLATFORM_WIN32_NT
, "Service Pack 2",
169 2, 0, 0, VER_NT_WORKSTATION
, 30 /* FIXME: Great, a reserved field with a value! */
174 0x05005F03, /* Assuming DOS 5 like the other NT */
177 sizeof(OSVERSIONINFOA
), 5, 1, 0xA28,
178 VER_PLATFORM_WIN32_NT
, "",
179 0, 0, 0, VER_NT_WORKSTATION
, 0 /* FIXME: Verify last 5 values */
184 static const char *WinVersionNames
[NB_WINDOWS_VERSIONS
] =
185 { /* no spaces in here ! */
194 "win2000,win2k,nt2k,nt2000",
198 /* if one of the following dlls is importing ntdll the windows
199 version autodetection switches wine to unicode (nt 3.51 or 4.0) */
200 static char * special_dlls
[] =
210 /* the current version has not been autodetected but forced via cmdline */
211 static BOOL versionForced
= FALSE
;
212 static WINDOWS_VERSION forcedWinVersion
= WIN31
; /* init value irrelevant */
214 /**********************************************************************
215 * VERSION_ParseWinVersion
217 static void VERSION_ParseWinVersion( const char *arg
)
220 const char *pCurr
, *p
;
221 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
223 pCurr
= WinVersionNames
[i
];
224 /* iterate through all winver aliases separated by comma */
226 p
= strchr(pCurr
, ',');
227 len
= p
? (int)p
- (int)pCurr
: strlen(pCurr
);
228 if ( (!strncmp( pCurr
, arg
, len
)) && (arg
[len
] == '\0') )
230 forcedWinVersion
= (WINDOWS_VERSION
)i
;
231 versionForced
= TRUE
;
237 MESSAGE("Invalid Windows version value '%s' specified in config file.\n", arg
);
238 MESSAGE("Valid versions are:" );
239 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
241 /* only list the first, "official" alias in case of aliases */
242 pCurr
= WinVersionNames
[i
];
243 p
= strchr(pCurr
, ',');
244 len
= (p
) ? (int)p
- (int)pCurr
: strlen(pCurr
);
246 MESSAGE(" '%.*s'%c", len
, pCurr
,
247 (i
== NB_WINDOWS_VERSIONS
- 1) ? '\n' : ',' );
253 /**********************************************************************
254 * VERSION_ParseDosVersion
256 static void VERSION_ParseDosVersion( const char *arg
)
259 if (sscanf( arg
, "%d.%d", &hi
, &lo
) == 2)
261 VersionData
[WIN31
].getVersion16
=
262 MAKELONG(LOWORD(VersionData
[WIN31
].getVersion16
),
267 MESSAGE("Wrong format for DOS version in config file. Use \"x.xx\"\n");
273 /**********************************************************************
274 * VERSION_ParseVersion
276 * Parse the contents of the Version key.
278 static void VERSION_ParseVersion( HKEY hkey
, BOOL
*got_win_ver
, BOOL
*got_dos_ver
)
280 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
281 static const WCHAR DosW
[] = {'D','O','S',0};
283 UNICODE_STRING valueW
;
284 char tmp
[64], buffer
[50];
285 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
290 RtlInitUnicodeString( &valueW
, WindowsW
);
291 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
293 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
,
294 (WCHAR
*)info
->Data
, info
->DataLength
);
296 VERSION_ParseWinVersion( buffer
);
297 TRACE( "got win version %s\n", WinVersionNames
[forcedWinVersion
] );
303 RtlInitUnicodeString( &valueW
, DosW
);
304 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
306 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
,
307 (WCHAR
*)info
->Data
, info
->DataLength
);
309 VERSION_ParseDosVersion( buffer
);
310 TRACE( "got dos version %lx\n", VersionData
[WIN31
].getVersion16
);
317 /**********************************************************************
320 static void VERSION_Init(void)
322 OBJECT_ATTRIBUTES attr
;
323 UNICODE_STRING nameW
;
324 HKEY hkey
, config_key
;
325 BOOL got_win_ver
= FALSE
, got_dos_ver
= FALSE
;
326 WCHAR buffer
[MAX_PATH
], appversion
[MAX_PATH
+20], *appname
, *p
;
327 static BOOL init_done
;
328 static const WCHAR configW
[] = {'M','a','c','h','i','n','e','\\',
329 'S','o','f','t','w','a','r','e','\\',
330 'W','i','n','e','\\',
331 'W','i','n','e','\\',
332 'C','o','n','f','i','g',0};
333 static const WCHAR appdefaultsW
[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
334 static const WCHAR versionW
[] = {'\\','V','e','r','s','i','o','n',0};
336 if (init_done
) return;
337 if (!GetModuleFileNameW( 0, buffer
, MAX_PATH
))
339 WARN( "could not get module file name\n" );
344 if ((p
= strrchrW( appname
, '/' ))) appname
= p
+ 1;
345 if ((p
= strrchrW( appname
, '\\' ))) appname
= p
+ 1;
347 attr
.Length
= sizeof(attr
);
348 attr
.RootDirectory
= 0;
349 attr
.ObjectName
= &nameW
;
351 attr
.SecurityDescriptor
= NULL
;
352 attr
.SecurityQualityOfService
= NULL
;
353 RtlInitUnicodeString( &nameW
, configW
);
355 if (NtOpenKey( &config_key
, KEY_ALL_ACCESS
, &attr
)) return;
356 attr
.RootDirectory
= config_key
;
358 /* open AppDefaults\\appname\\Version key */
360 strcpyW( appversion
, appdefaultsW
);
361 strcatW( appversion
, appname
);
362 strcatW( appversion
, versionW
);
363 RtlInitUnicodeString( &nameW
, appversion
);
365 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
367 VERSION_ParseVersion( hkey
, &got_win_ver
, &got_dos_ver
);
371 if (got_win_ver
&& got_dos_ver
) goto done
;
373 RtlInitUnicodeString( &nameW
, versionW
+ 1 );
374 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
376 VERSION_ParseVersion( hkey
, &got_win_ver
, &got_dos_ver
);
381 NtClose( config_key
);
385 /**********************************************************************
386 * VERSION_GetSystemDLLVersion
388 * This function tries to figure out if a given (native) dll comes from
389 * win95/98 or winnt. Since all values in the OptionalHeader are not a
390 * usable hint, we test if a dll imports the ntdll.
391 * This is at least working for all system dlls like comctl32, comdlg32 and
393 * If you have a better idea to figure this out...
395 static DWORD
VERSION_GetSystemDLLVersion( HMODULE hmod
)
398 IMAGE_IMPORT_DESCRIPTOR
*pe_imp
;
400 if ((pe_imp
= RtlImageDirectoryEntryToData( hmod
, TRUE
, IMAGE_DIRECTORY_ENTRY_IMPORT
, &size
)))
402 for ( ; pe_imp
->Name
; pe_imp
++)
404 char * name
= (char *)hmod
+ (unsigned int)pe_imp
->Name
;
407 if (!strncasecmp(name
, "ntdll", 5))
409 switch(RtlImageNtHeader(hmod
)->OptionalHeader
.MajorOperatingSystemVersion
) {
411 MESSAGE("WARNING: very old native DLL (NT 3.x) used, might cause instability.\n");
415 case 6: return WINXP
;
417 FIXME("Unknown DLL OS version, please report !!\n");
425 /**********************************************************************
426 * VERSION_GetLinkedDllVersion
428 * Some version data (not reliable!):
429 * linker/OS/image/subsys
431 * x.xx/1.00/0.00/3.10 Win32s (any version ?)
432 * 2.39/1.00/0.00/3.10 Win32s freecell.exe (any version)
433 * 2.50/1.00/4.00/4.00 Win32s 1.30 winhlp32.exe
434 * 2.60/3.51/3.51/3.51 NT351SP5 system dlls
435 * 2.60/3.51/3.51/4.00 NT351SP5 comctl32 dll
436 * 2.xx/1.00/0.00/4.00 Win95 system files
437 * x.xx/4.00/0.00/4.00 Win95 most applications
438 * 3.10/4.00/0.00/4.00 Win98 notepad
439 * x.xx/5.00/5.00/4.00 Win98 system dlls (e.g. comctl32.dll)
440 * x.xx/4.00/4.00/4.00 NT 4 most apps
441 * 5.12/5.00/5.00/4.00 NT4+IE5 comctl32.dll
442 * 5.12/5.00/5.00/4.00 Win98 calc
443 * x.xx/5.00/5.00/4.00 win95/win98/NT4 IE5 files
445 static DWORD
VERSION_GetLinkedDllVersion(void)
448 DWORD WinVersion
= NB_WINDOWS_VERSIONS
;
449 PIMAGE_OPTIONAL_HEADER ophd
;
450 IMAGE_NT_HEADERS
*nt
;
452 /* First check the native dlls provided. These have to be
453 from one windows version */
454 for ( wm
= MODULE_modref_list
; wm
; wm
=wm
->next
)
456 nt
= RtlImageNtHeader(wm
->module
);
457 ophd
= &nt
->OptionalHeader
;
459 TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
461 ophd
->MajorLinkerVersion
, ophd
->MinorLinkerVersion
,
462 ophd
->MajorOperatingSystemVersion
, ophd
->MinorOperatingSystemVersion
,
463 ophd
->MajorImageVersion
, ophd
->MinorImageVersion
,
464 ophd
->MajorSubsystemVersion
, ophd
->MinorSubsystemVersion
);
466 /* test if it is an external (native) dll */
467 if (!(wm
->flags
& WINE_MODREF_INTERNAL
))
470 for (i
= 0; special_dlls
[i
]; i
++)
472 /* test if it is a special dll */
473 if (!strcasecmp(wm
->modname
, special_dlls
[i
]))
475 DWORD DllVersion
= VERSION_GetSystemDLLVersion(wm
->module
);
476 if (WinVersion
== NB_WINDOWS_VERSIONS
)
477 WinVersion
= DllVersion
;
479 if (WinVersion
!= DllVersion
) {
480 ERR("You mixed system DLLs from different windows versions! Expect a crash! (%s: expected version '%s', but is '%s')\n",
482 VersionData
[WinVersion
].getVersionEx
.szCSDVersion
,
483 VersionData
[DllVersion
].getVersionEx
.szCSDVersion
);
484 return WIN20
; /* this may let the exe exiting */
493 if(WinVersion
!= NB_WINDOWS_VERSIONS
) return WinVersion
;
495 /* we are using no external system dlls, look at the exe */
496 nt
= RtlImageNtHeader(GetModuleHandleA(NULL
));
497 ophd
= &nt
->OptionalHeader
;
499 TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
500 ophd
->MajorLinkerVersion
, ophd
->MinorLinkerVersion
,
501 ophd
->MajorOperatingSystemVersion
, ophd
->MinorOperatingSystemVersion
,
502 ophd
->MajorImageVersion
, ophd
->MinorImageVersion
,
503 ophd
->MajorSubsystemVersion
, ophd
->MinorSubsystemVersion
);
505 /* special nt 3.51 */
506 if (3 == ophd
->MajorOperatingSystemVersion
&& 51 == ophd
->MinorOperatingSystemVersion
)
511 /* the MajorSubsystemVersion is the only usable sign */
512 if (ophd
->MajorSubsystemVersion
< 4)
514 if ( ophd
->MajorOperatingSystemVersion
== 1
515 && ophd
->MinorOperatingSystemVersion
== 0)
517 return WIN31
; /* win32s */
520 if (ophd
->Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_CUI
)
521 return NT351
; /* FIXME: NT 3.1, not tested */
529 /**********************************************************************
533 * Don't call this function too early during the Wine init,
534 * as pdb->exe_modref (required by VERSION_GetImageVersion()) might still
535 * be NULL in such cases, which causes the winver to ALWAYS be detected
537 * And as we cache the winver once it has been determined, this is bad.
538 * This can happen much easier than you might think, as this function
539 * is called by EVERY GetVersion*() API !
542 static WINDOWS_VERSION
VERSION_GetVersion(void)
544 static WORD winver
= 0xffff;
546 if (winver
== 0xffff) /* to be determined */
548 WINDOWS_VERSION retver
;
551 if (versionForced
) /* user has overridden any sensible checks */
552 winver
= forcedWinVersion
;
555 retver
= VERSION_GetLinkedDllVersion();
557 /* cache determined value, but do not store in case of WIN31 */
558 if (retver
!= WIN31
) winver
= retver
;
568 /***********************************************************************
569 * GetVersion (KERNEL.3)
571 LONG WINAPI
GetVersion16(void)
573 WINDOWS_VERSION ver
= VERSION_GetVersion();
574 return VersionData
[ver
].getVersion16
;
578 /***********************************************************************
579 * GetVersion (KERNEL32.@)
581 LONG WINAPI
GetVersion(void)
583 WINDOWS_VERSION ver
= VERSION_GetVersion();
584 return VersionData
[ver
].getVersion32
;
588 /***********************************************************************
589 * GetVersionEx (KERNEL.149)
591 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
593 WINDOWS_VERSION ver
= VERSION_GetVersion();
594 if (v
->dwOSVersionInfoSize
< sizeof(OSVERSIONINFO16
))
596 WARN("wrong OSVERSIONINFO size from app\n");
597 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
600 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
601 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
602 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
603 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
604 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
609 /***********************************************************************
610 * GetVersionExA (KERNEL32.@)
612 BOOL WINAPI
GetVersionExA(OSVERSIONINFOA
*v
)
614 WINDOWS_VERSION ver
= VERSION_GetVersion();
615 LPOSVERSIONINFOEXA vex
;
617 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOA
) &&
618 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXA
))
620 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
621 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOA
),
622 sizeof(OSVERSIONINFOEXA
));
623 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
626 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
627 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
628 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
629 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
630 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
631 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXA
)) {
632 vex
= (LPOSVERSIONINFOEXA
) v
;
633 vex
->wServicePackMajor
= VersionData
[ver
].getVersionEx
.wServicePackMajor
;
634 vex
->wServicePackMinor
= VersionData
[ver
].getVersionEx
.wServicePackMinor
;
635 vex
->wSuiteMask
= VersionData
[ver
].getVersionEx
.wSuiteMask
;
636 vex
->wProductType
= VersionData
[ver
].getVersionEx
.wProductType
;
642 /***********************************************************************
643 * GetVersionExW (KERNEL32.@)
645 BOOL WINAPI
GetVersionExW(OSVERSIONINFOW
*v
)
647 WINDOWS_VERSION ver
= VERSION_GetVersion();
648 LPOSVERSIONINFOEXW vex
;
650 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOW
) &&
651 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXW
))
653 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
654 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOW
),
655 sizeof(OSVERSIONINFOEXW
));
656 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
659 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
660 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
661 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
662 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
663 MultiByteToWideChar( CP_ACP
, 0, VersionData
[ver
].getVersionEx
.szCSDVersion
, -1,
664 v
->szCSDVersion
, sizeof(v
->szCSDVersion
)/sizeof(WCHAR
) );
665 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXW
)) {
666 vex
= (LPOSVERSIONINFOEXW
) v
;
667 vex
->wServicePackMajor
= VersionData
[ver
].getVersionEx
.wServicePackMajor
;
668 vex
->wServicePackMinor
= VersionData
[ver
].getVersionEx
.wServicePackMinor
;
669 vex
->wSuiteMask
= VersionData
[ver
].getVersionEx
.wSuiteMask
;
670 vex
->wProductType
= VersionData
[ver
].getVersionEx
.wProductType
;
676 /******************************************************************************
677 * VerifyVersionInfoA (KERNEL32.@)
679 BOOL WINAPI
VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo
, DWORD dwTypeMask
,
680 DWORDLONG dwlConditionMask
)
682 OSVERSIONINFOEXW verW
;
684 verW
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
685 verW
.dwMajorVersion
= lpVersionInfo
->dwMajorVersion
;
686 verW
.dwMinorVersion
= lpVersionInfo
->dwMinorVersion
;
687 verW
.dwBuildNumber
= lpVersionInfo
->dwBuildNumber
;
688 verW
.dwPlatformId
= lpVersionInfo
->dwPlatformId
;
689 verW
.wServicePackMajor
= lpVersionInfo
->wServicePackMajor
;
690 verW
.wServicePackMinor
= lpVersionInfo
->wServicePackMinor
;
691 verW
.wSuiteMask
= lpVersionInfo
->wSuiteMask
;
692 verW
.wProductType
= lpVersionInfo
->wProductType
;
693 verW
.wReserved
= lpVersionInfo
->wReserved
;
695 return VerifyVersionInfoW(&verW
, dwTypeMask
, dwlConditionMask
);
699 /******************************************************************************
700 * VerifyVersionInfoW (KERNEL32.@)
702 BOOL WINAPI
VerifyVersionInfoW( LPOSVERSIONINFOEXW lpVersionInfo
, DWORD dwTypeMask
,
703 DWORDLONG dwlConditionMask
)
705 OSVERSIONINFOEXW ver
;
708 FIXME("(%p,%lu,%llx): Not all cases correctly implemented yet\n", lpVersionInfo
, dwTypeMask
, dwlConditionMask
);
710 - Check the following special case on Windows (various versions):
711 o lp->wSuiteMask == 0 and ver.wSuiteMask != 0 and VER_AND/VER_OR
712 o lp->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)
713 - MSDN talks about some tests being impossible. Check what really happens.
716 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
717 if(!GetVersionExW((LPOSVERSIONINFOW
) &ver
))
722 if(!(dwTypeMask
&& dwlConditionMask
)) {
724 SetLastError(ERROR_BAD_ARGUMENTS
);
727 if(dwTypeMask
& VER_PRODUCT_TYPE
)
728 switch(dwlConditionMask
>> 7*3 & 0x07) {
730 if(ver
.wProductType
!= lpVersionInfo
->wProductType
)
734 if(ver
.wProductType
<= lpVersionInfo
->wProductType
)
737 case VER_GREATER_EQUAL
:
738 if(ver
.wProductType
< lpVersionInfo
->wProductType
)
742 if(ver
.wProductType
>= lpVersionInfo
->wProductType
)
746 if(ver
.wProductType
> lpVersionInfo
->wProductType
)
751 SetLastError(ERROR_BAD_ARGUMENTS
);
754 if(dwTypeMask
& VER_SUITENAME
&& res
)
755 switch(dwlConditionMask
>> 6*3 & 0x07) {
757 if((lpVersionInfo
->wSuiteMask
& ver
.wSuiteMask
) != lpVersionInfo
->wSuiteMask
)
761 if(!(lpVersionInfo
->wSuiteMask
& ver
.wSuiteMask
) && lpVersionInfo
->wSuiteMask
)
766 SetLastError(ERROR_BAD_ARGUMENTS
);
769 if(dwTypeMask
& VER_PLATFORMID
&& res
)
770 switch(dwlConditionMask
>> 3*3 & 0x07) {
772 if(ver
.dwPlatformId
!= lpVersionInfo
->dwPlatformId
)
776 if(ver
.dwPlatformId
<= lpVersionInfo
->dwPlatformId
)
779 case VER_GREATER_EQUAL
:
780 if(ver
.dwPlatformId
< lpVersionInfo
->dwPlatformId
)
784 if(ver
.dwPlatformId
>= lpVersionInfo
->dwPlatformId
)
788 if(ver
.dwPlatformId
> lpVersionInfo
->dwPlatformId
)
793 SetLastError(ERROR_BAD_ARGUMENTS
);
796 if(dwTypeMask
& VER_BUILDNUMBER
&& res
)
797 switch(dwlConditionMask
>> 2*3 & 0x07) {
799 if(ver
.dwBuildNumber
!= lpVersionInfo
->dwBuildNumber
)
803 if(ver
.dwBuildNumber
<= lpVersionInfo
->dwBuildNumber
)
806 case VER_GREATER_EQUAL
:
807 if(ver
.dwBuildNumber
< lpVersionInfo
->dwBuildNumber
)
811 if(ver
.dwBuildNumber
>= lpVersionInfo
->dwBuildNumber
)
815 if(ver
.dwBuildNumber
> lpVersionInfo
->dwBuildNumber
)
820 SetLastError(ERROR_BAD_ARGUMENTS
);
823 if(dwTypeMask
& VER_MAJORVERSION
&& res
)
824 switch(dwlConditionMask
>> 1*3 & 0x07) {
826 if(ver
.dwMajorVersion
!= lpVersionInfo
->dwMajorVersion
)
830 if(ver
.dwMajorVersion
<= lpVersionInfo
->dwMajorVersion
)
833 case VER_GREATER_EQUAL
:
834 if(ver
.dwMajorVersion
< lpVersionInfo
->dwMajorVersion
)
838 if(ver
.dwMajorVersion
>= lpVersionInfo
->dwMajorVersion
)
842 if(ver
.dwMajorVersion
> lpVersionInfo
->dwMajorVersion
)
847 SetLastError(ERROR_BAD_ARGUMENTS
);
850 if(dwTypeMask
& VER_MINORVERSION
&& res
)
851 switch(dwlConditionMask
>> 0*3 & 0x07) {
853 if(ver
.dwMinorVersion
!= lpVersionInfo
->dwMinorVersion
)
857 if(ver
.dwMinorVersion
<= lpVersionInfo
->dwMinorVersion
)
860 case VER_GREATER_EQUAL
:
861 if(ver
.dwMinorVersion
< lpVersionInfo
->dwMinorVersion
)
865 if(ver
.dwMinorVersion
>= lpVersionInfo
->dwMinorVersion
)
869 if(ver
.dwMinorVersion
> lpVersionInfo
->dwMinorVersion
)
874 SetLastError(ERROR_BAD_ARGUMENTS
);
877 if(dwTypeMask
& VER_SERVICEPACKMAJOR
&& res
)
878 switch(dwlConditionMask
>> 5*3 & 0x07) {
880 if(ver
.wServicePackMajor
!= lpVersionInfo
->wServicePackMajor
)
884 if(ver
.wServicePackMajor
<= lpVersionInfo
->wServicePackMajor
)
887 case VER_GREATER_EQUAL
:
888 if(ver
.wServicePackMajor
< lpVersionInfo
->wServicePackMajor
)
892 if(ver
.wServicePackMajor
>= lpVersionInfo
->wServicePackMajor
)
896 if(ver
.wServicePackMajor
> lpVersionInfo
->wServicePackMajor
)
901 SetLastError(ERROR_BAD_ARGUMENTS
);
904 if(dwTypeMask
& VER_SERVICEPACKMINOR
&& res
)
905 switch(dwlConditionMask
>> 4*3 & 0x07) {
907 if(ver
.wServicePackMinor
!= lpVersionInfo
->wServicePackMinor
)
911 if(ver
.wServicePackMinor
<= lpVersionInfo
->wServicePackMinor
)
914 case VER_GREATER_EQUAL
:
915 if(ver
.wServicePackMinor
< lpVersionInfo
->wServicePackMinor
)
919 if(ver
.wServicePackMinor
>= lpVersionInfo
->wServicePackMinor
)
923 if(ver
.wServicePackMinor
> lpVersionInfo
->wServicePackMinor
)
928 SetLastError(ERROR_BAD_ARGUMENTS
);
932 if(!(res
|| error_set
))
933 SetLastError(ERROR_OLD_WIN_VERSION
);
938 /***********************************************************************
939 * GetWinFlags (KERNEL.132)
941 DWORD WINAPI
GetWinFlags16(void)
943 static const long cpuflags
[5] =
944 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
951 /* There doesn't seem to be any Pentium flag. */
952 result
= cpuflags
[min(si
.wProcessorLevel
, 4)] | WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
953 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
954 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
956 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
957 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
963 /* Not used at this time. This is here for documentation only */
965 /* WINDEBUGINFO flags values */
966 #define WDI_OPTIONS 0x0001
967 #define WDI_FILTER 0x0002
968 #define WDI_ALLOCBREAK 0x0004
970 /* dwOptions values */
971 #define DBO_CHECKHEAP 0x0001
972 #define DBO_BUFFERFILL 0x0004
973 #define DBO_DISABLEGPTRAPPING 0x0010
974 #define DBO_CHECKFREE 0x0020
976 #define DBO_SILENT 0x8000
978 #define DBO_TRACEBREAK 0x2000
979 #define DBO_WARNINGBREAK 0x1000
980 #define DBO_NOERRORBREAK 0x0800
981 #define DBO_NOFATALBREAK 0x0400
982 #define DBO_INT3BREAK 0x0100
984 /* DebugOutput flags values */
985 #define DBF_TRACE 0x0000
986 #define DBF_WARNING 0x4000
987 #define DBF_ERROR 0x8000
988 #define DBF_FATAL 0xc000
990 /* dwFilter values */
991 #define DBF_KERNEL 0x1000
992 #define DBF_KRN_MEMMAN 0x0001
993 #define DBF_KRN_LOADMODULE 0x0002
994 #define DBF_KRN_SEGMENTLOAD 0x0004
995 #define DBF_USER 0x0800
996 #define DBF_GDI 0x0400
997 #define DBF_MMSYSTEM 0x0040
998 #define DBF_PENWIN 0x0020
999 #define DBF_APPLICATION 0x0008
1000 #define DBF_DRIVER 0x0010
1002 #endif /* NOLOGERROR */
1005 /***********************************************************************
1006 * GetWinDebugInfo (KERNEL.355)
1008 BOOL16 WINAPI
GetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
, UINT16 flags
)
1010 FIXME("(%8lx,%d): stub returning 0\n",
1011 (unsigned long)lpwdi
, flags
);
1012 /* 0 means not in debugging mode/version */
1013 /* Can this type of debugging be used in wine ? */
1014 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1019 /***********************************************************************
1020 * SetWinDebugInfo (KERNEL.356)
1022 BOOL16 WINAPI
SetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
)
1024 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
1025 /* 0 means not in debugging mode/version */
1026 /* Can this type of debugging be used in wine ? */
1027 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1032 /***********************************************************************
1036 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
1038 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
1040 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
1043 /***********************************************************************
1044 * DiagQuery (KERNEL.339)
1046 * returns TRUE if Win called with "/b" (bootlog.txt)
1048 BOOL16 WINAPI
DiagQuery16(void)
1050 /* perhaps implement a Wine "/b" command line flag sometime ? */
1054 /***********************************************************************
1055 * DiagOutput (KERNEL.340)
1057 * writes a debug string into <windir>\bootlog.txt
1059 void WINAPI
DiagOutput16(LPCSTR str
)
1062 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str
));