From c6bd4d8c35de1ae452a5b5bec69d4779c813b37f Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 18 Apr 2018 18:40:04 -0500 Subject: [PATCH] msi: Make MsiDatabaseOpenView() RPC-compatible. Signed-off-by: Zebediah Figura Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/msi/database.c | 5 ++--- dlls/msi/msiquery.c | 27 +++++++++++---------------- dlls/msi/tests/custom.c | 14 +++++++++++++- dlls/msi/winemsi.idl | 2 +- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index c1309a5be31..c1cf493dde6 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -1923,8 +1923,7 @@ HRESULT __cdecl remote_DatabaseGetSummaryInformation(MSIHANDLE db, UINT updateco return HRESULT_FROM_WIN32(r); } -HRESULT __cdecl remote_DatabaseOpenView(MSIHANDLE db, LPCWSTR query, MSIHANDLE *view) +UINT __cdecl remote_DatabaseOpenView(MSIHANDLE db, LPCWSTR query, MSIHANDLE *view) { - UINT r = MsiDatabaseOpenViewW(db, query, view); - return HRESULT_FROM_WIN32(r); + return MsiDatabaseOpenViewW(db, query, view); } diff --git a/dlls/msi/msiquery.c b/dlls/msi/msiquery.c index fb99c961b2b..9518c5958ae 100644 --- a/dlls/msi/msiquery.c +++ b/dlls/msi/msiquery.c @@ -116,9 +116,6 @@ UINT MSI_DatabaseOpenViewW(MSIDATABASE *db, TRACE("%s %p\n", debugstr_w(szQuery), pView); - if( !szQuery) - return ERROR_INVALID_PARAMETER; - /* pre allocate a handle to hold a pointer to the view */ query = alloc_msiobject( MSIHANDLETYPE_VIEW, sizeof (MSIQUERY), MSI_CloseView ); @@ -247,26 +244,24 @@ UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb, TRACE("%s %p\n", debugstr_w(szQuery), phView); + if (!phView) + return ERROR_INVALID_PARAMETER; + + if (!szQuery) + return ERROR_BAD_QUERY_SYNTAX; + db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE ); if( !db ) { - MSIHANDLE remote; - HRESULT hr; + MSIHANDLE remote, remote_view; if (!(remote = msi_get_remote(hdb))) return ERROR_INVALID_HANDLE; - hr = remote_DatabaseOpenView(remote, szQuery, phView); - - if (FAILED(hr)) - { - if (HRESULT_FACILITY(hr) == FACILITY_WIN32) - return HRESULT_CODE(hr); - - return ERROR_FUNCTION_FAILED; - } - - return ERROR_SUCCESS; + ret = remote_DatabaseOpenView(remote, szQuery, &remote_view); + if (!ret) + *phView = alloc_msi_remote_handle(remote_view); + return ret; } ret = MSI_DatabaseOpenViewW( db, szQuery, &query ); diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c index 07569946623..e7a56ae1cee 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; + MSIHANDLE hdb, view; UINT r; hdb = MsiGetActiveDatabase(hinst); @@ -252,6 +252,18 @@ static void test_db(MSIHANDLE hinst) r = MsiDatabaseIsTablePersistentA(hdb, "Test"); ok(hinst, r == MSICONDITION_TRUE, "got %u\n", r); + r = MsiDatabaseOpenViewA(hdb, NULL, &view); + ok(hinst, r == ERROR_BAD_QUERY_SYNTAX, "got %u\n", r); + + r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `Test`", NULL); + ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r); + + r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `Test`", &view); + ok(hinst, !r, "got %u\n", r); + + r = MsiCloseHandle(view); + ok(hinst, !r, "got %u\n", r); + r = MsiCloseHandle(hdb); ok(hinst, !r, "got %u\n", r); } diff --git a/dlls/msi/winemsi.idl b/dlls/msi/winemsi.idl index 86f03e3daa0..54e6eb890b3 100644 --- a/dlls/msi/winemsi.idl +++ b/dlls/msi/winemsi.idl @@ -59,7 +59,7 @@ interface IWineMsiRemote 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 ); - HRESULT remote_DatabaseOpenView( [in] MSIHANDLE db, [in] LPCWSTR query, [out] MSIHANDLE *view ); + UINT remote_DatabaseOpenView( [in] MSIHANDLE db, [in, string] LPCWSTR query, [out] MSIHANDLE *view ); MSIHANDLE remote_GetActiveDatabase( [in] MSIHANDLE hinst ); UINT remote_GetProperty( [in] MSIHANDLE hinst, [in, string] LPCWSTR property, [out, string] LPWSTR *value, [out] DWORD *size ); -- 2.11.4.GIT