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/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
45 static inline UCHAR
version_update_condition(UCHAR
*last_condition
, UCHAR condition
)
47 switch (*last_condition
)
50 *last_condition
= condition
;
53 if (condition
>= VER_EQUAL
&& condition
<= VER_LESS_EQUAL
)
55 *last_condition
= condition
;
60 case VER_GREATER_EQUAL
:
61 if (condition
>= VER_EQUAL
&& condition
<= VER_GREATER_EQUAL
)
66 if (condition
== VER_EQUAL
|| (condition
>= VER_LESS
&& condition
<= VER_LESS_EQUAL
))
70 if (!condition
) *last_condition
|= 0x10;
71 return *last_condition
& 0xf;
74 static inline BOOL
version_compare_values(ULONG left
, ULONG right
, UCHAR condition
)
79 if (left
!= right
) return FALSE
;
82 if (left
<= right
) return FALSE
;
84 case VER_GREATER_EQUAL
:
85 if (left
< right
) return FALSE
;
88 if (left
>= right
) return FALSE
;
91 if (left
> right
) return FALSE
;
100 /******************************************************************************
101 * VerifyVersionInfoA (KERNEL32.@)
103 BOOL WINAPI
VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo
, DWORD dwTypeMask
,
104 DWORDLONG dwlConditionMask
)
106 OSVERSIONINFOEXW verW
;
108 verW
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEXW
);
109 verW
.dwMajorVersion
= lpVersionInfo
->dwMajorVersion
;
110 verW
.dwMinorVersion
= lpVersionInfo
->dwMinorVersion
;
111 verW
.dwBuildNumber
= lpVersionInfo
->dwBuildNumber
;
112 verW
.dwPlatformId
= lpVersionInfo
->dwPlatformId
;
113 verW
.wServicePackMajor
= lpVersionInfo
->wServicePackMajor
;
114 verW
.wServicePackMinor
= lpVersionInfo
->wServicePackMinor
;
115 verW
.wSuiteMask
= lpVersionInfo
->wSuiteMask
;
116 verW
.wProductType
= lpVersionInfo
->wProductType
;
117 verW
.wReserved
= lpVersionInfo
->wReserved
;
119 return VerifyVersionInfoW(&verW
, dwTypeMask
, dwlConditionMask
);
123 /******************************************************************************
124 * VerifyVersionInfoW (KERNEL32.@)
126 BOOL WINAPI
VerifyVersionInfoW( LPOSVERSIONINFOEXW info
, DWORD dwTypeMask
,
127 DWORDLONG dwlConditionMask
)
129 OSVERSIONINFOEXW ver
;
131 TRACE("(%p 0x%x 0x%s)\n", info
, dwTypeMask
, wine_dbgstr_longlong(dwlConditionMask
));
133 ver
.dwOSVersionInfoSize
= sizeof(ver
);
134 if (!GetVersionExW((OSVERSIONINFOW
*)&ver
)) return FALSE
;
136 if (!dwTypeMask
|| !dwlConditionMask
)
138 SetLastError(ERROR_BAD_ARGUMENTS
);
142 if (dwTypeMask
& VER_PRODUCT_TYPE
)
144 if (!version_compare_values(ver
.wProductType
, info
->wProductType
, dwlConditionMask
>> 7*3 & 0x07))
147 if (dwTypeMask
& VER_SUITENAME
)
148 switch (dwlConditionMask
>> 6*3 & 0x07)
151 if ((info
->wSuiteMask
& ver
.wSuiteMask
) != info
->wSuiteMask
)
155 if (!(info
->wSuiteMask
& ver
.wSuiteMask
) && info
->wSuiteMask
)
159 SetLastError(ERROR_BAD_ARGUMENTS
);
162 if (dwTypeMask
& VER_PLATFORMID
)
164 if (!version_compare_values(ver
.dwPlatformId
, info
->dwPlatformId
, dwlConditionMask
>> 3*3 & 0x07))
167 if (dwTypeMask
& VER_BUILDNUMBER
)
169 if (!version_compare_values(ver
.dwBuildNumber
, info
->dwBuildNumber
, dwlConditionMask
>> 2*3 & 0x07))
173 if (dwTypeMask
& (VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
))
175 unsigned char condition
, last_condition
= 0;
176 BOOL succeeded
= TRUE
, do_next_check
= TRUE
;
178 if (dwTypeMask
& VER_MAJORVERSION
)
180 condition
= version_update_condition(&last_condition
, dwlConditionMask
>> 1*3 & 0x07);
181 succeeded
= version_compare_values(ver
.dwMajorVersion
, info
->dwMajorVersion
, condition
);
182 do_next_check
= (ver
.dwMajorVersion
== info
->dwMajorVersion
) &&
183 ((condition
>= VER_EQUAL
) && (condition
<= VER_LESS_EQUAL
));
185 if ((dwTypeMask
& VER_MINORVERSION
) && do_next_check
)
187 condition
= version_update_condition(&last_condition
, dwlConditionMask
>> 0*3 & 0x07);
188 succeeded
= version_compare_values(ver
.dwMinorVersion
, info
->dwMinorVersion
, condition
);
189 do_next_check
= (ver
.dwMinorVersion
== info
->dwMinorVersion
) &&
190 ((condition
>= VER_EQUAL
) && (condition
<= VER_LESS_EQUAL
));
192 if ((dwTypeMask
& VER_SERVICEPACKMAJOR
) && do_next_check
)
194 condition
= version_update_condition(&last_condition
, dwlConditionMask
>> 5*3 & 0x07);
195 succeeded
= version_compare_values(ver
.wServicePackMajor
, info
->wServicePackMajor
, condition
);
196 do_next_check
= (ver
.wServicePackMajor
== info
->wServicePackMajor
) &&
197 ((condition
>= VER_EQUAL
) && (condition
<= VER_LESS_EQUAL
));
199 if ((dwTypeMask
& VER_SERVICEPACKMINOR
) && do_next_check
)
201 condition
= version_update_condition(&last_condition
, dwlConditionMask
>> 4*3 & 0x07);
202 succeeded
= version_compare_values(ver
.wServicePackMinor
, info
->wServicePackMinor
, condition
);
205 if (!succeeded
) goto mismatch
;
211 SetLastError(ERROR_OLD_WIN_VERSION
);
215 /***********************************************************************
216 * TermsrvAppInstallMode (KERNEL32.@)
218 * Find out whether the terminal server is in INSTALL or EXECUTE mode.
220 BOOL WINAPI
TermsrvAppInstallMode(void)
226 /***********************************************************************
227 * SetTermsrvAppInstallMode (KERNEL32.@)
229 * This function is said to switch between the INSTALL (TRUE) or
230 * EXECUTE (FALSE) terminal server modes.
232 * This function always returns zero on WinXP Home so it's probably
233 * safe to return that value in most cases. However, if a terminal
234 * server is running it will probably return something else.
236 DWORD WINAPI
SetTermsrvAppInstallMode(BOOL bInstallMode
)
238 FIXME("(%d): stub\n", bInstallMode
);
242 /***********************************************************************
243 * GetCurrentPackageId (KERNEL32.@)
245 LONG WINAPI
GetCurrentPackageId(UINT32
*len
, BYTE
*buffer
)
247 FIXME("(%p %p): stub\n", len
, buffer
);
248 return APPMODEL_ERROR_NO_PACKAGE
;
251 /***********************************************************************
252 * GetCurrentPackageFamilyName (KERNEL32.@)
254 LONG WINAPI
GetCurrentPackageFamilyName(UINT32
*length
, PWSTR name
)
256 FIXME("(%p %p): stub\n", length
, name
);
257 return APPMODEL_ERROR_NO_PACKAGE
;
260 /***********************************************************************
261 * GetCurrentPackageFullName (KERNEL32.@)
263 LONG WINAPI
GetCurrentPackageFullName(UINT32
*length
, PWSTR name
)
265 FIXME("(%p %p): stub\n", length
, name
);
266 return APPMODEL_ERROR_NO_PACKAGE
;
269 /***********************************************************************
270 * GetPackageFullName (KERNEL32.@)
272 LONG WINAPI
GetPackageFullName(HANDLE process
, UINT32
*length
, PWSTR name
)
274 FIXME("(%p %p %p): stub\n", process
, length
, name
);
275 return APPMODEL_ERROR_NO_PACKAGE
;