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

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

    [WINESYNC] msi: Make MsiGetComponentState() 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 35b1b87dc90b5d0700ec0893bc3918e15a43b07d 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 | 31 +++++++++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 22 deletions(-)

diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c
index 1ff3ad98804..b19b6471ee2 100644
--- a/dll/win32/msi/install.c
+++ b/dll/win32/msi/install.c
@@ -1359,33 +1359,22 @@ UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, 
LPCWSTR szComponent,
     TRACE("%d %s %p %p\n", hInstall, debugstr_w(szComponent),
            piInstalled, piAction);
 
+    if (!szComponent)
+        return ERROR_UNKNOWN_COMPONENT;
+
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
         MSIHANDLE remote;
-        HRESULT hr;
-        BSTR component;
 
         if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
-        component = SysAllocString(szComponent);
-        if (!component)
-            return ERROR_OUTOFMEMORY;
-
-        hr = remote_GetComponentState(remote, component, piInstalled, 
piAction);
-
-        SysFreeString(component);
-
-        if (FAILED(hr))
-        {
-            if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
-                return HRESULT_CODE(hr);
-
-            return ERROR_FUNCTION_FAILED;
-        }
+        /* FIXME: should use SEH */
+        if (!piInstalled || !piAction)
+            return RPC_X_NULL_REF_POINTER;
 
-        return ERROR_SUCCESS;
+        return remote_GetComponentState(remote, szComponent, piInstalled, 
piAction);
     }
 
     ret = MSI_GetComponentStateW( package, szComponent, piInstalled, piAction);
diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index c0ec5a3aa7a..1155db34f8e 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -2541,11 +2541,10 @@ UINT __cdecl remote_SetFeatureState(MSIHANDLE hinst, 
LPCWSTR feature, INSTALLSTA
     return MsiSetFeatureStateW(hinst, feature, state);
 }
 
-HRESULT __cdecl remote_GetComponentState(MSIHANDLE hinst, BSTR component,
+UINT __cdecl remote_GetComponentState(MSIHANDLE hinst, LPCWSTR component,
                                       INSTALLSTATE *installed, INSTALLSTATE 
*action)
 {
-    UINT r = MsiGetComponentStateW(hinst, component, installed, action);
-    return HRESULT_FROM_WIN32(r);
+    return MsiGetComponentStateW(hinst, component, installed, action);
 }
 
 HRESULT __cdecl remote_SetComponentState(MSIHANDLE hinst, BSTR component, 
INSTALLSTATE state)
diff --git a/dll/win32/msi/winemsi.idl b/dll/win32/msi/winemsi.idl
index 8bdc10dcddc..59964871cb3 100644
--- a/dll/win32/msi/winemsi.idl
+++ b/dll/win32/msi/winemsi.idl
@@ -83,7 +83,7 @@ interface IWineMsiRemote
     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 );
     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 );
+    UINT remote_GetComponentState( [in] MSIHANDLE hinst, [in, string] LPCWSTR 
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 );
     HRESULT remote_SetInstallLevel( [in] MSIHANDLE hinst, [in] int level );
diff --git a/modules/rostests/winetests/msi/custom.c 
b/modules/rostests/winetests/msi/custom.c
index b30953a8553..b2c9352e27d 100644
--- a/modules/rostests/winetests/msi/custom.c
+++ b/modules/rostests/winetests/msi/custom.c
@@ -655,6 +655,8 @@ static void test_feature_states(MSIHANDLE hinst)
     INSTALLSTATE state, action;
     UINT r;
 
+    /* test feature states */
+
     r = MsiGetFeatureStateA(hinst, NULL, &state, &action);
     ok(hinst, r == ERROR_UNKNOWN_FEATURE, "got %u\n", r);
 
@@ -688,6 +690,35 @@ static void test_feature_states(MSIHANDLE hinst)
     r = MsiGetFeatureStateA(hinst, "One", &state, &action);
     ok(hinst, !r, "got %u\n", r);
     ok(hinst, action == INSTALLSTATE_LOCAL, "got action %d\n", action);
+
+    /* test component states */
+
+    r = MsiGetComponentStateA(hinst, NULL, &state, &action);
+    ok(hinst, r == ERROR_UNKNOWN_COMPONENT, "got %u\n", r);
+
+    r = MsiGetComponentStateA(hinst, "fake", &state, &action);
+    ok(hinst, r == ERROR_UNKNOWN_COMPONENT, "got %u\n", r);
+
+    r = MsiGetComponentStateA(hinst, "One", NULL, &action);
+    ok(hinst, r == RPC_X_NULL_REF_POINTER, "got %u\n", r);
+
+    r = MsiGetComponentStateA(hinst, "One", &state, NULL);
+    ok(hinst, r == RPC_X_NULL_REF_POINTER, "got %u\n", r);
+
+    r = MsiGetComponentStateA(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);
+
+    r = MsiGetComponentStateA(hinst, "dangler", &state, &action);
+    ok(hinst, !r, "got %u\n", r);
+    ok(hinst, state == INSTALLSTATE_ABSENT, "got state %d\n", state);
+    ok(hinst, action == INSTALLSTATE_UNKNOWN, "got action %d\n", action);
+
+    r = MsiGetComponentStateA(hinst, "component", &state, &action);
+    ok(hinst, !r, "got %u\n", r);
+    ok(hinst, state == INSTALLSTATE_UNKNOWN, "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

Reply via email to