2 * Windows version functions
4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998 Patrik Stridvall
16 #include "winversion.h"
22 OSVERSIONINFO32A getVersionEx
;
26 /* FIXME: compare values below with original and fix */
27 static const VERSION_DATA VersionData
[NB_WINDOWS_VERSIONS
] =
31 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
32 MAKELONG( 0x0a03, 0x8000 ),
34 sizeof(OSVERSIONINFO32A
), 3, 10, 0,
35 VER_PLATFORM_WIN32s
, "Win32s 1.3"
43 sizeof(OSVERSIONINFO32A
), 4, 0, 0x40003B6,
44 VER_PLATFORM_WIN32_WINDOWS
, "Win95"
52 sizeof(OSVERSIONINFO32A
), 3, 51, 0x421,
53 VER_PLATFORM_WIN32_NT
, "Service Pack 2"
61 sizeof(OSVERSIONINFO32A
), 4, 0, 0x565,
62 VER_PLATFORM_WIN32_NT
, "Service Pack 3"
67 static const char *VersionNames
[NB_WINDOWS_VERSIONS
] =
75 /* the current version has not been autodetected but forced via cmdline */
76 static BOOL32 versionForced
= FALSE
;
77 static WINDOWS_VERSION defaultVersion
= WIN31
;
80 /**********************************************************************
81 * VERSION_ParseVersion
83 void VERSION_ParseVersion( char *arg
)
86 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
88 if (!strcmp( VersionNames
[i
], arg
))
90 defaultVersion
= (WINDOWS_VERSION
)i
;
95 MSG("Invalid winver value '%s' specified.\n", arg
);
96 MSG("Valid versions are:" );
97 for (i
= 0; i
< NB_WINDOWS_VERSIONS
; i
++)
98 MSG(" '%s'%c", VersionNames
[i
],
99 (i
== NB_WINDOWS_VERSIONS
- 1) ? '\n' : ',' );
103 /**********************************************************************
106 WINDOWS_VERSION
VERSION_GetVersion(void)
108 PIMAGE_NT_HEADERS peheader
;
110 if (versionForced
) /* user has overridden any sensible checks */
111 return defaultVersion
;
112 if (!PROCESS_Current()->exe_modref
)
114 /* HACK: if we have loaded a PE image into this address space,
115 * we are probably using thunks, so Win95 is our best bet
117 if (PROCESS_Current()->modref_list
) return WIN95
;
118 return WIN31
; /* FIXME: hmm, look at DDB.version ? */
120 peheader
= PE_HEADER(PROCESS_Current()->exe_modref
->module
);
121 if (peheader
->OptionalHeader
.MajorSubsystemVersion
== 4)
122 /* FIXME: NT4 has the same majorversion; add a check here for it. */
124 if (peheader
->OptionalHeader
.MajorSubsystemVersion
== 3)
127 if (peheader
->OptionalHeader
.MinorSubsystemVersion
<= 11) return WIN31
;
129 if (peheader
->OptionalHeader
.MinorSubsystemVersion
== 50) return NT351
;
130 if (peheader
->OptionalHeader
.MinorSubsystemVersion
== 51) return NT351
;
132 ERR(ver
,"unknown subsystem version: %04x.%04x, please report.\n",
133 peheader
->OptionalHeader
.MajorSubsystemVersion
,
134 peheader
->OptionalHeader
.MinorSubsystemVersion
);
135 return defaultVersion
;
139 /**********************************************************************
140 * VERSION_GetVersionName
142 char *VERSION_GetVersionName()
144 WINDOWS_VERSION ver
= VERSION_GetVersion();
148 return "Windows 3.1";
152 return "Windows NT 3.51";
154 return "Windows NT 4.0";
156 FIXME(ver
,"Windows version %d not named",ver
);
157 return "Windows <Unknown>";
161 /***********************************************************************
162 * GetVersion16 (KERNEL.3)
164 LONG WINAPI
GetVersion16(void)
166 WINDOWS_VERSION ver
= VERSION_GetVersion();
167 return VersionData
[ver
].getVersion16
;
171 /***********************************************************************
172 * GetVersion32 (KERNEL32.427)
174 LONG WINAPI
GetVersion32(void)
176 WINDOWS_VERSION ver
= VERSION_GetVersion();
177 return VersionData
[ver
].getVersion32
;
181 /***********************************************************************
182 * GetVersionEx16 (KERNEL.149)
184 BOOL16 WINAPI
GetVersionEx16(OSVERSIONINFO16
*v
)
186 WINDOWS_VERSION ver
= VERSION_GetVersion();
187 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFO16
))
189 WARN(ver
,"wrong OSVERSIONINFO size from app");
192 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
193 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
194 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
195 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
196 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
201 /***********************************************************************
202 * GetVersionEx32A (KERNEL32.428)
204 BOOL32 WINAPI
GetVersionEx32A(OSVERSIONINFO32A
*v
)
206 WINDOWS_VERSION ver
= VERSION_GetVersion();
207 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFO32A
))
209 WARN(ver
,"wrong OSVERSIONINFO size from app");
212 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
213 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
214 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
215 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
216 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
221 /***********************************************************************
222 * GetVersionEx32W (KERNEL32.429)
224 BOOL32 WINAPI
GetVersionEx32W(OSVERSIONINFO32W
*v
)
226 WINDOWS_VERSION ver
= VERSION_GetVersion();
228 if (v
->dwOSVersionInfoSize
!=sizeof(OSVERSIONINFO32W
))
230 WARN(ver
,"wrong OSVERSIONINFO size from app");
233 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
234 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
235 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
236 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
237 lstrcpyAtoW( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
242 /***********************************************************************
243 * GetWinFlags (KERNEL.132)
245 DWORD WINAPI
GetWinFlags(void)
247 static const long cpuflags
[5] =
248 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
250 OSVERSIONINFO32A ovi
;
255 /* There doesn't seem to be any Pentium flag. */
256 result
= cpuflags
[MIN (si
.wProcessorLevel
, 4)];
261 result
|= WF_STANDARD
| WF_PMODE
| WF_80x87
;
265 result
|= WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
269 ERR(ver
, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
272 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
273 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
274 GetVersionEx32A(&ovi
);
275 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
276 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
281 /***********************************************************************
282 * GetWinDebugInfo (KERNEL.355)
284 BOOL16 WINAPI
GetWinDebugInfo(WINDEBUGINFO
*lpwdi
, UINT16 flags
)
286 FIXME(ver
, "(%8lx,%d): stub returning 0\n",
287 (unsigned long)lpwdi
, flags
);
288 /* 0 means not in debugging mode/version */
289 /* Can this type of debugging be used in wine ? */
290 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
295 /***********************************************************************
296 * SetWinDebugInfo (KERNEL.356)
298 BOOL16 WINAPI
SetWinDebugInfo(WINDEBUGINFO
*lpwdi
)
300 FIXME(ver
, "(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
301 /* 0 means not in debugging mode/version */
302 /* Can this type of debugging be used in wine ? */
303 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
308 /***********************************************************************
309 * DebugFillBuffer (KERNEL.329)
312 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
314 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
316 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
319 /***********************************************************************
320 * DiagQuery (KERNEL.339)
322 * returns TRUE if Win called with "/b" (bootlog.txt)
324 BOOL16 WINAPI
DiagQuery()
326 /* perhaps implement a Wine "/b" command line flag sometime ? */
330 /***********************************************************************
331 * DiagOutput (KERNEL.340)
333 * writes a debug string into <windir>\bootlog.txt
335 void WINAPI
DiagOutput(LPCSTR str
)
338 DPRINTF("DIAGOUTPUT:%s\n", debugstr_a(str
));
341 /***********************************************************************
342 * OaBuildVersion [OLEAUT32.170]
344 UINT32 WINAPI
OaBuildVersion()
346 WINDOWS_VERSION ver
= VERSION_GetVersion();
348 switch(VersionData
[ver
].getVersion32
)
350 case 0x80000a03: /* Win 3.1 */
351 return 0x140fd1; /* from Win32s 1.1e */
352 case 0xc0000004: /* Win 95 */
354 case 0x04213303: /* NT 3.51 */
355 return 0x0; /* FIXME */
356 case 0x05650004: /* NT 4.0 */
362 /***********************************************************************
363 * VERSION_OsIsUnicode [internal]
366 * some functions getting sometimes LPSTR sometimes LPWSTR...
369 BOOL32
VERSION_OsIsUnicode(void)
371 switch(VERSION_GetVersion())