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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/port.h"
32 #define WIN32_NO_STATUS
39 #include "wine/winbase16.h"
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
46 /***********************************************************************
47 * GetVersion (KERNEL.3)
49 DWORD WINAPI
GetVersion16(void)
51 static WORD dosver
, winver
;
53 if (!dosver
) /* not determined yet */
55 RTL_OSVERSIONINFOEXW info
;
57 info
.dwOSVersionInfoSize
= sizeof(info
);
58 if (RtlGetVersion( &info
) != STATUS_SUCCESS
) return 0;
60 if (info
.dwMajorVersion
<= 3)
61 winver
= MAKEWORD( info
.dwMajorVersion
, info
.dwMinorVersion
);
63 winver
= MAKEWORD( 3, 95 );
65 switch(info
.dwPlatformId
)
67 case VER_PLATFORM_WIN32s
:
68 switch(MAKELONG( info
.dwMinorVersion
, info
.dwMajorVersion
))
71 dosver
= 0x0303; /* DOS 3.3 for Windows 2.0 */
74 dosver
= 0x0500; /* DOS 5.0 for Windows 3.0 */
77 dosver
= 0x0616; /* DOS 6.22 for Windows 3.1 and later */
81 case VER_PLATFORM_WIN32_WINDOWS
:
82 /* DOS 8.0 for WinME, 7.0 for Win95/98 */
83 if (info
.dwMinorVersion
>= 90) dosver
= 0x0800;
86 case VER_PLATFORM_WIN32_NT
:
87 dosver
= 0x0500; /* always DOS 5.0 for NT */
90 TRACE( "DOS %d.%02d Win %d.%02d\n",
91 HIBYTE(dosver
), LOBYTE(dosver
), LOBYTE(winver
), HIBYTE(winver
) );
93 return MAKELONG( winver
, dosver
);
97 /***********************************************************************
98 * GetVersion (KERNEL32.@)
109 DWORD WINAPI
GetVersion(void)
111 DWORD result
= MAKELONG( MAKEWORD( NtCurrentTeb()->Peb
->OSMajorVersion
,
112 NtCurrentTeb()->Peb
->OSMinorVersion
),
113 (NtCurrentTeb()->Peb
->OSPlatformId
^ 2) << 14 );
114 if (NtCurrentTeb()->Peb
->OSPlatformId
== VER_PLATFORM_WIN32_NT
)
115 result
|= LOWORD(NtCurrentTeb()->Peb
->OSBuildNumber
) << 16;
120 /***********************************************************************
121 * GetVersionEx (KERNEL.149)
123 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
127 if (v
->dwOSVersionInfoSize
< sizeof(OSVERSIONINFO16
))
129 WARN("wrong OSVERSIONINFO size from app\n");
133 info
.dwOSVersionInfoSize
= sizeof(info
);
134 if (!GetVersionExA( &info
)) return FALSE
;
136 v
->dwMajorVersion
= info
.dwMajorVersion
;
137 v
->dwMinorVersion
= info
.dwMinorVersion
;
138 v
->dwBuildNumber
= info
.dwBuildNumber
;
139 v
->dwPlatformId
= info
.dwPlatformId
;
140 strcpy( v
->szCSDVersion
, info
.szCSDVersion
);
145 /***********************************************************************
146 * GetVersionExA (KERNEL32.@)
148 BOOL WINAPI
GetVersionExA(OSVERSIONINFOA
*v
)
150 RTL_OSVERSIONINFOEXW infoW
;
152 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOA
) &&
153 v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXA
))
155 WARN("wrong OSVERSIONINFO size from app (got: %d)\n",
156 v
->dwOSVersionInfoSize
);
157 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
161 infoW
.dwOSVersionInfoSize
= sizeof(infoW
);
162 if (RtlGetVersion( &infoW
) != STATUS_SUCCESS
) return FALSE
;
164 v
->dwMajorVersion
= infoW
.dwMajorVersion
;
165 v
->dwMinorVersion
= infoW
.dwMinorVersion
;
166 v
->dwBuildNumber
= infoW
.dwBuildNumber
;
167 v
->dwPlatformId
= infoW
.dwPlatformId
;
168 WideCharToMultiByte( CP_ACP
, 0, infoW
.szCSDVersion
, -1,
169 v
->szCSDVersion
, sizeof(v
->szCSDVersion
), NULL
, NULL
);
171 if(v
->dwOSVersionInfoSize
== sizeof(OSVERSIONINFOEXA
))
173 LPOSVERSIONINFOEXA vex
= (LPOSVERSIONINFOEXA
) v
;
174 vex
->wServicePackMajor
= infoW
.wServicePackMajor
;
175 vex
->wServicePackMinor
= infoW
.wServicePackMinor
;
176 vex
->wSuiteMask
= infoW
.wSuiteMask
;
177 vex
->wProductType
= infoW
.wProductType
;
183 /***********************************************************************
184 * GetVersionExW (KERNEL32.@)
186 BOOL WINAPI
GetVersionExW( OSVERSIONINFOW
*info
)
188 if (info
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOW
) &&
189 info
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOEXW
))
191 WARN("wrong OSVERSIONINFO size from app (got: %d)\n",
192 info
->dwOSVersionInfoSize
);
195 return (RtlGetVersion( (RTL_OSVERSIONINFOEXW
*)info
) == STATUS_SUCCESS
);
199 /******************************************************************************
200 * VerifyVersionInfoA (KERNEL32.@)
202 BOOL WINAPI
VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo
, DWORD dwTypeMask
,
203 DWORDLONG dwlConditionMask
)
205 OSVERSIONINFOEXW verW
;
207 verW
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
208 verW
.dwMajorVersion
= lpVersionInfo
->dwMajorVersion
;
209 verW
.dwMinorVersion
= lpVersionInfo
->dwMinorVersion
;
210 verW
.dwBuildNumber
= lpVersionInfo
->dwBuildNumber
;
211 verW
.dwPlatformId
= lpVersionInfo
->dwPlatformId
;
212 verW
.wServicePackMajor
= lpVersionInfo
->wServicePackMajor
;
213 verW
.wServicePackMinor
= lpVersionInfo
->wServicePackMinor
;
214 verW
.wSuiteMask
= lpVersionInfo
->wSuiteMask
;
215 verW
.wProductType
= lpVersionInfo
->wProductType
;
216 verW
.wReserved
= lpVersionInfo
->wReserved
;
218 return VerifyVersionInfoW(&verW
, dwTypeMask
, dwlConditionMask
);
222 /******************************************************************************
223 * VerifyVersionInfoW (KERNEL32.@)
225 BOOL WINAPI
VerifyVersionInfoW( LPOSVERSIONINFOEXW lpVersionInfo
, DWORD dwTypeMask
,
226 DWORDLONG dwlConditionMask
)
228 switch(RtlVerifyVersionInfo( lpVersionInfo
, dwTypeMask
, dwlConditionMask
))
230 case STATUS_INVALID_PARAMETER
:
231 SetLastError( ERROR_BAD_ARGUMENTS
);
233 case STATUS_REVISION_MISMATCH
:
234 SetLastError( ERROR_OLD_WIN_VERSION
);
241 /***********************************************************************
242 * GetWinFlags (KERNEL.132)
244 DWORD WINAPI
GetWinFlags16(void)
246 static const long cpuflags
[5] =
247 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
254 /* There doesn't seem to be any Pentium flag. */
255 result
= cpuflags
[min(si
.wProcessorLevel
, 4)] | WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
256 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
257 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
259 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
260 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
266 /* Not used at this time. This is here for documentation only */
268 /* WINDEBUGINFO flags values */
269 #define WDI_OPTIONS 0x0001
270 #define WDI_FILTER 0x0002
271 #define WDI_ALLOCBREAK 0x0004
273 /* dwOptions values */
274 #define DBO_CHECKHEAP 0x0001
275 #define DBO_BUFFERFILL 0x0004
276 #define DBO_DISABLEGPTRAPPING 0x0010
277 #define DBO_CHECKFREE 0x0020
279 #define DBO_SILENT 0x8000
281 #define DBO_TRACEBREAK 0x2000
282 #define DBO_WARNINGBREAK 0x1000
283 #define DBO_NOERRORBREAK 0x0800
284 #define DBO_NOFATALBREAK 0x0400
285 #define DBO_INT3BREAK 0x0100
287 /* DebugOutput flags values */
288 #define DBF_TRACE 0x0000
289 #define DBF_WARNING 0x4000
290 #define DBF_ERROR 0x8000
291 #define DBF_FATAL 0xc000
293 /* dwFilter values */
294 #define DBF_KERNEL 0x1000
295 #define DBF_KRN_MEMMAN 0x0001
296 #define DBF_KRN_LOADMODULE 0x0002
297 #define DBF_KRN_SEGMENTLOAD 0x0004
298 #define DBF_USER 0x0800
299 #define DBF_GDI 0x0400
300 #define DBF_MMSYSTEM 0x0040
301 #define DBF_PENWIN 0x0020
302 #define DBF_APPLICATION 0x0008
303 #define DBF_DRIVER 0x0010
305 #endif /* NOLOGERROR */
308 /***********************************************************************
309 * GetWinDebugInfo (KERNEL.355)
311 BOOL16 WINAPI
GetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
, UINT16 flags
)
313 FIXME("(%8lx,%d): stub returning 0\n",
314 (unsigned long)lpwdi
, flags
);
315 /* 0 means not in debugging mode/version */
316 /* Can this type of debugging be used in wine ? */
317 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
322 /***********************************************************************
323 * SetWinDebugInfo (KERNEL.356)
325 BOOL16 WINAPI
SetWinDebugInfo16(WINDEBUGINFO16
*lpwdi
)
327 FIXME("(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
328 /* 0 means not in debugging mode/version */
329 /* Can this type of debugging be used in wine ? */
330 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
335 /***********************************************************************
339 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
341 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
343 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
346 /***********************************************************************
347 * DiagQuery (KERNEL.339)
349 * returns TRUE if Win called with "/b" (bootlog.txt)
351 BOOL16 WINAPI
DiagQuery16(void)
353 /* perhaps implement a Wine "/b" command line flag sometime ? */
357 /***********************************************************************
358 * DiagOutput (KERNEL.340)
360 * writes a debug string into <windir>\bootlog.txt
362 void WINAPI
DiagOutput16(LPCSTR str
)
365 TRACE("DIAGOUTPUT:%s\n", debugstr_a(str
));
368 /***********************************************************************
369 * TermsrvAppInstallMode (KERNEL32.@)
371 * Find out whether the terminal server is in INSTALL or EXECUTE mode.
373 BOOL WINAPI
TermsrvAppInstallMode(void)
379 /***********************************************************************
380 * SetTermsrvAppInstallMode (KERNEL32.@)
382 * This function is said to switch between the INSTALL (TRUE) or
383 * EXECUTE (FALSE) terminal server modes.
385 * This function always returns zero on WinXP Home so it's probably
386 * safe to return that value in most cases. However, if a terminal
387 * server is running it will probably return something else.
389 DWORD WINAPI
SetTermsrvAppInstallMode(BOOL bInstallMode
)
391 FIXME("(%d): stub\n", bInstallMode
);