2 * Windows and DOS version functions
4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998 Patrik Stridvall
7 * Copyright 1998,2003 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 */
61 char human_readable
[32];
64 OSVERSIONINFOEXA getVersionEx
;
67 /* FIXME: compare values below with original and fix.
68 * An *excellent* win9x version page (ALL versions !)
69 * can be found at members.aol.com/axcel216/ver.htm */
70 static VERSION_DATA VersionData
[NB_WINDOWS_VERSIONS
] =
72 /* WIN20 FIXME: verify values */
75 MAKELONG( 0x0002, 0x0303 ), /* assume DOS 3.3 */
76 MAKELONG( 0x0002, 0x8000 ),
78 /* yes, sizeof(OSVERSIONINFOA) is correct here
79 * (in case of OSVERSIONINFOEXA application request,
80 * we adapt it dynamically). */
81 sizeof(OSVERSIONINFOA
), 2, 0, 0,
82 VER_PLATFORM_WIN32s
, "Win32s 1.3",
86 /* WIN30 FIXME: verify values */
89 MAKELONG( 0x0003, 0x0500 ), /* assume DOS 5.00 */
90 MAKELONG( 0x0003, 0x8000 ),
92 sizeof(OSVERSIONINFOA
), 3, 0, 0,
93 VER_PLATFORM_WIN32s
, "Win32s 1.3",
100 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
101 MAKELONG( 0x0a03, 0x8000 ),
103 sizeof(OSVERSIONINFOA
), 3, 10, 0,
104 VER_PLATFORM_WIN32s
, "Win32s 1.3",
114 /* Win95: 4, 0, 0x40003B6, ""
115 * Win95sp1: 4, 0, 0x40003B6, " A " (according to doc)
116 * Win95osr2: 4, 0, 0x4000457, " B " (according to doc)
117 * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
118 * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
119 * Win95a/b can be discerned via regkey SubVersionNumber
121 * http://support.microsoft.com/support/kb/articles/q158/2/38.asp
123 sizeof(OSVERSIONINFOA
), 4, 0, 0x40003B6,
124 VER_PLATFORM_WIN32_WINDOWS
, "",
128 /* WIN98 (second edition) */
134 /* Win98: 4, 10, 0x40A07CE, " " 4.10.1998
135 * Win98SE: 4, 10, 0x40A08AE, " A " 4.10.2222
137 sizeof(OSVERSIONINFOA
), 4, 10, 0x40A08AE,
138 VER_PLATFORM_WIN32_WINDOWS
, " A ",
148 sizeof(OSVERSIONINFOA
), 4, 90, 0x45A0BB8,
149 VER_PLATFORM_WIN32_WINDOWS
, " ",
159 sizeof(OSVERSIONINFOA
), 3, 51, 0x421,
160 VER_PLATFORM_WIN32_NT
, "Service Pack 2",
170 sizeof(OSVERSIONINFOA
), 4, 0, 0x565,
171 VER_PLATFORM_WIN32_NT
, "Service Pack 6",
172 6, 0, 0, VER_NT_WORKSTATION
, 0
181 sizeof(OSVERSIONINFOA
), 5, 0, 0x893,
182 VER_PLATFORM_WIN32_NT
, "Service Pack 3",
183 3, 0, 0, VER_NT_WORKSTATION
, 30 /* FIXME: Great, a reserved field with a value! */
189 0x05005F03, /* Assuming DOS 5 like the other NT */
192 sizeof(OSVERSIONINFOA
), 5, 1, 0xA28,
193 VER_PLATFORM_WIN32_NT
, "Service Pack 1",
194 1, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 30 /* FIXME: Great, a reserved field with a value! */
199 static const char *WinVersionNames
[NB_WINDOWS_VERSIONS
] =
200 { /* no spaces in here ! */
209 "win2000,win2k,nt2k,nt2000",
213 /* if one of the following dlls is importing ntdll the windows
214 version autodetection switches wine to unicode (nt 3.51 or 4.0) */
215 static char * special_dlls
[] =
225 /* the current version has not been autodetected but forced via cmdline */
226 static BOOL versionForced
= FALSE
;
227 static WINDOWS_VERSION forcedWinVersion
= WIN31
; /* init value irrelevant */
229 /**********************************************************************
230 * VERSION_ParseWinVersion
232 static void VERSION_ParseWinVersion( const char *arg
)
235 const char *pCurr
, *p
;
236 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
238 pCurr
= WinVersionNames
[i
];
239 /* iterate through all winver aliases separated by comma */
241 p
= strchr(pCurr
, ',');
242 len
= p
? (int)p
- (int)pCurr
: strlen(pCurr
);
243 if ( (!strncmp( pCurr
, arg
, len
)) && (arg
[len
] == '\0') )
245 forcedWinVersion
= (WINDOWS_VERSION
)i
;
246 versionForced
= TRUE
;
252 MESSAGE("Invalid Windows version value '%s' specified in config file.\n", arg
);
253 MESSAGE("Valid versions are:" );
254 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
256 /* only list the first, "official" alias in case of aliases */
257 pCurr
= WinVersionNames
[i
];
258 p
= strchr(pCurr
, ',');
259 len
= (p
) ? (int)p
- (int)pCurr
: strlen(pCurr
);
261 MESSAGE(" '%.*s'%c", len
, pCurr
,
262 (i
== NB_WINDOWS_VERSIONS
- 1) ? '\n' : ',' );
268 /**********************************************************************
269 * VERSION_ParseDosVersion
271 static void VERSION_ParseDosVersion( const char *arg
)
274 if (sscanf( arg
, "%d.%d", &hi
, &lo
) == 2)
276 VersionData
[WIN31
].getVersion16
=
277 MAKELONG(LOWORD(VersionData
[WIN31
].getVersion16
),
282 MESSAGE("Wrong format for DOS version in config file. Use \"x.xx\"\n");
288 /**********************************************************************
289 * VERSION_ParseVersion
291 * Parse the contents of the Version key.
293 static void VERSION_ParseVersion( HKEY hkey
, BOOL
*got_win_ver
, BOOL
*got_dos_ver
)
295 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
296 static const WCHAR DosW
[] = {'D','O','S',0};
298 UNICODE_STRING valueW
;
299 char tmp
[64], buffer
[50];
300 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
305 RtlInitUnicodeString( &valueW
, WindowsW
);
306 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
308 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
,
309 (WCHAR
*)info
->Data
, info
->DataLength
);
311 VERSION_ParseWinVersion( buffer
);
312 TRACE( "got win version %s\n", WinVersionNames
[forcedWinVersion
] );
318 RtlInitUnicodeString( &valueW
, DosW
);
319 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
321 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
,
322 (WCHAR
*)info
->Data
, info
->DataLength
);
324 VERSION_ParseDosVersion( buffer
);
325 TRACE( "got dos version %lx\n", VersionData
[WIN31
].getVersion16
);
332 /**********************************************************************
335 void VERSION_Init( const char *appname
)
337 OBJECT_ATTRIBUTES attr
;
338 UNICODE_STRING nameW
;
339 HKEY hkey
, config_key
;
340 BOOL got_win_ver
= FALSE
, got_dos_ver
= FALSE
;
341 static const WCHAR configW
[] = {'M','a','c','h','i','n','e','\\',
342 'S','o','f','t','w','a','r','e','\\',
343 'W','i','n','e','\\',
344 'W','i','n','e','\\',
345 'C','o','n','f','i','g',0};
346 static const WCHAR appdefaultsW
[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
347 static const WCHAR versionW
[] = {'\\','V','e','r','s','i','o','n',0};
349 attr
.Length
= sizeof(attr
);
350 attr
.RootDirectory
= 0;
351 attr
.ObjectName
= &nameW
;
353 attr
.SecurityDescriptor
= NULL
;
354 attr
.SecurityQualityOfService
= NULL
;
355 RtlInitUnicodeString( &nameW
, configW
);
357 if (NtOpenKey( &config_key
, KEY_ALL_ACCESS
, &attr
)) return;
358 attr
.RootDirectory
= config_key
;
360 /* open AppDefaults\\appname\\Version key */
361 if (appname
&& *appname
)
365 WCHAR appversion
[MAX_PATH
+20];
367 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
368 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
370 strcpyW( appversion
, appdefaultsW
);
371 len
= strlenW(appversion
);
372 RtlMultiByteToUnicodeN( appversion
+ len
, sizeof(appversion
) - len
*sizeof(WCHAR
),
373 &len
, appname
, strlen(appname
)+1 );
374 strcatW( appversion
, versionW
);
375 TRACE( "getting version from %s\n", debugstr_w(appversion
) );
376 RtlInitUnicodeString( &nameW
, appversion
);
378 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
380 VERSION_ParseVersion( hkey
, &got_win_ver
, &got_dos_ver
);
383 if (got_win_ver
&& got_dos_ver
) goto done
;
386 TRACE( "getting default version\n" );
387 RtlInitUnicodeString( &nameW
, versionW
+ 1 );
388 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
390 VERSION_ParseVersion( hkey
, &got_win_ver
, &got_dos_ver
);
395 NtClose( config_key
);
399 /**********************************************************************
400 * VERSION_GetSystemDLLVersion
402 * This function tries to figure out if a given (native) dll comes from
403 * win95/98 or winnt. Since all values in the OptionalHeader are not a
404 * usable hint, we test if a dll imports the ntdll.
405 * This is at least working for all system dlls like comctl32, comdlg32 and
407 * If you have a better idea to figure this out...
409 static DWORD
VERSION_GetSystemDLLVersion( HMODULE hmod
)
412 IMAGE_IMPORT_DESCRIPTOR
*pe_imp
;
414 if ((pe_imp
= RtlImageDirectoryEntryToData( hmod
, TRUE
, IMAGE_DIRECTORY_ENTRY_IMPORT
, &size
)))
416 for ( ; pe_imp
->Name
; pe_imp
++)
418 char * name
= (char *)hmod
+ (unsigned int)pe_imp
->Name
;
421 if (!strncasecmp(name
, "ntdll", 5))
423 switch(RtlImageNtHeader(hmod
)->OptionalHeader
.MajorOperatingSystemVersion
) {
425 MESSAGE("WARNING: very old native DLL (NT 3.x) used, might cause instability.\n");
429 case 6: return WINXP
;
431 FIXME("Unknown DLL OS version, please report !!\n");
439 /**********************************************************************
440 * VERSION_GetLinkedDllVersion
442 * Some version data (not reliable!):
443 * linker/OS/image/subsys
445 * x.xx/1.00/0.00/3.10 Win32s (any version ?)
446 * 2.39/1.00/0.00/3.10 Win32s freecell.exe (any version)
447 * 2.50/1.00/4.00/4.00 Win32s 1.30 winhlp32.exe
448 * 2.60/3.51/3.51/3.51 NT351SP5 system dlls
449 * 2.60/3.51/3.51/4.00 NT351SP5 comctl32 dll
450 * 2.xx/1.00/0.00/4.00 Win95 system files
451 * x.xx/4.00/0.00/4.00 Win95 most applications
452 * 3.10/4.00/0.00/4.00 Win98 notepad
453 * x.xx/5.00/5.00/4.00 Win98 system dlls (e.g. comctl32.dll)
454 * x.xx/4.00/4.00/4.00 NT 4 most apps
455 * 5.12/5.00/5.00/4.00 NT4+IE5 comctl32.dll
456 * 5.12/5.00/5.00/4.00 Win98 calc
457 * x.xx/5.00/5.00/4.00 win95/win98/NT4 IE5 files
459 static DWORD
VERSION_GetLinkedDllVersion(void)
461 DWORD WinVersion
= NB_WINDOWS_VERSIONS
;
462 PIMAGE_OPTIONAL_HEADER ophd
;
463 IMAGE_NT_HEADERS
*nt
;
464 ULONG count
, required
;
465 SYSTEM_MODULE_INFORMATION
* smi
;
467 /* First check the native dlls provided. These have to be
468 from one windows version */
469 smi
= (SYSTEM_MODULE_INFORMATION
*)&count
;
470 LdrQueryProcessModuleInformation(smi
, sizeof(count
), &required
);
471 smi
= RtlAllocateHeap(ntdll_get_process_heap(), 0, required
);
474 if (LdrQueryProcessModuleInformation(smi
, required
, NULL
) == STATUS_SUCCESS
)
477 for (k
= 0; k
< smi
->ModulesCount
; k
++)
479 nt
= RtlImageNtHeader(smi
->Modules
[k
].ImageBaseAddress
);
480 ophd
= &nt
->OptionalHeader
;
482 TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
483 &smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
],
484 ophd
->MajorLinkerVersion
, ophd
->MinorLinkerVersion
,
485 ophd
->MajorOperatingSystemVersion
, ophd
->MinorOperatingSystemVersion
,
486 ophd
->MajorImageVersion
, ophd
->MinorImageVersion
,
487 ophd
->MajorSubsystemVersion
, ophd
->MinorSubsystemVersion
);
489 /* test if it is an external (native) dll */
490 if (smi
->Modules
[k
].Flags
& LDR_WINE_INTERNAL
) continue;
492 for (i
= 0; special_dlls
[i
]; i
++)
494 /* test if it is a special dll */
495 if (!strcasecmp(&smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
], special_dlls
[i
]))
497 DWORD DllVersion
= VERSION_GetSystemDLLVersion(smi
->Modules
[k
].ImageBaseAddress
);
498 if (WinVersion
== NB_WINDOWS_VERSIONS
)
499 WinVersion
= DllVersion
;
502 if (WinVersion
!= DllVersion
) {
503 ERR("You mixed system DLLs from different windows versions! Expect a crash! (%s: expected version '%s', but is '%s')\n",
504 &smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
],
505 VersionData
[WinVersion
].getVersionEx
.szCSDVersion
,
506 VersionData
[DllVersion
].getVersionEx
.szCSDVersion
);
507 return WIN20
; /* this may let the exe exiting */
515 RtlFreeHeap(ntdll_get_process_heap(), 0, smi
);
518 if(WinVersion
!= NB_WINDOWS_VERSIONS
) return WinVersion
;
520 /* we are using no external system dlls, look at the exe */
521 nt
= RtlImageNtHeader(GetModuleHandleA(NULL
));
522 ophd
= &nt
->OptionalHeader
;
524 TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
525 ophd
->MajorLinkerVersion
, ophd
->MinorLinkerVersion
,
526 ophd
->MajorOperatingSystemVersion
, ophd
->MinorOperatingSystemVersion
,
527 ophd
->MajorImageVersion
, ophd
->MinorImageVersion
,
528 ophd
->MajorSubsystemVersion
, ophd
->MinorSubsystemVersion
);
530 /* special nt 3.51 */
531 if (3 == ophd
->MajorOperatingSystemVersion
&& 51 == ophd
->MinorOperatingSystemVersion
)
536 /* the MajorSubsystemVersion is the only usable sign */
537 if (ophd
->MajorSubsystemVersion
< 4)
539 if ( ophd
->MajorOperatingSystemVersion
== 1
540 && ophd
->MinorOperatingSystemVersion
== 0)
542 return WIN31
; /* win32s */
545 if (ophd
->Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_CUI
)
546 return NT351
; /* FIXME: NT 3.1, not tested */
554 /**********************************************************************
558 * Don't call this function too early during the Wine init,
559 * as pdb->exe_modref (required by VERSION_GetImageVersion()) might still
560 * be NULL in such cases, which causes the winver to ALWAYS be detected
562 * And as we cache the winver once it has been determined, this is bad.
563 * This can happen much easier than you might think, as this function
564 * is called by EVERY GetVersion*() API !
567 static WINDOWS_VERSION
VERSION_GetVersion(void)
569 static WORD winver
= 0xffff;
571 if (versionForced
) return forcedWinVersion
; /* user has overridden any sensible checks */
573 if (winver
== 0xffff) /* to be determined */
575 WINDOWS_VERSION retver
= VERSION_GetLinkedDllVersion();
577 /* cache determined value, but do not store in case of WIN31 */
578 if (retver
!= WIN31
) winver
= retver
;
585 /***********************************************************************
586 * GetVersion (KERNEL.3)
588 LONG WINAPI
GetVersion16(void)
590 WINDOWS_VERSION ver
= VERSION_GetVersion();
591 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
592 return VersionData
[ver
].getVersion16
;
596 /***********************************************************************
597 * GetVersion (KERNEL32.@)
599 LONG WINAPI
GetVersion(void)
601 WINDOWS_VERSION ver
= VERSION_GetVersion();
602 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
603 return VersionData
[ver
].getVersion32
;
607 /***********************************************************************
608 * GetVersionEx (KERNEL.149)
610 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
612 WINDOWS_VERSION ver
= VERSION_GetVersion();
613 if (v
->dwOSVersionInfoSize
< sizeof(OSVERSIONINFO16
))
615 WARN("wrong OSVERSIONINFO size from app\n");
616 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
619 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
620 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
621 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
622 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
623 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
624 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
629 /***********************************************************************
630 * GetVersionExA (KERNEL32.@)
632 BOOL WINAPI
GetVersionExA(OSVERSIONINFOA
*v
)
634 WINDOWS_VERSION ver
= VERSION_GetVersion();
635 LPOSVERSIONINFOEXA vex
;
637 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOA
) &&
638 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXA
))
640 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
641 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOA
),
642 sizeof(OSVERSIONINFOEXA
));
643 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
646 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
647 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
648 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
649 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
650 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
651 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXA
)) {
652 vex
= (LPOSVERSIONINFOEXA
) v
;
653 vex
->wServicePackMajor
= VersionData
[ver
].getVersionEx
.wServicePackMajor
;
654 vex
->wServicePackMinor
= VersionData
[ver
].getVersionEx
.wServicePackMinor
;
655 vex
->wSuiteMask
= VersionData
[ver
].getVersionEx
.wSuiteMask
;
656 vex
->wProductType
= VersionData
[ver
].getVersionEx
.wProductType
;
658 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
663 /***********************************************************************
664 * GetVersionExW (KERNEL32.@)
666 BOOL WINAPI
GetVersionExW(OSVERSIONINFOW
*v
)
668 WINDOWS_VERSION ver
= VERSION_GetVersion();
669 LPOSVERSIONINFOEXW vex
;
671 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOW
) &&
672 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXW
))
674 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
675 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOW
),
676 sizeof(OSVERSIONINFOEXW
));
677 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
680 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
681 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
682 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
683 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
684 MultiByteToWideChar( CP_ACP
, 0, VersionData
[ver
].getVersionEx
.szCSDVersion
, -1,
685 v
->szCSDVersion
, sizeof(v
->szCSDVersion
)/sizeof(WCHAR
) );
686 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXW
)) {
687 vex
= (LPOSVERSIONINFOEXW
) v
;
688 vex
->wServicePackMajor
= VersionData
[ver
].getVersionEx
.wServicePackMajor
;
689 vex
->wServicePackMinor
= VersionData
[ver
].getVersionEx
.wServicePackMinor
;
690 vex
->wSuiteMask
= VersionData
[ver
].getVersionEx
.wSuiteMask
;
691 vex
->wProductType
= VersionData
[ver
].getVersionEx
.wProductType
;
693 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
698 /******************************************************************************
699 * VerifyVersionInfoA (KERNEL32.@)
701 BOOL WINAPI
VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo
, DWORD dwTypeMask
,
702 DWORDLONG dwlConditionMask
)
704 OSVERSIONINFOEXW verW
;
706 verW
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
707 verW
.dwMajorVersion
= lpVersionInfo
->dwMajorVersion
;
708 verW
.dwMinorVersion
= lpVersionInfo
->dwMinorVersion
;
709 verW
.dwBuildNumber
= lpVersionInfo
->dwBuildNumber
;
710 verW
.dwPlatformId
= lpVersionInfo
->dwPlatformId
;
711 verW
.wServicePackMajor
= lpVersionInfo
->wServicePackMajor
;
712 verW
.wServicePackMinor
= lpVersionInfo
->wServicePackMinor
;
713 verW
.wSuiteMask
= lpVersionInfo
->wSuiteMask
;
714 verW
.wProductType
= lpVersionInfo
->wProductType
;
715 verW
.wReserved
= lpVersionInfo
->wReserved
;
717 return VerifyVersionInfoW(&verW
, dwTypeMask
, dwlConditionMask
);
721 /******************************************************************************
722 * VerifyVersionInfoW (KERNEL32.@)
724 BOOL WINAPI
VerifyVersionInfoW( LPOSVERSIONINFOEXW lpVersionInfo
, DWORD dwTypeMask
,
725 DWORDLONG dwlConditionMask
)
727 OSVERSIONINFOEXW ver
;
730 FIXME("(%p,%lu,%llx): Not all cases correctly implemented yet\n", lpVersionInfo
, dwTypeMask
, dwlConditionMask
);
732 - Check the following special case on Windows (various versions):
733 o lp->wSuiteMask == 0 and ver.wSuiteMask != 0 and VER_AND/VER_OR
734 o lp->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)
735 - MSDN talks about some tests being impossible. Check what really happens.
738 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
739 if(!GetVersionExW((LPOSVERSIONINFOW
) &ver
))
744 if(!(dwTypeMask
&& dwlConditionMask
)) {
746 SetLastError(ERROR_BAD_ARGUMENTS
);
749 if(dwTypeMask
& VER_PRODUCT_TYPE
)
750 switch(dwlConditionMask
>> 7*3 & 0x07) {
752 if(ver
.wProductType
!= lpVersionInfo
->wProductType
)
756 if(ver
.wProductType
<= lpVersionInfo
->wProductType
)
759 case VER_GREATER_EQUAL
:
760 if(ver
.wProductType
< lpVersionInfo
->wProductType
)
764 if(ver
.wProductType
>= lpVersionInfo
->wProductType
)
768 if(ver
.wProductType
> lpVersionInfo
->wProductType
)
773 SetLastError(ERROR_BAD_ARGUMENTS
);
776 if(dwTypeMask
& VER_SUITENAME
&& res
)
777 switch(dwlConditionMask
>> 6*3 & 0x07) {
779 if((lpVersionInfo
->wSuiteMask
& ver
.wSuiteMask
) != lpVersionInfo
->wSuiteMask
)
783 if(!(lpVersionInfo
->wSuiteMask
& ver
.wSuiteMask
) && lpVersionInfo
->wSuiteMask
)
788 SetLastError(ERROR_BAD_ARGUMENTS
);
791 if(dwTypeMask
& VER_PLATFORMID
&& res
)
792 switch(dwlConditionMask
>> 3*3 & 0x07) {
794 if(ver
.dwPlatformId
!= lpVersionInfo
->dwPlatformId
)
798 if(ver
.dwPlatformId
<= lpVersionInfo
->dwPlatformId
)
801 case VER_GREATER_EQUAL
:
802 if(ver
.dwPlatformId
< lpVersionInfo
->dwPlatformId
)
806 if(ver
.dwPlatformId
>= lpVersionInfo
->dwPlatformId
)
810 if(ver
.dwPlatformId
> lpVersionInfo
->dwPlatformId
)
815 SetLastError(ERROR_BAD_ARGUMENTS
);
818 if(dwTypeMask
& VER_BUILDNUMBER
&& res
)
819 switch(dwlConditionMask
>> 2*3 & 0x07) {
821 if(ver
.dwBuildNumber
!= lpVersionInfo
->dwBuildNumber
)
825 if(ver
.dwBuildNumber
<= lpVersionInfo
->dwBuildNumber
)
828 case VER_GREATER_EQUAL
:
829 if(ver
.dwBuildNumber
< lpVersionInfo
->dwBuildNumber
)
833 if(ver
.dwBuildNumber
>= lpVersionInfo
->dwBuildNumber
)
837 if(ver
.dwBuildNumber
> lpVersionInfo
->dwBuildNumber
)
842 SetLastError(ERROR_BAD_ARGUMENTS
);
845 if(dwTypeMask
& VER_MAJORVERSION
&& res
)
846 switch(dwlConditionMask
>> 1*3 & 0x07) {
848 if(ver
.dwMajorVersion
!= lpVersionInfo
->dwMajorVersion
)
852 if(ver
.dwMajorVersion
<= lpVersionInfo
->dwMajorVersion
)
855 case VER_GREATER_EQUAL
:
856 if(ver
.dwMajorVersion
< lpVersionInfo
->dwMajorVersion
)
860 if(ver
.dwMajorVersion
>= lpVersionInfo
->dwMajorVersion
)
864 if(ver
.dwMajorVersion
> lpVersionInfo
->dwMajorVersion
)
869 SetLastError(ERROR_BAD_ARGUMENTS
);
872 if(dwTypeMask
& VER_MINORVERSION
&& res
)
873 switch(dwlConditionMask
>> 0*3 & 0x07) {
875 if(ver
.dwMinorVersion
!= lpVersionInfo
->dwMinorVersion
)
879 if(ver
.dwMinorVersion
<= lpVersionInfo
->dwMinorVersion
)
882 case VER_GREATER_EQUAL
:
883 if(ver
.dwMinorVersion
< lpVersionInfo
->dwMinorVersion
)
887 if(ver
.dwMinorVersion
>= lpVersionInfo
->dwMinorVersion
)
891 if(ver
.dwMinorVersion
> lpVersionInfo
->dwMinorVersion
)
896 SetLastError(ERROR_BAD_ARGUMENTS
);
899 if(dwTypeMask
& VER_SERVICEPACKMAJOR
&& res
)
900 switch(dwlConditionMask
>> 5*3 & 0x07) {
902 if(ver
.wServicePackMajor
!= lpVersionInfo
->wServicePackMajor
)
906 if(ver
.wServicePackMajor
<= lpVersionInfo
->wServicePackMajor
)
909 case VER_GREATER_EQUAL
:
910 if(ver
.wServicePackMajor
< lpVersionInfo
->wServicePackMajor
)
914 if(ver
.wServicePackMajor
>= lpVersionInfo
->wServicePackMajor
)
918 if(ver
.wServicePackMajor
> lpVersionInfo
->wServicePackMajor
)
923 SetLastError(ERROR_BAD_ARGUMENTS
);
926 if(dwTypeMask
& VER_SERVICEPACKMINOR
&& res
)
927 switch(dwlConditionMask
>> 4*3 & 0x07) {
929 if(ver
.wServicePackMinor
!= lpVersionInfo
->wServicePackMinor
)
933 if(ver
.wServicePackMinor
<= lpVersionInfo
->wServicePackMinor
)
936 case VER_GREATER_EQUAL
:
937 if(ver
.wServicePackMinor
< lpVersionInfo
->wServicePackMinor
)
941 if(ver
.wServicePackMinor
>= lpVersionInfo
->wServicePackMinor
)
945 if(ver
.wServicePackMinor
> lpVersionInfo
->wServicePackMinor
)
950 SetLastError(ERROR_BAD_ARGUMENTS
);
954 if(!(res
|| error_set
))
955 SetLastError(ERROR_OLD_WIN_VERSION
);
960 /***********************************************************************
961 * GetWinFlags (KERNEL.132)
963 DWORD WINAPI
GetWinFlags16(void)
965 static const long cpuflags
[5] =
966 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
973 /* There doesn't seem to be any Pentium flag. */
974 result
= cpuflags
[min(si
.wProcessorLevel
, 4)] | WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
975 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
976 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
978 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
979 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
985 /* Not used at this time. This is here for documentation only */
987 /* WINDEBUGINFO flags values */
988 #define WDI_OPTIONS 0x0001
989 #define WDI_FILTER 0x0002
990 #define WDI_ALLOCBREAK 0x0004
992 /* dwOptions values */
993 #define DBO_CHECKHEAP 0x0001
994 #define DBO_BUFFERFILL 0x0004
995 #define DBO_DISABLEGPTRAPPING 0x0010
996 #define DBO_CHECKFREE 0x0020
998 #define DBO_SILENT 0x8000
1000 #define DBO_TRACEBREAK 0x2000
1001 #define DBO_WARNINGBREAK 0x1000
1002 #define DBO_NOERRORBREAK 0x0800
1003 #define DBO_NOFATALBREAK 0x0400
1004 #define DBO_INT3BREAK 0x0100
1006 /* DebugOutput flags values */
1007 #define DBF_TRACE 0x0000
1008 #define DBF_WARNING 0x4000
1009 #define DBF_ERROR 0x8000
1010 #define DBF_FATAL 0xc000
1012 /* dwFilter values */
1013 #define DBF_KERNEL 0x1000
1014 #define DBF_KRN_MEMMAN 0x0001
1015 #define DBF_KRN_LOADMODULE 0x0002
1016 #define DBF_KRN_SEGMENTLOAD 0x0004
1017 #define DBF_USER 0x0800
1018 #define DBF_GDI 0x0400
1019 #define DBF_MMSYSTEM 0x0040
1020 #define DBF_PENWIN 0x0020
1021 #define DBF_APPLICATION 0x0008
1022 #define DBF_DRIVER 0x0010
1024 #endif /* NOLOGERROR */
1027 /***********************************************************************
1028 * GetWinDebugInfo (KERNEL.355)
1030 BOOL16 WINAPI
GetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
, UINT16 flags
)
1032 FIXME("(%8lx,%d): stub returning 0\n",
1033 (unsigned long)lpwdi
, flags
);
1034 /* 0 means not in debugging mode/version */
1035 /* Can this type of debugging be used in wine ? */
1036 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1041 /***********************************************************************
1042 * SetWinDebugInfo (KERNEL.356)
1044 BOOL16 WINAPI
SetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
)
1046 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
1047 /* 0 means not in debugging mode/version */
1048 /* Can this type of debugging be used in wine ? */
1049 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1054 /***********************************************************************
1058 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
1060 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
1062 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
1065 /***********************************************************************
1066 * DiagQuery (KERNEL.339)
1068 * returns TRUE if Win called with "/b" (bootlog.txt)
1070 BOOL16 WINAPI
DiagQuery16(void)
1072 /* perhaps implement a Wine "/b" command line flag sometime ? */
1076 /***********************************************************************
1077 * DiagOutput (KERNEL.340)
1079 * writes a debug string into <windir>\bootlog.txt
1081 void WINAPI
DiagOutput16(LPCSTR str
)
1084 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str
));