2 * Windows version functions
4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Marcus Meissner
18 WIN31
, /* Windows 3.1 */
19 WIN95
, /* Windows 95 */
20 NT351
, /* Windows NT 3.51 */
21 NT40
, /* Windows NT 4.0 */
29 OSVERSIONINFO32A getVersionEx
;
33 /* FIXME: compare values below with original and fix */
34 static const VERSION_DATA VersionData
[NB_VERSIONS
] =
38 MAKELONG( 0x0a03, 0x0616 ), /* DOS 6.22 */
39 MAKELONG( 0x0a03, 0x8000 ),
41 sizeof(OSVERSIONINFO32A
), 3, 10, 0,
42 VER_PLATFORM_WIN32s
, "Win32s 1.3"
50 sizeof(OSVERSIONINFO32A
), 4, 0, 0x40003B6,
51 VER_PLATFORM_WIN32_WINDOWS
, "Win95"
59 sizeof(OSVERSIONINFO32A
), 3, 51, 0x421,
60 VER_PLATFORM_WIN32_NT
, "Service Pack 2"
68 sizeof(OSVERSIONINFO32A
), 4, 0, 0x565,
69 VER_PLATFORM_WIN32_NT
, "Service Pack 3"
74 static const char *VersionNames
[NB_VERSIONS
] =
82 /* the current version has not been autodetected but forced via cmdline */
83 static BOOL32 versionForced
= FALSE
;
84 static VERSION defaultVersion
= WIN31
;
87 /**********************************************************************
88 * VERSION_ParseVersion
90 void VERSION_ParseVersion( char *arg
)
93 for (i
= 0; i
< NB_VERSIONS
; i
++)
95 if (!strcmp( VersionNames
[i
], arg
))
97 defaultVersion
= (VERSION
)i
;
102 MSG("Invalid winver value '%s' specified.\n", arg
);
103 MSG("Valid versions are:" );
104 for (i
= 0; i
< NB_VERSIONS
; i
++)
105 MSG(" '%s'%c", VersionNames
[i
],
106 (i
== NB_VERSIONS
- 1) ? '\n' : ',' );
110 /**********************************************************************
111 * VERSION_get_version
113 static VERSION
VERSION_GetVersion(void)
115 LPIMAGE_NT_HEADERS peheader
;
117 if (versionForced
) /* user has overridden any sensible checks */
118 return defaultVersion
;
119 if (!PROCESS_Current()->exe_modref
)
121 /* HACK: if we have loaded a PE image into this address space,
122 * we are probably using thunks, so Win95 is our best bet
124 if (PROCESS_Current()->modref_list
) return WIN95
;
125 return WIN31
; /* FIXME: hmm, look at DDB.version ? */
127 peheader
= PE_HEADER(PROCESS_Current()->exe_modref
->module
);
128 if (peheader
->OptionalHeader
.MajorSubsystemVersion
== 4)
129 /* FIXME: NT4 has the same majorversion; add a check here for it. */
131 if (peheader
->OptionalHeader
.MajorSubsystemVersion
== 3)
134 if (peheader
->OptionalHeader
.MinorSubsystemVersion
<= 11) return WIN31
;
136 if (peheader
->OptionalHeader
.MinorSubsystemVersion
== 51) return NT351
;
138 ERR(ver
,"unknown subsystem version: %04x.%04x, please report.\n",
139 peheader
->OptionalHeader
.MajorSubsystemVersion
,
140 peheader
->OptionalHeader
.MinorSubsystemVersion
);
141 return defaultVersion
;
145 /***********************************************************************
146 * GetVersion16 (KERNEL.3)
148 LONG WINAPI
GetVersion16(void)
150 VERSION ver
= VERSION_GetVersion();
151 return VersionData
[ver
].getVersion16
;
155 /***********************************************************************
156 * GetVersion32 (KERNEL32.427)
158 LONG WINAPI
GetVersion32(void)
160 VERSION ver
= VERSION_GetVersion();
161 return VersionData
[ver
].getVersion32
;
165 /***********************************************************************
166 * GetVersionEx32A (KERNEL32.428)
168 BOOL32 WINAPI
GetVersionEx32A(OSVERSIONINFO32A
*v
)
170 VERSION ver
= VERSION_GetVersion();
171 if (v
->dwOSVersionInfoSize
!= sizeof(OSVERSIONINFO32A
))
173 WARN(ver
,"wrong OSVERSIONINFO size from app");
176 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
177 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
178 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
179 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
180 strcpy( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
185 /***********************************************************************
186 * GetVersionEx32W (KERNEL32.429)
188 BOOL32 WINAPI
GetVersionEx32W(OSVERSIONINFO32W
*v
)
190 VERSION ver
= VERSION_GetVersion();
191 if (v
->dwOSVersionInfoSize
!=sizeof(OSVERSIONINFO32W
))
193 WARN(ver
,"wrong OSVERSIONINFO size from app");
196 v
->dwMajorVersion
= VersionData
[ver
].getVersionEx
.dwMajorVersion
;
197 v
->dwMinorVersion
= VersionData
[ver
].getVersionEx
.dwMinorVersion
;
198 v
->dwBuildNumber
= VersionData
[ver
].getVersionEx
.dwBuildNumber
;
199 v
->dwPlatformId
= VersionData
[ver
].getVersionEx
.dwPlatformId
;
200 lstrcpyAtoW( v
->szCSDVersion
, VersionData
[ver
].getVersionEx
.szCSDVersion
);
205 /***********************************************************************
206 * GetWinFlags (KERNEL.132)
208 DWORD WINAPI
GetWinFlags(void)
210 static const long cpuflags
[5] =
211 { WF_CPU086
, WF_CPU186
, WF_CPU286
, WF_CPU386
, WF_CPU486
};
213 OSVERSIONINFO32A ovi
;
218 /* There doesn't seem to be any Pentium flag. */
219 result
= cpuflags
[MIN (si
.wProcessorLevel
, 4)];
224 result
|= WF_STANDARD
| WF_PMODE
| WF_80x87
;
228 result
|= WF_ENHANCED
| WF_PMODE
| WF_80x87
| WF_PAGING
;
232 ERR(ver
, "Unknown mode set? This shouldn't happen. Check GetWinFlags()!\n");
235 if (si
.wProcessorLevel
>= 4) result
|= WF_HASCPUID
;
236 ovi
.dwOSVersionInfoSize
= sizeof(ovi
);
237 GetVersionEx32A(&ovi
);
238 if (ovi
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
239 result
|= WF_WIN32WOW
; /* undocumented WF_WINNT */
244 /***********************************************************************
245 * GetWinDebugInfo (KERNEL.355)
247 BOOL16 WINAPI
GetWinDebugInfo(WINDEBUGINFO
*lpwdi
, UINT16 flags
)
249 FIXME(ver
, "(%8lx,%d): stub returning 0\n",
250 (unsigned long)lpwdi
, flags
);
251 /* 0 means not in debugging mode/version */
252 /* Can this type of debugging be used in wine ? */
253 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
258 /***********************************************************************
259 * SetWinDebugInfo (KERNEL.356)
261 BOOL16 WINAPI
SetWinDebugInfo(WINDEBUGINFO
*lpwdi
)
263 FIXME(ver
, "(%8lx): stub returning 0\n", (unsigned long)lpwdi
);
264 /* 0 means not in debugging mode/version */
265 /* Can this type of debugging be used in wine ? */
266 /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */
271 /***********************************************************************
272 * DebugFillBuffer (KERNEL.329)
275 * Should fill lpBuffer only if DBO_BUFFERFILL has been set by SetWinDebugInfo()
277 void WINAPI
DebugFillBuffer(LPSTR lpBuffer
, WORD wBytes
)
279 memset(lpBuffer
, DBGFILL_BUFFER
, wBytes
);
282 /***********************************************************************
283 * DiagQuery (KERNEL.339)
285 * returns TRUE if Win called with "/b" (bootlog.txt)
287 BOOL16 WINAPI
DiagQuery()
289 /* perhaps implement a Wine "/b" command line flag sometime ? */
293 /***********************************************************************
294 * DiagOutput (KERNEL.340)
296 * writes a debug string into <windir>\bootlog.txt
298 void WINAPI
DiagOutput(LPCSTR str
)
301 DPRINTF("DIAGOUTPUT:%s\n",str
);