[PATCH 2/3] msi: Store the current script in the package.

Zebediah Figura z.figura12 at gmail.com
Tue Sep 19 00:23:38 CDT 2017


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/msi/action.c  | 22 +++++++++++++---------
 dlls/msi/custom.c  | 34 ++--------------------------------
 dlls/msi/dialog.c  |  2 +-
 dlls/msi/install.c |  8 ++++----
 dlls/msi/msi.c     |  6 +++---
 dlls/msi/msipriv.h |  8 +++-----
 dlls/msi/package.c |  1 +
 7 files changed, 27 insertions(+), 54 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index e92e5570dd..a9391de73c 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -506,7 +506,7 @@ static UINT ITERATE_Actions(MSIRECORD *row, LPVOID param)
         return ERROR_SUCCESS;
     }
 
-    rc = ACTION_PerformAction(package, action, SCRIPT_NONE);
+    rc = ACTION_PerformAction(package, action);
 
     msi_dialog_check_messages( NULL );
 
@@ -600,7 +600,7 @@ static UINT ACTION_ProcessUISequence(MSIPACKAGE *package)
 /********************************************************
  * ACTION helper functions and functions that perform the actions
  *******************************************************/
-static UINT ACTION_HandleCustomAction(MSIPACKAGE *package, LPCWSTR action, UINT script)
+static UINT ACTION_HandleCustomAction(MSIPACKAGE *package, LPCWSTR action)
 {
     UINT arc;
     INT uirc;
@@ -609,7 +609,7 @@ static UINT ACTION_HandleCustomAction(MSIPACKAGE *package, LPCWSTR action, UINT
     if (uirc == IDCANCEL)
         return ERROR_INSTALL_USEREXIT;
     ui_actioninfo(package, action, TRUE, 0);
-    arc = ACTION_CustomAction( package, action, script );
+    arc = ACTION_CustomAction(package, action);
     uirc = !arc;
 
     if (arc == ERROR_FUNCTION_NOT_CALLED && needs_ui_sequence(package))
@@ -1543,9 +1543,11 @@ static UINT execute_script( MSIPACKAGE *package, UINT script )
 
     TRACE("executing script %u\n", script);
 
+    package->script = script;
+
     LIST_FOR_EACH_ENTRY( action, &package->script_actions[script], struct action, entry )
     {
-        rc = ACTION_PerformAction( package, action->action, script );
+        rc = ACTION_PerformAction(package, action->action);
         if (rc != ERROR_SUCCESS)
         {
             ERR("Execution of script %i halted; action %s returned %u\n",
@@ -1554,6 +1556,8 @@ static UINT execute_script( MSIPACKAGE *package, UINT script )
         }
     }
 
+    package->script = SCRIPT_NONE;
+
     msi_free_action_script(package, script);
     return rc;
 }
@@ -5636,7 +5640,7 @@ static UINT ACTION_ExecuteAction(MSIPACKAGE *package)
         msiobj_release(&uirow->hdr);
     }
     else
-        rc = ACTION_PerformAction(package, action, SCRIPT_NONE);
+        rc = ACTION_PerformAction(package, action);
 
     /* Send all set properties. */
     if (!MSI_OpenQuery(package->db, &view, prop_query))
@@ -7875,7 +7879,7 @@ static UINT ACTION_HandleStandardAction(MSIPACKAGE *package, LPCWSTR action)
     return rc;
 }
 
-UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script)
+UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action)
 {
     UINT rc;
 
@@ -7885,7 +7889,7 @@ UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script)
     rc = ACTION_HandleStandardAction(package, action);
 
     if (rc == ERROR_FUNCTION_NOT_CALLED)
-        rc = ACTION_HandleCustomAction(package, action, script);
+        rc = ACTION_HandleCustomAction(package, action);
 
     if (rc == ERROR_FUNCTION_NOT_CALLED)
         WARN("unhandled msi action %s\n", debugstr_w(action));
@@ -7938,7 +7942,7 @@ static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq)
             return ERROR_FUNCTION_FAILED;
         }
 
-        rc = ACTION_PerformAction(package, action, SCRIPT_NONE);
+        rc = ACTION_PerformAction(package, action);
 
         msiobj_release(&row->hdr);
     }
@@ -8036,7 +8040,7 @@ UINT MSI_InstallPackage( MSIPACKAGE *package, LPCWSTR szPackagePath,
         msi_set_property( package->db, szRollbackDisabled, szOne, -1 );
     }
 
-    rc = ACTION_PerformAction(package, action, SCRIPT_NONE);
+    rc = ACTION_PerformAction(package, action);
 
     /* process the ending type action */
     if (rc == ERROR_SUCCESS)
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index a3e32d9a24..b463ab659c 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -1123,24 +1123,6 @@ static UINT HANDLE_CustomType53_54( MSIPACKAGE *package, const WCHAR *source, co
     return wait_thread_handle( info );
 }
 
-static BOOL action_type_matches_script( UINT type, UINT script )
-{
-    switch (script)
-    {
-    case SCRIPT_NONE:
-        return FALSE;
-    case SCRIPT_INSTALL:
-        return !(type & msidbCustomActionTypeCommit) && !(type & msidbCustomActionTypeRollback);
-    case SCRIPT_COMMIT:
-        return (type & msidbCustomActionTypeCommit);
-    case SCRIPT_ROLLBACK:
-        return (type & msidbCustomActionTypeRollback);
-    default:
-        ERR("unhandled script %u\n", script);
-    }
-    return FALSE;
-}
-
 static UINT defer_custom_action( MSIPACKAGE *package, const WCHAR *action, UINT type )
 {
     WCHAR *actiondata = msi_dup_property( package->db, action );
@@ -1178,7 +1160,7 @@ static UINT defer_custom_action( MSIPACKAGE *package, const WCHAR *action, UINT
     return ERROR_SUCCESS;
 }
 
-UINT ACTION_CustomAction( MSIPACKAGE *package, LPCWSTR action, UINT script )
+UINT ACTION_CustomAction( MSIPACKAGE *package, LPCWSTR action )
 {
     static const WCHAR query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
@@ -1218,7 +1200,7 @@ UINT ACTION_CustomAction( MSIPACKAGE *package, LPCWSTR action, UINT script )
         if (type & msidbCustomActionTypeNoImpersonate)
             WARN("msidbCustomActionTypeNoImpersonate not handled\n");
 
-        if (!action_type_matches_script( type, script ))
+        if (package->script == SCRIPT_NONE)
         {
             rc = defer_custom_action( package, action, type );
             goto end;
@@ -1227,15 +1209,6 @@ UINT ACTION_CustomAction( MSIPACKAGE *package, LPCWSTR action, UINT script )
         {
             LPWSTR actiondata = msi_dup_property( package->db, action );
 
-            if (type & msidbCustomActionTypeInScript)
-                package->scheduled_action_running = TRUE;
-
-            if (type & msidbCustomActionTypeCommit)
-                package->commit_action_running = TRUE;
-
-            if (type & msidbCustomActionTypeRollback)
-                package->rollback_action_running = TRUE;
-
             if (deferred_data)
                 set_deferred_action_props(package, deferred_data);
             else if (actiondata)
@@ -1317,9 +1290,6 @@ UINT ACTION_CustomAction( MSIPACKAGE *package, LPCWSTR action, UINT script )
     }
 
 end:
-    package->scheduled_action_running = FALSE;
-    package->commit_action_running = FALSE;
-    package->rollback_action_running = FALSE;
     msiobj_release(&row->hdr);
     return rc;
 }
diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c
index 1d24acd217..2ccaf62843 100644
--- a/dlls/msi/dialog.c
+++ b/dlls/msi/dialog.c
@@ -4366,7 +4366,7 @@ static UINT event_spawn_wait_dialog( msi_dialog *dialog, const WCHAR *argument )
 
 static UINT event_do_action( msi_dialog *dialog, const WCHAR *argument )
 {
-    ACTION_PerformAction( dialog->package, argument, SCRIPT_NONE );
+    ACTION_PerformAction( dialog->package, argument );
     return ERROR_SUCCESS;
 }
 
diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index 261a259f3f..6ab3f0dfbc 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -105,7 +105,7 @@ UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction )
         return ERROR_SUCCESS;
     }
  
-    ret = ACTION_PerformAction( package, szAction, SCRIPT_NONE );
+    ret = ACTION_PerformAction( package, szAction );
     msiobj_release( &package->hdr );
 
     return ret;
@@ -736,15 +736,15 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode)
         break;
 
     case MSIRUNMODE_SCHEDULED:
-        r = package->scheduled_action_running;
+        r = (package->script == SCRIPT_INSTALL);
         break;
 
     case MSIRUNMODE_ROLLBACK:
-        r = package->rollback_action_running;
+        r = (package->script == SCRIPT_ROLLBACK);
         break;
 
     case MSIRUNMODE_COMMIT:
-        r = package->commit_action_running;
+        r = (package->script == SCRIPT_COMMIT);
         break;
 
     case MSIRUNMODE_MAINTENANCE:
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 7e5e23fc51..f8ecfb8f41 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -3747,7 +3747,7 @@ UINT WINAPI MsiCollectUserInfoW(LPCWSTR szProduct)
     if (!package)
         return ERROR_CALL_NOT_IMPLEMENTED;
 
-    rc = ACTION_PerformAction(package, szFirstRun, SCRIPT_NONE);
+    rc = ACTION_PerformAction(package, szFirstRun);
     msiobj_release( &package->hdr );
 
     MsiCloseHandle(handle);
@@ -3773,7 +3773,7 @@ UINT WINAPI MsiCollectUserInfoA(LPCSTR szProduct)
     if (!package)
         return ERROR_CALL_NOT_IMPLEMENTED;
 
-    rc = ACTION_PerformAction(package, szFirstRun, SCRIPT_NONE);
+    rc = ACTION_PerformAction(package, szFirstRun);
     msiobj_release( &package->hdr );
 
     MsiCloseHandle(handle);
@@ -3854,7 +3854,7 @@ UINT WINAPI MsiConfigureFeatureW(LPCWSTR szProduct, LPCWSTR szFeature, INSTALLST
 
     MsiSetInternalUI( INSTALLUILEVEL_BASIC, NULL );
 
-    r = ACTION_PerformAction( package, szCostInitialize, SCRIPT_NONE );
+    r = ACTION_PerformAction( package, szCostInitialize );
     if (r != ERROR_SUCCESS)
         goto end;
 
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index efe75c8be7..5a0ca827b2 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -418,6 +418,7 @@ typedef struct tagMSIPACKAGE
     struct list mimes;
     struct list appids;
 
+    enum script script;
     struct list script_actions[SCRIPT_MAX];
     struct list unique_actions;
     BOOL   ExecuteSequenceRun;
@@ -445,9 +446,6 @@ typedef struct tagMSIPACKAGE
     struct list sourcelist_info;
     struct list sourcelist_media;
 
-    unsigned char scheduled_action_running : 1;
-    unsigned char commit_action_running : 1;
-    unsigned char rollback_action_running : 1;
     unsigned char need_reboot_at_end : 1;
     unsigned char need_reboot_now : 1;
     unsigned char need_rollback : 1;
@@ -980,9 +978,9 @@ extern WCHAR *gszLogFile DECLSPEC_HIDDEN;
 extern HINSTANCE msi_hInstance DECLSPEC_HIDDEN;
 
 /* action related functions */
-extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script) DECLSPEC_HIDDEN;
+extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action) DECLSPEC_HIDDEN;
 extern void ACTION_FinishCustomActions( const MSIPACKAGE* package) DECLSPEC_HIDDEN;
-extern UINT ACTION_CustomAction(MSIPACKAGE *, const WCHAR *, UINT) DECLSPEC_HIDDEN;
+extern UINT ACTION_CustomAction(MSIPACKAGE *, const WCHAR *) DECLSPEC_HIDDEN;
 
 /* actions in other modules */
 extern UINT ACTION_AppSearch(MSIPACKAGE *package) DECLSPEC_HIDDEN;
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 476c92dcc0..fc7d531b81 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -1116,6 +1116,7 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
             msi_load_admin_properties( package );
 
         package->log_file = INVALID_HANDLE_VALUE;
+        package->script = SCRIPT_NONE;
     }
     return package;
 }
-- 
2.14.1




More information about the wine-patches mailing list