Commit a3ca06be authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

ntdll: Fix RtlVerifyVersionInfo handling of major, minor and service pack…

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.
parent 31d9341e
...@@ -81,21 +81,21 @@ START_TEST(version) ...@@ -81,21 +81,21 @@ START_TEST(version)
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
VER_MAJORVERSION, 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.dwMinorVersion = 0;
info.wServicePackMajor = 10; info.wServicePackMajor = 10;
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
VER_MAJORVERSION, 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.wServicePackMajor = 0;
info.wServicePackMinor = 10; info.wServicePackMinor = 10;
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL), pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
VER_MAJORVERSION, 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); GetVersionEx((OSVERSIONINFO *)&info);
info.wServicePackMinor++; info.wServicePackMinor++;
...@@ -104,6 +104,37 @@ START_TEST(version) ...@@ -104,6 +104,37 @@ START_TEST(version)
ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION), ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError()); "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 */ /* test the failure hierarchy for the four version fields */
GetVersionEx((OSVERSIONINFO *)&info); GetVersionEx((OSVERSIONINFO *)&info);
...@@ -132,6 +163,7 @@ START_TEST(version) ...@@ -132,6 +163,7 @@ START_TEST(version)
ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); 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); GetVersionEx((OSVERSIONINFO *)&info);
info.dwBuildNumber++; info.dwBuildNumber++;
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
...@@ -147,6 +179,7 @@ START_TEST(version) ...@@ -147,6 +179,7 @@ START_TEST(version)
GetVersionEx((OSVERSIONINFO *)&info); GetVersionEx((OSVERSIONINFO *)&info);
info.dwOSVersionInfoSize = 0; info.dwOSVersionInfoSize = 0;
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL)); pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
} }
...@@ -646,6 +646,7 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info, ...@@ -646,6 +646,7 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
if(dwTypeMask & (VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR)) if(dwTypeMask & (VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR))
{ {
unsigned char condition = 0; unsigned char condition = 0;
BOOLEAN do_next_check = TRUE;
if(dwTypeMask & VER_MAJORVERSION) if(dwTypeMask & VER_MAJORVERSION)
condition = dwlConditionMask >> 1*3 & 0x07; condition = dwlConditionMask >> 1*3 & 0x07;
...@@ -659,27 +660,28 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info, ...@@ -659,27 +660,28 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
if(dwTypeMask & VER_MAJORVERSION) if(dwTypeMask & VER_MAJORVERSION)
{ {
status = version_compare_values(ver.dwMajorVersion, info->dwMajorVersion, condition); status = version_compare_values(ver.dwMajorVersion, info->dwMajorVersion, condition);
if (status != STATUS_SUCCESS) do_next_check = (ver.dwMajorVersion == info->dwMajorVersion) &&
return status; ((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); status = version_compare_values(ver.dwMinorVersion, info->dwMinorVersion, condition);
if (status != STATUS_SUCCESS) do_next_check = (ver.dwMinorVersion == info->dwMinorVersion) &&
return status; ((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); status = version_compare_values(ver.wServicePackMajor, info->wServicePackMajor, condition);
if (status != STATUS_SUCCESS) do_next_check = (ver.wServicePackMajor == info->wServicePackMajor) &&
return status; ((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); status = version_compare_values(ver.wServicePackMinor, info->wServicePackMinor, condition);
if (status != STATUS_SUCCESS)
return status;
} }
if (status != STATUS_SUCCESS)
return status;
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment