[Wine-patches] [eterhack] version: Fix processing "\\\\VarFileInfo\\\\Translation" (eterbug #4656).

Alexander Morozov amorozov на etersoft.ru
Пн Окт 10 17:42:52 MSD 2011


----------- следующая часть -----------
From ad4b6b7acc285919b1593b87ec40319a0bcd4409 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Mon, 10 Oct 2011 17:37:23 +0400
Subject: [PATCH] version: Fix processing "\\\\VarFileInfo\\\\Translation"
 (eterbug #4656).

---
 dlls/version/version.c |   61 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/dlls/version/version.c b/dlls/version/version.c
index bc90dcc..86a942e 100644
--- a/dlls/version/version.c
+++ b/dlls/version/version.c
@@ -888,13 +888,66 @@ static BOOL VersionInfo32_QueryValue( const VS_VERSION_INFO_STRUCT32 *info, LPCW
 }
 
 /***********************************************************************
+ *           VERSION_IsRootOrTranslationA             [internal]
+ */
+static BOOL VERSION_IsRootOrTranslationA( LPCSTR value )
+{
+    static const char varfileinfoA[] = "VarFileInfo\\";
+    static const char translationA[] = "Translation";
+
+    BOOL check_translation = FALSE;
+    UINT len;
+
+    while (*value)
+    {
+        if (*value == '\\')
+            ++value;
+        else if (check_translation && !strcasecmp( value, translationA ))
+            return TRUE;
+        else if (!strncasecmp( value, varfileinfoA, len = strlen(varfileinfoA) ))
+        {
+            check_translation = TRUE;
+            value += len;
+        }
+        else return FALSE;
+    }
+    return TRUE;
+}
+
+/***********************************************************************
+ *           VERSION_IsRootOrTranslationW             [internal]
+ */
+static BOOL VERSION_IsRootOrTranslationW( LPCWSTR value )
+{
+    static const WCHAR varfileinfoW[] = { '\\','V','a','r','F','i','l','e','I','n','f','o','\\', 0 };
+    static const WCHAR translationW[] = { '\\','T','r','a','n','s','l','a','t','i','o','n', 0 };
+
+    BOOL check_translation = FALSE;
+    UINT len;
+
+    while (*value)
+    {
+        if (*value == '\\')
+            ++value;
+        else if (check_translation && !strcmpiW( value, translationW ))
+            return TRUE;
+        else if (!strncmpiW( value, varfileinfoW, len = strlenW(varfileinfoW) ))
+        {
+            check_translation = TRUE;
+            value += len;
+        }
+        else return FALSE;
+    }
+    return TRUE;
+}
+
+/***********************************************************************
  *           VerQueryValueA              [VERSION.@]
  */
 BOOL WINAPI VerQueryValueA( LPCVOID pBlock, LPCSTR lpSubBlock,
                                LPVOID *lplpBuffer, PUINT puLen )
 {
     static const char rootA[] = "\\";
-    static const char varfileinfoA[] = "\\VarFileInfo\\Translation";
     const VS_VERSION_INFO_STRUCT16 *info = pBlock;
 
     TRACE("(%p,%s,%p,%p)\n",
@@ -924,7 +977,7 @@ BOOL WINAPI VerQueryValueA( LPCVOID pBlock, LPCSTR lpSubBlock,
 
         HeapFree(GetProcessHeap(), 0, lpSubBlockW);
 
-        if (ret && strcasecmp( lpSubBlock, rootA ) && strcasecmp( lpSubBlock, varfileinfoA ))
+        if (ret && !VERSION_IsRootOrTranslationA( lpSubBlock ))
         {
             /* Set lpBuffer so it points to the 'empty' area where we store
              * the converted strings
@@ -951,8 +1004,6 @@ BOOL WINAPI VerQueryValueW( LPCVOID pBlock, LPCWSTR lpSubBlock,
 {
     static const WCHAR nullW[] = { 0 };
     static const WCHAR rootW[] = { '\\', 0 };
-    static const WCHAR varfileinfoW[] = { '\\','V','a','r','F','i','l','e','I','n','f','o',
-                                          '\\','T','r','a','n','s','l','a','t','i','o','n', 0 };
 
     const VS_VERSION_INFO_STRUCT32 *info = pBlock;
 
@@ -983,7 +1034,7 @@ BOOL WINAPI VerQueryValueW( LPCVOID pBlock, LPCWSTR lpSubBlock,
 
         HeapFree(GetProcessHeap(), 0, lpSubBlockA);
 
-        if (ret && strcmpiW( lpSubBlock, rootW ) && strcmpiW( lpSubBlock, varfileinfoW ))
+        if (ret && !VERSION_IsRootOrTranslationW( lpSubBlock ))
         {
             /* Set lpBuffer so it points to the 'empty' area where we store
              * the converted strings
-- 
1.7.6.1



Подробная информация о списке рассылки Wine-patches