msi: Make MsiGetProperty() RPC-compatible.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-04-17 10:35:36 -05:00 committed by Alexandre Julliard
parent 72a04f4b37
commit 2192c9a50a
3 changed files with 46 additions and 40 deletions

View File

@ -34,6 +34,7 @@
#include "msipriv.h" #include "msipriv.h"
#include "winemsi.h" #include "winemsi.h"
#include "wine/heap.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/exception.h" #include "wine/exception.h"
@ -64,6 +65,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 ); 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 msi_schedule_action( MSIPACKAGE *package, UINT script, const WCHAR *action )
{ {
UINT count; UINT count;

View File

@ -29,7 +29,6 @@
#include "winnls.h" #include "winnls.h"
#include "shlwapi.h" #include "shlwapi.h"
#include "wingdi.h" #include "wingdi.h"
#include "wine/debug.h"
#include "msi.h" #include "msi.h"
#include "msiquery.h" #include "msiquery.h"
#include "objidl.h" #include "objidl.h"
@ -39,11 +38,14 @@
#include "winver.h" #include "winver.h"
#include "urlmon.h" #include "urlmon.h"
#include "shlobj.h" #include "shlobj.h"
#include "wine/unicode.h"
#include "objbase.h" #include "objbase.h"
#include "msidefs.h" #include "msidefs.h"
#include "sddl.h" #include "sddl.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "msipriv.h" #include "msipriv.h"
#include "winemsi.h" #include "winemsi.h"
#include "resource.h" #include "resource.h"
@ -2396,52 +2398,34 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE ); package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE );
if (!package) if (!package)
{ {
HRESULT hr; LPWSTR value = NULL, buffer;
LPWSTR value = NULL;
MSIHANDLE remote; MSIHANDLE remote;
BSTR bname;
if (!(remote = msi_get_remote(handle))) if (!(remote = msi_get_remote(handle)))
return ERROR_INVALID_HANDLE; return ERROR_INVALID_HANDLE;
bname = SysAllocString( name ); r = remote_GetProperty(remote, name, &value, &len);
if (!bname) if (r != ERROR_SUCCESS)
return ERROR_OUTOFMEMORY; return r;
hr = remote_GetProperty(remote, bname, NULL, &len); /* String might contain embedded nulls.
if (FAILED(hr)) * Native returns the correct size but truncates the string. */
goto done; buffer = heap_alloc_zero((len + 1) * sizeof(WCHAR));
if (!buffer)
len++;
value = msi_alloc(len * sizeof(WCHAR));
if (!value)
{ {
r = ERROR_OUTOFMEMORY; midl_user_free(value);
goto done; return ERROR_OUTOFMEMORY;
} }
strcpyW(buffer, value);
hr = remote_GetProperty(remote, bname, value, &len); r = msi_strcpy_to_awstring(buffer, len, szValueBuf, pchValueBuf);
if (FAILED(hr))
goto done;
r = msi_strcpy_to_awstring( value, len, szValueBuf, pchValueBuf );
/* Bug required by Adobe installers */ /* Bug required by Adobe installers */
if (!szValueBuf->unicode && !szValueBuf->str.a) if (pchValueBuf && !szValueBuf->unicode && !szValueBuf->str.a)
*pchValueBuf *= sizeof(WCHAR); *pchValueBuf *= sizeof(WCHAR);
done: heap_free(buffer);
SysFreeString(bname); midl_user_free(value);
msi_free(value);
if (FAILED(hr))
{
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
return HRESULT_CODE(hr);
return ERROR_FUNCTION_FAILED;
}
return r; return r;
} }
@ -2498,11 +2482,22 @@ HRESULT __cdecl remote_GetActiveDatabase(MSIHANDLE hinst, MSIHANDLE *handle)
return S_OK; 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); WCHAR empty[1];
if (r != ERROR_SUCCESS) return HRESULT_FROM_WIN32(r); UINT r;
return S_OK;
*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) HRESULT __cdecl remote_SetProperty(MSIHANDLE hinst, BSTR property, BSTR value)

View File

@ -42,7 +42,7 @@ interface IWineMsiRemote
HRESULT remote_DatabaseOpenView( [in] MSIHANDLE db, [in] LPCWSTR query, [out] MSIHANDLE *view ); HRESULT remote_DatabaseOpenView( [in] MSIHANDLE db, [in] LPCWSTR query, [out] MSIHANDLE *view );
HRESULT remote_GetActiveDatabase( [in] MSIHANDLE hinst, [out] MSIHANDLE *handle ); 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_SetProperty( [in] MSIHANDLE hinst, [in] BSTR property, [in] BSTR value );
HRESULT remote_ProcessMessage( [in] MSIHANDLE hinst, [in] INSTALLMESSAGE message, [in] MSIHANDLE record ); HRESULT remote_ProcessMessage( [in] MSIHANDLE hinst, [in] INSTALLMESSAGE message, [in] MSIHANDLE record );
HRESULT remote_DoAction( [in] MSIHANDLE hinst, [in] BSTR action ); HRESULT remote_DoAction( [in] MSIHANDLE hinst, [in] BSTR action );