msi 3: Only call a custom action remotely if the type is msidbCustomActionTypeInScript

James Hawkins truiken at gmail.com
Mon Jul 16 21:21:45 CDT 2007


Hi,

Fixes a problem with an installer that checks the returned length
exactly, and fails because we double it (for the bug, which is
correct), but this happens because we run all custom actions remotely,
whether they're supposed to be remote or not.

Changelog:
* Only call a custom action remotely if the type is
msidbCustomActionTypeInScript.

 dlls/msi/custom.c |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 77 insertions(+), 1 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index 06699d2..86d4ccb 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -647,7 +647,7 @@ static UINT get_action_info( const GUID 
     return ERROR_SUCCESS;
 }
 
-static DWORD WINAPI ACTION_CallDllFunction( const GUID *guid )
+static DWORD WINAPI ACTION_CallRemoteDllFunction( const GUID *guid )
 {
     MsiCustomActionEntryPoint fn;
     MSIHANDLE hPackage, handle;
@@ -713,6 +713,82 @@ static DWORD WINAPI ACTION_CallDllFuncti
     return r;
 }
 
+static DWORD WINAPI ACTION_CallLocalDllFunction( msi_custom_action_info *info )
+{
+    MsiCustomActionEntryPoint fn;
+    MSIHANDLE hPackage;
+    HANDLE hModule;
+    LPSTR proc;
+    UINT r = ERROR_FUNCTION_FAILED;
+
+    TRACE("%s %s\n", debugstr_w( info->source ), debugstr_w( info->target ) );
+
+    hModule = LoadLibraryW( info->source );
+    if (!hModule)
+    {
+        ERR("failed to load dll %s\n", debugstr_w( info->source ) );
+        return r;
+    }
+
+    proc = strdupWtoA( info->target );
+    fn = (MsiCustomActionEntryPoint) GetProcAddress( hModule, proc );
+    msi_free( proc );
+    if (fn)
+    {
+        hPackage = alloc_msihandle( &info->package->hdr );
+        if (hPackage)
+        {
+            TRACE("calling %s\n", debugstr_w( info->target ) );
+            handle_msi_break( info->target );
+
+            __TRY
+            {
+                r = fn( hPackage );
+            }
+            __EXCEPT_PAGE_FAULT
+            {
+                ERR("Custom action (%s:%s) caused a page fault: %08x\n",
+                    debugstr_w(info->source), debugstr_w(info->target), GetExceptionCode());
+                r = ERROR_SUCCESS;
+            }
+            __ENDTRY;
+
+            MsiCloseHandle( hPackage );
+        }
+        else
+            ERR("failed to create handle for %p\n", info->package );
+    }
+    else
+        ERR("GetProcAddress(%s) failed\n", debugstr_w( info->target ) );
+
+    FreeLibrary(hModule);
+
+    return r;
+}
+
+static DWORD WINAPI ACTION_CallDllFunction(const GUID *guid)
+{
+    msi_custom_action_info *info;
+    UINT r;
+
+    info = find_action_by_guid(guid);
+    if (!info)
+    {
+        ERR("failed to find action %s\n", debugstr_guid(guid));
+        return ERROR_FUNCTION_FAILED;
+    }
+
+    TRACE("%s %s\n", debugstr_w(info->source), debugstr_w(info->target));
+
+    if (info->type & msidbCustomActionTypeInScript)
+        r = ACTION_CallRemoteDllFunction(guid);
+    else
+        r = ACTION_CallLocalDllFunction(info);
+
+    release_custom_action_data(info);
+    return r;
+}
+
 static DWORD WINAPI DllThread( LPVOID arg )
 {
     LPGUID guid = arg;
-- 
1.4.1


More information about the wine-patches mailing list