Author: cwittich
Date: Wed Jul 23 06:19:01 2008
New Revision: 34692
URL:
http://svn.reactos.org/svn/reactos?rev=34692&view=rev
Log:
fix all kernel32 version winetests
Modified:
trunk/reactos/lib/rtl/version.c
Modified: trunk/reactos/lib/rtl/version.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/version.c?rev=3469…
==============================================================================
--- trunk/reactos/lib/rtl/version.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/version.c [iso-8859-1] Wed Jul 23 06:19:01 2008
@@ -22,16 +22,40 @@
/* FUNCTIONS ****************************************************************/
+static inline NTSTATUS version_compare_values(ULONG left, ULONG right, UCHAR condition)
+{
+ switch (condition) {
+ case VER_EQUAL:
+ if (left != right) return STATUS_REVISION_MISMATCH;
+ break;
+ case VER_GREATER:
+ if (left <= right) return STATUS_REVISION_MISMATCH;
+ break;
+ case VER_GREATER_EQUAL:
+ if (left < right) return STATUS_REVISION_MISMATCH;
+ break;
+ case VER_LESS:
+ if (left >= right) return STATUS_REVISION_MISMATCH;
+ break;
+ case VER_LESS_EQUAL:
+ if (left > right) return STATUS_REVISION_MISMATCH;
+ break;
+ default:
+ return STATUS_REVISION_MISMATCH;
+ }
+ return STATUS_SUCCESS;
+}
+
/*
* @implemented
*/
NTSTATUS
NTAPI
RtlVerifyVersionInfo(
- IN PRTL_OSVERSIONINFOEXW VersionInfo,
- IN ULONG TypeMask,
- IN ULONGLONG ConditionMask
- )
+ IN PRTL_OSVERSIONINFOEXW VersionInfo,
+ IN ULONG TypeMask,
+ IN ULONGLONG ConditionMask
+ )
{
RTL_OSVERSIONINFOEXW ver;
NTSTATUS status;
@@ -44,32 +68,20 @@
*/
ver.dwOSVersionInfoSize = sizeof(ver);
- if ((status = RtlGetVersion( (PRTL_OSVERSIONINFOW)&ver )) != STATUS_SUCCESS)
return status;
+ status = RtlGetVersion( (PRTL_OSVERSIONINFOW)&ver );
+ if (status != STATUS_SUCCESS) return status;
if(!(TypeMask && ConditionMask)) return STATUS_INVALID_PARAMETER;
if(TypeMask & VER_PRODUCT_TYPE)
- switch(ConditionMask >> 7*3 & 0x07) {
- case VER_EQUAL:
- if(ver.wProductType != VersionInfo->wProductType) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER:
- if(ver.wProductType <= VersionInfo->wProductType) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER_EQUAL:
- if(ver.wProductType < VersionInfo->wProductType) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS:
- if(ver.wProductType >= VersionInfo->wProductType) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS_EQUAL:
- if(ver.wProductType > VersionInfo->wProductType) return
STATUS_REVISION_MISMATCH;
- break;
- default:
- return STATUS_INVALID_PARAMETER;
- }
+ {
+ status = version_compare_values(ver.wProductType, VersionInfo->wProductType,
ConditionMask >> 7 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
+ if (status != STATUS_SUCCESS)
+ return status;
+ }
if(TypeMask & VER_SUITENAME)
- switch(ConditionMask >> 6*3 & 0x07)
+ {
+ switch(ConditionMask >> 6 * VER_NUM_BITS_PER_CONDITION_MASK &
VER_CONDITION_MASK)
{
case VER_AND:
if((VersionInfo->wSuiteMask & ver.wSuiteMask) !=
VersionInfo->wSuiteMask)
@@ -82,132 +94,59 @@
default:
return STATUS_INVALID_PARAMETER;
}
+ }
if(TypeMask & VER_PLATFORMID)
- switch(ConditionMask >> 3*3 & 0x07)
+ {
+ status = version_compare_values(ver.dwPlatformId, VersionInfo->dwPlatformId,
ConditionMask >> 3 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
+ if (status != STATUS_SUCCESS)
+ return status;
+ }
+ if(TypeMask & VER_BUILDNUMBER)
+ {
+ status = version_compare_values(ver.dwBuildNumber, VersionInfo->dwBuildNumber,
ConditionMask >> 2 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
+ if (status != STATUS_SUCCESS)
+ return status;
+ }
+ if(TypeMask &
(VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR))
+ {
+ unsigned char condition = 0;
+ BOOLEAN do_next_check = TRUE;
+
+ if(TypeMask & VER_MAJORVERSION)
+ condition = ConditionMask >> 1 * VER_NUM_BITS_PER_CONDITION_MASK &
VER_CONDITION_MASK;
+ else if(TypeMask & VER_MINORVERSION)
+ condition = ConditionMask >> 0 * VER_NUM_BITS_PER_CONDITION_MASK &
VER_CONDITION_MASK;
+ else if(TypeMask & VER_SERVICEPACKMAJOR)
+ condition = ConditionMask >> 5 * VER_NUM_BITS_PER_CONDITION_MASK &
VER_CONDITION_MASK;
+ else if(TypeMask & VER_SERVICEPACKMINOR)
+ condition = ConditionMask >> 4 * VER_NUM_BITS_PER_CONDITION_MASK &
VER_CONDITION_MASK;
+
+ if(TypeMask & VER_MAJORVERSION)
{
- case VER_EQUAL:
- if(ver.dwPlatformId != VersionInfo->dwPlatformId) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER:
- if(ver.dwPlatformId <= VersionInfo->dwPlatformId) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER_EQUAL:
- if(ver.dwPlatformId < VersionInfo->dwPlatformId) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS:
- if(ver.dwPlatformId >= VersionInfo->dwPlatformId) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS_EQUAL:
- if(ver.dwPlatformId > VersionInfo->dwPlatformId) return
STATUS_REVISION_MISMATCH;
- break;
- default:
- return STATUS_INVALID_PARAMETER;
+ status = version_compare_values(ver.dwMajorVersion,
VersionInfo->dwMajorVersion, condition);
+ do_next_check = (ver.dwMajorVersion == VersionInfo->dwMajorVersion)
&&
+ ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
}
- if(TypeMask & VER_BUILDNUMBER)
- switch(ConditionMask >> 2*3 & 0x07)
+ if((TypeMask & VER_MINORVERSION) && do_next_check)
{
- case VER_EQUAL:
- if(ver.dwBuildNumber != VersionInfo->dwBuildNumber) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER:
- if(ver.dwBuildNumber <= VersionInfo->dwBuildNumber) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER_EQUAL:
- if(ver.dwBuildNumber < VersionInfo->dwBuildNumber) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS:
- if(ver.dwBuildNumber >= VersionInfo->dwBuildNumber) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS_EQUAL:
- if(ver.dwBuildNumber > VersionInfo->dwBuildNumber) return
STATUS_REVISION_MISMATCH;
- break;
- default:
- return STATUS_INVALID_PARAMETER;
+ status = version_compare_values(ver.dwMinorVersion,
VersionInfo->dwMinorVersion, condition);
+ do_next_check = (ver.dwMinorVersion == VersionInfo->dwMinorVersion)
&&
+ ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
}
- if(TypeMask & VER_MAJORVERSION)
- switch(ConditionMask >> 1*3 & 0x07)
+ if((TypeMask & VER_SERVICEPACKMAJOR) && do_next_check)
{
- case VER_EQUAL:
- if(ver.dwMajorVersion != VersionInfo->dwMajorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER:
- if(ver.dwMajorVersion <= VersionInfo->dwMajorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER_EQUAL:
- if(ver.dwMajorVersion < VersionInfo->dwMajorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS:
- if(ver.dwMajorVersion >= VersionInfo->dwMajorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS_EQUAL:
- if(ver.dwMajorVersion > VersionInfo->dwMajorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- default:
- return STATUS_INVALID_PARAMETER;
+ status = version_compare_values(ver.wServicePackMajor,
VersionInfo->wServicePackMajor, condition);
+ do_next_check = (ver.wServicePackMajor == VersionInfo->wServicePackMajor)
&&
+ ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
}
- if(TypeMask & VER_MINORVERSION)
- switch(ConditionMask >> 0*3 & 0x07)
+ if((TypeMask & VER_SERVICEPACKMINOR) && do_next_check)
{
- case VER_EQUAL:
- if(ver.dwMinorVersion != VersionInfo->dwMinorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER:
- if(ver.dwMinorVersion <= VersionInfo->dwMinorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER_EQUAL:
- if(ver.dwMinorVersion < VersionInfo->dwMinorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS:
- if(ver.dwMinorVersion >= VersionInfo->dwMinorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS_EQUAL:
- if(ver.dwMinorVersion > VersionInfo->dwMinorVersion) return
STATUS_REVISION_MISMATCH;
- break;
- default:
- return STATUS_INVALID_PARAMETER;
+ status = version_compare_values(ver.wServicePackMinor,
VersionInfo->wServicePackMinor, condition);
}
- if(TypeMask & VER_SERVICEPACKMAJOR)
- switch(ConditionMask >> 5*3 & 0x07)
- {
- case VER_EQUAL:
- if(ver.wServicePackMajor != VersionInfo->wServicePackMajor) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER:
- if(ver.wServicePackMajor <= VersionInfo->wServicePackMajor) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER_EQUAL:
- if(ver.wServicePackMajor < VersionInfo->wServicePackMajor) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS:
- if(ver.wServicePackMajor >= VersionInfo->wServicePackMajor) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS_EQUAL:
- if(ver.wServicePackMajor > VersionInfo->wServicePackMajor) return
STATUS_REVISION_MISMATCH;
- break;
- default:
- return STATUS_INVALID_PARAMETER;
- }
- if(TypeMask & VER_SERVICEPACKMINOR)
- switch(ConditionMask >> 4*3 & 0x07)
- {
- case VER_EQUAL:
- if(ver.wServicePackMinor != VersionInfo->wServicePackMinor) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER:
- if(ver.wServicePackMinor <= VersionInfo->wServicePackMinor) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER_EQUAL:
- if(ver.wServicePackMinor < VersionInfo->wServicePackMinor) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS:
- if(ver.wServicePackMinor >= VersionInfo->wServicePackMinor) return
STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS_EQUAL:
- if(ver.wServicePackMinor > VersionInfo->wServicePackMinor) return
STATUS_REVISION_MISMATCH;
- break;
- default:
- return STATUS_INVALID_PARAMETER;
- }
+
+ if (status != STATUS_SUCCESS)
+ return status;
+ }
return STATUS_SUCCESS;
}