2 * Windows and DOS version functions
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Patrik Stridvall
6 * Copyright 1998, 2003 Andreas Mohr
7 * Copyright 1997, 2003 Alexandre Julliard
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"
38 #include "wine/winbase16.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
45 /***********************************************************************
46 * GetVersion (KERNEL.3)
48 DWORD WINAPI
GetVersion16(void)
50 static WORD dosver
, winver
;
52 if (!dosver
) /* not determined yet */
54 RTL_OSVERSIONINFOEXW info
;
56 info
.dwOSVersionInfoSize
= sizeof(info
);
57 if (RtlGetVersion( &info
) != STATUS_SUCCESS
) return 0;
59 if (info
.dwMajorVersion
<= 3)
60 winver
= MAKEWORD( info
.dwMajorVersion
, info
.dwMinorVersion
);
62 winver
= MAKEWORD( 3, 95 );
64 switch(info
.dwPlatformId
)
66 case VER_PLATFORM_WIN32s
:
67 switch(MAKELONG( info
.dwMinorVersion
, info
.dwMajorVersion
))
70 dosver
= 0x0303; /* DOS 3.3 for Windows 2.0 */
73 dosver
= 0x0500; /* DOS 5.0 for Windows 3.0 */
76 dosver
= 0x0616; /* DOS 6.22 for Windows 3.1 and later */
80 case VER_PLATFORM_WIN32_WINDOWS
:
81 /* DOS 8.0 for WinME, 7.0 for Win95/98 */
82 if (info
.dwMinorVersion
>= 90) dosver
= 0x0800;
85 case VER_PLATFORM_WIN32_NT
:
86 dosver
= 0x0500; /* always DOS 5.0 for NT */
89 TRACE( "DOS %d.%02d Win %d.%02d\n",
90 HIBYTE(dosver
), LOBYTE(dosver
), LOBYTE(winver
), HIBYTE(winver
) );
92 return MAKELONG( winver
, dosver
);
96 /***********************************************************************
97 * GetVersion (KERNEL32.@)
108 DWORD WINAPI
GetVersion(void)
110 RTL_OSVERSIONINFOEXW info
;
113 info
.dwOSVersionInfoSize
= sizeof(info
);
114 if (RtlGetVersion( &info
) != STATUS_SUCCESS
) return 0;
116 result
= MAKELONG( MAKEWORD( info
.dwMajorVersion
, info
.dwMinorVersion
),
117 (info
.dwPlatformId
^ 2) << 14 );
118 if (info
.dwPlatformId
== VER_PLATFORM_WIN32_NT
) result
|= LOWORD(info
.dwBuildNumber
) << 16;
123 /***********************************************************************
124 * GetVersionEx (KERNEL.149)
126 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
130 if (v
->dwOSVersionInfoSize
< sizeof(OSVERSIONINFO16
))
132 WARN("wrong OSVERSIONINFO size from app\n");
136 info
.dwOSVersionInfoSize
= sizeof(info
);
137 if (!GetVersionExA( &info
)) return FALSE
;
139 v
->dwMajorVersion
= info
.dwMajorVersion
;
140 v
->dwMinorVersion
= info
.dwMinorVersion
;
141 v
->dwBuildNumber
= info
.dwBuildNumber
;
142 v
->dwPlatformId
= info
.dwPlatformId
;
143 strcpy( v
->szCSDVersion
, info
.szCSDVersion
);
148 /***********************************************************************
149 * GetVersionExA (KERNEL32.@)
151 BOOL WINAPI
GetVersionExA(OSVERSIONINFOA
*v
)
153 RTL_OSVERSIONINFOEXW infoW
;
155 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOA
) &&
156 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXA
))
158 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
159 v
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOA
),
160 sizeof(OSVERSIONINFOEXA
));
164 infoW
.dwOSVersionInfoSize
= sizeof(infoW
);
165 if (RtlGetVersion( &infoW
) != STATUS_SUCCESS
) return FALSE
;
167 v
->dwMajorVersion
= infoW
.dwMajorVersion
;
168 v
->dwMinorVersion
= infoW
.dwMinorVersion
;
169 v
->dwBuildNumber
= infoW
.dwBuildNumber
;
170 v
->dwPlatformId
= infoW
.dwPlatformId
;
171 WideCharToMultiByte( CP_ACP
, 0, infoW
.szCSDVersion
, -1,
172 v
->szCSDVersion
, sizeof(v
->szCSDVersion
), NULL
, NULL
);
174 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXA
))
176 LPOSVERSIONINFOEXA vex
= (LPOSVERSIONINFOEXA
) v
;
177 vex
->wServicePackMajor
= infoW
.wServicePackMajor
;
178 vex
->wServicePackMinor
= infoW
.wServicePackMinor
;
179 vex
->wSuiteMask
= infoW
.wSuiteMask
;
180 vex
->wProductType
= infoW
.wProductType
;
186 /***********************************************************************
187 * GetVersionExW (KERNEL32.@)
189 BOOL WINAPI
GetVersionExW( OSVERSIONINFOW
*info
)
191 if (info
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOW
) &&
192 info
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXW
))
194 WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n",
195 info
->dwOSVersionInfoSize
, sizeof(OSVERSIONINFOW
),
196 sizeof(OSVERSIONINFOEXW
));
199 return (RtlGetVersion( (RTL_OSVERSIONINFOEXW
*)info
) == STATUS_SUCCESS
);
203 /******************************************************************************
204 * VerifyVersionInfoA (KERNEL32.@)
206 BOOL WINAPI
VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo
, DWORD dwTypeMask
,
207 DWORDLONG dwlConditionMask
)
209 OSVERSIONINFOEXW verW
;
211 verW
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
212 verW
.dwMajorVersion
= lpVersionInfo
->dwMajorVersion
;
213 verW
.dwMinorVersion
= lpVersionInfo
->dwMinorVersion
;
214 verW
.dwBuildNumber
= lpVersionInfo
->dwBuildNumber
;
215 verW
.dwPlatformId
= lpVersionInfo
->dwPlatformId
;
216 verW
.wServicePackMajor
= lpVersionInfo
->wServicePackMajor
;
217 verW
.wServicePackMinor
= lpVersionInfo
->wServicePackMinor
;
218 verW
.wSuiteMask
= lpVersionInfo
->wSuiteMask
;
219 verW
.wProductType
= lpVersionInfo
->wProductType
;
220 verW
.wReserved
= lpVersionInfo
->wReserved
;
222 return VerifyVersionInfoW(&verW
, dwTypeMask
, dwlConditionMask
);
226 /******************************************************************************
227 * VerifyVersionInfoW (KERNEL32.@)
229 BOOL WINAPI
VerifyVersionInfoW( LPOSVERSIONINFOEXW lpVersionInfo
, DWORD dwTypeMask
,
230 DWORDLONG dwlConditionMask
)
232 switch(RtlVerifyVersionInfo( lpVersionInfo
, dwTypeMask
, dwlConditionMask
))
234 case STATUS_INVALID_PARAMETER
:
235 SetLastError( ERROR_BAD_ARGUMENTS
);
237 case STATUS_REVISION_MISMATCH
:
238 SetLastError( ERROR_OLD_WIN_VERSION
);
245 /***********************************************************************
246 * GetWinFlags (KERNEL.132)
248 DWORD WINAPI
GetWinFlags16(void)
250 static const long cpuflags
[5] =
251 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
258 /* There doesn't seem to be any Pentium flag. */
259 result
= cpuflags
[min(si
.wProcessorLevel
, 4)] | WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
260 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
261 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
263 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
264 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
270 /* Not used at this time. This is here for documentation only */
272 /* WINDEBUGINFO flags values */
273 #define WDI_OPTIONS 0x0001
274 #define WDI_FILTER 0x0002
275 #define WDI_ALLOCBREAK 0x0004
277 /* dwOptions values */
278 #define DBO_CHECKHEAP 0x0001
279 #define DBO_BUFFERFILL 0x0004
280 #define DBO_DISABLEGPTRAPPING 0x0010
281 #define DBO_CHECKFREE 0x0020
283 #define DBO_SILENT 0x8000
285 #define DBO_TRACEBREAK 0x2000
286 #define DBO_WARNINGBREAK 0x1000
287 #define DBO_NOERRORBREAK 0x0800
288 #define DBO_NOFATALBREAK 0x0400
289 #define DBO_INT3BREAK 0x0100
291 /* DebugOutput flags values */
292 #define DBF_TRACE 0x0000
293 #define DBF_WARNING 0x4000
294 #define DBF_ERROR 0x8000
295 #define DBF_FATAL 0xc000
297 /* dwFilter values */
298 #define DBF_KERNEL 0x1000
299 #define DBF_KRN_MEMMAN 0x0001
300 #define DBF_KRN_LOADMODULE 0x0002
301 #define DBF_KRN_SEGMENTLOAD 0x0004
302 #define DBF_USER 0x0800
303 #define DBF_GDI 0x0400
304 #define DBF_MMSYSTEM 0x0040
305 #define DBF_PENWIN 0x0020
306 #define DBF_APPLICATION 0x0008
307 #define DBF_DRIVER 0x0010
309 #endif /* NOLOGERROR */
312 /***********************************************************************
313 * GetWinDebugInfo (KERNEL.355)
315 BOOL16 WINAPI
GetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
, UINT16 flags
)
317 FIXME("(%8lx,%d): stub returning 0\n",
318 (unsigned long)lpwdi
, flags
);
319 /* 0 means not in debugging mode/version */
320 /* Can this type of debugging be used in wine ? */
321 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
326 /***********************************************************************
327 * SetWinDebugInfo (KERNEL.356)
329 BOOL16 WINAPI
SetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
)
331 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
332 /* 0 means not in debugging mode/version */
333 /* Can this type of debugging be used in wine ? */
334 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
339 /***********************************************************************
343 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
345 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
347 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
350 /***********************************************************************
351 * DiagQuery (KERNEL.339)
353 * returns TRUE if Win called with "/b" (bootlog.txt)
355 BOOL16 WINAPI
DiagQuery16(void)
357 /* perhaps implement a Wine "/b" command line flag sometime ? */
361 /***********************************************************************
362 * DiagOutput (KERNEL.340)
364 * writes a debug string into <windir>\bootlog.txt
366 void WINAPI
DiagOutput16(LPCSTR str
)
369 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str
));