Zebediah Figura : msi: Make MsiSetFeatureState() RPC-compatible.

Alexandre Julliard julliard at winehq.org
Tue Apr 24 18:46:09 CDT 2018


Module: wine
Branch: master
Commit: 863680d5edcdb9fd62910cd7266658d2e3a0e743
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=863680d5edcdb9fd62910cd7266658d2e3a0e743

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Apr 23 23:18:16 2018 -0500

msi: Make MsiSetFeatureState() RPC-compatible.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msi/install.c      | 26 ++++----------------------
 dlls/msi/package.c      |  5 ++---
 dlls/msi/tests/custom.c | 17 +++++++++++++++++
 dlls/msi/winemsi.idl    |  2 +-
 4 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index 706fdb4..1ff3ad9 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -685,9 +685,6 @@ UINT WINAPI MsiSetFeatureStateA(MSIHANDLE hInstall, LPCSTR szFeature,
 
     szwFeature = strdupAtoW(szFeature);
 
-    if (!szwFeature)
-        return ERROR_FUNCTION_FAILED;
-   
     rc = MsiSetFeatureStateW(hInstall,szwFeature, iState); 
 
     msi_free(szwFeature);
@@ -818,33 +815,18 @@ UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
 
     TRACE("%s %i\n",debugstr_w(szFeature), iState);
 
+    if (!szFeature)
+        return ERROR_UNKNOWN_FEATURE;
+
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     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;
-
-        hr = remote_SetFeatureState(remote, feature, iState);
-
-        SysFreeString(feature);
-
-        if (FAILED(hr))
-        {
-            if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
-                return HRESULT_CODE(hr);
-
-            return ERROR_FUNCTION_FAILED;
-        }
-
-        return ERROR_SUCCESS;
+        return remote_SetFeatureState(remote, szFeature, iState);
     }
 
     rc = MSI_SetFeatureStateW(package,szFeature,iState);
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index ec05d43..f8b150b 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -2529,10 +2529,9 @@ UINT __cdecl remote_GetFeatureState(MSIHANDLE hinst, LPCWSTR feature,
     return MsiGetFeatureStateW(hinst, feature, installed, action);
 }
 
-HRESULT __cdecl remote_SetFeatureState(MSIHANDLE hinst, BSTR feature, INSTALLSTATE state)
+UINT __cdecl remote_SetFeatureState(MSIHANDLE hinst, LPCWSTR feature, INSTALLSTATE state)
 {
-    UINT r = MsiSetFeatureStateW(hinst, feature, state);
-    return HRESULT_FROM_WIN32(r);
+    return MsiSetFeatureStateW(hinst, feature, state);
 }
 
 HRESULT __cdecl remote_GetComponentState(MSIHANDLE hinst, BSTR component,
diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c
index ef4e282..b30953a 100644
--- a/dlls/msi/tests/custom.c
+++ b/dlls/msi/tests/custom.c
@@ -671,6 +671,23 @@ static void test_feature_states(MSIHANDLE hinst)
     ok(hinst, !r, "got %u\n", r);
     ok(hinst, state == INSTALLSTATE_ABSENT, "got state %d\n", state);
     ok(hinst, action == INSTALLSTATE_LOCAL, "got action %d\n", action);
+
+    r = MsiSetFeatureStateA(hinst, NULL, INSTALLSTATE_ABSENT);
+    ok(hinst, r == ERROR_UNKNOWN_FEATURE, "got %u\n", r);
+
+    r = MsiSetFeatureStateA(hinst, "One", INSTALLSTATE_ADVERTISED);
+    ok(hinst, !r, "got %u\n", r);
+
+    r = MsiGetFeatureStateA(hinst, "One", &state, &action);
+    ok(hinst, !r, "got %u\n", r);
+    ok(hinst, action == INSTALLSTATE_ADVERTISED, "got action %d\n", action);
+
+    r = MsiSetFeatureStateA(hinst, "One", INSTALLSTATE_LOCAL);
+    ok(hinst, !r, "got %u\n", r);
+
+    r = MsiGetFeatureStateA(hinst, "One", &state, &action);
+    ok(hinst, !r, "got %u\n", r);
+    ok(hinst, action == INSTALLSTATE_LOCAL, "got action %d\n", action);
 }
 
 /* Main test. Anything that doesn't depend on a specific install configuration
diff --git a/dlls/msi/winemsi.idl b/dlls/msi/winemsi.idl
index 091ef16..8bdc10d 100644
--- a/dlls/msi/winemsi.idl
+++ b/dlls/msi/winemsi.idl
@@ -82,7 +82,7 @@ interface IWineMsiRemote
     BOOL remote_GetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode );
     UINT remote_SetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [in] BOOL state );
     UINT remote_GetFeatureState( [in] MSIHANDLE hinst, [in, string] LPCWSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
-    HRESULT remote_SetFeatureState( [in] MSIHANDLE hinst, [in] BSTR feature, [in] INSTALLSTATE state );
+    UINT remote_SetFeatureState( [in] MSIHANDLE hinst, [in, string] LPCWSTR feature, [in] INSTALLSTATE state );
     HRESULT remote_GetComponentState( [in] MSIHANDLE hinst, [in] BSTR component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
     HRESULT remote_SetComponentState( [in] MSIHANDLE hinst, [in] BSTR component, [in] INSTALLSTATE state );
     HRESULT remote_GetLanguage( [in] MSIHANDLE hinst, [out] LANGID *language );




More information about the wine-cvs mailing list