https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ed5fbe399d6f2e85e24b8a9e960d94e5fb58d69a

commit ed5fbe399d6f2e85e24b8a9e960d94e5fb58d69a
Author:     winesync <[email protected]>
AuthorDate: Sat Mar 12 15:12:01 2022 +0100
Commit:     Mark Jansen <[email protected]>
CommitDate: Sun Mar 20 19:27:40 2022 +0100

    [WINESYNC] msi: Make MsiGetFeatureState() RPC-compatible.
    
    Signed-off-by: Zebediah Figura <[email protected]>
    Signed-off-by: Hans Leidekker <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id 9f428f592dc949d528c149692addf8e34f3f005b by Zebediah Figura 
<[email protected]>
---
 dll/win32/msi/install.c                 | 25 +++++++------------------
 dll/win32/msi/package.c                 |  5 ++---
 dll/win32/msi/winemsi.idl               |  2 +-
 modules/rostests/winetests/msi/custom.c | 24 ++++++++++++++++++++++++
 4 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c
index 17a0cd516eb..706fdb47955 100644
--- a/dll/win32/msi/install.c
+++ b/dll/win32/msi/install.c
@@ -964,33 +964,22 @@ UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, 
LPCWSTR szFeature,
 
     TRACE("%d %s %p %p\n", hInstall, debugstr_w(szFeature), piInstalled, 
piAction);
 
+    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_GetFeatureState(remote, feature, piInstalled, piAction);
-
-        SysFreeString(feature);
+        /* FIXME: should use SEH */
+        if (!piInstalled || !piAction)
+            return RPC_X_NULL_REF_POINTER;
 
-        if (FAILED(hr))
-        {
-            if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
-                return HRESULT_CODE(hr);
-
-            return ERROR_FUNCTION_FAILED;
-        }
-
-        return ERROR_SUCCESS;
+        return remote_GetFeatureState(remote, szFeature, piInstalled, 
piAction);
     }
 
     ret = MSI_GetFeatureStateW(package, szFeature, piInstalled, piAction);
diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index 25fe859dfd6..ed7216b85ab 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -2530,11 +2530,10 @@ UINT __cdecl remote_SetMode(MSIHANDLE hinst, MSIRUNMODE 
mode, BOOL state)
     return MsiSetMode(hinst, mode, state);
 }
 
-HRESULT __cdecl remote_GetFeatureState(MSIHANDLE hinst, BSTR feature,
+UINT __cdecl remote_GetFeatureState(MSIHANDLE hinst, LPCWSTR feature,
                                     INSTALLSTATE *installed, INSTALLSTATE 
*action)
 {
-    UINT r = MsiGetFeatureStateW(hinst, feature, installed, action);
-    return HRESULT_FROM_WIN32(r);
+    return MsiGetFeatureStateW(hinst, feature, installed, action);
 }
 
 HRESULT __cdecl remote_SetFeatureState(MSIHANDLE hinst, BSTR feature, 
INSTALLSTATE state)
diff --git a/dll/win32/msi/winemsi.idl b/dll/win32/msi/winemsi.idl
index c4c7e88db83..091ef16504c 100644
--- a/dll/win32/msi/winemsi.idl
+++ b/dll/win32/msi/winemsi.idl
@@ -81,7 +81,7 @@ interface IWineMsiRemote
     UINT remote_GetSourcePath( [in] MSIHANDLE hinst, [in, string] LPCWSTR 
folder, [out, string] LPWSTR *value );
     BOOL remote_GetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode );
     UINT remote_SetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [in] BOOL 
state );
-    HRESULT remote_GetFeatureState( [in] MSIHANDLE hinst, [in] BSTR feature, 
[out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
+    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 );
     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 );
diff --git a/modules/rostests/winetests/msi/custom.c 
b/modules/rostests/winetests/msi/custom.c
index 5f2ff5db095..ef4e282ea7f 100644
--- a/modules/rostests/winetests/msi/custom.c
+++ b/modules/rostests/winetests/msi/custom.c
@@ -650,6 +650,29 @@ static void test_mode(MSIHANDLE hinst)
     ok(hinst, !r, "got %u\n", r);
 }
 
+static void test_feature_states(MSIHANDLE hinst)
+{
+    INSTALLSTATE state, action;
+    UINT r;
+
+    r = MsiGetFeatureStateA(hinst, NULL, &state, &action);
+    ok(hinst, r == ERROR_UNKNOWN_FEATURE, "got %u\n", r);
+
+    r = MsiGetFeatureStateA(hinst, "fake", &state, &action);
+    ok(hinst, r == ERROR_UNKNOWN_FEATURE, "got %u\n", r);
+
+    r = MsiGetFeatureStateA(hinst, "One", NULL, &action);
+    ok(hinst, r == RPC_X_NULL_REF_POINTER, "got %u\n", r);
+
+    r = MsiGetFeatureStateA(hinst, "One", &state, NULL);
+    ok(hinst, r == RPC_X_NULL_REF_POINTER, "got %u\n", r);
+
+    r = MsiGetFeatureStateA(hinst, "One", &state, &action);
+    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);
+}
+
 /* 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)
@@ -678,6 +701,7 @@ UINT WINAPI main_test(MSIHANDLE hinst)
     test_doaction(hinst);
     test_targetpath(hinst);
     test_mode(hinst);
+    test_feature_states(hinst);
 
     return ERROR_SUCCESS;
 }

Reply via email to