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"
40 #include "ntdll_misc.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
46 WIN20
, /* Windows 2.0 */
47 WIN30
, /* Windows 3.0 */
48 WIN31
, /* Windows 3.1 */
49 WIN95
, /* Windows 95 */
50 WIN98
, /* Windows 98 */
51 WINME
, /* Windows Me */
52 NT351
, /* Windows NT 3.51 */
53 NT40
, /* Windows NT 4.0 */
54 NT2K
, /* Windows 2000 */
55 WINXP
, /* Windows XP */
63 OSVERSIONINFOEXA getVersionEx
;
66 /* FIXME: compare values below with original and fix.
67 * An *excellent* win9x version page (ALL versions !)
68 * can be found at members.aol.com/axcel216/ver.htm */
69 static VERSION_DATA VersionData
[NB_WINDOWS_VERSIONS
] =
71 /* WIN20 FIXME: verify values */
73 MAKELONG( 0x0002, 0x0303 ), /* assume DOS 3.3 */
74 MAKELONG( 0x0002, 0x8000 ),
76 sizeof(OSVERSIONINFOA
), 2, 0, 0,
77 VER_PLATFORM_WIN32s
, "Win32s 1.3",
81 /* WIN30 FIXME: verify values */
83 MAKELONG( 0x0003, 0x0500 ), /* assume DOS 5.00 */
84 MAKELONG( 0x0003, 0x8000 ),
86 sizeof(OSVERSIONINFOA
), 3, 0, 0,
87 VER_PLATFORM_WIN32s
, "Win32s 1.3",
93 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
94 MAKELONG( 0x0a03, 0x8000 ),
96 sizeof(OSVERSIONINFOA
), 3, 10, 0,
97 VER_PLATFORM_WIN32s
, "Win32s 1.3",
106 /* Win95: 4, 0, 0x40003B6, ""
107 * Win95sp1: 4, 0, 0x40003B6, " A " (according to doc)
108 * Win95osr2: 4, 0, 0x4000457, " B " (according to doc)
109 * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
110 * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
111 * Win95a/b can be discerned via regkey SubVersionNumber
113 * http://support.microsoft.com/support/kb/articles/q158/2/38.asp
115 sizeof(OSVERSIONINFOA
), 4, 0, 0x40003B6,
116 VER_PLATFORM_WIN32_WINDOWS
, "",
120 /* WIN98 (second edition) */
125 /* Win98: 4, 10, 0x40A07CE, " " 4.10.1998
126 * Win98SE: 4, 10, 0x40A08AE, " A " 4.10.2222
128 sizeof(OSVERSIONINFOA
), 4, 10, 0x40A08AE,
129 VER_PLATFORM_WIN32_WINDOWS
, " A ",
138 sizeof(OSVERSIONINFOA
), 4, 90, 0x45A0BB8,
139 VER_PLATFORM_WIN32_WINDOWS
, " ",
148 sizeof(OSVERSIONINFOA
), 3, 51, 0x421,
149 VER_PLATFORM_WIN32_NT
, "Service Pack 2",
158 sizeof(OSVERSIONINFOA
), 4, 0, 0x565,
159 VER_PLATFORM_WIN32_NT
, "Service Pack 6",
160 6, 0, 0, VER_NT_WORKSTATION
, 0
168 sizeof(OSVERSIONINFOA
), 5, 0, 0x893,
169 VER_PLATFORM_WIN32_NT
, "Service Pack 2",
170 2, 0, 0, VER_NT_WORKSTATION
, 30 /* FIXME: Great, a reserved field with a value! */
175 0x05005F03, /* Assuming DOS 5 like the other NT */
178 sizeof(OSVERSIONINFOA
), 5, 1, 0xA28,
179 VER_PLATFORM_WIN32_NT
, "",
180 0, 0, 0, VER_NT_WORKSTATION
, 0 /* FIXME: Verify last 5 values */
185 static const char *WinVersionNames
[NB_WINDOWS_VERSIONS
] =
186 { /* no spaces in here ! */
195 "win2000,win2k,nt2k,nt2000",
199 /* if one of the following dlls is importing ntdll the windows
200 version autodetection switches wine to unicode (nt 3.51 or 4.0) */
201 static char * special_dlls
[] =
211 /* the current version has not been autodetected but forced via cmdline */
212 static BOOL versionForced
= FALSE
;
213 static WINDOWS_VERSION forcedWinVersion
= WIN31
; /* init value irrelevant */
215 /**********************************************************************
216 * VERSION_ParseWinVersion
218 static void VERSION_ParseWinVersion( const char *arg
)
221 const char *pCurr
, *p
;
222 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
224 pCurr
= WinVersionNames
[i
];
225 /* iterate through all winver aliases separated by comma */
227 p
= strchr(pCurr
, ',');
228 len
= p
? (int)p
- (int)pCurr
: strlen(pCurr
);
229 if ( (!strncmp( pCurr
, arg
, len
)) && (arg
[len
] == '\0') )
231 forcedWinVersion
= (WINDOWS_VERSION
)i
;
232 versionForced
= TRUE
;
238 MESSAGE("Invalid Windows version value '%s' specified in config file.\n", arg
);
239 MESSAGE("Valid versions are:" );
240 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
242 /* only list the first, "official" alias in case of aliases */
243 pCurr
= WinVersionNames
[i
];
244 p
= strchr(pCurr
, ',');
245 len
= (p
) ? (int)p
- (int)pCurr
: strlen(pCurr
);
247 MESSAGE(" '%.*s'%c", len
, pCurr
,
248 (i
== NB_WINDOWS_VERSIONS
- 1) ? '\n' : ',' );
254 /**********************************************************************
255 * VERSION_ParseDosVersion
257 static void VERSION_ParseDosVersion( const char *arg
)
260 if (sscanf( arg
, "%d.%d", &hi
, &lo
) == 2)
262 VersionData
[WIN31
].getVersion16
=
263 MAKELONG(LOWORD(VersionData
[WIN31
].getVersion16
),
268 MESSAGE("Wrong format for DOS version in config file. Use \"x.xx\"\n");
274 /**********************************************************************
275 * VERSION_ParseVersion
277 * Parse the contents of the Version key.
279 static void VERSION_ParseVersion( HKEY hkey
, BOOL
*got_win_ver
, BOOL
*got_dos_ver
)
281 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
282 static const WCHAR DosW
[] = {'D','O','S',0};
284 UNICODE_STRING valueW
;
285 char tmp
[64], buffer
[50];
286 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
291 RtlInitUnicodeString( &valueW
, WindowsW
);
292 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
294 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
,
295 (WCHAR
*)info
->Data
, info
->DataLength
);
297 VERSION_ParseWinVersion( buffer
);
298 TRACE( "got win version %s\n", WinVersionNames
[forcedWinVersion
] );
304 RtlInitUnicodeString( &valueW
, DosW
);
305 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
307 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
,
308 (WCHAR
*)info
->Data
, info
->DataLength
);
310 VERSION_ParseDosVersion( buffer
);
311 TRACE( "got dos version %lx\n", VersionData
[WIN31
].getVersion16
);
318 /**********************************************************************
321 static void VERSION_Init(void)
323 OBJECT_ATTRIBUTES attr
;
324 UNICODE_STRING nameW
;
325 HKEY hkey
, config_key
;
326 BOOL got_win_ver
= FALSE
, got_dos_ver
= FALSE
;
327 WCHAR buffer
[MAX_PATH
], appversion
[MAX_PATH
+20], *appname
, *p
;
328 static BOOL init_done
;
329 static const WCHAR configW
[] = {'M','a','c','h','i','n','e','\\',
330 'S','o','f','t','w','a','r','e','\\',
331 'W','i','n','e','\\',
332 'W','i','n','e','\\',
333 'C','o','n','f','i','g',0};
334 static const WCHAR appdefaultsW
[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
335 static const WCHAR versionW
[] = {'\\','V','e','r','s','i','o','n',0};
337 if (init_done
) return;
338 if (!GetModuleFileNameW( 0, buffer
, MAX_PATH
))
340 WARN( "could not get module file name\n" );
345 if ((p
= strrchrW( appname
, '/' ))) appname
= p
+ 1;
346 if ((p
= strrchrW( appname
, '\\' ))) appname
= p
+ 1;
348 attr
.Length
= sizeof(attr
);
349 attr
.RootDirectory
= 0;
350 attr
.ObjectName
= &nameW
;
352 attr
.SecurityDescriptor
= NULL
;
353 attr
.SecurityQualityOfService
= NULL
;
354 RtlInitUnicodeString( &nameW
, configW
);
356 if (NtOpenKey( &config_key
, KEY_ALL_ACCESS
, &attr
)) return;
357 attr
.RootDirectory
= config_key
;
359 /* open AppDefaults\\appname\\Version key */
361 strcpyW( appversion
, appdefaultsW
);
362 strcatW( appversion
, appname
);
363 strcatW( appversion
, versionW
);
364 RtlInitUnicodeString( &nameW
, appversion
);
366 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
368 VERSION_ParseVersion( hkey
, &got_win_ver
, &got_dos_ver
);
372 if (got_win_ver
&& got_dos_ver
) goto done
;
374 RtlInitUnicodeString( &nameW
, versionW
+ 1 );
375 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
377 VERSION_ParseVersion( hkey
, &got_win_ver
, &got_dos_ver
);
382 NtClose( config_key
);
386 /**********************************************************************
387 * VERSION_GetSystemDLLVersion
389 * This function tries to figure out if a given (native) dll comes from
390 * win95/98 or winnt. Since all values in the OptionalHeader are not a
391 * usable hint, we test if a dll imports the ntdll.
392 * This is at least working for all system dlls like comctl32, comdlg32 and
394 * If you have a better idea to figure this out...
396 static DWORD
VERSION_GetSystemDLLVersion( HMODULE hmod
)
399 IMAGE_IMPORT_DESCRIPTOR
*pe_imp
;
401 if ((pe_imp
= RtlImageDirectoryEntryToData( hmod
, TRUE
, IMAGE_DIRECTORY_ENTRY_IMPORT
, &size
)))
403 for ( ; pe_imp
->Name
; pe_imp
++)
405 char * name
= (char *)hmod
+ (unsigned int)pe_imp
->Name
;
408 if (!strncasecmp(name
, "ntdll", 5))
410 switch(RtlImageNtHeader(hmod
)->OptionalHeader
.MajorOperatingSystemVersion
) {
412 MESSAGE("WARNING: very old native DLL (NT 3.x) used, might cause instability.\n");
416 case 6: return WINXP
;
418 FIXME("Unknown DLL OS version, please report !!\n");
426 /**********************************************************************
427 * VERSION_GetLinkedDllVersion
429 * Some version data (not reliable!):
430 * linker/OS/image/subsys
432 * x.xx/1.00/0.00/3.10 Win32s (any version ?)
433 * 2.39/1.00/0.00/3.10 Win32s freecell.exe (any version)
434 * 2.50/1.00/4.00/4.00 Win32s 1.30 winhlp32.exe
435 * 2.60/3.51/3.51/3.51 NT351SP5 system dlls
436 * 2.60/3.51/3.51/4.00 NT351SP5 comctl32 dll
437 * 2.xx/1.00/0.00/4.00 Win95 system files
438 * x.xx/4.00/0.00/4.00 Win95 most applications
439 * 3.10/4.00/0.00/4.00 Win98 notepad
440 * x.xx/5.00/5.00/4.00 Win98 system dlls (e.g. comctl32.dll)
441 * x.xx/4.00/4.00/4.00 NT 4 most apps
442 * 5.12/5.00/5.00/4.00 NT4+IE5 comctl32.dll
443 * 5.12/5.00/5.00/4.00 Win98 calc
444 * x.xx/5.00/5.00/4.00 win95/win98/NT4 IE5 files
446 static DWORD
VERSION_GetLinkedDllVersion(void)
448 DWORD WinVersion
= NB_WINDOWS_VERSIONS
;
449 PIMAGE_OPTIONAL_HEADER ophd
;
450 IMAGE_NT_HEADERS
*nt
;
451 ULONG count
, required
;
452 SYSTEM_MODULE_INFORMATION
* smi
;
454 /* First check the native dlls provided. These have to be
455 from one windows version */
456 smi
= (SYSTEM_MODULE_INFORMATION
*)&count
;
457 LdrQueryProcessModuleInformation(smi
, sizeof(count
), &required
);
458 smi
= RtlAllocateHeap(ntdll_get_process_heap(), 0, required
);
461 if (LdrQueryProcessModuleInformation(smi
, required
, NULL
) == STATUS_SUCCESS
)
464 for (k
= 0; k
< smi
->ModulesCount
; k
++)
466 nt
= RtlImageNtHeader(smi
->Modules
[k
].ImageBaseAddress
);
467 ophd
= &nt
->OptionalHeader
;
469 TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
470 &smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
],
471 ophd
->MajorLinkerVersion
, ophd
->MinorLinkerVersion
,
472 ophd
->MajorOperatingSystemVersion
, ophd
->MinorOperatingSystemVersion
,
473 ophd
->MajorImageVersion
, ophd
->MinorImageVersion
,
474 ophd
->MajorSubsystemVersion
, ophd
->MinorSubsystemVersion
);
477 /* test if it is an external (native) dll */
478 if (!(smi
->Modules
[k
].Flags
& LDR_WINE_INTERNAL
))
481 for (i
= 0; special_dlls
[i
]; i
++)
483 /* test if it is a special dll */
484 if (!strcasecmp(&smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
], special_dlls
[i
]))
486 DWORD DllVersion
= VERSION_GetSystemDLLVersion(smi
->Modules
[k
].ImageBaseAddress
);
487 if (WinVersion
== NB_WINDOWS_VERSIONS
)
488 WinVersion
= DllVersion
;
491 if (WinVersion
!= DllVersion
) {
492 ERR("You mixed system DLLs from different windows versions! Expect a crash! (%s: expected version '%s', but is '%s')\n",
493 &smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
],
494 VersionData
[WinVersion
].getVersionEx
.szCSDVersion
,
495 VersionData
[DllVersion
].getVersionEx
.szCSDVersion
);
496 return WIN20
; /* this may let the exe exiting */
504 RtlFreeHeap(ntdll_get_process_heap(), 0, smi
);
507 if(WinVersion
!= NB_WINDOWS_VERSIONS
) return WinVersion
;
509 /* we are using no external system dlls, look at the exe */
510 nt
= RtlImageNtHeader(GetModuleHandleA(NULL
));
511 ophd
= &nt
->OptionalHeader
;
513 TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
514 ophd
->MajorLinkerVersion
, ophd
->MinorLinkerVersion
,
515 ophd
->MajorOperatingSystemVersion
, ophd
->MinorOperatingSystemVersion
,
516 ophd
->MajorImageVersion
, ophd
->MinorImageVersion
,
517 ophd
->MajorSubsystemVersion
, ophd
->MinorSubsystemVersion
);
519 /* special nt 3.51 */
520 if (3 == ophd
->MajorOperatingSystemVersion
&& 51 == ophd
->MinorOperatingSystemVersion
)
525 /* the MajorSubsystemVersion is the only usable sign */
526 if (ophd
->MajorSubsystemVersion
< 4)
528 if ( ophd
->MajorOperatingSystemVersion
== 1
529 && ophd
->MinorOperatingSystemVersion
== 0)
531 return WIN31
; /* win32s */
534 if (ophd
->Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_CUI
)
535 return NT351
; /* FIXME: NT 3.1, not tested */
543 /**********************************************************************
547 * Don't call this function too early during the Wine init,
548 * as pdb->exe_modref (required by VERSION_GetImageVersion()) might still
549 * be NULL in such cases, which causes the winver to ALWAYS be detected
551 * And as we cache the winver once it has been determined, this is bad.
552 * This can happen much easier than you might think, as this function
553 * is called by EVERY GetVersion*() API !
556 static WINDOWS_VERSION
VERSION_GetVersion(void)
558 static WORD winver
= 0xffff;
560 if (winver
== 0xffff) /* to be determined */
562 WINDOWS_VERSION retver
;
565 if (versionForced
) /* user has overridden any sensible checks */
566 winver
= forcedWinVersion
;
569 retver
= VERSION_GetLinkedDllVersion();
571 /* cache determined value, but do not store in case of WIN31 */
572 if (retver
!= WIN31
) winver
= retver
;
582 /***********************************************************************
583 * GetVersion (KERNEL.3)
585 LONG WINAPI
GetVersion16(void)
587 WINDOWS_VERSION ver
= VERSION_GetVersion();
588 return VersionData
[ver
].getVersion16
;
592 /***********************************************************************
593 * GetVersion (KERNEL32.@)
595 LONG WINAPI
GetVersion(void)
597 WINDOWS_VERSION ver
= VERSION_GetVersion();
598 return VersionData
[ver
].getVersion32
;
602 /***********************************************************************
603 * GetVersionEx (KERNEL.149)
605 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
607 WINDOWS_VERSION ver
= VERSION_GetVersion();
608 if (v
->dwOSVersionInfoSize
< sizeof(OSVERSIONINFO16
))
610 WARN("wrong OSVERSIONINFO size from app\n");
611 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
614 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
615 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
616 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
617 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
618 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
623 /***********************************************************************
624 * GetVersionExA (KERNEL32.@)
626 BOOL WINAPI
GetVersionExA(OSVERSIONINFOA
*v
)
628 WINDOWS_VERSION ver
= VERSION_GetVersion();
629 LPOSVERSIONINFOEXA vex
;
631 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOA
) &&
632 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXA
))
634 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
635 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOA
),
636 sizeof(OSVERSIONINFOEXA
));
637 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
640 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
641 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
642 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
643 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
644 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
645 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXA
)) {
646 vex
= (LPOSVERSIONINFOEXA
) v
;
647 vex
->wServicePackMajor
= VersionData
[ver
].getVersionEx
.wServicePackMajor
;
648 vex
->wServicePackMinor
= VersionData
[ver
].getVersionEx
.wServicePackMinor
;
649 vex
->wSuiteMask
= VersionData
[ver
].getVersionEx
.wSuiteMask
;
650 vex
->wProductType
= VersionData
[ver
].getVersionEx
.wProductType
;
656 /***********************************************************************
657 * GetVersionExW (KERNEL32.@)
659 BOOL WINAPI
GetVersionExW(OSVERSIONINFOW
*v
)
661 WINDOWS_VERSION ver
= VERSION_GetVersion();
662 LPOSVERSIONINFOEXW vex
;
664 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOW
) &&
665 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXW
))
667 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
668 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOW
),
669 sizeof(OSVERSIONINFOEXW
));
670 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
673 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
674 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
675 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
676 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
677 MultiByteToWideChar( CP_ACP
, 0, VersionData
[ver
].getVersionEx
.szCSDVersion
, -1,
678 v
->szCSDVersion
, sizeof(v
->szCSDVersion
)/sizeof(WCHAR
) );
679 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXW
)) {
680 vex
= (LPOSVERSIONINFOEXW
) v
;
681 vex
->wServicePackMajor
= VersionData
[ver
].getVersionEx
.wServicePackMajor
;
682 vex
->wServicePackMinor
= VersionData
[ver
].getVersionEx
.wServicePackMinor
;
683 vex
->wSuiteMask
= VersionData
[ver
].getVersionEx
.wSuiteMask
;
684 vex
->wProductType
= VersionData
[ver
].getVersionEx
.wProductType
;
690 /******************************************************************************
691 * VerifyVersionInfoA (KERNEL32.@)
693 BOOL WINAPI
VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo
, DWORD dwTypeMask
,
694 DWORDLONG dwlConditionMask
)
696 OSVERSIONINFOEXW verW
;
698 verW
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
699 verW
.dwMajorVersion
= lpVersionInfo
->dwMajorVersion
;
700 verW
.dwMinorVersion
= lpVersionInfo
->dwMinorVersion
;
701 verW
.dwBuildNumber
= lpVersionInfo
->dwBuildNumber
;
702 verW
.dwPlatformId
= lpVersionInfo
->dwPlatformId
;
703 verW
.wServicePackMajor
= lpVersionInfo
->wServicePackMajor
;
704 verW
.wServicePackMinor
= lpVersionInfo
->wServicePackMinor
;
705 verW
.wSuiteMask
= lpVersionInfo
->wSuiteMask
;
706 verW
.wProductType
= lpVersionInfo
->wProductType
;
707 verW
.wReserved
= lpVersionInfo
->wReserved
;
709 return VerifyVersionInfoW(&verW
, dwTypeMask
, dwlConditionMask
);
713 /******************************************************************************
714 * VerifyVersionInfoW (KERNEL32.@)
716 BOOL WINAPI
VerifyVersionInfoW( LPOSVERSIONINFOEXW lpVersionInfo
, DWORD dwTypeMask
,
717 DWORDLONG dwlConditionMask
)
719 OSVERSIONINFOEXW ver
;
722 FIXME("(%p,%lu,%llx): Not all cases correctly implemented yet\n", lpVersionInfo
, dwTypeMask
, dwlConditionMask
);
724 - Check the following special case on Windows (various versions):
725 o lp->wSuiteMask == 0 and ver.wSuiteMask != 0 and VER_AND/VER_OR
726 o lp->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)
727 - MSDN talks about some tests being impossible. Check what really happens.
730 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
731 if(!GetVersionExW((LPOSVERSIONINFOW
) &ver
))
736 if(!(dwTypeMask
&& dwlConditionMask
)) {
738 SetLastError(ERROR_BAD_ARGUMENTS
);
741 if(dwTypeMask
& VER_PRODUCT_TYPE
)
742 switch(dwlConditionMask
>> 7*3 & 0x07) {
744 if(ver
.wProductType
!= lpVersionInfo
->wProductType
)
748 if(ver
.wProductType
<= lpVersionInfo
->wProductType
)
751 case VER_GREATER_EQUAL
:
752 if(ver
.wProductType
< lpVersionInfo
->wProductType
)
756 if(ver
.wProductType
>= lpVersionInfo
->wProductType
)
760 if(ver
.wProductType
> lpVersionInfo
->wProductType
)
765 SetLastError(ERROR_BAD_ARGUMENTS
);
768 if(dwTypeMask
& VER_SUITENAME
&& res
)
769 switch(dwlConditionMask
>> 6*3 & 0x07) {
771 if((lpVersionInfo
->wSuiteMask
& ver
.wSuiteMask
) != lpVersionInfo
->wSuiteMask
)
775 if(!(lpVersionInfo
->wSuiteMask
& ver
.wSuiteMask
) && lpVersionInfo
->wSuiteMask
)
780 SetLastError(ERROR_BAD_ARGUMENTS
);
783 if(dwTypeMask
& VER_PLATFORMID
&& res
)
784 switch(dwlConditionMask
>> 3*3 & 0x07) {
786 if(ver
.dwPlatformId
!= lpVersionInfo
->dwPlatformId
)
790 if(ver
.dwPlatformId
<= lpVersionInfo
->dwPlatformId
)
793 case VER_GREATER_EQUAL
:
794 if(ver
.dwPlatformId
< lpVersionInfo
->dwPlatformId
)
798 if(ver
.dwPlatformId
>= lpVersionInfo
->dwPlatformId
)
802 if(ver
.dwPlatformId
> lpVersionInfo
->dwPlatformId
)
807 SetLastError(ERROR_BAD_ARGUMENTS
);
810 if(dwTypeMask
& VER_BUILDNUMBER
&& res
)
811 switch(dwlConditionMask
>> 2*3 & 0x07) {
813 if(ver
.dwBuildNumber
!= lpVersionInfo
->dwBuildNumber
)
817 if(ver
.dwBuildNumber
<= lpVersionInfo
->dwBuildNumber
)
820 case VER_GREATER_EQUAL
:
821 if(ver
.dwBuildNumber
< lpVersionInfo
->dwBuildNumber
)
825 if(ver
.dwBuildNumber
>= lpVersionInfo
->dwBuildNumber
)
829 if(ver
.dwBuildNumber
> lpVersionInfo
->dwBuildNumber
)
834 SetLastError(ERROR_BAD_ARGUMENTS
);
837 if(dwTypeMask
& VER_MAJORVERSION
&& res
)
838 switch(dwlConditionMask
>> 1*3 & 0x07) {
840 if(ver
.dwMajorVersion
!= lpVersionInfo
->dwMajorVersion
)
844 if(ver
.dwMajorVersion
<= lpVersionInfo
->dwMajorVersion
)
847 case VER_GREATER_EQUAL
:
848 if(ver
.dwMajorVersion
< lpVersionInfo
->dwMajorVersion
)
852 if(ver
.dwMajorVersion
>= lpVersionInfo
->dwMajorVersion
)
856 if(ver
.dwMajorVersion
> lpVersionInfo
->dwMajorVersion
)
861 SetLastError(ERROR_BAD_ARGUMENTS
);
864 if(dwTypeMask
& VER_MINORVERSION
&& res
)
865 switch(dwlConditionMask
>> 0*3 & 0x07) {
867 if(ver
.dwMinorVersion
!= lpVersionInfo
->dwMinorVersion
)
871 if(ver
.dwMinorVersion
<= lpVersionInfo
->dwMinorVersion
)
874 case VER_GREATER_EQUAL
:
875 if(ver
.dwMinorVersion
< lpVersionInfo
->dwMinorVersion
)
879 if(ver
.dwMinorVersion
>= lpVersionInfo
->dwMinorVersion
)
883 if(ver
.dwMinorVersion
> lpVersionInfo
->dwMinorVersion
)
888 SetLastError(ERROR_BAD_ARGUMENTS
);
891 if(dwTypeMask
& VER_SERVICEPACKMAJOR
&& res
)
892 switch(dwlConditionMask
>> 5*3 & 0x07) {
894 if(ver
.wServicePackMajor
!= lpVersionInfo
->wServicePackMajor
)
898 if(ver
.wServicePackMajor
<= lpVersionInfo
->wServicePackMajor
)
901 case VER_GREATER_EQUAL
:
902 if(ver
.wServicePackMajor
< lpVersionInfo
->wServicePackMajor
)
906 if(ver
.wServicePackMajor
>= lpVersionInfo
->wServicePackMajor
)
910 if(ver
.wServicePackMajor
> lpVersionInfo
->wServicePackMajor
)
915 SetLastError(ERROR_BAD_ARGUMENTS
);
918 if(dwTypeMask
& VER_SERVICEPACKMINOR
&& res
)
919 switch(dwlConditionMask
>> 4*3 & 0x07) {
921 if(ver
.wServicePackMinor
!= lpVersionInfo
->wServicePackMinor
)
925 if(ver
.wServicePackMinor
<= lpVersionInfo
->wServicePackMinor
)
928 case VER_GREATER_EQUAL
:
929 if(ver
.wServicePackMinor
< lpVersionInfo
->wServicePackMinor
)
933 if(ver
.wServicePackMinor
>= lpVersionInfo
->wServicePackMinor
)
937 if(ver
.wServicePackMinor
> lpVersionInfo
->wServicePackMinor
)
942 SetLastError(ERROR_BAD_ARGUMENTS
);
946 if(!(res
|| error_set
))
947 SetLastError(ERROR_OLD_WIN_VERSION
);
952 /***********************************************************************
953 * GetWinFlags (KERNEL.132)
955 DWORD WINAPI
GetWinFlags16(void)
957 static const long cpuflags
[5] =
958 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
965 /* There doesn't seem to be any Pentium flag. */
966 result
= cpuflags
[min(si
.wProcessorLevel
, 4)] | WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
967 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
968 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
970 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
971 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
977 /* Not used at this time. This is here for documentation only */
979 /* WINDEBUGINFO flags values */
980 #define WDI_OPTIONS 0x0001
981 #define WDI_FILTER 0x0002
982 #define WDI_ALLOCBREAK 0x0004
984 /* dwOptions values */
985 #define DBO_CHECKHEAP 0x0001
986 #define DBO_BUFFERFILL 0x0004
987 #define DBO_DISABLEGPTRAPPING 0x0010
988 #define DBO_CHECKFREE 0x0020
990 #define DBO_SILENT 0x8000
992 #define DBO_TRACEBREAK 0x2000
993 #define DBO_WARNINGBREAK 0x1000
994 #define DBO_NOERRORBREAK 0x0800
995 #define DBO_NOFATALBREAK 0x0400
996 #define DBO_INT3BREAK 0x0100
998 /* DebugOutput flags values */
999 #define DBF_TRACE 0x0000
1000 #define DBF_WARNING 0x4000
1001 #define DBF_ERROR 0x8000
1002 #define DBF_FATAL 0xc000
1004 /* dwFilter values */
1005 #define DBF_KERNEL 0x1000
1006 #define DBF_KRN_MEMMAN 0x0001
1007 #define DBF_KRN_LOADMODULE 0x0002
1008 #define DBF_KRN_SEGMENTLOAD 0x0004
1009 #define DBF_USER 0x0800
1010 #define DBF_GDI 0x0400
1011 #define DBF_MMSYSTEM 0x0040
1012 #define DBF_PENWIN 0x0020
1013 #define DBF_APPLICATION 0x0008
1014 #define DBF_DRIVER 0x0010
1016 #endif /* NOLOGERROR */
1019 /***********************************************************************
1020 * GetWinDebugInfo (KERNEL.355)
1022 BOOL16 WINAPI
GetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
, UINT16 flags
)
1024 FIXME("(%8lx,%d): stub returning 0\n",
1025 (unsigned long)lpwdi
, flags
);
1026 /* 0 means not in debugging mode/version */
1027 /* Can this type of debugging be used in wine ? */
1028 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1033 /***********************************************************************
1034 * SetWinDebugInfo (KERNEL.356)
1036 BOOL16 WINAPI
SetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
)
1038 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
1039 /* 0 means not in debugging mode/version */
1040 /* Can this type of debugging be used in wine ? */
1041 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1046 /***********************************************************************
1050 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
1052 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
1054 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
1057 /***********************************************************************
1058 * DiagQuery (KERNEL.339)
1060 * returns TRUE if Win called with "/b" (bootlog.txt)
1062 BOOL16 WINAPI
DiagQuery16(void)
1064 /* perhaps implement a Wine "/b" command line flag sometime ? */
1068 /***********************************************************************
1069 * DiagOutput (KERNEL.340)
1071 * writes a debug string into <windir>\bootlog.txt
1073 void WINAPI
DiagOutput16(LPCSTR str
)
1076 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str
));