https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4253f35129732f579b9f9…
commit 4253f35129732f579b9f9c21f9728f472756cc05
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:11:59 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:39 2022 +0100
[WINESYNC] msi: Make MsiGetSourcePath() RPC-compatible.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id d2b0981a2ceb8371460f009e0250ad2690ca0e93 by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/install.c | 41 ++-------------
dll/win32/msi/package.c | 17 +++++--
dll/win32/msi/winemsi.idl | 2 +-
modules/rostests/winetests/msi/custom.c | 89 +++++++++++++++++++++++++++++++--
4 files changed, 106 insertions(+), 43 deletions(-)
diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c
index ba329eb8f80..88b3ff518e2 100644
--- a/dll/win32/msi/install.c
+++ b/dll/win32/msi/install.c
@@ -334,50 +334,19 @@ static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR
szFolder,
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
if (!package)
{
- HRESULT hr;
LPWSTR value = NULL;
MSIHANDLE remote;
- BSTR folder;
- DWORD len;
if (!(remote = msi_get_remote(hInstall)))
return ERROR_INVALID_HANDLE;
- folder = SysAllocString( szFolder );
- if (!folder)
- return ERROR_OUTOFMEMORY;
-
- len = 0;
- hr = remote_GetSourcePath(remote, folder, NULL, &len);
- if (FAILED(hr))
- goto done;
-
- len++;
- value = msi_alloc(len * sizeof(WCHAR));
- if (!value)
- {
- r = ERROR_OUTOFMEMORY;
- goto done;
- }
-
- hr = remote_GetSourcePath(remote, folder, value, &len);
- if (FAILED(hr))
- goto done;
-
- r = msi_strcpy_to_awstring( value, len, szPathBuf, pcchPathBuf );
-
-done:
- SysFreeString( folder );
- msi_free( value );
-
- if (FAILED(hr))
- {
- if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
- return HRESULT_CODE(hr);
+ r = remote_GetSourcePath(remote, szFolder, &value);
+ if (r != ERROR_SUCCESS)
+ return r;
- return ERROR_FUNCTION_FAILED;
- }
+ r = msi_strcpy_to_awstring(value, -1, szPathBuf, pcchPathBuf);
+ midl_user_free(value);
return r;
}
diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index 89ac2ce3a6f..1e554af5eee 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -2503,10 +2503,21 @@ UINT __cdecl remote_SetTargetPath(MSIHANDLE hinst, LPCWSTR folder,
LPCWSTR value
return MsiSetTargetPathW(hinst, folder, value);
}
-HRESULT __cdecl remote_GetSourcePath(MSIHANDLE hinst, BSTR folder, BSTR value, DWORD
*size)
+UINT __cdecl remote_GetSourcePath(MSIHANDLE hinst, LPCWSTR folder, LPWSTR *value)
{
- UINT r = MsiGetSourcePathW(hinst, folder, value, size);
- return HRESULT_FROM_WIN32(r);
+ WCHAR empty[1];
+ DWORD size = 1;
+ UINT r;
+
+ r = MsiGetSourcePathW(hinst, folder, empty, &size);
+ if (r == ERROR_MORE_DATA)
+ {
+ *value = midl_user_allocate(++size * sizeof(WCHAR));
+ if (!*value)
+ return ERROR_OUTOFMEMORY;
+ r = MsiGetSourcePathW(hinst, folder, *value, &size);
+ }
+ return r;
}
HRESULT __cdecl remote_GetMode(MSIHANDLE hinst, MSIRUNMODE mode, BOOL *ret)
diff --git a/dll/win32/msi/winemsi.idl b/dll/win32/msi/winemsi.idl
index a0e1ddbb840..06db52e5fc5 100644
--- a/dll/win32/msi/winemsi.idl
+++ b/dll/win32/msi/winemsi.idl
@@ -78,7 +78,7 @@ interface IWineMsiRemote
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 );
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 );
+ UINT remote_GetSourcePath( [in] MSIHANDLE hinst, [in, string] LPCWSTR folder, [out,
string] LPWSTR *value );
HRESULT remote_GetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [out] BOOL *ret
);
HRESULT 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 );
diff --git a/modules/rostests/winetests/msi/custom.c
b/modules/rostests/winetests/msi/custom.c
index 111032c37a4..d596f1ec328 100644
--- a/modules/rostests/winetests/msi/custom.c
+++ b/modules/rostests/winetests/msi/custom.c
@@ -458,9 +458,9 @@ static void test_targetpath(MSIHANDLE hinst)
static const WCHAR targetdirW[] =
{'T','A','R','G','E','T','D','I','R',0};
static const WCHAR xyzW[] = {'C',':','\\',0};
static const WCHAR xyW[] = {'C',':',0};
- char buffer[20];
- WCHAR bufferW[20];
- DWORD sz;
+ WCHAR bufferW[100];
+ char buffer[100];
+ DWORD sz, srcsz;
UINT r;
/* test invalid values */
@@ -557,6 +557,89 @@ static void test_targetpath(MSIHANDLE hinst)
ok(hinst, !strcmp(buffer, "C:\\subdir\\"), "got
\"%s\"\n", buffer);
r = MsiSetTargetPathA(hinst, "TARGETDIR", "C:\\");
+
+ /* test GetSourcePath() */
+
+ r = MsiGetSourcePathA(hinst, NULL, NULL, NULL);
+ ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+ r = MsiGetSourcePathA(hinst, "TARGETDIR", NULL, NULL );
+ ok(hinst, !r, "got %u\n", r);
+
+ r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, NULL );
+ ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
+ /* Returned size is in bytes, not chars, but only for custom actions.
+ * Seems to be a casualty of RPC... */
+
+ srcsz = 0;
+ MsiGetSourcePathW(hinst, targetdirW, NULL, &srcsz);
+
+ sz = 0;
+ r = MsiGetSourcePathA(hinst, "TARGETDIR", NULL, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ todo_wine_ok(hinst, sz == srcsz * 2, "got size %u\n", sz);
+
+ sz = 0;
+ strcpy(buffer,"q");
+ r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !strcmp(buffer, "q"), "got \"%s\"\n",
buffer);
+ todo_wine_ok(hinst, sz == srcsz * 2, "got size %u\n", sz);
+
+ sz = 1;
+ strcpy(buffer,"x");
+ r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
+ todo_wine_ok(hinst, sz == srcsz * 2, "got size %u\n", sz);
+
+ sz = srcsz;
+ strcpy(buffer,"x");
+ r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, strlen(buffer) == srcsz - 1, "wrong buffer length %d\n",
strlen(buffer));
+ todo_wine_ok(hinst, sz == srcsz * 2, "got size %u\n", sz);
+
+ sz = srcsz + 1;
+ strcpy(buffer,"x");
+ r = MsiGetSourcePathA(hinst, "TARGETDIR", buffer, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, strlen(buffer) == srcsz, "wrong buffer length %d\n",
strlen(buffer));
+ ok(hinst, sz == srcsz, "got size %u\n", sz);
+
+ sz = 0;
+ r = MsiGetSourcePathW(hinst, targetdirW, NULL, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, sz == srcsz, "got size %u\n", sz);
+
+ sz = 0;
+ bufferW[0] = 'q';
+ r = MsiGetSourcePathW(hinst, targetdirW, bufferW, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, bufferW[0] == 'q', "got %s\n", dbgstr_w(bufferW));
+ ok(hinst, sz == srcsz, "got size %u\n", sz);
+
+ sz = 1;
+ bufferW[0] = 'q';
+ r = MsiGetSourcePathW(hinst, targetdirW, bufferW, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, !bufferW[0], "got %s\n", dbgstr_w(bufferW));
+ ok(hinst, sz == srcsz, "got size %u\n", sz);
+
+ sz = srcsz;
+ bufferW[0] = 'q';
+ r = MsiGetSourcePathW(hinst, targetdirW, bufferW, &sz);
+ ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
+ ok(hinst, lstrlenW(bufferW) == srcsz - 1, "wrong buffer length %d\n",
lstrlenW(bufferW));
+ ok(hinst, sz == srcsz, "got size %u\n", sz);
+
+ sz = srcsz + 1;
+ bufferW[0] = 'q';
+ r = MsiGetSourcePathW(hinst, targetdirW, bufferW, &sz);
+ ok(hinst, !r, "got %u\n", r);
+ ok(hinst, lstrlenW(bufferW) == srcsz, "wrong buffer length %d\n",
lstrlenW(bufferW));
+ ok(hinst, sz == srcsz, "got size %u\n", sz);
}
/* Main test. Anything that doesn't depend on a specific install configuration