Module: wine Branch: refs/heads/master Commit: a3ca06be2ff43853e7bb1baf9869f12547779e74 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=a3ca06be2ff43853e7bb1baf...
Author: Robert Shearman rob@codeweavers.com Date: Mon Jul 17 12:11:04 2006 +0100
ntdll: Fix RtlVerifyVersionInfo handling of major, minor and service pack versions, which are tested in a hierarchical manner.
Add some new tests for the different condition values.
---
dlls/kernel/tests/version.c | 43 ++++++++++++++++++++++++++++++++++++++----- dlls/ntdll/version.c | 24 +++++++++++++----------- 2 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/dlls/kernel/tests/version.c b/dlls/kernel/tests/version.c index 73ba665..96999e5 100644 --- a/dlls/kernel/tests/version.c +++ b/dlls/kernel/tests/version.c @@ -81,21 +81,21 @@ START_TEST(version) ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), VER_MAJORVERSION, VER_GREATER_EQUAL)); - todo_wine ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); + ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
info.dwMinorVersion = 0; info.wServicePackMajor = 10; ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), VER_MAJORVERSION, VER_GREATER_EQUAL)); - todo_wine ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); + ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
info.wServicePackMajor = 0; info.wServicePackMinor = 10; ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), VER_MAJORVERSION, VER_GREATER_EQUAL)); - todo_wine ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); + ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
GetVersionEx((OSVERSIONINFO *)&info); info.wServicePackMinor++; @@ -104,6 +104,37 @@ START_TEST(version) ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION), "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
+ GetVersionEx((OSVERSIONINFO *)&info); + info.wServicePackMajor--; + ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, + pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER)); + ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); + + GetVersionEx((OSVERSIONINFO *)&info); + info.wServicePackMajor--; + ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, + pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); + ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); + + GetVersionEx((OSVERSIONINFO *)&info); + info.wServicePackMajor++; + ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, + pVerSetConditionMask(0, VER_MINORVERSION, VER_LESS)); + ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); + + GetVersionEx((OSVERSIONINFO *)&info); + info.wServicePackMajor++; + ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, + pVerSetConditionMask(0, VER_MINORVERSION, VER_LESS_EQUAL)); + ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); + + GetVersionEx((OSVERSIONINFO *)&info); + info.wServicePackMajor--; + ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, + pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL)); + ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION), + "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError()); + /* test the failure hierarchy for the four version fields */
GetVersionEx((OSVERSIONINFO *)&info); @@ -132,6 +163,7 @@ START_TEST(version) ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
+ /* shows that build number fits into the hierarchy after major version, but before minor version */ GetVersionEx((OSVERSIONINFO *)&info); info.dwBuildNumber++; ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, @@ -147,6 +179,7 @@ START_TEST(version) GetVersionEx((OSVERSIONINFO *)&info); info.dwOSVersionInfoSize = 0; ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, - pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL)); - ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); + pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); + todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION), + "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError()); } diff --git a/dlls/ntdll/version.c b/dlls/ntdll/version.c index a5b9d45..340ae8b 100644 --- a/dlls/ntdll/version.c +++ b/dlls/ntdll/version.c @@ -646,6 +646,7 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( co if(dwTypeMask & (VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR)) { unsigned char condition = 0; + BOOLEAN do_next_check = TRUE;
if(dwTypeMask & VER_MAJORVERSION) condition = dwlConditionMask >> 1*3 & 0x07; @@ -659,27 +660,28 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( co if(dwTypeMask & VER_MAJORVERSION) { status = version_compare_values(ver.dwMajorVersion, info->dwMajorVersion, condition); - if (status != STATUS_SUCCESS) - return status; + do_next_check = (ver.dwMajorVersion == info->dwMajorVersion) && + ((condition != VER_EQUAL) || (status == STATUS_SUCCESS)); } - if(dwTypeMask & VER_MINORVERSION) + if((dwTypeMask & VER_MINORVERSION) && do_next_check) { status = version_compare_values(ver.dwMinorVersion, info->dwMinorVersion, condition); - if (status != STATUS_SUCCESS) - return status; + do_next_check = (ver.dwMinorVersion == info->dwMinorVersion) && + ((condition != VER_EQUAL) || (status == STATUS_SUCCESS)); } - if(dwTypeMask & VER_SERVICEPACKMAJOR) + if((dwTypeMask & VER_SERVICEPACKMAJOR) && do_next_check) { status = version_compare_values(ver.wServicePackMajor, info->wServicePackMajor, condition); - if (status != STATUS_SUCCESS) - return status; + do_next_check = (ver.wServicePackMajor == info->wServicePackMajor) && + ((condition != VER_EQUAL) || (status == STATUS_SUCCESS)); } - if(dwTypeMask & VER_SERVICEPACKMINOR) + if((dwTypeMask & VER_SERVICEPACKMINOR) && do_next_check) { status = version_compare_values(ver.wServicePackMinor, info->wServicePackMinor, condition); - if (status != STATUS_SUCCESS) - return status; } + + if (status != STATUS_SUCCESS) + return status; }
return STATUS_SUCCESS;