Removed obsolete INT_Int31Handler.
[wine/multimedia.git] / misc / version.c
blobcac9b7ffa00d8465650a9427d280dbac114e7370
1 /*
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
24 #include "config.h"
25 #include "wine/port.h"
27 #include <string.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "winuser.h"
34 #include "winternl.h"
35 #include "winerror.h"
36 #include "wine/winbase16.h"
37 #include "module.h"
38 #include "wine/unicode.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(ver);
43 typedef enum
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 */
55 NB_WINDOWS_VERSIONS
56 } WINDOWS_VERSION;
58 typedef struct
60 LONG getVersion16;
61 LONG getVersion32;
62 OSVERSIONINFOEXA getVersionEx;
63 } VERSION_DATA;
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",
77 0, 0, 0, 0, 0
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",
87 0, 0, 0, 0, 0
90 /* WIN31 */
92 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
93 MAKELONG( 0x0a03, 0x8000 ),
95 sizeof(OSVERSIONINFOA), 3, 10, 0,
96 VER_PLATFORM_WIN32s, "Win32s 1.3",
97 0, 0, 0, 0, 0
100 /* WIN95 */
102 0x07005F03,
103 0xC0000004,
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
111 * See also:
112 * http://support.microsoft.com/support/kb/articles/q158/2/38.asp
114 sizeof(OSVERSIONINFOA), 4, 0, 0x40003B6,
115 VER_PLATFORM_WIN32_WINDOWS, "",
116 0, 0, 0, 0, 0
119 /* WIN98 (second edition) */
121 0x070A5F03,
122 0xC0000A04,
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 ",
129 0, 0, 0, 0, 0
132 /* WINME */
134 0x08005F03,
135 0xC0005A04,
137 sizeof(OSVERSIONINFOA), 4, 90, 0x45A0BB8,
138 VER_PLATFORM_WIN32_WINDOWS, " ",
139 0, 0, 0, 0, 0
142 /* NT351 */
144 0x05000A03,
145 0x04213303,
147 sizeof(OSVERSIONINFOA), 3, 51, 0x421,
148 VER_PLATFORM_WIN32_NT, "Service Pack 2",
149 0, 0, 0, 0, 0
152 /* NT40 */
154 0x05000A03,
155 0x05650004,
157 sizeof(OSVERSIONINFOA), 4, 0, 0x565,
158 VER_PLATFORM_WIN32_NT, "Service Pack 6",
159 6, 0, 0, VER_NT_WORKSTATION, 0
162 /* NT2K */
164 0x05005F03,
165 0x08930005,
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! */
172 /* WINXP */
174 0x05005F03, /* Assuming DOS 5 like the other NT */
175 0x0A280105,
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 ! */
186 "win20",
187 "win30",
188 "win31",
189 "win95",
190 "win98",
191 "winme",
192 "nt351",
193 "nt40",
194 "win2000,win2k,nt2k,nt2000",
195 "winxp"
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[] =
202 "comdlg32.dll",
203 "comctl32.dll",
204 "shell32.dll",
205 "ole32.dll",
206 "rpcrt4.dll",
207 NULL
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 )
219 int i, len;
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 */
225 do {
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;
232 return;
234 pCurr = p+1;
235 } while (p);
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' : ',' );
249 ExitProcess(1);
253 /**********************************************************************
254 * VERSION_ParseDosVersion
256 static void VERSION_ParseDosVersion( const char *arg )
258 int hi, lo;
259 if (sscanf( arg, "%d.%d", &hi, &lo ) == 2)
261 VersionData[WIN31].getVersion16 =
262 MAKELONG(LOWORD(VersionData[WIN31].getVersion16),
263 (hi<<8) + lo);
265 else
267 MESSAGE("Wrong format for DOS version in config file. Use \"x.xx\"\n");
268 ExitProcess(1);
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;
286 DWORD count, len;
288 if (!*got_win_ver)
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 );
295 buffer[len] = 0;
296 VERSION_ParseWinVersion( buffer );
297 TRACE( "got win version %s\n", WinVersionNames[forcedWinVersion] );
298 *got_win_ver = TRUE;
301 if (!*got_dos_ver)
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 );
308 buffer[len] = 0;
309 VERSION_ParseDosVersion( buffer );
310 TRACE( "got dos version %lx\n", VersionData[WIN31].getVersion16 );
311 *got_dos_ver = TRUE;
317 /**********************************************************************
318 * VERSION_Init
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" );
340 return;
342 init_done = TRUE;
343 appname = buffer;
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;
350 attr.Attributes = 0;
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 );
368 NtClose( hkey );
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 );
377 NtClose( hkey );
380 done:
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
392 * shell32.
393 * If you have a better idea to figure this out...
395 static DWORD VERSION_GetSystemDLLVersion( HMODULE hmod )
397 DWORD size;
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;
405 TRACE("%s\n", name);
407 if (!strncasecmp(name, "ntdll", 5))
409 switch(RtlImageNtHeader(hmod)->OptionalHeader.MajorOperatingSystemVersion) {
410 case 3:
411 MESSAGE("WARNING: very old native DLL (NT 3.x) used, might cause instability.\n");
412 return NT351;
413 case 4: return NT40;
414 case 5: return NT2K;
415 case 6: return WINXP;
416 default:
417 FIXME("Unknown DLL OS version, please report !!\n");
418 return WINXP;
423 return WIN95;
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)
447 WINE_MODREF *wm;
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",
460 wm->modname,
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))
469 int i;
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;
478 else {
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",
481 wm->modname,
482 VersionData[WinVersion].getVersionEx.szCSDVersion,
483 VersionData[DllVersion].getVersionEx.szCSDVersion);
484 return WIN20; /* this may let the exe exiting */
487 break;
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)
508 return NT351;
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 */
522 else
523 return WIN95;
526 return WIN95;
529 /**********************************************************************
530 * VERSION_GetVersion
532 * WARNING !!!
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
536 * as WIN31.
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;
550 VERSION_Init();
551 if (versionForced) /* user has overridden any sensible checks */
552 winver = forcedWinVersion;
553 else
555 retver = VERSION_GetLinkedDllVersion();
557 /* cache determined value, but do not store in case of WIN31 */
558 if (retver != WIN31) winver = retver;
560 return retver;
564 return winver;
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);
598 return FALSE;
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 );
605 return TRUE;
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);
624 return FALSE;
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;
638 return TRUE;
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);
657 return FALSE;
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;
672 return TRUE;
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;
706 BOOL res, error_set;
708 FIXME("(%p,%lu,%llx): Not all cases correctly implemented yet\n", lpVersionInfo, dwTypeMask, dwlConditionMask);
709 /* FIXME:
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))
718 return FALSE;
720 res = TRUE;
721 error_set = FALSE;
722 if(!(dwTypeMask && dwlConditionMask)) {
723 res = FALSE;
724 SetLastError(ERROR_BAD_ARGUMENTS);
725 error_set = TRUE;
727 if(dwTypeMask & VER_PRODUCT_TYPE)
728 switch(dwlConditionMask >> 7*3 & 0x07) {
729 case VER_EQUAL:
730 if(ver.wProductType != lpVersionInfo->wProductType)
731 res = FALSE;
732 break;
733 case VER_GREATER:
734 if(ver.wProductType <= lpVersionInfo->wProductType)
735 res = FALSE;
736 break;
737 case VER_GREATER_EQUAL:
738 if(ver.wProductType < lpVersionInfo->wProductType)
739 res = FALSE;
740 break;
741 case VER_LESS:
742 if(ver.wProductType >= lpVersionInfo->wProductType)
743 res = FALSE;
744 break;
745 case VER_LESS_EQUAL:
746 if(ver.wProductType > lpVersionInfo->wProductType)
747 res = FALSE;
748 break;
749 default:
750 res = FALSE;
751 SetLastError(ERROR_BAD_ARGUMENTS);
752 error_set = TRUE;
754 if(dwTypeMask & VER_SUITENAME && res)
755 switch(dwlConditionMask >> 6*3 & 0x07) {
756 case VER_AND:
757 if((lpVersionInfo->wSuiteMask & ver.wSuiteMask) != lpVersionInfo->wSuiteMask)
758 res = FALSE;
759 break;
760 case VER_OR:
761 if(!(lpVersionInfo->wSuiteMask & ver.wSuiteMask) && lpVersionInfo->wSuiteMask)
762 res = FALSE;
763 break;
764 default:
765 res = FALSE;
766 SetLastError(ERROR_BAD_ARGUMENTS);
767 error_set = TRUE;
769 if(dwTypeMask & VER_PLATFORMID && res)
770 switch(dwlConditionMask >> 3*3 & 0x07) {
771 case VER_EQUAL:
772 if(ver.dwPlatformId != lpVersionInfo->dwPlatformId)
773 res = FALSE;
774 break;
775 case VER_GREATER:
776 if(ver.dwPlatformId <= lpVersionInfo->dwPlatformId)
777 res = FALSE;
778 break;
779 case VER_GREATER_EQUAL:
780 if(ver.dwPlatformId < lpVersionInfo->dwPlatformId)
781 res = FALSE;
782 break;
783 case VER_LESS:
784 if(ver.dwPlatformId >= lpVersionInfo->dwPlatformId)
785 res = FALSE;
786 break;
787 case VER_LESS_EQUAL:
788 if(ver.dwPlatformId > lpVersionInfo->dwPlatformId)
789 res = FALSE;
790 break;
791 default:
792 res = FALSE;
793 SetLastError(ERROR_BAD_ARGUMENTS);
794 error_set = TRUE;
796 if(dwTypeMask & VER_BUILDNUMBER && res)
797 switch(dwlConditionMask >> 2*3 & 0x07) {
798 case VER_EQUAL:
799 if(ver.dwBuildNumber != lpVersionInfo->dwBuildNumber)
800 res = FALSE;
801 break;
802 case VER_GREATER:
803 if(ver.dwBuildNumber <= lpVersionInfo->dwBuildNumber)
804 res = FALSE;
805 break;
806 case VER_GREATER_EQUAL:
807 if(ver.dwBuildNumber < lpVersionInfo->dwBuildNumber)
808 res = FALSE;
809 break;
810 case VER_LESS:
811 if(ver.dwBuildNumber >= lpVersionInfo->dwBuildNumber)
812 res = FALSE;
813 break;
814 case VER_LESS_EQUAL:
815 if(ver.dwBuildNumber > lpVersionInfo->dwBuildNumber)
816 res = FALSE;
817 break;
818 default:
819 res = FALSE;
820 SetLastError(ERROR_BAD_ARGUMENTS);
821 error_set = TRUE;
823 if(dwTypeMask & VER_MAJORVERSION && res)
824 switch(dwlConditionMask >> 1*3 & 0x07) {
825 case VER_EQUAL:
826 if(ver.dwMajorVersion != lpVersionInfo->dwMajorVersion)
827 res = FALSE;
828 break;
829 case VER_GREATER:
830 if(ver.dwMajorVersion <= lpVersionInfo->dwMajorVersion)
831 res = FALSE;
832 break;
833 case VER_GREATER_EQUAL:
834 if(ver.dwMajorVersion < lpVersionInfo->dwMajorVersion)
835 res = FALSE;
836 break;
837 case VER_LESS:
838 if(ver.dwMajorVersion >= lpVersionInfo->dwMajorVersion)
839 res = FALSE;
840 break;
841 case VER_LESS_EQUAL:
842 if(ver.dwMajorVersion > lpVersionInfo->dwMajorVersion)
843 res = FALSE;
844 break;
845 default:
846 res = FALSE;
847 SetLastError(ERROR_BAD_ARGUMENTS);
848 error_set = TRUE;
850 if(dwTypeMask & VER_MINORVERSION && res)
851 switch(dwlConditionMask >> 0*3 & 0x07) {
852 case VER_EQUAL:
853 if(ver.dwMinorVersion != lpVersionInfo->dwMinorVersion)
854 res = FALSE;
855 break;
856 case VER_GREATER:
857 if(ver.dwMinorVersion <= lpVersionInfo->dwMinorVersion)
858 res = FALSE;
859 break;
860 case VER_GREATER_EQUAL:
861 if(ver.dwMinorVersion < lpVersionInfo->dwMinorVersion)
862 res = FALSE;
863 break;
864 case VER_LESS:
865 if(ver.dwMinorVersion >= lpVersionInfo->dwMinorVersion)
866 res = FALSE;
867 break;
868 case VER_LESS_EQUAL:
869 if(ver.dwMinorVersion > lpVersionInfo->dwMinorVersion)
870 res = FALSE;
871 break;
872 default:
873 res = FALSE;
874 SetLastError(ERROR_BAD_ARGUMENTS);
875 error_set = TRUE;
877 if(dwTypeMask & VER_SERVICEPACKMAJOR && res)
878 switch(dwlConditionMask >> 5*3 & 0x07) {
879 case VER_EQUAL:
880 if(ver.wServicePackMajor != lpVersionInfo->wServicePackMajor)
881 res = FALSE;
882 break;
883 case VER_GREATER:
884 if(ver.wServicePackMajor <= lpVersionInfo->wServicePackMajor)
885 res = FALSE;
886 break;
887 case VER_GREATER_EQUAL:
888 if(ver.wServicePackMajor < lpVersionInfo->wServicePackMajor)
889 res = FALSE;
890 break;
891 case VER_LESS:
892 if(ver.wServicePackMajor >= lpVersionInfo->wServicePackMajor)
893 res = FALSE;
894 break;
895 case VER_LESS_EQUAL:
896 if(ver.wServicePackMajor > lpVersionInfo->wServicePackMajor)
897 res = FALSE;
898 break;
899 default:
900 res = FALSE;
901 SetLastError(ERROR_BAD_ARGUMENTS);
902 error_set = TRUE;
904 if(dwTypeMask & VER_SERVICEPACKMINOR && res)
905 switch(dwlConditionMask >> 4*3 & 0x07) {
906 case VER_EQUAL:
907 if(ver.wServicePackMinor != lpVersionInfo->wServicePackMinor)
908 res = FALSE;
909 break;
910 case VER_GREATER:
911 if(ver.wServicePackMinor <= lpVersionInfo->wServicePackMinor)
912 res = FALSE;
913 break;
914 case VER_GREATER_EQUAL:
915 if(ver.wServicePackMinor < lpVersionInfo->wServicePackMinor)
916 res = FALSE;
917 break;
918 case VER_LESS:
919 if(ver.wServicePackMinor >= lpVersionInfo->wServicePackMinor)
920 res = FALSE;
921 break;
922 case VER_LESS_EQUAL:
923 if(ver.wServicePackMinor > lpVersionInfo->wServicePackMinor)
924 res = FALSE;
925 break;
926 default:
927 res = FALSE;
928 SetLastError(ERROR_BAD_ARGUMENTS);
929 error_set = TRUE;
932 if(!(res || error_set))
933 SetLastError(ERROR_OLD_WIN_VERSION);
934 return res;
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 };
945 SYSTEM_INFO si;
946 OSVERSIONINFOA ovi;
947 DWORD result;
949 GetSystemInfo(&si);
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);
955 GetVersionExA(&ovi);
956 if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT)
957 result |= WF_WIN32WOW; /* undocumented WF_WINNT */
958 return result;
962 #if 0
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 */
1015 return 0;
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 */
1028 return 0;
1032 /***********************************************************************
1033 * K329 (KERNEL.329)
1035 * TODO:
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 ? */
1051 return FALSE;
1054 /***********************************************************************
1055 * DiagOutput (KERNEL.340)
1057 * writes a debug string into <windir>\bootlog.txt
1059 void WINAPI DiagOutput16(LPCSTR str)
1061 /* FIXME */
1062 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str));