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);
476 /* test if it is an external (native) dll */
477 if (smi->Modules[k].Flags & LDR_WINE_INTERNAL) continue;
479 for (i = 0; special_dlls[i]; i++)
481 /* test if it is a special dll */
482 if (!strcasecmp(&smi->Modules[k].Name[smi->Modules[k].NameOffset], special_dlls[i]))
484 DWORD DllVersion = VERSION_GetSystemDLLVersion(smi->Modules[k].ImageBaseAddress);
485 if (WinVersion == NB_WINDOWS_VERSIONS)
486 WinVersion = DllVersion;
489 if (WinVersion != DllVersion) {
490 ERR("You mixed system DLLs from different windows versions! Expect a crash! (%s: expected version '%s', but is '%s')\n",
491 &smi->Modules[k].Name[smi->Modules[k].NameOffset],
492 VersionData[WinVersion].getVersionEx.szCSDVersion,
493 VersionData[DllVersion].getVersionEx.szCSDVersion);
494 return WIN20; /* this may let the exe exiting */
502 RtlFreeHeap(ntdll_get_process_heap(), 0, smi);
505 if(WinVersion != NB_WINDOWS_VERSIONS) return WinVersion;
507 /* we are using no external system dlls, look at the exe */
508 nt = RtlImageNtHeader(GetModuleHandleA(NULL));
509 ophd = &nt->OptionalHeader;
511 TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
512 ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
513 ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
514 ophd->MajorImageVersion, ophd->MinorImageVersion,
515 ophd->MajorSubsystemVersion, ophd->MinorSubsystemVersion);
517 /* special nt 3.51 */
518 if (3 == ophd->MajorOperatingSystemVersion && 51 == ophd->MinorOperatingSystemVersion)
523 /* the MajorSubsystemVersion is the only usable sign */
524 if (ophd->MajorSubsystemVersion < 4)
526 if ( ophd->MajorOperatingSystemVersion == 1
527 && ophd->MinorOperatingSystemVersion == 0)
529 return WIN31; /* win32s */
532 if (ophd->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
533 return NT351; /* FIXME: NT 3.1, not tested */
541 /**********************************************************************
545 * Don't call this function too early during the Wine init,
546 * as pdb->exe_modref (required by VERSION_GetImageVersion()) might still
547 * be NULL in such cases, which causes the winver to ALWAYS be detected
549 * And as we cache the winver once it has been determined, this is bad.
550 * This can happen much easier than you might think, as this function
551 * is called by EVERY GetVersion*() API !
554 static WINDOWS_VERSION VERSION_GetVersion(void)
556 static WORD winver = 0xffff;
558 if (winver == 0xffff) /* to be determined */
560 WINDOWS_VERSION retver;
563 if (versionForced) /* user has overridden any sensible checks */
564 winver = forcedWinVersion;
567 retver = VERSION_GetLinkedDllVersion();
569 /* cache determined value, but do not store in case of WIN31 */
570 if (retver != WIN31) winver = retver;
580 /***********************************************************************
581 * GetVersion (KERNEL.3)
583 LONG WINAPI GetVersion16(void)
585 WINDOWS_VERSION ver = VERSION_GetVersion();
586 return VersionData[ver].getVersion16;
590 /***********************************************************************
591 * GetVersion (KERNEL32.@)
593 LONG WINAPI GetVersion(void)
595 WINDOWS_VERSION ver = VERSION_GetVersion();
596 return VersionData[ver].getVersion32;
600 /***********************************************************************
601 * GetVersionEx (KERNEL.149)
603 BOOL16 WINAPI GetVersionEx16(OSVERSIONINFO16 *v)
605 WINDOWS_VERSION ver = VERSION_GetVersion();
606 if (v->dwOSVersionInfoSize < sizeof(OSVERSIONINFO16))
608 WARN("wrong OSVERSIONINFO size from app\n");
609 SetLastError(ERROR_INSUFFICIENT_BUFFER);
612 v->dwMajorVersion = VersionData[ver].getVersionEx.dwMajorVersion;
613 v->dwMinorVersion = VersionData[ver].getVersionEx.dwMinorVersion;
614 v->dwBuildNumber = VersionData[ver].getVersionEx.dwBuildNumber;
615 v->dwPlatformId = VersionData[ver].getVersionEx.dwPlatformId;
616 strcpy( v->szCSDVersion, VersionData[ver].getVersionEx.szCSDVersion );
621 /***********************************************************************
622 * GetVersionExA (KERNEL32.@)
624 BOOL WINAPI GetVersionExA(OSVERSIONINFOA *v)
626 WINDOWS_VERSION ver = VERSION_GetVersion();
627 LPOSVERSIONINFOEXA vex;
629 if (v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA) &&
630 v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXA))
632 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
633 v->dwOSVersionInfoSize, sizeof(OSVERSIONINFOA),
634 sizeof(OSVERSIONINFOEXA));
635 SetLastError(ERROR_INSUFFICIENT_BUFFER);
638 v->dwMajorVersion = VersionData[ver].getVersionEx.dwMajorVersion;
639 v->dwMinorVersion = VersionData[ver].getVersionEx.dwMinorVersion;
640 v->dwBuildNumber = VersionData[ver].getVersionEx.dwBuildNumber;
641 v->dwPlatformId = VersionData[ver].getVersionEx.dwPlatformId;
642 strcpy( v->szCSDVersion, VersionData[ver].getVersionEx.szCSDVersion );
643 if(v->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA)) {
644 vex = (LPOSVERSIONINFOEXA) v;
645 vex->wServicePackMajor = VersionData[ver].getVersionEx.wServicePackMajor;
646 vex->wServicePackMinor = VersionData[ver].getVersionEx.wServicePackMinor;
647 vex->wSuiteMask = VersionData[ver].getVersionEx.wSuiteMask;
648 vex->wProductType = VersionData[ver].getVersionEx.wProductType;
654 /***********************************************************************
655 * GetVersionExW (KERNEL32.@)
657 BOOL WINAPI GetVersionExW(OSVERSIONINFOW *v)
659 WINDOWS_VERSION ver = VERSION_GetVersion();
660 LPOSVERSIONINFOEXW vex;
662 if (v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW) &&
663 v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW))
665 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
666 v->dwOSVersionInfoSize, sizeof(OSVERSIONINFOW),
667 sizeof(OSVERSIONINFOEXW));
668 SetLastError(ERROR_INSUFFICIENT_BUFFER);
671 v->dwMajorVersion = VersionData[ver].getVersionEx.dwMajorVersion;
672 v->dwMinorVersion = VersionData[ver].getVersionEx.dwMinorVersion;
673 v->dwBuildNumber = VersionData[ver].getVersionEx.dwBuildNumber;
674 v->dwPlatformId = VersionData[ver].getVersionEx.dwPlatformId;
675 MultiByteToWideChar( CP_ACP, 0, VersionData[ver].getVersionEx.szCSDVersion, -1,
676 v->szCSDVersion, sizeof(v->szCSDVersion)/sizeof(WCHAR) );
677 if(v->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW)) {
678 vex = (LPOSVERSIONINFOEXW) v;
679 vex->wServicePackMajor = VersionData[ver].getVersionEx.wServicePackMajor;
680 vex->wServicePackMinor = VersionData[ver].getVersionEx.wServicePackMinor;
681 vex->wSuiteMask = VersionData[ver].getVersionEx.wSuiteMask;
682 vex->wProductType = VersionData[ver].getVersionEx.wProductType;
688 /******************************************************************************
689 * VerifyVersionInfoA (KERNEL32.@)
691 BOOL WINAPI VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo, DWORD dwTypeMask,
692 DWORDLONG dwlConditionMask)
694 OSVERSIONINFOEXW verW;
696 verW.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
697 verW.dwMajorVersion = lpVersionInfo->dwMajorVersion;
698 verW.dwMinorVersion = lpVersionInfo->dwMinorVersion;
699 verW.dwBuildNumber = lpVersionInfo->dwBuildNumber;
700 verW.dwPlatformId = lpVersionInfo->dwPlatformId;
701 verW.wServicePackMajor = lpVersionInfo->wServicePackMajor;
702 verW.wServicePackMinor = lpVersionInfo->wServicePackMinor;
703 verW.wSuiteMask = lpVersionInfo->wSuiteMask;
704 verW.wProductType = lpVersionInfo->wProductType;
705 verW.wReserved = lpVersionInfo->wReserved;
707 return VerifyVersionInfoW(&verW, dwTypeMask, dwlConditionMask);
711 /******************************************************************************
712 * VerifyVersionInfoW (KERNEL32.@)
714 BOOL WINAPI VerifyVersionInfoW( LPOSVERSIONINFOEXW lpVersionInfo, DWORD dwTypeMask,
715 DWORDLONG dwlConditionMask)
717 OSVERSIONINFOEXW ver;
720 FIXME("(%p,%lu,%llx): Not all cases correctly implemented yet\n", lpVersionInfo, dwTypeMask, dwlConditionMask);
722 - Check the following special case on Windows (various versions):
723 o lp->wSuiteMask == 0 and ver.wSuiteMask != 0 and VER_AND/VER_OR
724 o lp->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)
725 - MSDN talks about some tests being impossible. Check what really happens.
728 ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
729 if(!GetVersionExW((LPOSVERSIONINFOW) &ver))
734 if(!(dwTypeMask && dwlConditionMask)) {
736 SetLastError(ERROR_BAD_ARGUMENTS);
739 if(dwTypeMask & VER_PRODUCT_TYPE)
740 switch(dwlConditionMask >> 7*3 & 0x07) {
742 if(ver.wProductType != lpVersionInfo->wProductType)
746 if(ver.wProductType <= lpVersionInfo->wProductType)
749 case VER_GREATER_EQUAL:
750 if(ver.wProductType < lpVersionInfo->wProductType)
754 if(ver.wProductType >= lpVersionInfo->wProductType)
758 if(ver.wProductType > lpVersionInfo->wProductType)
763 SetLastError(ERROR_BAD_ARGUMENTS);
766 if(dwTypeMask & VER_SUITENAME && res)
767 switch(dwlConditionMask >> 6*3 & 0x07) {
769 if((lpVersionInfo->wSuiteMask & ver.wSuiteMask) != lpVersionInfo->wSuiteMask)
773 if(!(lpVersionInfo->wSuiteMask & ver.wSuiteMask) && lpVersionInfo->wSuiteMask)
778 SetLastError(ERROR_BAD_ARGUMENTS);
781 if(dwTypeMask & VER_PLATFORMID && res)
782 switch(dwlConditionMask >> 3*3 & 0x07) {
784 if(ver.dwPlatformId != lpVersionInfo->dwPlatformId)
788 if(ver.dwPlatformId <= lpVersionInfo->dwPlatformId)
791 case VER_GREATER_EQUAL:
792 if(ver.dwPlatformId < lpVersionInfo->dwPlatformId)
796 if(ver.dwPlatformId >= lpVersionInfo->dwPlatformId)
800 if(ver.dwPlatformId > lpVersionInfo->dwPlatformId)
805 SetLastError(ERROR_BAD_ARGUMENTS);
808 if(dwTypeMask & VER_BUILDNUMBER && res)
809 switch(dwlConditionMask >> 2*3 & 0x07) {
811 if(ver.dwBuildNumber != lpVersionInfo->dwBuildNumber)
815 if(ver.dwBuildNumber <= lpVersionInfo->dwBuildNumber)
818 case VER_GREATER_EQUAL:
819 if(ver.dwBuildNumber < lpVersionInfo->dwBuildNumber)
823 if(ver.dwBuildNumber >= lpVersionInfo->dwBuildNumber)
827 if(ver.dwBuildNumber > lpVersionInfo->dwBuildNumber)
832 SetLastError(ERROR_BAD_ARGUMENTS);
835 if(dwTypeMask & VER_MAJORVERSION && res)
836 switch(dwlConditionMask >> 1*3 & 0x07) {
838 if(ver.dwMajorVersion != lpVersionInfo->dwMajorVersion)
842 if(ver.dwMajorVersion <= lpVersionInfo->dwMajorVersion)
845 case VER_GREATER_EQUAL:
846 if(ver.dwMajorVersion < lpVersionInfo->dwMajorVersion)
850 if(ver.dwMajorVersion >= lpVersionInfo->dwMajorVersion)
854 if(ver.dwMajorVersion > lpVersionInfo->dwMajorVersion)
859 SetLastError(ERROR_BAD_ARGUMENTS);
862 if(dwTypeMask & VER_MINORVERSION && res)
863 switch(dwlConditionMask >> 0*3 & 0x07) {
865 if(ver.dwMinorVersion != lpVersionInfo->dwMinorVersion)
869 if(ver.dwMinorVersion <= lpVersionInfo->dwMinorVersion)
872 case VER_GREATER_EQUAL:
873 if(ver.dwMinorVersion < lpVersionInfo->dwMinorVersion)
877 if(ver.dwMinorVersion >= lpVersionInfo->dwMinorVersion)
881 if(ver.dwMinorVersion > lpVersionInfo->dwMinorVersion)
886 SetLastError(ERROR_BAD_ARGUMENTS);
889 if(dwTypeMask & VER_SERVICEPACKMAJOR && res)
890 switch(dwlConditionMask >> 5*3 & 0x07) {
892 if(ver.wServicePackMajor != lpVersionInfo->wServicePackMajor)
896 if(ver.wServicePackMajor <= lpVersionInfo->wServicePackMajor)
899 case VER_GREATER_EQUAL:
900 if(ver.wServicePackMajor < lpVersionInfo->wServicePackMajor)
904 if(ver.wServicePackMajor >= lpVersionInfo->wServicePackMajor)
908 if(ver.wServicePackMajor > lpVersionInfo->wServicePackMajor)
913 SetLastError(ERROR_BAD_ARGUMENTS);
916 if(dwTypeMask & VER_SERVICEPACKMINOR && res)
917 switch(dwlConditionMask >> 4*3 & 0x07) {
919 if(ver.wServicePackMinor != lpVersionInfo->wServicePackMinor)
923 if(ver.wServicePackMinor <= lpVersionInfo->wServicePackMinor)
926 case VER_GREATER_EQUAL:
927 if(ver.wServicePackMinor < lpVersionInfo->wServicePackMinor)
931 if(ver.wServicePackMinor >= lpVersionInfo->wServicePackMinor)
935 if(ver.wServicePackMinor > lpVersionInfo->wServicePackMinor)
940 SetLastError(ERROR_BAD_ARGUMENTS);
944 if(!(res || error_set))
945 SetLastError(ERROR_OLD_WIN_VERSION);
950 /***********************************************************************
951 * GetWinFlags (KERNEL.132)
953 DWORD WINAPI GetWinFlags16(void)
955 static const long cpuflags[5] =
956 { WF_CPU086, WF_CPU186, WF_CPU286, WF_CPU386, WF_CPU486 };
963 /* There doesn't seem to be any Pentium flag. */
964 result = cpuflags[min(si.wProcessorLevel, 4)] | WF_ENHANCED | WF_PMODE | WF_80x87 | WF_PAGING;
965 if (si.wProcessorLevel >= 4) result |= WF_HASCPUID;
966 ovi.dwOSVersionInfoSize = sizeof(ovi);
968 if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT)
969 result |= WF_WIN32WOW; /* undocumented WF_WINNT */
975 /* Not used at this time. This is here for documentation only */
977 /* WINDEBUGINFO flags values */
978 #define WDI_OPTIONS 0x0001
979 #define WDI_FILTER 0x0002
980 #define WDI_ALLOCBREAK 0x0004
982 /* dwOptions values */
983 #define DBO_CHECKHEAP 0x0001
984 #define DBO_BUFFERFILL 0x0004
985 #define DBO_DISABLEGPTRAPPING 0x0010
986 #define DBO_CHECKFREE 0x0020
988 #define DBO_SILENT 0x8000
990 #define DBO_TRACEBREAK 0x2000
991 #define DBO_WARNINGBREAK 0x1000
992 #define DBO_NOERRORBREAK 0x0800
993 #define DBO_NOFATALBREAK 0x0400
994 #define DBO_INT3BREAK 0x0100
996 /* DebugOutput flags values */
997 #define DBF_TRACE 0x0000
998 #define DBF_WARNING 0x4000
999 #define DBF_ERROR 0x8000
1000 #define DBF_FATAL 0xc000
1002 /* dwFilter values */
1003 #define DBF_KERNEL 0x1000
1004 #define DBF_KRN_MEMMAN 0x0001
1005 #define DBF_KRN_LOADMODULE 0x0002
1006 #define DBF_KRN_SEGMENTLOAD 0x0004
1007 #define DBF_USER 0x0800
1008 #define DBF_GDI 0x0400
1009 #define DBF_MMSYSTEM 0x0040
1010 #define DBF_PENWIN 0x0020
1011 #define DBF_APPLICATION 0x0008
1012 #define DBF_DRIVER 0x0010
1014 #endif /* NOLOGERROR */
1017 /***********************************************************************
1018 * GetWinDebugInfo (KERNEL.355)
1020 BOOL16 WINAPI GetWinDebugInfo16(WINDEBUGINFO16 *lpwdi, UINT16 flags)
1022 FIXME("(%8lx,%d): stub returning 0\n",
1023 (unsigned long)lpwdi, flags);
1024 /* 0 means not in debugging mode/version */
1025 /* Can this type of debugging be used in wine ? */
1026 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1031 /***********************************************************************
1032 * SetWinDebugInfo (KERNEL.356)
1034 BOOL16 WINAPI SetWinDebugInfo16(WINDEBUGINFO16 *lpwdi)
1036 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi);
1037 /* 0 means not in debugging mode/version */
1038 /* Can this type of debugging be used in wine ? */
1039 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1044 /***********************************************************************
1048 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
1050 void WINAPI DebugFillBuffer(LPSTR lpBuffer, WORD wBytes)
1052 memset(lpBuffer, DBGFILL_BUFFER, wBytes);
1055 /***********************************************************************
1056 * DiagQuery (KERNEL.339)
1058 * returns TRUE if Win called with "/b" (bootlog.txt)
1060 BOOL16 WINAPI DiagQuery16(void)
1062 /* perhaps implement a Wine "/b" command line flag sometime ? */
1066 /***********************************************************************
1067 * DiagOutput (KERNEL.340)
1069 * writes a debug string into <windir>\bootlog.txt
1071 void WINAPI DiagOutput16(LPCSTR str)
1074 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str));