msi: Set the UserSID and ProductCode properties for deferred custom actions

James Hawkins truiken at gmail.com
Thu Jun 14 15:19:38 CDT 2007


Hi,

Fixes bug 6763.  http://bugs.winehq.org/show_bug.cgi?id=6763

Changelog:
* Set the UserSID and ProductCode properties for deferred custom actions.

 dlls/msi/custom.c |   64 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 47 insertions(+), 17 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index 9170a7e..29dab3c 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -38,6 +38,15 @@ #define CUSTOM_ACTION_TYPE_MASK 0x3F
 static const WCHAR c_collen[] = {'C',':','\\',0};
 static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
 
+
+static const WCHAR szActionData[] = {
+    'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0
+};
+static const WCHAR ProdCode[] = {
+    'P','r','o','d','u','c','t','C','o','d','e',0
+};
+static const WCHAR UserSID[] = {'U','s','e','r','S','I','D',0};
+
 typedef struct tagMSIRUNNINGACTION
 {
     struct list entry;
@@ -123,31 +132,48 @@ static BOOL check_execution_scheduling_o
     return TRUE;
 }
 
-/* stores the CustomActionData before the action:
- *     [CustomActionData]Action
+/* stores the following properties before the action:
+ *
+ *    [CustomActionData;UserSID;ProductCode]Action
  */
-static LPWSTR msi_get_deferred_action(LPCWSTR action, LPCWSTR actiondata)
+static LPWSTR msi_get_deferred_action(LPCWSTR action, LPCWSTR actiondata,
+                                      LPCWSTR usersid, LPCWSTR prodcode)
 {
     LPWSTR deferred;
     DWORD len;
 
-    static const WCHAR begin[] = {'[',0};
-    static const WCHAR end[] = {']',0};
+    static const WCHAR format[] = {'[','%','s',';','%','s',';','%','s',']','%','s',0};
 
     if (!actiondata)
         return strdupW(action);
 
-    len = lstrlenW(action) + lstrlenW(actiondata) + 3;
+    len = lstrlenW(action) + lstrlenW(actiondata) + 
+          lstrlenW(usersid) + lstrlenW(prodcode) + 5;
     deferred = msi_alloc(len * sizeof(WCHAR));
 
-    lstrcpyW(deferred, begin);
-    lstrcatW(deferred, actiondata);
-    lstrcatW(deferred, end);
-    lstrcatW(deferred, action);
-
+    sprintfW(deferred, format, actiondata, usersid, prodcode, action);
     return deferred;
 }
 
+static void set_deferred_action_props(MSIPACKAGE *package, LPWSTR deferred_data)
+{
+    LPWSTR end, beg = deferred_data;
+
+    end = strchrW(beg, ';');
+    *end = '\0';
+    MSI_SetPropertyW(package, szActionData, beg);
+    beg = end + 1;
+
+    end = strchrW(beg, ';');
+    *end = '\0';
+    MSI_SetPropertyW(package, UserSID, beg);
+    beg = end + 1;
+
+    end = strchrW(beg, ']');
+    *end = '\0';
+    MSI_SetPropertyW(package, ProdCode, beg);
+}
+
 UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
 {
     UINT rc = ERROR_SUCCESS;
@@ -205,7 +231,9 @@ UINT ACTION_CustomAction(MSIPACKAGE *pac
         if (!execute)
         {
             LPWSTR actiondata = msi_dup_property(package, action);
-            LPWSTR deferred = msi_get_deferred_action(action, actiondata);
+            LPWSTR usersid = msi_dup_property(package, UserSID);
+            LPWSTR prodcode = msi_dup_property(package, ProdCode);
+            LPWSTR deferred = msi_get_deferred_action(action, actiondata, usersid, prodcode);
 
             if (type & msidbCustomActionTypeCommit)
             {
@@ -219,23 +247,25 @@ UINT ACTION_CustomAction(MSIPACKAGE *pac
             }
 
             rc = ERROR_SUCCESS;
+            msi_free(actiondata);
+            msi_free(usersid);
+            msi_free(prodcode);
             msi_free(deferred);
             goto end;
         }
         else
         {
-            /*Set ActionData*/
-
-            static const WCHAR szActionData[] = {
-            'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0};
             static const WCHAR szBlank[] = {0};
+
             LPWSTR actiondata = msi_dup_property( package, action );
+
             if (deferred_data)
-                MSI_SetPropertyW(package,szActionData,deferred_data);
+                set_deferred_action_props(package, deferred_data);
             else if (actiondata)
                 MSI_SetPropertyW(package,szActionData,actiondata);
             else
                 MSI_SetPropertyW(package,szActionData,szBlank);
+
             msi_free(actiondata);
         }
     }
-- 
1.4.1


More information about the wine-patches mailing list