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
14 #include "wine/winbase16.h"
19 #include "winversion.h"
25 OSVERSIONINFOA getVersionEx
;
29 /* FIXME: compare values below with original and fix */
30 static VERSION_DATA VersionData
[NB_WINDOWS_VERSIONS
] =
34 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
35 MAKELONG( 0x0a03, 0x8000 ),
37 sizeof(OSVERSIONINFOA
), 3, 10, 0,
38 VER_PLATFORM_WIN32s
, "Win32s 1.3"
46 sizeof(OSVERSIONINFOA
), 4, 0, 0x40003B6,
47 VER_PLATFORM_WIN32_WINDOWS
, "Win95"
55 sizeof(OSVERSIONINFOA
), 3, 51, 0x421,
56 VER_PLATFORM_WIN32_NT
, "Service Pack 2"
64 sizeof(OSVERSIONINFOA
), 4, 0, 0x565,
65 VER_PLATFORM_WIN32_NT
, "Service Pack 3"
70 static const char *WinVersionNames
[NB_WINDOWS_VERSIONS
] =
78 /* the current version has not been autodetected but forced via cmdline */
79 static BOOL versionForced
= FALSE
;
80 static WINDOWS_VERSION defaultWinVersion
= WIN31
;
83 /**********************************************************************
84 * VERSION_ParseWinVersion
86 void VERSION_ParseWinVersion( const char *arg
)
89 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
91 if (!strcmp( WinVersionNames
[i
], arg
))
93 defaultWinVersion
= (WINDOWS_VERSION
)i
;
98 MSG("Invalid winver value '%s' specified.\n", arg
);
99 MSG("Valid versions are:" );
100 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
101 MSG(" '%s'%c", WinVersionNames
[i
],
102 (i
== NB_WINDOWS_VERSIONS
- 1) ? '\n' : ',' );
106 /**********************************************************************
107 * VERSION_ParseDosVersion
109 void VERSION_ParseDosVersion( const char *arg
)
112 if (sscanf( arg
, "%d.%d", &hi
, &lo
) == 2)
114 VersionData
[WIN31
].getVersion16
=
115 MAKELONG(LOWORD(VersionData
[WIN31
].getVersion16
),
119 fprintf( stderr
, "-dosver: Wrong version format. Use \"-dosver x.xx\"\n");
123 /**********************************************************************
126 WINDOWS_VERSION
VERSION_GetVersion(void)
128 PIMAGE_NT_HEADERS peheader
;
130 if (versionForced
) /* user has overridden any sensible checks */
131 return defaultWinVersion
;
132 if (!PROCESS_Current()->exe_modref
)
134 /* HACK: if we have loaded a PE image into this address space,
135 * we are probably using thunks, so Win95 is our best bet
137 if (PROCESS_Current()->modref_list
) return WIN95
;
138 return WIN31
; /* FIXME: hmm, look at DDB.version ? */
140 peheader
= PE_HEADER(PROCESS_Current()->exe_modref
->module
);
141 if (peheader
->OptionalHeader
.MajorSubsystemVersion
== 4) {
142 /* FIXME: check probably not 100% good, verify with win98 too */
143 if (peheader
->OptionalHeader
.MajorOperatingSystemVersion
== 4)
147 if (peheader
->OptionalHeader
.MajorSubsystemVersion
== 3)
150 if (peheader
->OptionalHeader
.MinorSubsystemVersion
<= 11) return WIN31
;
152 if (peheader
->OptionalHeader
.MinorSubsystemVersion
== 50) return NT351
;
153 if (peheader
->OptionalHeader
.MinorSubsystemVersion
== 51) return NT351
;
155 if (peheader
->OptionalHeader
.MajorSubsystemVersion
)
156 ERR(ver
,"unknown subsystem version: %04x.%04x, please report.\n",
157 peheader
->OptionalHeader
.MajorSubsystemVersion
,
158 peheader
->OptionalHeader
.MinorSubsystemVersion
);
159 return defaultWinVersion
;
163 /**********************************************************************
164 * VERSION_GetVersionName
166 char *VERSION_GetVersionName()
168 WINDOWS_VERSION ver
= VERSION_GetVersion();
172 return "Windows 3.1";
176 return "Windows NT 3.51";
178 return "Windows NT 4.0";
180 FIXME(ver
,"Windows version %d not named",ver
);
181 return "Windows <Unknown>";
185 /***********************************************************************
186 * GetVersion16 (KERNEL.3)
188 LONG WINAPI
GetVersion16(void)
190 WINDOWS_VERSION ver
= VERSION_GetVersion();
191 return VersionData
[ver
].getVersion16
;
195 /***********************************************************************
196 * GetVersion32 (KERNEL32.427)
198 LONG WINAPI
GetVersion(void)
200 WINDOWS_VERSION ver
= VERSION_GetVersion();
201 return VersionData
[ver
].getVersion32
;
205 /***********************************************************************
206 * GetVersionEx16 (KERNEL.149)
208 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
210 WINDOWS_VERSION ver
= VERSION_GetVersion();
211 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFO16
))
213 WARN(ver
,"wrong OSVERSIONINFO size from app");
216 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
217 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
218 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
219 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
220 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
225 /***********************************************************************
226 * GetVersionEx32A (KERNEL32.428)
228 BOOL WINAPI
GetVersionExA(OSVERSIONINFOA
*v
)
230 WINDOWS_VERSION ver
= VERSION_GetVersion();
231 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFOA
))
233 WARN(ver
,"wrong OSVERSIONINFO size from app");
236 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
237 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
238 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
239 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
240 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
245 /***********************************************************************
246 * GetVersionEx32W (KERNEL32.429)
248 BOOL WINAPI
GetVersionExW(OSVERSIONINFOW
*v
)
250 WINDOWS_VERSION ver
= VERSION_GetVersion();
252 if (v
->dwOSVersionInfoSize
!=sizeof(OSVERSIONINFOW
))
254 WARN(ver
,"wrong OSVERSIONINFO size from app");
257 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
258 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
259 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
260 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
261 lstrcpyAtoW( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
266 /***********************************************************************
267 * GetWinFlags (KERNEL.132)
269 DWORD WINAPI
GetWinFlags16(void)
271 static const long cpuflags
[5] =
272 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
279 /* There doesn't seem to be any Pentium flag. */
280 result
= cpuflags
[MIN (si
.wProcessorLevel
, 4)];
285 result
|= WF_STANDARD
| WF_PMODE
| WF_80x87
;
289 result
|= WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
293 ERR(ver
, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
296 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
297 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
299 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
300 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
305 /***********************************************************************
306 * GetWinDebugInfo (KERNEL.355)
308 BOOL16 WINAPI
GetWinDebugInfo16(WINDEBUGINFO
*lpwdi
, UINT16 flags
)
310 FIXME(ver
, "(%8lx,%d): stub returning 0\n",
311 (unsigned long)lpwdi
, flags
);
312 /* 0 means not in debugging mode/version */
313 /* Can this type of debugging be used in wine ? */
314 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
319 /***********************************************************************
320 * SetWinDebugInfo (KERNEL.356)
322 BOOL16 WINAPI
SetWinDebugInfo16(WINDEBUGINFO
*lpwdi
)
324 FIXME(ver
, "(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
325 /* 0 means not in debugging mode/version */
326 /* Can this type of debugging be used in wine ? */
327 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
332 /***********************************************************************
333 * DebugFillBuffer (KERNEL.329)
336 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
338 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
340 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
343 /***********************************************************************
344 * DiagQuery (KERNEL.339)
346 * returns TRUE if Win called with "/b" (bootlog.txt)
348 BOOL16 WINAPI
DiagQuery16()
350 /* perhaps implement a Wine "/b" command line flag sometime ? */
354 /***********************************************************************
355 * DiagOutput (KERNEL.340)
357 * writes a debug string into <windir>\bootlog.txt
359 void WINAPI
DiagOutput16(LPCSTR str
)
362 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str
));
365 /***********************************************************************
366 * OaBuildVersion [OLEAUT32.170]
368 UINT WINAPI
OaBuildVersion()
370 WINDOWS_VERSION ver
= VERSION_GetVersion();
372 FIXME(ver
, "Please report to a.mohr@mailto.de if you get version error messages !\n");
373 switch(VersionData
[ver
].getVersion32
)
375 case 0x80000a03: /* Win 3.1 */
376 return 0x140fd1; /* from Win32s 1.1e */
377 case 0xc0000004: /* Win 95 */
378 return 0x1e10a9; /* some older version: 0x0a0bd3 */
379 case 0x04213303: /* NT 3.51 */
380 FIXME(ver
, "NT 3.51 version value unknown !\n");
381 return 0x1e10a9; /* value borrowed from Win95 */
382 case 0x05650004: /* NT 4.0 */
388 /***********************************************************************
389 * VERSION_OsIsUnicode [internal]
392 * some functions getting sometimes LPSTR sometimes LPWSTR...
395 BOOL
VERSION_OsIsUnicode(void)
397 switch(VERSION_GetVersion())