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

Alexandre Julliard julliard at winehq.org
Mon Apr 23 17:58:36 CDT 2018


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Sat Apr 21 19:33:46 2018 -0500

msi: Make MsiSetTargetPath() 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 | 16 ++++++++++++++++
 dlls/msi/winemsi.idl    |  2 +-
 4 files changed, 20 insertions(+), 29 deletions(-)

diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index 68d8eb5..ba329eb 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -535,36 +535,12 @@ UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder,
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
-        HRESULT hr;
-        BSTR folder, path;
         MSIHANDLE remote;
 
         if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
-        folder = SysAllocString( szFolder );
-        path = SysAllocString( szFolderPath );
-        if (!folder || !path)
-        {
-            SysFreeString(folder);
-            SysFreeString(path);
-            return ERROR_OUTOFMEMORY;
-        }
-
-        hr = remote_SetTargetPath(remote, folder, path);
-
-        SysFreeString(folder);
-        SysFreeString(path);
-
-        if (FAILED(hr))
-        {
-            if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
-                return HRESULT_CODE(hr);
-
-            return ERROR_FUNCTION_FAILED;
-        }
-
-        return ERROR_SUCCESS;
+        return remote_SetTargetPath(remote, szFolder, szFolderPath);
     }
 
     ret = MSI_SetTargetPathW( package, szFolder, szFolderPath );
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index d1a6923..220692b 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -2491,10 +2491,9 @@ UINT __cdecl remote_GetTargetPath(MSIHANDLE hinst, LPCWSTR folder, LPWSTR *value
     return r;
 }
 
-HRESULT __cdecl remote_SetTargetPath(MSIHANDLE hinst, BSTR folder, BSTR value)
+UINT __cdecl remote_SetTargetPath(MSIHANDLE hinst, LPCWSTR folder, LPCWSTR value)
 {
-    UINT r = MsiSetTargetPathW(hinst, folder, value);
-    return HRESULT_FROM_WIN32(r);
+    return MsiSetTargetPathW(hinst, folder, value);
 }
 
 HRESULT __cdecl remote_GetSourcePath(MSIHANDLE hinst, BSTR folder, BSTR value, DWORD *size)
diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c
index 5062ecd..111032c 100644
--- a/dlls/msi/tests/custom.c
+++ b/dlls/msi/tests/custom.c
@@ -541,6 +541,22 @@ static void test_targetpath(MSIHANDLE hinst)
     ok(hinst, !r, "got %u\n", r);
     ok(hinst, !lstrcmpW(bufferW, xyzW), "got %s\n", dbgstr_w(bufferW));
     ok(hinst, sz == 3, "got size %u\n", sz);
+
+    r = MsiSetTargetPathA(hinst, NULL, "C:\\subdir");
+    ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+    r = MsiSetTargetPathA(hinst, "TARGETDIR", NULL);
+    ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+    r = MsiSetTargetPathA(hinst, "TARGETDIR", "C:\\subdir");
+    ok(hinst, !r, "got %u\n", r);
+
+    sz = sizeof(buffer);
+    r = MsiGetTargetPathA(hinst, "TARGETDIR", buffer, &sz);
+    ok(hinst, !r, "got %u\n", r);
+    ok(hinst, !strcmp(buffer, "C:\\subdir\\"), "got \"%s\"\n", buffer);
+
+    r = MsiSetTargetPathA(hinst, "TARGETDIR", "C:\\");
 }
 
 /* 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 5e09c85..a0e1ddb 100644
--- a/dlls/msi/winemsi.idl
+++ b/dlls/msi/winemsi.idl
@@ -77,7 +77,7 @@ interface IWineMsiRemote
     UINT remote_DoAction( [in] MSIHANDLE hinst, [in, string] LPCWSTR action );
     UINT remote_Sequence( [in] MSIHANDLE hinst, [in, string] LPCWSTR table, [in] int sequence );
     UINT remote_GetTargetPath( [in] MSIHANDLE hinst, [in, string] LPCWSTR folder, [out, string] LPWSTR *value );
-    HRESULT remote_SetTargetPath( [in] MSIHANDLE hinst, [in] BSTR folder, [in] BSTR value );
+    UINT remote_SetTargetPath( [in] MSIHANDLE hinst, [in, string] LPCWSTR folder, [in, string] LPCWSTR value );
     HRESULT remote_GetSourcePath( [in] MSIHANDLE hinst, [in] BSTR folder, [out, size_is(*size)] BSTR value, [in, out] DWORD *size );
     HRESULT remote_GetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [out] BOOL *ret );
     HRESULT remote_SetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [in] BOOL state );




More information about the wine-cvs mailing list