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
18 #include "winversion.h"
24 OSVERSIONINFO32A getVersionEx
;
28 /* FIXME: compare values below with original and fix */
29 static VERSION_DATA VersionData
[NB_WINDOWS_VERSIONS
] =
33 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
34 MAKELONG( 0x0a03, 0x8000 ),
36 sizeof(OSVERSIONINFO32A
), 3, 10, 0,
37 VER_PLATFORM_WIN32s
, "Win32s 1.3"
45 sizeof(OSVERSIONINFO32A
), 4, 0, 0x40003B6,
46 VER_PLATFORM_WIN32_WINDOWS
, "Win95"
54 sizeof(OSVERSIONINFO32A
), 3, 51, 0x421,
55 VER_PLATFORM_WIN32_NT
, "Service Pack 2"
63 sizeof(OSVERSIONINFO32A
), 4, 0, 0x565,
64 VER_PLATFORM_WIN32_NT
, "Service Pack 3"
69 static const char *WinVersionNames
[NB_WINDOWS_VERSIONS
] =
77 /* the current version has not been autodetected but forced via cmdline */
78 static BOOL32 versionForced
= FALSE
;
79 static WINDOWS_VERSION defaultWinVersion
= WIN31
;
82 /**********************************************************************
83 * VERSION_ParseWinVersion
85 void VERSION_ParseWinVersion( const char *arg
)
88 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
90 if (!strcmp( WinVersionNames
[i
], arg
))
92 defaultWinVersion
= (WINDOWS_VERSION
)i
;
97 MSG("Invalid winver value '%s' specified.\n", arg
);
98 MSG("Valid versions are:" );
99 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
100 MSG(" '%s'%c", WinVersionNames
[i
],
101 (i
== NB_WINDOWS_VERSIONS
- 1) ? '\n' : ',' );
105 /**********************************************************************
106 * VERSION_ParseDosVersion
108 void VERSION_ParseDosVersion( const char *arg
)
111 if (sscanf( arg
, "%d.%d", &hi
, &lo
) == 2)
113 VersionData
[WIN31
].getVersion16
=
114 MAKELONG(LOWORD(VersionData
[WIN31
].getVersion16
),
118 fprintf( stderr
, "-dosver: Wrong version format. Use \"-dosver x.xx\"\n");
122 /**********************************************************************
125 WINDOWS_VERSION
VERSION_GetVersion(void)
127 PIMAGE_NT_HEADERS peheader
;
129 if (versionForced
) /* user has overridden any sensible checks */
130 return defaultWinVersion
;
131 if (!PROCESS_Current()->exe_modref
)
133 /* HACK: if we have loaded a PE image into this address space,
134 * we are probably using thunks, so Win95 is our best bet
136 if (PROCESS_Current()->modref_list
) return WIN95
;
137 return WIN31
; /* FIXME: hmm, look at DDB.version ? */
139 peheader
= PE_HEADER(PROCESS_Current()->exe_modref
->module
);
140 if (peheader
->OptionalHeader
.MajorSubsystemVersion
== 4) {
141 /* FIXME: check probably not 100% good, verify with win98 too */
142 if (peheader
->OptionalHeader
.MajorOperatingSystemVersion
== 4)
146 if (peheader
->OptionalHeader
.MajorSubsystemVersion
== 3)
149 if (peheader
->OptionalHeader
.MinorSubsystemVersion
<= 11) return WIN31
;
151 if (peheader
->OptionalHeader
.MinorSubsystemVersion
== 50) return NT351
;
152 if (peheader
->OptionalHeader
.MinorSubsystemVersion
== 51) return NT351
;
154 ERR(ver
,"unknown subsystem version: %04x.%04x, please report.\n",
155 peheader
->OptionalHeader
.MajorSubsystemVersion
,
156 peheader
->OptionalHeader
.MinorSubsystemVersion
);
157 return defaultWinVersion
;
161 /**********************************************************************
162 * VERSION_GetVersionName
164 char *VERSION_GetVersionName()
166 WINDOWS_VERSION ver
= VERSION_GetVersion();
170 return "Windows 3.1";
174 return "Windows NT 3.51";
176 return "Windows NT 4.0";
178 FIXME(ver
,"Windows version %d not named",ver
);
179 return "Windows <Unknown>";
183 /***********************************************************************
184 * GetVersion16 (KERNEL.3)
186 LONG WINAPI
GetVersion16(void)
188 WINDOWS_VERSION ver
= VERSION_GetVersion();
189 return VersionData
[ver
].getVersion16
;
193 /***********************************************************************
194 * GetVersion32 (KERNEL32.427)
196 LONG WINAPI
GetVersion32(void)
198 WINDOWS_VERSION ver
= VERSION_GetVersion();
199 return VersionData
[ver
].getVersion32
;
203 /***********************************************************************
204 * GetVersionEx16 (KERNEL.149)
206 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
208 WINDOWS_VERSION ver
= VERSION_GetVersion();
209 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFO16
))
211 WARN(ver
,"wrong OSVERSIONINFO size from app");
214 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
215 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
216 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
217 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
218 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
223 /***********************************************************************
224 * GetVersionEx32A (KERNEL32.428)
226 BOOL32 WINAPI
GetVersionEx32A(OSVERSIONINFO32A
*v
)
228 WINDOWS_VERSION ver
= VERSION_GetVersion();
229 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFO32A
))
231 WARN(ver
,"wrong OSVERSIONINFO size from app");
234 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
235 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
236 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
237 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
238 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
243 /***********************************************************************
244 * GetVersionEx32W (KERNEL32.429)
246 BOOL32 WINAPI
GetVersionEx32W(OSVERSIONINFO32W
*v
)
248 WINDOWS_VERSION ver
= VERSION_GetVersion();
250 if (v
->dwOSVersionInfoSize
!=sizeof(OSVERSIONINFO32W
))
252 WARN(ver
,"wrong OSVERSIONINFO size from app");
255 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
256 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
257 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
258 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
259 lstrcpyAtoW( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
264 /***********************************************************************
265 * GetWinFlags (KERNEL.132)
267 DWORD WINAPI
GetWinFlags(void)
269 static const long cpuflags
[5] =
270 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
272 OSVERSIONINFO32A ovi
;
277 /* There doesn't seem to be any Pentium flag. */
278 result
= cpuflags
[MIN (si
.wProcessorLevel
, 4)];
283 result
|= WF_STANDARD
| WF_PMODE
| WF_80x87
;
287 result
|= WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
291 ERR(ver
, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
294 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
295 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
296 GetVersionEx32A(&ovi
);
297 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
298 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
303 /***********************************************************************
304 * GetWinDebugInfo (KERNEL.355)
306 BOOL16 WINAPI
GetWinDebugInfo(WINDEBUGINFO
*lpwdi
, UINT16 flags
)
308 FIXME(ver
, "(%8lx,%d): stub returning 0\n",
309 (unsigned long)lpwdi
, flags
);
310 /* 0 means not in debugging mode/version */
311 /* Can this type of debugging be used in wine ? */
312 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
317 /***********************************************************************
318 * SetWinDebugInfo (KERNEL.356)
320 BOOL16 WINAPI
SetWinDebugInfo(WINDEBUGINFO
*lpwdi
)
322 FIXME(ver
, "(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
323 /* 0 means not in debugging mode/version */
324 /* Can this type of debugging be used in wine ? */
325 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
330 /***********************************************************************
331 * DebugFillBuffer (KERNEL.329)
334 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
336 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
338 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
341 /***********************************************************************
342 * DiagQuery (KERNEL.339)
344 * returns TRUE if Win called with "/b" (bootlog.txt)
346 BOOL16 WINAPI
DiagQuery()
348 /* perhaps implement a Wine "/b" command line flag sometime ? */
352 /***********************************************************************
353 * DiagOutput (KERNEL.340)
355 * writes a debug string into <windir>\bootlog.txt
357 void WINAPI
DiagOutput(LPCSTR str
)
360 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str
));
363 /***********************************************************************
364 * OaBuildVersion [OLEAUT32.170]
366 UINT32 WINAPI
OaBuildVersion()
368 WINDOWS_VERSION ver
= VERSION_GetVersion();
370 FIXME(ver
, "Please report to a.mohr@mailto.de if you get version error messages !\n");
371 switch(VersionData
[ver
].getVersion32
)
373 case 0x80000a03: /* Win 3.1 */
374 return 0x140fd1; /* from Win32s 1.1e */
375 case 0xc0000004: /* Win 95 */
376 return 0x1e10a9; /* some older version: 0x0a0bd3 */
377 case 0x04213303: /* NT 3.51 */
378 FIXME(ver
, "NT 3.51 version value unknown !\n");
379 return 0x1e10a9; /* value borrowed from Win95 */
380 case 0x05650004: /* NT 4.0 */
386 /***********************************************************************
387 * VERSION_OsIsUnicode [internal]
390 * some functions getting sometimes LPSTR sometimes LPWSTR...
393 BOOL32
VERSION_OsIsUnicode(void)
395 switch(VERSION_GetVersion())