ntdll: Use a common condition value for the major, minor and service pack version numbers.

This commit is contained in:
Robert Shearman 2006-07-17 12:09:27 +01:00 committed by Alexandre Julliard
parent 644e079d57
commit 31d9341e8e
2 changed files with 44 additions and 31 deletions

View File

@ -53,7 +53,7 @@ START_TEST(version)
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION, ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION,
pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL)); pVerSetConditionMask(0, 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());
ret = pVerifyVersionInfoA(&info, VER_BUILDNUMBER | VER_MAJORVERSION | ret = pVerifyVersionInfoA(&info, VER_BUILDNUMBER | VER_MAJORVERSION |
VER_MINORVERSION/* | VER_PLATFORMID | VER_SERVICEPACKMAJOR | VER_MINORVERSION/* | VER_PLATFORMID | VER_SERVICEPACKMAJOR |
@ -101,7 +101,7 @@ START_TEST(version)
info.wServicePackMinor++; info.wServicePackMinor++;
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
todo_wine 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());
/* test the failure hierarchy for the four version fields */ /* test the failure hierarchy for the four version fields */
@ -110,7 +110,7 @@ START_TEST(version)
info.wServicePackMajor++; info.wServicePackMajor++;
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
todo_wine 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); GetVersionEx((OSVERSIONINFO *)&info);
@ -129,10 +129,9 @@ START_TEST(version)
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
todo_wine 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,
@ -142,13 +141,12 @@ START_TEST(version)
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL)); pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
todo_wine ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError()); ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
/* test bad dwOSVersionInfoSize */ /* test bad dwOSVersionInfoSize */
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_MINORVERSION, VER_GREATER_EQUAL)); pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION), ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
} }

View File

@ -642,29 +642,44 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
if (status != STATUS_SUCCESS) if (status != STATUS_SUCCESS)
return status; return status;
} }
if(dwTypeMask & VER_MAJORVERSION)
if(dwTypeMask & (VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR))
{ {
status = version_compare_values(ver.dwMajorVersion, info->dwMajorVersion, dwlConditionMask >> 1*3 & 0x07); unsigned char condition = 0;
if (status != STATUS_SUCCESS)
return status; if(dwTypeMask & VER_MAJORVERSION)
} condition = dwlConditionMask >> 1*3 & 0x07;
if(dwTypeMask & VER_MINORVERSION) else if(dwTypeMask & VER_MINORVERSION)
{ condition = dwlConditionMask >> 0*3 & 0x07;
status = version_compare_values(ver.dwMinorVersion, info->dwMinorVersion, dwlConditionMask >> 0*3 & 0x07); else if(dwTypeMask & VER_SERVICEPACKMAJOR)
if (status != STATUS_SUCCESS) condition = dwlConditionMask >> 5*3 & 0x07;
return status; else if(dwTypeMask & VER_SERVICEPACKMINOR)
} condition = dwlConditionMask >> 4*3 & 0x07;
if(dwTypeMask & VER_SERVICEPACKMAJOR)
{ if(dwTypeMask & VER_MAJORVERSION)
status = version_compare_values(ver.wServicePackMajor, info->wServicePackMajor, dwlConditionMask >> 5*3 & 0x07); {
if (status != STATUS_SUCCESS) status = version_compare_values(ver.dwMajorVersion, info->dwMajorVersion, condition);
return status; if (status != STATUS_SUCCESS)
} return status;
if(dwTypeMask & VER_SERVICEPACKMINOR) }
{ if(dwTypeMask & VER_MINORVERSION)
status = version_compare_values(ver.wServicePackMinor, info->wServicePackMinor, dwlConditionMask >> 4*3 & 0x07); {
if (status != STATUS_SUCCESS) status = version_compare_values(ver.dwMinorVersion, info->dwMinorVersion, condition);
return status; if (status != STATUS_SUCCESS)
return status;
}
if(dwTypeMask & VER_SERVICEPACKMAJOR)
{
status = version_compare_values(ver.wServicePackMajor, info->wServicePackMajor, condition);
if (status != STATUS_SUCCESS)
return status;
}
if(dwTypeMask & VER_SERVICEPACKMINOR)
{
status = version_compare_values(ver.wServicePackMinor, info->wServicePackMinor, condition);
if (status != STATUS_SUCCESS)
return status;
}
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;