James Hawkins : msi: Check the file version when a version is provided in the signature.

Alexandre Julliard julliard at winehq.org
Mon Oct 20 08:00:48 CDT 2008


Module: wine
Branch: master
Commit: 859bd01b5e0d492808721570c5d77b247782f31e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=859bd01b5e0d492808721570c5d77b247782f31e

Author: James Hawkins <jhawkins at codeweavers.com>
Date:   Mon Oct 20 04:19:30 2008 -0500

msi: Check the file version when a version is provided in the signature.

---

 dlls/msi/appsearch.c     |   60 +++++++++++++++++++++++++++++++++++++++++++--
 dlls/msi/tests/package.c |   35 +++++++-------------------
 2 files changed, 67 insertions(+), 28 deletions(-)

diff --git a/dlls/msi/appsearch.c b/dlls/msi/appsearch.c
index 247cee0..31a1f5d 100644
--- a/dlls/msi/appsearch.c
+++ b/dlls/msi/appsearch.c
@@ -155,6 +155,60 @@ static void ACTION_FreeSignature(MSISIGNATURE *sig)
     msi_free(sig->Languages);
 }
 
+static LPWSTR app_search_file(LPWSTR path, MSISIGNATURE *sig)
+{
+    VS_FIXEDFILEINFO *info;
+    DWORD attr, handle, size;
+    LPWSTR val = NULL;
+    LPBYTE buffer;
+
+    static const WCHAR root[] = {'\\',0};
+
+    attr = GetFileAttributesW(path);
+    if (attr == INVALID_FILE_ATTRIBUTES || attr == FILE_ATTRIBUTE_DIRECTORY)
+        return NULL;
+
+    size = GetFileVersionInfoSizeW(path, &handle);
+    if (!size)
+        return strdupW(path);
+
+    buffer = msi_alloc(size);
+    if (!buffer)
+        return NULL;
+
+    if (!GetFileVersionInfoW(path, 0, size, buffer))
+        goto done;
+
+    if (!VerQueryValueW(buffer, root, (LPVOID)&info, &size) || !info)
+        goto done;
+
+    if (sig->MinVersionLS || sig->MinVersionMS)
+    {
+        if (info->dwFileVersionMS < sig->MinVersionMS)
+            goto done;
+
+        if (info->dwFileVersionMS == sig->MinVersionMS &&
+            info->dwFileVersionLS < sig->MinVersionLS)
+            goto done;
+    }
+
+    if (sig->MaxVersionLS || sig->MaxVersionMS)
+    {
+        if (info->dwFileVersionMS > sig->MaxVersionMS)
+            goto done;
+
+        if (info->dwFileVersionMS == sig->MaxVersionMS &&
+            info->dwFileVersionLS > sig->MaxVersionLS)
+            goto done;
+    }
+
+    val = strdupW(path);
+
+done:
+    msi_free(buffer);
+    return val;
+}
+
 static UINT ACTION_AppSearchComponents(MSIPACKAGE *package, LPWSTR *appValue, MSISIGNATURE *sig)
 {
     static const WCHAR query[] =  {
@@ -211,7 +265,7 @@ static UINT ACTION_AppSearchComponents(MSIPACKAGE *package, LPWSTR *appValue, MS
 
     if (type != msidbLocatorTypeDirectory && sigpresent && !isdir)
     {
-        *appValue = strdupW(path);
+        *appValue = app_search_file(path, sig);
     }
     else if (!sigpresent && (type != msidbLocatorTypeDirectory || isdir))
     {
@@ -383,7 +437,7 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue, MSISIGNAT
         rc = ACTION_SearchDirectory(package, sig, (LPWSTR)value, 0, appValue);
         break;
     case msidbLocatorTypeFileName:
-        *appValue = strdupW((LPWSTR)value);
+        *appValue = app_search_file((LPWSTR)value, sig);
         break;
     case msidbLocatorTypeRawValue:
         ACTION_ConvertRegValue(regType, value, sz, appValue);
@@ -475,7 +529,7 @@ static UINT ACTION_AppSearchIni(MSIPACKAGE *package, LPWSTR *appValue,
             FIXME("unimplemented for Directory (%s)\n", debugstr_w(buf));
             break;
         case msidbLocatorTypeFileName:
-            FIXME("unimplemented for File (%s)\n", debugstr_w(buf));
+            *appValue = app_search_file(buf, sig);
             break;
         case msidbLocatorTypeRawValue:
             *appValue = get_ini_field(buf, field);
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index fcb1969..a900b73 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -5840,7 +5840,10 @@ static void test_appsearch(void)
 
     r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
     ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
-    ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
+    todo_wine
+    {
+        ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
+    }
 
     MsiCloseHandle( hpkg );
     DeleteFileA(msifile);
@@ -6093,10 +6096,7 @@ static void test_appsearch_complocator(void)
     size = MAX_PATH;
     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
-    }
+    ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
 
     size = MAX_PATH;
     sprintf(path, "%s\\FileName10.dll", CURR_DIR);
@@ -6538,10 +6538,7 @@ static void test_appsearch_reglocator(void)
     size = MAX_PATH;
     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
-    }
+    ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
 
     size = MAX_PATH;
     sprintf(path, "%s\\", CURR_DIR);
@@ -6611,10 +6608,7 @@ static void test_appsearch_reglocator(void)
     size = MAX_PATH;
     r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
-    }
+    ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
 
     size = MAX_PATH;
     sprintf(path, "%s\\FileName5.dll", CURR_DIR);
@@ -6854,10 +6848,7 @@ static void test_appsearch_inilocator(void)
     sprintf(path, "%s\\FileName1", CURR_DIR);
     r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
-    }
+    ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
 
     size = MAX_PATH;
     r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
@@ -6902,10 +6893,7 @@ static void test_appsearch_inilocator(void)
     sprintf(path, "%s\\FileName2.dll", CURR_DIR);
     r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
-    }
+    ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
 
     size = MAX_PATH;
     r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
@@ -6916,10 +6904,7 @@ static void test_appsearch_inilocator(void)
     sprintf(path, "%s\\FileName4.dll", CURR_DIR);
     r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
-    }
+    ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
 
     delete_win_ini("IniFile.ini");
     DeleteFileA("FileName1");




More information about the wine-cvs mailing list