[PATCH 3/4] ntdll: Move the implementation of RtlVerifyVersionInfo into a helper.

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Mar 16 08:06:00 CDT 2020


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/ntdll/version.c | 54 +++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 23 deletions(-)

diff --git a/dlls/ntdll/version.c b/dlls/ntdll/version.c
index f48f725..60c4942 100644
--- a/dlls/ntdll/version.c
+++ b/dlls/ntdll/version.c
@@ -701,25 +701,16 @@ static inline NTSTATUS version_compare_values(ULONG left, ULONG right, UCHAR con
     return STATUS_SUCCESS;
 }
 
-/******************************************************************************
- *        RtlVerifyVersionInfo   (NTDLL.@)
- */
-NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
-                                      DWORD dwTypeMask, DWORDLONG dwlConditionMask )
+static NTSTATUS verify_version_info(const RTL_OSVERSIONINFOEXW *info, const RTL_OSVERSIONINFOEXW *ver,
+                                    DWORD dwTypeMask, DWORDLONG dwlConditionMask)
 {
-    RTL_OSVERSIONINFOEXW ver;
     NTSTATUS status;
 
-    TRACE("(%p,0x%x,0x%s)\n", info, dwTypeMask, wine_dbgstr_longlong(dwlConditionMask));
-
-    ver.dwOSVersionInfoSize = sizeof(ver);
-    if ((status = RtlGetVersion( &ver )) != STATUS_SUCCESS) return status;
-
     if(!(dwTypeMask && dwlConditionMask)) return STATUS_INVALID_PARAMETER;
 
     if(dwTypeMask & VER_PRODUCT_TYPE)
     {
-        status = version_compare_values(ver.wProductType, info->wProductType, dwlConditionMask >> 7*3 & 0x07);
+        status = version_compare_values(ver->wProductType, info->wProductType, dwlConditionMask >> 7*3 & 0x07);
         if (status != STATUS_SUCCESS)
             return status;
     }
@@ -727,11 +718,11 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
         switch(dwlConditionMask >> 6*3 & 0x07)
         {
             case VER_AND:
-                if((info->wSuiteMask & ver.wSuiteMask) != info->wSuiteMask)
+                if((info->wSuiteMask & ver->wSuiteMask) != info->wSuiteMask)
                     return STATUS_REVISION_MISMATCH;
                 break;
             case VER_OR:
-                if(!(info->wSuiteMask & ver.wSuiteMask) && info->wSuiteMask)
+                if(!(info->wSuiteMask & ver->wSuiteMask) && info->wSuiteMask)
                     return STATUS_REVISION_MISMATCH;
                 break;
             default:
@@ -739,13 +730,13 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
         }
     if(dwTypeMask & VER_PLATFORMID)
     {
-        status = version_compare_values(ver.dwPlatformId, info->dwPlatformId, dwlConditionMask >> 3*3 & 0x07);
+        status = version_compare_values(ver->dwPlatformId, info->dwPlatformId, dwlConditionMask >> 3*3 & 0x07);
         if (status != STATUS_SUCCESS)
             return status;
     }
     if(dwTypeMask & VER_BUILDNUMBER)
     {
-        status = version_compare_values(ver.dwBuildNumber, info->dwBuildNumber, dwlConditionMask >> 2*3 & 0x07);
+        status = version_compare_values(ver->dwBuildNumber, info->dwBuildNumber, dwlConditionMask >> 2*3 & 0x07);
         if (status != STATUS_SUCCESS)
             return status;
     }
@@ -758,28 +749,28 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
         if(dwTypeMask & VER_MAJORVERSION)
         {
             condition = version_update_condition(&last_condition, dwlConditionMask >> 1*3 & 0x07);
-            status = version_compare_values(ver.dwMajorVersion, info->dwMajorVersion, condition);
-            do_next_check = (ver.dwMajorVersion == info->dwMajorVersion) &&
+            status = version_compare_values(ver->dwMajorVersion, info->dwMajorVersion, condition);
+            do_next_check = (ver->dwMajorVersion == info->dwMajorVersion) &&
                 ((condition >= VER_EQUAL) && (condition <= VER_LESS_EQUAL));
         }
         if((dwTypeMask & VER_MINORVERSION) && do_next_check)
         {
             condition = version_update_condition(&last_condition, dwlConditionMask >> 0*3 & 0x07);
-            status = version_compare_values(ver.dwMinorVersion, info->dwMinorVersion, condition);
-            do_next_check = (ver.dwMinorVersion == info->dwMinorVersion) &&
+            status = version_compare_values(ver->dwMinorVersion, info->dwMinorVersion, condition);
+            do_next_check = (ver->dwMinorVersion == info->dwMinorVersion) &&
                 ((condition >= VER_EQUAL) && (condition <= VER_LESS_EQUAL));
         }
         if((dwTypeMask & VER_SERVICEPACKMAJOR) && do_next_check)
         {
             condition = version_update_condition(&last_condition, dwlConditionMask >> 5*3 & 0x07);
-            status = version_compare_values(ver.wServicePackMajor, info->wServicePackMajor, condition);
-            do_next_check = (ver.wServicePackMajor == info->wServicePackMajor) &&
+            status = version_compare_values(ver->wServicePackMajor, info->wServicePackMajor, condition);
+            do_next_check = (ver->wServicePackMajor == info->wServicePackMajor) &&
                 ((condition >= VER_EQUAL) && (condition <= VER_LESS_EQUAL));
         }
         if((dwTypeMask & VER_SERVICEPACKMINOR) && do_next_check)
         {
             condition = version_update_condition(&last_condition, dwlConditionMask >> 4*3 & 0x07);
-            status = version_compare_values(ver.wServicePackMinor, info->wServicePackMinor, condition);
+            status = version_compare_values(ver->wServicePackMinor, info->wServicePackMinor, condition);
         }
 
         if (status != STATUS_SUCCESS)
@@ -789,6 +780,23 @@ NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
     return STATUS_SUCCESS;
 }
 
+/******************************************************************************
+ *        RtlVerifyVersionInfo   (NTDLL.@)
+ */
+NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
+                                      DWORD dwTypeMask, DWORDLONG dwlConditionMask )
+{
+    RTL_OSVERSIONINFOEXW ver;
+    NTSTATUS status;
+
+    TRACE("(%p,0x%x,0x%s)\n", info, dwTypeMask, wine_dbgstr_longlong(dwlConditionMask));
+
+    ver.dwOSVersionInfoSize = sizeof(ver);
+    if ((status = RtlGetVersion( &ver )) != STATUS_SUCCESS) return status;
+
+    return verify_version_info(info, &ver, dwTypeMask, dwlConditionMask);
+}
+
 /******************************************************************************
  *  __wine_get_compat_win_version   (NTDLL.@)
  *
-- 
2.21.0




More information about the wine-devel mailing list