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"
39 #include "wine/winbase16.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
43 #include "ntdll_misc.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
49 WIN20
, /* Windows 2.0 */
50 WIN30
, /* Windows 3.0 */
51 WIN31
, /* Windows 3.1 */
52 WIN95
, /* Windows 95 */
53 WIN98
, /* Windows 98 */
54 WINME
, /* Windows Me */
55 NT351
, /* Windows NT 3.51 */
56 NT40
, /* Windows NT 4.0 */
57 NT2K
, /* Windows 2000 */
58 WINXP
, /* Windows XP */
59 WIN2K3
, /* Windows 2003 */
65 char human_readable
[32];
68 OSVERSIONINFOEXA getVersionEx
;
71 /* FIXME: compare values below with original and fix.
72 * An *excellent* win9x version page (ALL versions !)
73 * can be found at members.aol.com/axcel216/ver.htm */
74 static VERSION_DATA VersionData
[NB_WINDOWS_VERSIONS
] =
76 /* WIN20 FIXME: verify values */
79 MAKELONG( 0x0002, 0x0303 ), /* assume DOS 3.3 */
80 MAKELONG( 0x0002, 0x8000 ),
82 /* yes, sizeof(OSVERSIONINFOA) is correct here
83 * (in case of OSVERSIONINFOEXA application request,
84 * we adapt it dynamically). */
85 sizeof(OSVERSIONINFOA
), 2, 0, 0,
86 VER_PLATFORM_WIN32s
, "Win32s 1.3",
90 /* WIN30 FIXME: verify values */
93 MAKELONG( 0x0003, 0x0500 ), /* assume DOS 5.00 */
94 MAKELONG( 0x0003, 0x8000 ),
96 sizeof(OSVERSIONINFOA
), 3, 0, 0,
97 VER_PLATFORM_WIN32s
, "Win32s 1.3",
104 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
105 MAKELONG( 0x0a03, 0x8000 ),
107 sizeof(OSVERSIONINFOA
), 3, 10, 0,
108 VER_PLATFORM_WIN32s
, "Win32s 1.3",
118 /* Win95: 4, 0, 0x40003B6, ""
119 * Win95sp1: 4, 0, 0x40003B6, " A " (according to doc)
120 * Win95osr2: 4, 0, 0x4000457, " B " (according to doc)
121 * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
122 * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
123 * Win95a/b can be discerned via regkey SubVersionNumber
125 * http://support.microsoft.com/support/kb/articles/q158/2/38.asp
127 sizeof(OSVERSIONINFOA
), 4, 0, 0x40003B6,
128 VER_PLATFORM_WIN32_WINDOWS
, "",
132 /* WIN98 (second edition) */
138 /* Win98: 4, 10, 0x40A07CE, " " 4.10.1998
139 * Win98SE: 4, 10, 0x40A08AE, " A " 4.10.2222
141 sizeof(OSVERSIONINFOA
), 4, 10, 0x40A08AE,
142 VER_PLATFORM_WIN32_WINDOWS
, " A ",
152 sizeof(OSVERSIONINFOA
), 4, 90, 0x45A0BB8,
153 VER_PLATFORM_WIN32_WINDOWS
, " ",
163 sizeof(OSVERSIONINFOA
), 3, 51, 0x421,
164 VER_PLATFORM_WIN32_NT
, "Service Pack 2",
174 sizeof(OSVERSIONINFOA
), 4, 0, 0x565,
175 VER_PLATFORM_WIN32_NT
, "Service Pack 6",
176 6, 0, 0, VER_NT_WORKSTATION
, 0
185 sizeof(OSVERSIONINFOA
), 5, 0, 0x893,
186 VER_PLATFORM_WIN32_NT
, "Service Pack 3",
187 3, 0, 0, VER_NT_WORKSTATION
, 30 /* FIXME: Great, a reserved field with a value! */
193 0x05005F03, /* Assuming DOS 5 like the other NT */
196 sizeof(OSVERSIONINFOA
), 5, 1, 0xA28,
197 VER_PLATFORM_WIN32_NT
, "Service Pack 1",
198 1, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_WORKSTATION
, 30 /* FIXME: Great, a reserved field with a value! */
204 0x05005F03, /* Assuming DOS 5 like the other NT */
207 sizeof(OSVERSIONINFOA
), 5, 2, 0xECE,
208 VER_PLATFORM_WIN32_NT
, "",
209 0, 0, VER_SUITE_SINGLEUSERTS
, VER_NT_SERVER
, 0
214 static const char *WinVersionNames
[NB_WINDOWS_VERSIONS
] =
215 { /* no spaces in here ! */
224 "win2000,win2k,nt2k,nt2000",
229 /* if one of the following dlls is importing ntdll the windows
230 version autodetection switches wine to unicode (nt 3.51 or 4.0) */
231 static char * special_dlls
[] =
241 /* the current version has not been autodetected but forced via cmdline */
242 static BOOL versionForced
= FALSE
;
243 static WINDOWS_VERSION forcedWinVersion
= WIN31
; /* init value irrelevant */
245 /**********************************************************************
246 * VERSION_ParseWinVersion
248 static void VERSION_ParseWinVersion( const char *arg
)
251 const char *pCurr
, *p
;
252 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
254 pCurr
= WinVersionNames
[i
];
255 /* iterate through all winver aliases separated by comma */
257 p
= strchr(pCurr
, ',');
258 len
= p
? (int)p
- (int)pCurr
: strlen(pCurr
);
259 if ( (!strncmp( pCurr
, arg
, len
)) && (arg
[len
] == '\0') )
261 forcedWinVersion
= (WINDOWS_VERSION
)i
;
262 versionForced
= TRUE
;
268 MESSAGE("Invalid Windows version value '%s' specified in config file.\n", arg
);
269 MESSAGE("Valid versions are:" );
270 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
272 /* only list the first, "official" alias in case of aliases */
273 pCurr
= WinVersionNames
[i
];
274 p
= strchr(pCurr
, ',');
275 len
= (p
) ? (int)p
- (int)pCurr
: strlen(pCurr
);
277 MESSAGE(" '%.*s'%c", len
, pCurr
,
278 (i
== NB_WINDOWS_VERSIONS
- 1) ? '\n' : ',' );
284 /**********************************************************************
285 * VERSION_ParseDosVersion
287 static void VERSION_ParseDosVersion( const char *arg
)
290 if (sscanf( arg
, "%d.%d", &hi
, &lo
) == 2)
292 VersionData
[WIN31
].getVersion16
=
293 MAKELONG(LOWORD(VersionData
[WIN31
].getVersion16
),
298 MESSAGE("Wrong format for DOS version in config file. Use \"x.xx\"\n");
304 /**********************************************************************
305 * VERSION_ParseVersion
307 * Parse the contents of the Version key.
309 static void VERSION_ParseVersion( HKEY hkey
, BOOL
*got_win_ver
, BOOL
*got_dos_ver
)
311 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
312 static const WCHAR DosW
[] = {'D','O','S',0};
314 UNICODE_STRING valueW
;
315 char tmp
[64], buffer
[50];
316 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)tmp
;
321 RtlInitUnicodeString( &valueW
, WindowsW
);
322 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
324 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
,
325 (WCHAR
*)info
->Data
, info
->DataLength
);
327 VERSION_ParseWinVersion( buffer
);
328 TRACE( "got win version %s\n", WinVersionNames
[forcedWinVersion
] );
334 RtlInitUnicodeString( &valueW
, DosW
);
335 if (!NtQueryValueKey( hkey
, &valueW
, KeyValuePartialInformation
, tmp
, sizeof(tmp
), &count
))
337 RtlUnicodeToMultiByteN( buffer
, sizeof(buffer
)-1, &len
,
338 (WCHAR
*)info
->Data
, info
->DataLength
);
340 VERSION_ParseDosVersion( buffer
);
341 TRACE( "got dos version %lx\n", VersionData
[WIN31
].getVersion16
);
348 /**********************************************************************
351 void VERSION_Init( const char *appname
)
353 OBJECT_ATTRIBUTES attr
;
354 UNICODE_STRING nameW
;
355 HKEY hkey
, config_key
;
356 BOOL got_win_ver
= FALSE
, got_dos_ver
= FALSE
;
357 static const WCHAR configW
[] = {'M','a','c','h','i','n','e','\\',
358 'S','o','f','t','w','a','r','e','\\',
359 'W','i','n','e','\\',
360 'W','i','n','e','\\',
361 'C','o','n','f','i','g',0};
362 static const WCHAR appdefaultsW
[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
363 static const WCHAR versionW
[] = {'\\','V','e','r','s','i','o','n',0};
365 attr
.Length
= sizeof(attr
);
366 attr
.RootDirectory
= 0;
367 attr
.ObjectName
= &nameW
;
369 attr
.SecurityDescriptor
= NULL
;
370 attr
.SecurityQualityOfService
= NULL
;
371 RtlInitUnicodeString( &nameW
, configW
);
373 if (NtOpenKey( &config_key
, KEY_ALL_ACCESS
, &attr
)) return;
374 attr
.RootDirectory
= config_key
;
376 /* open AppDefaults\\appname\\Version key */
377 if (appname
&& *appname
)
381 WCHAR appversion
[MAX_PATH
+20];
383 if ((p
= strrchr( appname
, '/' ))) appname
= p
+ 1;
384 if ((p
= strrchr( appname
, '\\' ))) appname
= p
+ 1;
386 strcpyW( appversion
, appdefaultsW
);
387 len
= strlenW(appversion
);
388 RtlMultiByteToUnicodeN( appversion
+ len
, sizeof(appversion
) - len
*sizeof(WCHAR
),
389 &len
, appname
, strlen(appname
)+1 );
390 strcatW( appversion
, versionW
);
391 TRACE( "getting version from %s\n", debugstr_w(appversion
) );
392 RtlInitUnicodeString( &nameW
, appversion
);
394 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
396 VERSION_ParseVersion( hkey
, &got_win_ver
, &got_dos_ver
);
399 if (got_win_ver
&& got_dos_ver
) goto done
;
402 TRACE( "getting default version\n" );
403 RtlInitUnicodeString( &nameW
, versionW
+ 1 );
404 if (!NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
))
406 VERSION_ParseVersion( hkey
, &got_win_ver
, &got_dos_ver
);
411 NtClose( config_key
);
415 /**********************************************************************
416 * VERSION_GetSystemDLLVersion
418 * This function tries to figure out if a given (native) dll comes from
419 * win95/98 or winnt. Since all values in the OptionalHeader are not a
420 * usable hint, we test if a dll imports the ntdll.
421 * This is at least working for all system dlls like comctl32, comdlg32 and
423 * If you have a better idea to figure this out...
425 static DWORD
VERSION_GetSystemDLLVersion( HMODULE hmod
)
428 IMAGE_IMPORT_DESCRIPTOR
*pe_imp
;
430 if ((pe_imp
= RtlImageDirectoryEntryToData( hmod
, TRUE
, IMAGE_DIRECTORY_ENTRY_IMPORT
, &size
)))
432 for ( ; pe_imp
->Name
; pe_imp
++)
434 char * name
= (char *)hmod
+ (unsigned int)pe_imp
->Name
;
437 if (!strncasecmp(name
, "ntdll", 5))
439 switch(RtlImageNtHeader(hmod
)->OptionalHeader
.MajorOperatingSystemVersion
) {
441 MESSAGE("WARNING: very old native DLL (NT 3.x) used, might cause instability.\n");
445 case 6: return WINXP
;
446 case 7: return WIN2K3
; /* FIXME: Not sure, should be verified with a Win2K3 dll */
448 FIXME("Unknown DLL OS version, please report !!\n");
456 /**********************************************************************
457 * VERSION_GetLinkedDllVersion
459 * Some version data (not reliable!):
460 * linker/OS/image/subsys
462 * x.xx/1.00/0.00/3.10 Win32s (any version ?)
463 * 2.39/1.00/0.00/3.10 Win32s freecell.exe (any version)
464 * 2.50/1.00/4.00/4.00 Win32s 1.30 winhlp32.exe
465 * 2.60/3.51/3.51/3.51 NT351SP5 system dlls
466 * 2.60/3.51/3.51/4.00 NT351SP5 comctl32 dll
467 * 2.xx/1.00/0.00/4.00 Win95 system files
468 * x.xx/4.00/0.00/4.00 Win95 most applications
469 * 3.10/4.00/0.00/4.00 Win98 notepad
470 * x.xx/5.00/5.00/4.00 Win98 system dlls (e.g. comctl32.dll)
471 * x.xx/4.00/4.00/4.00 NT 4 most apps
472 * 5.12/5.00/5.00/4.00 NT4+IE5 comctl32.dll
473 * 5.12/5.00/5.00/4.00 Win98 calc
474 * x.xx/5.00/5.00/4.00 win95/win98/NT4 IE5 files
476 static DWORD
VERSION_GetLinkedDllVersion(void)
478 DWORD WinVersion
= NB_WINDOWS_VERSIONS
;
479 PIMAGE_OPTIONAL_HEADER ophd
;
480 IMAGE_NT_HEADERS
*nt
;
481 ULONG count
, required
;
482 SYSTEM_MODULE_INFORMATION
* smi
;
484 /* First check the native dlls provided. These have to be
485 from one windows version */
486 smi
= (SYSTEM_MODULE_INFORMATION
*)&count
;
487 LdrQueryProcessModuleInformation(smi
, sizeof(count
), &required
);
488 smi
= RtlAllocateHeap(ntdll_get_process_heap(), 0, required
);
491 if (LdrQueryProcessModuleInformation(smi
, required
, NULL
) == STATUS_SUCCESS
)
494 for (k
= 0; k
< smi
->ModulesCount
; k
++)
496 nt
= RtlImageNtHeader(smi
->Modules
[k
].ImageBaseAddress
);
497 ophd
= &nt
->OptionalHeader
;
499 TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
500 &smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
],
501 ophd
->MajorLinkerVersion
, ophd
->MinorLinkerVersion
,
502 ophd
->MajorOperatingSystemVersion
, ophd
->MinorOperatingSystemVersion
,
503 ophd
->MajorImageVersion
, ophd
->MinorImageVersion
,
504 ophd
->MajorSubsystemVersion
, ophd
->MinorSubsystemVersion
);
506 /* test if it is an external (native) dll */
507 if (smi
->Modules
[k
].Flags
& LDR_WINE_INTERNAL
) continue;
509 for (i
= 0; special_dlls
[i
]; i
++)
511 /* test if it is a special dll */
512 if (!strcasecmp(&smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
], special_dlls
[i
]))
514 DWORD DllVersion
= VERSION_GetSystemDLLVersion(smi
->Modules
[k
].ImageBaseAddress
);
515 if (WinVersion
== NB_WINDOWS_VERSIONS
)
516 WinVersion
= DllVersion
;
519 if (WinVersion
!= DllVersion
) {
520 ERR("You mixed system DLLs from different windows versions! Expect a crash! (%s: expected version '%s', but is '%s')\n",
521 &smi
->Modules
[k
].Name
[smi
->Modules
[k
].NameOffset
],
522 VersionData
[WinVersion
].getVersionEx
.szCSDVersion
,
523 VersionData
[DllVersion
].getVersionEx
.szCSDVersion
);
524 return WIN20
; /* this may let the exe exiting */
532 RtlFreeHeap(ntdll_get_process_heap(), 0, smi
);
535 if(WinVersion
!= NB_WINDOWS_VERSIONS
) return WinVersion
;
537 /* we are using no external system dlls, look at the exe */
538 nt
= RtlImageNtHeader(GetModuleHandleA(NULL
));
539 ophd
= &nt
->OptionalHeader
;
541 TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
542 ophd
->MajorLinkerVersion
, ophd
->MinorLinkerVersion
,
543 ophd
->MajorOperatingSystemVersion
, ophd
->MinorOperatingSystemVersion
,
544 ophd
->MajorImageVersion
, ophd
->MinorImageVersion
,
545 ophd
->MajorSubsystemVersion
, ophd
->MinorSubsystemVersion
);
547 /* special nt 3.51 */
548 if (3 == ophd
->MajorOperatingSystemVersion
&& 51 == ophd
->MinorOperatingSystemVersion
)
553 /* the MajorSubsystemVersion is the only usable sign */
554 if (ophd
->MajorSubsystemVersion
< 4)
556 if ( ophd
->MajorOperatingSystemVersion
== 1
557 && ophd
->MinorOperatingSystemVersion
== 0)
559 return WIN31
; /* win32s */
562 if (ophd
->Subsystem
== IMAGE_SUBSYSTEM_WINDOWS_CUI
)
563 return NT351
; /* FIXME: NT 3.1, not tested */
571 /**********************************************************************
575 * Don't call this function too early during the Wine init,
576 * as pdb->exe_modref (required by VERSION_GetImageVersion()) might still
577 * be NULL in such cases, which causes the winver to ALWAYS be detected
579 * And as we cache the winver once it has been determined, this is bad.
580 * This can happen much easier than you might think, as this function
581 * is called by EVERY GetVersion*() API !
584 static WINDOWS_VERSION
VERSION_GetVersion(void)
586 static WORD winver
= 0xffff;
588 if (versionForced
) return forcedWinVersion
; /* user has overridden any sensible checks */
590 if (winver
== 0xffff) /* to be determined */
592 WINDOWS_VERSION retver
= VERSION_GetLinkedDllVersion();
594 /* cache determined value, but do not store in case of WIN31 */
595 if (retver
!= WIN31
) winver
= retver
;
602 /***********************************************************************
603 * GetVersion (KERNEL.3)
605 LONG WINAPI
GetVersion16(void)
607 WINDOWS_VERSION ver
= VERSION_GetVersion();
608 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
609 return VersionData
[ver
].getVersion16
;
613 /***********************************************************************
614 * GetVersion (KERNEL32.@)
616 LONG WINAPI
GetVersion(void)
618 WINDOWS_VERSION ver
= VERSION_GetVersion();
619 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
620 return VersionData
[ver
].getVersion32
;
624 /***********************************************************************
625 * GetVersionEx (KERNEL.149)
627 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
629 WINDOWS_VERSION ver
= VERSION_GetVersion();
630 if (v
->dwOSVersionInfoSize
< sizeof(OSVERSIONINFO16
))
632 WARN("wrong OSVERSIONINFO size from app\n");
633 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
636 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
637 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
638 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
639 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
640 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
641 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
646 /***********************************************************************
647 * GetVersionExA (KERNEL32.@)
649 BOOL WINAPI
GetVersionExA(OSVERSIONINFOA
*v
)
651 WINDOWS_VERSION ver
= VERSION_GetVersion();
652 LPOSVERSIONINFOEXA vex
;
654 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOA
) &&
655 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXA
))
657 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
658 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOA
),
659 sizeof(OSVERSIONINFOEXA
));
660 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
663 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
664 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
665 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
666 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
667 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
668 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXA
)) {
669 vex
= (LPOSVERSIONINFOEXA
) v
;
670 vex
->wServicePackMajor
= VersionData
[ver
].getVersionEx
.wServicePackMajor
;
671 vex
->wServicePackMinor
= VersionData
[ver
].getVersionEx
.wServicePackMinor
;
672 vex
->wSuiteMask
= VersionData
[ver
].getVersionEx
.wSuiteMask
;
673 vex
->wProductType
= VersionData
[ver
].getVersionEx
.wProductType
;
675 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
680 /***********************************************************************
681 * GetVersionExW (KERNEL32.@)
683 BOOL WINAPI
GetVersionExW(OSVERSIONINFOW
*v
)
685 WINDOWS_VERSION ver
= VERSION_GetVersion();
686 LPOSVERSIONINFOEXW vex
;
688 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOW
) &&
689 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXW
))
691 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
692 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOW
),
693 sizeof(OSVERSIONINFOEXW
));
694 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
697 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
698 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
699 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
700 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
701 MultiByteToWideChar( CP_ACP
, 0, VersionData
[ver
].getVersionEx
.szCSDVersion
, -1,
702 v
->szCSDVersion
, sizeof(v
->szCSDVersion
)/sizeof(WCHAR
) );
703 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXW
)) {
704 vex
= (LPOSVERSIONINFOEXW
) v
;
705 vex
->wServicePackMajor
= VersionData
[ver
].getVersionEx
.wServicePackMajor
;
706 vex
->wServicePackMinor
= VersionData
[ver
].getVersionEx
.wServicePackMinor
;
707 vex
->wSuiteMask
= VersionData
[ver
].getVersionEx
.wSuiteMask
;
708 vex
->wProductType
= VersionData
[ver
].getVersionEx
.wProductType
;
710 TRACE("<-- %s (%s)\n", VersionData
[ver
].human_readable
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
715 /******************************************************************************
716 * VerifyVersionInfoA (KERNEL32.@)
718 BOOL WINAPI
VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo
, DWORD dwTypeMask
,
719 DWORDLONG dwlConditionMask
)
721 OSVERSIONINFOEXW verW
;
723 verW
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
724 verW
.dwMajorVersion
= lpVersionInfo
->dwMajorVersion
;
725 verW
.dwMinorVersion
= lpVersionInfo
->dwMinorVersion
;
726 verW
.dwBuildNumber
= lpVersionInfo
->dwBuildNumber
;
727 verW
.dwPlatformId
= lpVersionInfo
->dwPlatformId
;
728 verW
.wServicePackMajor
= lpVersionInfo
->wServicePackMajor
;
729 verW
.wServicePackMinor
= lpVersionInfo
->wServicePackMinor
;
730 verW
.wSuiteMask
= lpVersionInfo
->wSuiteMask
;
731 verW
.wProductType
= lpVersionInfo
->wProductType
;
732 verW
.wReserved
= lpVersionInfo
->wReserved
;
734 return VerifyVersionInfoW(&verW
, dwTypeMask
, dwlConditionMask
);
738 /******************************************************************************
739 * VerifyVersionInfoW (KERNEL32.@)
741 BOOL WINAPI
VerifyVersionInfoW( LPOSVERSIONINFOEXW lpVersionInfo
, DWORD dwTypeMask
,
742 DWORDLONG dwlConditionMask
)
744 OSVERSIONINFOEXW ver
;
747 FIXME("(%p,%lu,%llx): Not all cases correctly implemented yet\n", lpVersionInfo
, dwTypeMask
, dwlConditionMask
);
749 - Check the following special case on Windows (various versions):
750 o lp->wSuiteMask == 0 and ver.wSuiteMask != 0 and VER_AND/VER_OR
751 o lp->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)
752 - MSDN talks about some tests being impossible. Check what really happens.
755 ver
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
756 if(!GetVersionExW((LPOSVERSIONINFOW
) &ver
))
761 if(!(dwTypeMask
&& dwlConditionMask
)) {
763 SetLastError(ERROR_BAD_ARGUMENTS
);
766 if(dwTypeMask
& VER_PRODUCT_TYPE
)
767 switch(dwlConditionMask
>> 7*3 & 0x07) {
769 if(ver
.wProductType
!= lpVersionInfo
->wProductType
)
773 if(ver
.wProductType
<= lpVersionInfo
->wProductType
)
776 case VER_GREATER_EQUAL
:
777 if(ver
.wProductType
< lpVersionInfo
->wProductType
)
781 if(ver
.wProductType
>= lpVersionInfo
->wProductType
)
785 if(ver
.wProductType
> lpVersionInfo
->wProductType
)
790 SetLastError(ERROR_BAD_ARGUMENTS
);
793 if(dwTypeMask
& VER_SUITENAME
&& res
)
794 switch(dwlConditionMask
>> 6*3 & 0x07) {
796 if((lpVersionInfo
->wSuiteMask
& ver
.wSuiteMask
) != lpVersionInfo
->wSuiteMask
)
800 if(!(lpVersionInfo
->wSuiteMask
& ver
.wSuiteMask
) && lpVersionInfo
->wSuiteMask
)
805 SetLastError(ERROR_BAD_ARGUMENTS
);
808 if(dwTypeMask
& VER_PLATFORMID
&& res
)
809 switch(dwlConditionMask
>> 3*3 & 0x07) {
811 if(ver
.dwPlatformId
!= lpVersionInfo
->dwPlatformId
)
815 if(ver
.dwPlatformId
<= lpVersionInfo
->dwPlatformId
)
818 case VER_GREATER_EQUAL
:
819 if(ver
.dwPlatformId
< lpVersionInfo
->dwPlatformId
)
823 if(ver
.dwPlatformId
>= lpVersionInfo
->dwPlatformId
)
827 if(ver
.dwPlatformId
> lpVersionInfo
->dwPlatformId
)
832 SetLastError(ERROR_BAD_ARGUMENTS
);
835 if(dwTypeMask
& VER_BUILDNUMBER
&& res
)
836 switch(dwlConditionMask
>> 2*3 & 0x07) {
838 if(ver
.dwBuildNumber
!= lpVersionInfo
->dwBuildNumber
)
842 if(ver
.dwBuildNumber
<= lpVersionInfo
->dwBuildNumber
)
845 case VER_GREATER_EQUAL
:
846 if(ver
.dwBuildNumber
< lpVersionInfo
->dwBuildNumber
)
850 if(ver
.dwBuildNumber
>= lpVersionInfo
->dwBuildNumber
)
854 if(ver
.dwBuildNumber
> lpVersionInfo
->dwBuildNumber
)
859 SetLastError(ERROR_BAD_ARGUMENTS
);
862 if(dwTypeMask
& VER_MAJORVERSION
&& res
)
863 switch(dwlConditionMask
>> 1*3 & 0x07) {
865 if(ver
.dwMajorVersion
!= lpVersionInfo
->dwMajorVersion
)
869 if(ver
.dwMajorVersion
<= lpVersionInfo
->dwMajorVersion
)
872 case VER_GREATER_EQUAL
:
873 if(ver
.dwMajorVersion
< lpVersionInfo
->dwMajorVersion
)
877 if(ver
.dwMajorVersion
>= lpVersionInfo
->dwMajorVersion
)
881 if(ver
.dwMajorVersion
> lpVersionInfo
->dwMajorVersion
)
886 SetLastError(ERROR_BAD_ARGUMENTS
);
889 if(dwTypeMask
& VER_MINORVERSION
&& res
)
890 switch(dwlConditionMask
>> 0*3 & 0x07) {
892 if(ver
.dwMinorVersion
!= lpVersionInfo
->dwMinorVersion
)
896 if(ver
.dwMinorVersion
<= lpVersionInfo
->dwMinorVersion
)
899 case VER_GREATER_EQUAL
:
900 if(ver
.dwMinorVersion
< lpVersionInfo
->dwMinorVersion
)
904 if(ver
.dwMinorVersion
>= lpVersionInfo
->dwMinorVersion
)
908 if(ver
.dwMinorVersion
> lpVersionInfo
->dwMinorVersion
)
913 SetLastError(ERROR_BAD_ARGUMENTS
);
916 if(dwTypeMask
& VER_SERVICEPACKMAJOR
&& res
)
917 switch(dwlConditionMask
>> 5*3 & 0x07) {
919 if(ver
.wServicePackMajor
!= lpVersionInfo
->wServicePackMajor
)
923 if(ver
.wServicePackMajor
<= lpVersionInfo
->wServicePackMajor
)
926 case VER_GREATER_EQUAL
:
927 if(ver
.wServicePackMajor
< lpVersionInfo
->wServicePackMajor
)
931 if(ver
.wServicePackMajor
>= lpVersionInfo
->wServicePackMajor
)
935 if(ver
.wServicePackMajor
> lpVersionInfo
->wServicePackMajor
)
940 SetLastError(ERROR_BAD_ARGUMENTS
);
943 if(dwTypeMask
& VER_SERVICEPACKMINOR
&& res
)
944 switch(dwlConditionMask
>> 4*3 & 0x07) {
946 if(ver
.wServicePackMinor
!= lpVersionInfo
->wServicePackMinor
)
950 if(ver
.wServicePackMinor
<= lpVersionInfo
->wServicePackMinor
)
953 case VER_GREATER_EQUAL
:
954 if(ver
.wServicePackMinor
< lpVersionInfo
->wServicePackMinor
)
958 if(ver
.wServicePackMinor
>= lpVersionInfo
->wServicePackMinor
)
962 if(ver
.wServicePackMinor
> lpVersionInfo
->wServicePackMinor
)
967 SetLastError(ERROR_BAD_ARGUMENTS
);
971 if(!(res
|| error_set
))
972 SetLastError(ERROR_OLD_WIN_VERSION
);
977 /***********************************************************************
978 * GetWinFlags (KERNEL.132)
980 DWORD WINAPI
GetWinFlags16(void)
982 static const long cpuflags
[5] =
983 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
990 /* There doesn't seem to be any Pentium flag. */
991 result
= cpuflags
[min(si
.wProcessorLevel
, 4)] | WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
992 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
993 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
995 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
996 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
1002 /* Not used at this time. This is here for documentation only */
1004 /* WINDEBUGINFO flags values */
1005 #define WDI_OPTIONS 0x0001
1006 #define WDI_FILTER 0x0002
1007 #define WDI_ALLOCBREAK 0x0004
1009 /* dwOptions values */
1010 #define DBO_CHECKHEAP 0x0001
1011 #define DBO_BUFFERFILL 0x0004
1012 #define DBO_DISABLEGPTRAPPING 0x0010
1013 #define DBO_CHECKFREE 0x0020
1015 #define DBO_SILENT 0x8000
1017 #define DBO_TRACEBREAK 0x2000
1018 #define DBO_WARNINGBREAK 0x1000
1019 #define DBO_NOERRORBREAK 0x0800
1020 #define DBO_NOFATALBREAK 0x0400
1021 #define DBO_INT3BREAK 0x0100
1023 /* DebugOutput flags values */
1024 #define DBF_TRACE 0x0000
1025 #define DBF_WARNING 0x4000
1026 #define DBF_ERROR 0x8000
1027 #define DBF_FATAL 0xc000
1029 /* dwFilter values */
1030 #define DBF_KERNEL 0x1000
1031 #define DBF_KRN_MEMMAN 0x0001
1032 #define DBF_KRN_LOADMODULE 0x0002
1033 #define DBF_KRN_SEGMENTLOAD 0x0004
1034 #define DBF_USER 0x0800
1035 #define DBF_GDI 0x0400
1036 #define DBF_MMSYSTEM 0x0040
1037 #define DBF_PENWIN 0x0020
1038 #define DBF_APPLICATION 0x0008
1039 #define DBF_DRIVER 0x0010
1041 #endif /* NOLOGERROR */
1044 /***********************************************************************
1045 * GetWinDebugInfo (KERNEL.355)
1047 BOOL16 WINAPI
GetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
, UINT16 flags
)
1049 FIXME("(%8lx,%d): stub returning 0\n",
1050 (unsigned long)lpwdi
, flags
);
1051 /* 0 means not in debugging mode/version */
1052 /* Can this type of debugging be used in wine ? */
1053 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1058 /***********************************************************************
1059 * SetWinDebugInfo (KERNEL.356)
1061 BOOL16 WINAPI
SetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
)
1063 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
1064 /* 0 means not in debugging mode/version */
1065 /* Can this type of debugging be used in wine ? */
1066 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
1071 /***********************************************************************
1075 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
1077 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
1079 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
1082 /***********************************************************************
1083 * DiagQuery (KERNEL.339)
1085 * returns TRUE if Win called with "/b" (bootlog.txt)
1087 BOOL16 WINAPI
DiagQuery16(void)
1089 /* perhaps implement a Wine "/b" command line flag sometime ? */
1093 /***********************************************************************
1094 * DiagOutput (KERNEL.340)
1096 * writes a debug string into <windir>\bootlog.txt
1098 void WINAPI
DiagOutput16(LPCSTR str
)
1101 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str
));