Hans Leidekker : msi: Improve the BindImage action stub.

Alexandre Julliard julliard at winehq.org
Tue May 24 12:53:45 CDT 2011


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Tue May 24 10:49:56 2011 +0200

msi: Improve the BindImage action stub.

---

 dlls/msi/Makefile.in |    2 +-
 dlls/msi/action.c    |   68 ++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 62 insertions(+), 8 deletions(-)

diff --git a/dlls/msi/Makefile.in b/dlls/msi/Makefile.in
index 3954e9e..c12b25d 100644
--- a/dlls/msi/Makefile.in
+++ b/dlls/msi/Makefile.in
@@ -1,7 +1,7 @@
 MODULE    = msi.dll
 IMPORTLIB = msi
 IMPORTS   = uuid urlmon wininet comctl32 shell32 shlwapi cabinet oleaut32 ole32 version user32 gdi32 advapi32
-DELAYIMPORTS = odbccp32 wintrust crypt32
+DELAYIMPORTS = odbccp32 wintrust crypt32 imagehlp
 
 C_SRCS = \
 	action.c \
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 61c0783..291f283 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -36,6 +36,7 @@
 #include "objbase.h"
 #include "mscoree.h"
 #include "shlwapi.h"
+#include "imagehlp.h"
 #include "wine/unicode.h"
 #include "winver.h"
 
@@ -7097,7 +7098,6 @@ static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package )
 {
     UINT r;
     MSIQUERY *view;
-
     static const WCHAR query[] =
         {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','U','p','g','r','a','d','e',0};
 
@@ -7121,6 +7121,66 @@ static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package )
     return ERROR_SUCCESS;
 }
 
+static void bind_image( const char *filename, const char *path )
+{
+    if (!BindImageEx( 0, filename, path, NULL, NULL ))
+    {
+        WARN("failed to bind image %u\n", GetLastError());
+    }
+}
+
+static UINT ITERATE_BindImage( MSIRECORD *rec, LPVOID param )
+{
+    UINT i;
+    MSIFILE *file;
+    MSIPACKAGE *package = param;
+    const WCHAR *key = MSI_RecordGetString( rec, 1 );
+    const WCHAR *paths = MSI_RecordGetString( rec, 2 );
+    char *filenameA, *pathA;
+    WCHAR *pathW, **path_list;
+
+    if (!(file = msi_get_loaded_file( package, key )))
+    {
+        WARN("file %s not found\n", debugstr_w(key));
+        return ERROR_SUCCESS;
+    }
+    if (!(filenameA = strdupWtoA( file->TargetPath ))) return ERROR_SUCCESS;
+    path_list = msi_split_string( paths, ';' );
+    if (!path_list) bind_image( filenameA, NULL );
+    else
+    {
+        for (i = 0; path_list[i] && path_list[i][0]; i++)
+        {
+            deformat_string( package, path_list[i], &pathW );
+            if ((pathA = strdupWtoA( pathW )))
+            {
+                bind_image( filenameA, pathA );
+                msi_free( pathA );
+            }
+            msi_free( pathW );
+        }
+    }
+    msi_free( path_list );
+    msi_free( filenameA );
+    return ERROR_SUCCESS;
+}
+
+static UINT ACTION_BindImage( MSIPACKAGE *package )
+{
+    UINT r;
+    MSIQUERY *view;
+    static const WCHAR query[] =
+        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','B','i','n','d','I','m','a','g','e',0};
+
+    r = MSI_DatabaseOpenViewW( package->db, query, &view );
+    if (r == ERROR_SUCCESS)
+    {
+        r = MSI_IterateRecords( view, NULL, ITERATE_BindImage, package );
+        msiobj_release( &view->hdr );
+    }
+    return ERROR_SUCCESS;
+}
+
 static UINT msi_unimplemented_action_stub( MSIPACKAGE *package,
                                            LPCSTR action, LPCWSTR table )
 {
@@ -7145,12 +7205,6 @@ static UINT msi_unimplemented_action_stub( MSIPACKAGE *package,
     return ERROR_SUCCESS;
 }
 
-static UINT ACTION_BindImage( MSIPACKAGE *package )
-{
-    static const WCHAR table[] = { 'B','i','n','d','I','m','a','g','e',0 };
-    return msi_unimplemented_action_stub( package, "BindImage", table );
-}
-
 static UINT ACTION_IsolateComponents( MSIPACKAGE *package )
 {
     static const WCHAR table[] = {




More information about the wine-cvs mailing list