[PATCH 6/6] msi: Make MsiGetFeatureCost() RPC-compatible.

Zebediah Figura z.figura12 at gmail.com
Tue Apr 24 22:27:42 CDT 2018


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/msi/install.c       | 22 ++++------------------
 dlls/msi/package.c       |  7 +++----
 dlls/msi/tests/custom.c  | 20 ++++++++++++++++++++
 dlls/msi/tests/install.c |  1 +
 dlls/msi/winemsi.idl     |  3 ++-
 5 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index 63aed1e..45c5537 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -1068,29 +1068,15 @@ UINT WINAPI MsiGetFeatureCostW(MSIHANDLE hInstall, LPCWSTR szFeature,
     if (!package)
     {
         MSIHANDLE remote;
-        HRESULT hr;
-        BSTR feature;
 
         if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
-        feature = SysAllocString(szFeature);
-        if (!feature)
-            return ERROR_OUTOFMEMORY;
+        /* FIXME: should use SEH */
+        if (!piCost)
+            return RPC_X_NULL_REF_POINTER;
 
-        hr = remote_GetFeatureCost(remote, feature, iCostTree, iState, piCost);
-
-        SysFreeString(feature);
-
-        if (FAILED(hr))
-        {
-            if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
-                return HRESULT_CODE(hr);
-
-            return ERROR_FUNCTION_FAILED;
-        }
-
-        return ERROR_SUCCESS;
+        return remote_GetFeatureCost(remote, szFeature, iCostTree, iState, piCost);
     }
 
     if (!piCost)
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index c93a0c8..b633250 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -2583,11 +2583,10 @@ MSICONDITION __cdecl remote_EvaluateCondition(MSIHANDLE hinst, LPCWSTR condition
     return MsiEvaluateConditionW(hinst, condition);
 }
 
-HRESULT __cdecl remote_GetFeatureCost(MSIHANDLE hinst, BSTR feature,
-                                          INT cost_tree, INSTALLSTATE state, INT *cost)
+UINT __cdecl remote_GetFeatureCost(MSIHANDLE hinst, LPCWSTR feature,
+    MSICOSTTREE cost_tree, INSTALLSTATE state, INT *cost)
 {
-    UINT r = MsiGetFeatureCostW(hinst, feature, cost_tree, state, cost);
-    return HRESULT_FROM_WIN32(r);
+    return MsiGetFeatureCostW(hinst, feature, cost_tree, state, cost);
 }
 
 HRESULT __cdecl remote_EnumComponentCosts(MSIHANDLE hinst, BSTR component,
diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c
index 2035a8f..ecd172a 100644
--- a/dlls/msi/tests/custom.c
+++ b/dlls/msi/tests/custom.c
@@ -855,6 +855,25 @@ static void test_format_record(MSIHANDLE hinst)
     MsiCloseHandle(rec);
 }
 
+static void test_costs(MSIHANDLE hinst)
+{
+    INT cost;
+    UINT r;
+
+    cost = 0xdead;
+    r = MsiGetFeatureCostA(hinst, NULL, MSICOSTTREE_CHILDREN, INSTALLSTATE_LOCAL, &cost);
+    ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+    todo_wine_ok(hinst, !cost, "got %d\n", cost);
+
+    r = MsiGetFeatureCostA(hinst, "One", MSICOSTTREE_CHILDREN, INSTALLSTATE_LOCAL, NULL);
+    ok(hinst, r == RPC_X_NULL_REF_POINTER, "got %u\n", r);
+
+    cost = 0xdead;
+    r = MsiGetFeatureCostA(hinst, "One", MSICOSTTREE_CHILDREN, INSTALLSTATE_LOCAL, &cost);
+    ok(hinst, !r, "got %u\n", r);
+    todo_wine_ok(hinst, cost == 8, "got %d\n", cost);
+}
+
 /* Main test. Anything that doesn't depend on a specific install configuration
  * or have undesired side effects should go here. */
 UINT WINAPI main_test(MSIHANDLE hinst)
@@ -885,6 +904,7 @@ UINT WINAPI main_test(MSIHANDLE hinst)
     test_misc(hinst);
     test_feature_states(hinst);
     test_format_record(hinst);
+    test_costs(hinst);
 
     return ERROR_SUCCESS;
 }
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 6a7383b..5c83d30 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -698,6 +698,7 @@ static const CHAR ca1_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
                                                "CostInitialize\t\t100\n"
                                                "FileCost\t\t200\n"
                                                "CostFinalize\t\t300\n"
+                                               "InstallValidate\t\t400\n"
                                                "embednull\t\t600\n"
                                                "maintest\tMAIN_TEST\t700\n"
                                                "testretval\tTEST_RETVAL\t710\n";
diff --git a/dlls/msi/winemsi.idl b/dlls/msi/winemsi.idl
index 6bdd117..fa98ac0 100644
--- a/dlls/msi/winemsi.idl
+++ b/dlls/msi/winemsi.idl
@@ -29,6 +29,7 @@ typedef int MSIRUNMODE;
 typedef int INSTALLSTATE;
 typedef int MSICOLINFO;
 typedef int MSIMODIFY;
+typedef int MSICOSTTREE;
 
 #define MSIFIELD_NULL   0
 #define MSIFIELD_INT    1
@@ -89,7 +90,7 @@ interface IWineMsiRemote
     UINT remote_SetInstallLevel( [in] MSIHANDLE hinst, [in] int level );
     UINT remote_FormatRecord( [in] MSIHANDLE hinst, [in] struct wire_record *record, [out, string] LPWSTR *value);
     MSICONDITION remote_EvaluateCondition( [in] MSIHANDLE hinst, [in, string] LPCWSTR condition );
-    HRESULT remote_GetFeatureCost( [in] MSIHANDLE hinst, [in] BSTR feature, [in] INT cost_tree, [in] INSTALLSTATE state, [out] INT *cost );
+    UINT remote_GetFeatureCost( [in] MSIHANDLE hinst, [in, string] LPCWSTR feature, [in] MSICOSTTREE cost_tree, [in] INSTALLSTATE state, [out] INT *cost );
     HRESULT remote_EnumComponentCosts( [in] MSIHANDLE hinst, [in] BSTR component, [in] DWORD index, [in] INSTALLSTATE state,
                                        [out, size_is(*buflen)] BSTR drive, [in, out] DWORD *buflen, [out] INT *cost, [out] INT *temp );
 
-- 
2.7.4




More information about the wine-devel mailing list