From afb5eede24c35308d2370fd3b492545aed607ce6 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 18 Apr 2018 18:40:05 -0500 Subject: [PATCH] msi: Make MsiViewExecute() RPC-compatible. Signed-off-by: Zebediah Figura Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/msi/msiquery.c | 39 ++++++++++++++++++++++++++++++--------- dlls/msi/record.c | 6 ++++++ dlls/msi/tests/custom.c | 20 +++++++++++++++++++- dlls/msi/winemsi.idl | 2 ++ 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/dlls/msi/msiquery.c b/dlls/msi/msiquery.c index 9518c5958ae..bfc239a53d5 100644 --- a/dlls/msi/msiquery.c +++ b/dlls/msi/msiquery.c @@ -458,25 +458,32 @@ UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec) TRACE("%d %d\n", hView, hRec); - query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW ); - if( !query ) - return ERROR_INVALID_HANDLE; - if( hRec ) { rec = msihandle2msiinfo( hRec, MSIHANDLETYPE_RECORD ); if( !rec ) - { - ret = ERROR_INVALID_HANDLE; - goto out; - } + return ERROR_INVALID_HANDLE; + } + + query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW ); + if( !query ) + { + MSIHANDLE remote; + + if (!(remote = msi_get_remote(hView))) + return ERROR_INVALID_HANDLE; + + ret = remote_ViewExecute(remote, rec ? (struct wire_record *)&rec->count : NULL); + + if (rec) + msiobj_release(&rec->hdr); + return ret; } msiobj_lock( &rec->hdr ); ret = MSI_ViewExecute( query, rec ); msiobj_unlock( &rec->hdr ); -out: msiobj_release( &query->hdr ); if( rec ) msiobj_release( &rec->hdr ); @@ -1033,3 +1040,17 @@ MSICONDITION WINAPI MsiDatabaseIsTablePersistentW( return r; } + +UINT __cdecl remote_ViewExecute(MSIHANDLE view, struct wire_record *remote_rec) +{ + MSIHANDLE rec = 0; + UINT r; + + if ((r = unmarshal_record(remote_rec, &rec))) + return r; + + r = MsiViewExecute(view, rec); + + MsiCloseHandle(rec); + return r; +} diff --git a/dlls/msi/record.c b/dlls/msi/record.c index 7b53d86edfe..4c504eac472 100644 --- a/dlls/msi/record.c +++ b/dlls/msi/record.c @@ -1061,6 +1061,12 @@ UINT unmarshal_record(const struct wire_record *in, MSIHANDLE *out) unsigned int i; UINT r; + if (!in) + { + *out = 0; + return ERROR_SUCCESS; + } + rec = MSI_CreateRecord(in->count); if (!rec) return ERROR_OUTOFMEMORY; diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c index e7a56ae1cee..8a0a20aff05 100644 --- a/dlls/msi/tests/custom.c +++ b/dlls/msi/tests/custom.c @@ -243,7 +243,7 @@ static void test_props(MSIHANDLE hinst) static void test_db(MSIHANDLE hinst) { - MSIHANDLE hdb, view; + MSIHANDLE hdb, view, rec; UINT r; hdb = MsiGetActiveDatabase(hinst); @@ -261,6 +261,24 @@ static void test_db(MSIHANDLE hinst) r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `Test`", &view); ok(hinst, !r, "got %u\n", r); + r = MsiViewExecute(view, 0); + ok(hinst, !r, "got %u\n", r); + + r = MsiCloseHandle(view); + ok(hinst, !r, "got %u\n", r); + + r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `Test` WHERE `Name` = ?", &view); + ok(hinst, !r, "got %u\n", r); + + rec = MsiCreateRecord(1); + MsiRecordSetStringA(rec, 1, "one"); + + r = MsiViewExecute(view, rec); + ok(hinst, !r, "got %u\n", r); + + r = MsiCloseHandle(rec); + ok(hinst, !r, "got %u\n", r); + r = MsiCloseHandle(view); ok(hinst, !r, "got %u\n", r); diff --git a/dlls/msi/winemsi.idl b/dlls/msi/winemsi.idl index 54e6eb890b3..e698f76e202 100644 --- a/dlls/msi/winemsi.idl +++ b/dlls/msi/winemsi.idl @@ -56,6 +56,8 @@ struct wire_record { ] interface IWineMsiRemote { + UINT remote_ViewExecute( [in] MSIHANDLE view, [in, unique] struct wire_record *record ); + MSICONDITION remote_DatabaseIsTablePersistent( [in] MSIHANDLE db, [in] LPCWSTR table ); HRESULT remote_DatabaseGetPrimaryKeys( [in] MSIHANDLE db, [in] LPCWSTR table, [out] MSIHANDLE *keys ); HRESULT remote_DatabaseGetSummaryInformation( [in] MSIHANDLE db, [in] UINT updatecount, [out] MSIHANDLE *suminfo );