https://git.reactos.org/?p=reactos.git;a=commitdiff;h=62ababd70dba7298de02f…
commit 62ababd70dba7298de02f6a20bcacafd0d087491
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:11:46 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:34 2022 +0100
[WINESYNC] msi: Make MsiGetProperty() 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 2192c9a50a91d175f367534d2ed84fe24f4253aa by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/custom.c | 11 +++++++
dll/win32/msi/package.c | 73 ++++++++++++++++++++++-------------------------
dll/win32/msi/winemsi.idl | 2 +-
3 files changed, 46 insertions(+), 40 deletions(-)
diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c
index 680172bbcbd..7a05cb5d670 100644
--- a/dll/win32/msi/custom.c
+++ b/dll/win32/msi/custom.c
@@ -35,6 +35,7 @@
#include "msipriv.h"
#include "winemsi.h"
+#include "wine/heap.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "wine/exception.h"
@@ -69,6 +70,16 @@ static CRITICAL_SECTION msi_custom_action_cs = {
&msi_custom_action_cs_debug, -1
static struct list msi_pending_custom_actions = LIST_INIT( msi_pending_custom_actions );
+void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len)
+{
+ return heap_alloc(len);
+}
+
+void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr)
+{
+ heap_free(ptr);
+}
+
UINT msi_schedule_action( MSIPACKAGE *package, UINT script, const WCHAR *action )
{
UINT count;
diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index 78152dd7055..afdeaaf2165 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -29,7 +29,6 @@
#include "winnls.h"
#include "shlwapi.h"
#include "wingdi.h"
-#include "wine/debug.h"
#include "msi.h"
#include "msiquery.h"
#include "objidl.h"
@@ -39,11 +38,14 @@
#include "winver.h"
#include "urlmon.h"
#include "shlobj.h"
-#include "wine/unicode.h"
#include "objbase.h"
#include "msidefs.h"
#include "sddl.h"
+#include "wine/heap.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
#include "msipriv.h"
#include "winemsi.h"
#include "resource.h"
@@ -2403,52 +2405,34 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE );
if (!package)
{
- HRESULT hr;
- LPWSTR value = NULL;
+ LPWSTR value = NULL, buffer;
MSIHANDLE remote;
- BSTR bname;
if (!(remote = msi_get_remote(handle)))
return ERROR_INVALID_HANDLE;
- bname = SysAllocString( name );
- if (!bname)
- return ERROR_OUTOFMEMORY;
-
- hr = remote_GetProperty(remote, bname, NULL, &len);
- if (FAILED(hr))
- goto done;
+ r = remote_GetProperty(remote, name, &value, &len);
+ if (r != ERROR_SUCCESS)
+ return r;
- len++;
- value = msi_alloc(len * sizeof(WCHAR));
- if (!value)
+ /* String might contain embedded nulls.
+ * Native returns the correct size but truncates the string. */
+ buffer = heap_alloc_zero((len + 1) * sizeof(WCHAR));
+ if (!buffer)
{
- r = ERROR_OUTOFMEMORY;
- goto done;
+ midl_user_free(value);
+ return ERROR_OUTOFMEMORY;
}
+ strcpyW(buffer, value);
- hr = remote_GetProperty(remote, bname, value, &len);
- if (FAILED(hr))
- goto done;
-
- r = msi_strcpy_to_awstring( value, len, szValueBuf, pchValueBuf );
+ r = msi_strcpy_to_awstring(buffer, len, szValueBuf, pchValueBuf);
/* Bug required by Adobe installers */
- if (!szValueBuf->unicode && !szValueBuf->str.a)
+ if (pchValueBuf && !szValueBuf->unicode &&
!szValueBuf->str.a)
*pchValueBuf *= sizeof(WCHAR);
-done:
- SysFreeString(bname);
- msi_free(value);
-
- if (FAILED(hr))
- {
- if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
- return HRESULT_CODE(hr);
-
- return ERROR_FUNCTION_FAILED;
- }
-
+ heap_free(buffer);
+ midl_user_free(value);
return r;
}
@@ -2505,11 +2489,22 @@ HRESULT __cdecl remote_GetActiveDatabase(MSIHANDLE hinst,
MSIHANDLE *handle)
return S_OK;
}
-HRESULT __cdecl remote_GetProperty(MSIHANDLE hinst, BSTR property, BSTR value, DWORD
*size)
+UINT __cdecl remote_GetProperty(MSIHANDLE hinst, LPCWSTR property, LPWSTR *value, DWORD
*size)
{
- UINT r = MsiGetPropertyW(hinst, property, value, size);
- if (r != ERROR_SUCCESS) return HRESULT_FROM_WIN32(r);
- return S_OK;
+ WCHAR empty[1];
+ UINT r;
+
+ *size = 0;
+ r = MsiGetPropertyW(hinst, property, empty, size);
+ if (r == ERROR_MORE_DATA)
+ {
+ ++*size;
+ *value = midl_user_allocate(*size * sizeof(WCHAR));
+ if (!*value)
+ return ERROR_OUTOFMEMORY;
+ r = MsiGetPropertyW(hinst, property, *value, size);
+ }
+ return r;
}
HRESULT __cdecl remote_SetProperty(MSIHANDLE hinst, BSTR property, BSTR value)
diff --git a/dll/win32/msi/winemsi.idl b/dll/win32/msi/winemsi.idl
index 560b3067822..07a315b2171 100644
--- a/dll/win32/msi/winemsi.idl
+++ b/dll/win32/msi/winemsi.idl
@@ -42,7 +42,7 @@ interface IWineMsiRemote
HRESULT remote_DatabaseOpenView( [in] MSIHANDLE db, [in] LPCWSTR query, [out]
MSIHANDLE *view );
HRESULT remote_GetActiveDatabase( [in] MSIHANDLE hinst, [out] MSIHANDLE *handle );
- HRESULT remote_GetProperty( [in] MSIHANDLE hinst, [in] BSTR property, [out,
size_is(*size)] BSTR value, [in, out] DWORD *size );
+ UINT remote_GetProperty( [in] MSIHANDLE hinst, [in, string] LPCWSTR property, [out,
string] LPWSTR *value, [out] DWORD *size );
HRESULT remote_SetProperty( [in] MSIHANDLE hinst, [in] BSTR property, [in] BSTR value
);
HRESULT remote_ProcessMessage( [in] MSIHANDLE hinst, [in] INSTALLMESSAGE message,
[in] MSIHANDLE record );
HRESULT remote_DoAction( [in] MSIHANDLE hinst, [in] BSTR action );