sync msi to wine 1.1.31
[reactos.git] / reactos / dll / win32 / msi / custom.c
index 71864d5..5ac9c1b 100644 (file)
@@ -659,7 +659,7 @@ static UINT get_action_info( const GUID *guid, INT *type, MSIHANDLE *handle,
     return ERROR_SUCCESS;
 }
 
-static DWORD WINAPI ACTION_CallDllFunction( const GUID *guid )
+static DWORD ACTION_CallDllFunction( const GUID *guid )
 {
     MsiCustomActionEntryPoint fn;
     MSIHANDLE hPackage, handle;
@@ -679,7 +679,7 @@ static DWORD WINAPI ACTION_CallDllFunction( const GUID *guid )
     hModule = LoadLibraryW( dll );
     if (!hModule)
     {
-        ERR("failed to load dll %s\n", debugstr_w( dll ) );
+        ERR("failed to load dll %s (%u)\n", debugstr_w( dll ), GetLastError() );
         return r;
     }
 
@@ -695,8 +695,6 @@ static DWORD WINAPI ACTION_CallDllFunction( const GUID *guid )
             TRACE("calling %s\n", debugstr_w( function ) );
             handle_msi_break( function );
 
-            CoInitialize(NULL);
-
             __TRY
             {
                 r = fn( hPackage );
@@ -709,8 +707,6 @@ static DWORD WINAPI ACTION_CallDllFunction( const GUID *guid )
             }
             __ENDTRY;
 
-            CoUninitialize();
-
             MsiCloseHandle( hPackage );
         }
         else
@@ -744,7 +740,7 @@ static DWORD WINAPI DllThread( LPVOID arg )
     return rc;
 }
 
-static DWORD WINAPI ACTION_CAInstallPackage(const GUID *guid)
+static DWORD ACTION_CAInstallPackage(const GUID *guid)
 {
     msi_custom_action_info *info;
     UINT r = ERROR_FUNCTION_FAILED;
@@ -855,6 +851,7 @@ static UINT HANDLE_CustomType23(MSIPACKAGE *package, LPCWSTR source,
     msi_custom_action_info *info;
     WCHAR package_path[MAX_PATH];
     DWORD size;
+    UINT r;
 
     static const WCHAR backslash[] = {'\\',0};
 
@@ -867,7 +864,9 @@ static UINT HANDLE_CustomType23(MSIPACKAGE *package, LPCWSTR source,
 
     info = do_msidbCAConcurrentInstall(package, type, package_path, target, action);
 
-    return wait_thread_handle(info);
+    r = wait_thread_handle(info);
+    release_custom_action_data( info );
+    return r;
 }
 
 static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
@@ -892,7 +891,9 @@ static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source,
 
     info = do_msidbCustomActionTypeDll( package, type, tmp_file, target, action );
 
-    return wait_thread_handle( info );
+    r = wait_thread_handle( info );
+    release_custom_action_data( info );
+    return r;
 }
 
 static UINT HANDLE_CustomType2(MSIPACKAGE *package, LPCWSTR source,
@@ -955,6 +956,7 @@ static UINT HANDLE_CustomType17(MSIPACKAGE *package, LPCWSTR source,
 {
     msi_custom_action_info *info;
     MSIFILE *file;
+    UINT r;
 
     TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
 
@@ -967,7 +969,9 @@ static UINT HANDLE_CustomType17(MSIPACKAGE *package, LPCWSTR source,
 
     info = do_msidbCustomActionTypeDll( package, type, file->TargetPath, target, action );
 
-    return wait_thread_handle( info );
+    r = wait_thread_handle( info );
+    release_custom_action_data( info );
+    return r;
 }
 
 static UINT HANDLE_CustomType18(MSIPACKAGE *package, LPCWSTR source,
@@ -1042,15 +1046,16 @@ static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
     if( row )
     {
         LPCWSTR error = MSI_RecordGetString( row, 1 );
-        MessageBoxW( NULL, error, NULL, MB_OK );
+        if ((gUILevel & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
+            MessageBoxW( NULL, error, NULL, MB_OK );
         msiobj_release( &row->hdr );
     }
-    else
+    else if ((gUILevel & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
         MessageBoxW( NULL, deformated, NULL, MB_OK );
 
     msi_free( deformated );
 
-    return ERROR_FUNCTION_FAILED;
+    return ERROR_INSTALL_FAILURE;
 }
 
 static UINT HANDLE_CustomType50(MSIPACKAGE *package, LPCWSTR source,
@@ -1147,7 +1152,7 @@ static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
     return wait_process_handle(package, type, info.hProcess, action);
 }
 
-static DWORD WINAPI ACTION_CallScript( const GUID *guid )
+static DWORD ACTION_CallScript( const GUID *guid )
 {
     msi_custom_action_info *info;
     MSIHANDLE hPackage;
@@ -1171,9 +1176,7 @@ static DWORD WINAPI ACTION_CallScript( const GUID *guid )
     else
         ERR("failed to create handle for %p\n", info->package );
 
-    if (info->type & msidbCustomActionTypeAsync &&
-        info->type & msidbCustomActionTypeContinue)
-        release_custom_action_data( info );
+    release_custom_action_data( info );
 
     return S_OK;
 }
@@ -1230,13 +1233,16 @@ static msi_custom_action_info *do_msidbCustomActionTypeScript(
 static UINT HANDLE_CustomType37_38(MSIPACKAGE *package, LPCWSTR source,
                                LPCWSTR target, const INT type, LPCWSTR action)
 {
+    UINT r;
     msi_custom_action_info *info;
 
     TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
 
     info = do_msidbCustomActionTypeScript( package, type, target, NULL, action );
 
-    return wait_thread_handle( info );
+    r = wait_thread_handle( info );
+    release_custom_action_data( info );
+    return r;
 }
 
 static UINT HANDLE_CustomType5_6(MSIPACKAGE *package, LPCWSTR source,
@@ -1281,6 +1287,7 @@ static UINT HANDLE_CustomType5_6(MSIPACKAGE *package, LPCWSTR source,
 
     info = do_msidbCustomActionTypeScript( package, type, bufferw, target, action );
     r = wait_thread_handle( info );
+    release_custom_action_data( info );
 
 done:
     msi_free(bufferw);
@@ -1345,6 +1352,7 @@ static UINT HANDLE_CustomType21_22(MSIPACKAGE *package, LPCWSTR source,
 
     info = do_msidbCustomActionTypeScript( package, type, bufferw, target, action );
     r = wait_thread_handle( info );
+    release_custom_action_data( info );
 
 done:
     msi_free(bufferw);
@@ -1357,6 +1365,7 @@ static UINT HANDLE_CustomType53_54(MSIPACKAGE *package, LPCWSTR source,
 {
     msi_custom_action_info *info;
     WCHAR *prop;
+    UINT r;
 
     TRACE("%s %s\n", debugstr_w(source), debugstr_w(target));
 
@@ -1366,7 +1375,9 @@ static UINT HANDLE_CustomType53_54(MSIPACKAGE *package, LPCWSTR source,
 
     info = do_msidbCustomActionTypeScript( package, type, prop, NULL, action );
     msi_free(prop);
-    return wait_thread_handle( info );
+    r = wait_thread_handle( info );
+    release_custom_action_data( info );
+    return r;
 }
 
 void ACTION_FinishCustomActions(const MSIPACKAGE* package)