2003-08-13 03:27:48 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
2005-02-16 17:05:11 +01:00
|
|
|
* Copyright 2002-2005 Mike McCormack for CodeWeavers
|
2003-08-13 03:27:48 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-08-13 03:27:48 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/debug.h"
|
2018-09-08 03:17:22 +02:00
|
|
|
#include "wine/exception.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "msi.h"
|
|
|
|
#include "msiquery.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "objidl.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
#include "msipriv.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "query.h"
|
2018-04-16 03:52:10 +02:00
|
|
|
#include "winemsi.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2006-10-11 09:27:15 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2005-05-31 11:30:28 +02:00
|
|
|
static void MSI_CloseView( MSIOBJECTHDR *arg )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIQUERY *query = (MSIQUERY*) arg;
|
2005-05-23 14:08:17 +02:00
|
|
|
struct list *ptr, *t;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
if( query->view && query->view->ops->delete )
|
|
|
|
query->view->ops->delete( query->view );
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release( &query->db->hdr );
|
2005-05-23 14:08:17 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( ptr, t, &query->mem )
|
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( ptr );
|
2005-05-23 14:08:17 +02:00
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2009-10-18 18:41:41 +02:00
|
|
|
UINT VIEW_find_column( MSIVIEW *table, LPCWSTR name, LPCWSTR table_name, UINT *n )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2011-07-27 10:53:10 +02:00
|
|
|
LPCWSTR col_name, haystack_table_name;
|
2003-08-13 03:27:48 +02:00
|
|
|
UINT i, count, r;
|
|
|
|
|
|
|
|
r = table->ops->get_dimensions( table, NULL, &count );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
|
|
|
|
for( i=1; i<=count; i++ )
|
|
|
|
{
|
|
|
|
INT x;
|
|
|
|
|
2009-10-18 18:41:41 +02:00
|
|
|
r = table->ops->get_column_info( table, i, &col_name, NULL,
|
|
|
|
NULL, &haystack_table_name );
|
2003-08-13 03:27:48 +02:00
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
2019-06-13 08:42:35 +02:00
|
|
|
x = wcscmp( name, col_name );
|
2009-10-18 18:41:41 +02:00
|
|
|
if( table_name )
|
2019-06-13 08:42:35 +02:00
|
|
|
x |= wcscmp( table_name, haystack_table_name );
|
2003-08-13 03:27:48 +02:00
|
|
|
if( !x )
|
|
|
|
{
|
|
|
|
*n = i;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb,
|
|
|
|
LPCSTR szQuery, MSIHANDLE *phView)
|
|
|
|
{
|
|
|
|
UINT r;
|
2003-09-27 04:24:31 +02:00
|
|
|
LPWSTR szwQuery;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s %p\n", hdb, debugstr_a(szQuery), phView);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
if( szQuery )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwQuery = strdupAtoW( szQuery );
|
2003-08-13 03:27:48 +02:00
|
|
|
if( !szwQuery )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
szwQuery = NULL;
|
|
|
|
|
|
|
|
r = MsiDatabaseOpenViewW( hdb, szwQuery, phView);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwQuery );
|
2003-08-13 03:27:48 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
UINT MSI_DatabaseOpenViewW(MSIDATABASE *db,
|
|
|
|
LPCWSTR szQuery, MSIQUERY **pView)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
|
|
|
MSIQUERY *query;
|
|
|
|
UINT r;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
TRACE("%s %p\n", debugstr_w(szQuery), pView);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
/* pre allocate a handle to hold a pointer to the view */
|
2004-07-10 00:25:34 +02:00
|
|
|
query = alloc_msiobject( MSIHANDLETYPE_VIEW, sizeof (MSIQUERY),
|
|
|
|
MSI_CloseView );
|
|
|
|
if( !query )
|
2003-08-13 03:27:48 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_addref( &db->hdr );
|
2003-08-13 03:27:48 +02:00
|
|
|
query->db = db;
|
2005-05-23 14:08:17 +02:00
|
|
|
list_init( &query->mem );
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-05-23 14:08:17 +02:00
|
|
|
r = MSI_ParseSQL( db, szQuery, &query->view, &query->mem );
|
2004-07-10 00:25:34 +02:00
|
|
|
if( r == ERROR_SUCCESS )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_addref( &query->hdr );
|
|
|
|
*pView = query;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release( &query->hdr );
|
2004-07-19 21:35:05 +02:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
UINT WINAPIV MSI_OpenQuery( MSIDATABASE *db, MSIQUERY **view, LPCWSTR fmt, ... )
|
2005-06-02 12:29:28 +02:00
|
|
|
{
|
|
|
|
UINT r;
|
2005-09-12 13:13:05 +02:00
|
|
|
int size = 100, res;
|
|
|
|
LPWSTR query;
|
2005-06-02 12:29:28 +02:00
|
|
|
|
2005-09-12 13:13:05 +02:00
|
|
|
/* construct the string */
|
|
|
|
for (;;)
|
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
__ms_va_list va;
|
2005-09-20 13:59:14 +02:00
|
|
|
query = msi_alloc( size*sizeof(WCHAR) );
|
2019-06-13 08:42:35 +02:00
|
|
|
__ms_va_start(va, fmt);
|
|
|
|
res = vswprintf(query, size, fmt, va);
|
|
|
|
__ms_va_end(va);
|
2005-09-12 13:13:05 +02:00
|
|
|
if (res == -1) size *= 2;
|
|
|
|
else if (res >= size) size = res + 1;
|
|
|
|
else break;
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( query );
|
2005-09-12 13:13:05 +02:00
|
|
|
}
|
|
|
|
/* perform the query */
|
|
|
|
r = MSI_DatabaseOpenViewW(db, query, view);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(query);
|
2005-06-02 12:29:28 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-08-09 10:41:41 +02:00
|
|
|
UINT MSI_IterateRecords( MSIQUERY *view, LPDWORD count,
|
2005-02-02 10:55:51 +01:00
|
|
|
record_func func, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
UINT r, n = 0, max = 0;
|
|
|
|
|
|
|
|
r = MSI_ViewExecute( view, NULL );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
|
|
|
|
if( count )
|
|
|
|
max = *count;
|
|
|
|
|
|
|
|
/* iterate a query */
|
|
|
|
for( n = 0; (max == 0) || (n < max); n++ )
|
|
|
|
{
|
|
|
|
r = MSI_ViewFetch( view, &rec );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
break;
|
2005-09-21 12:20:03 +02:00
|
|
|
if (func)
|
|
|
|
r = func( rec, param );
|
2005-02-02 10:55:51 +01:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSI_ViewClose( view );
|
|
|
|
|
|
|
|
if( count )
|
|
|
|
*count = n;
|
|
|
|
|
2005-02-16 17:05:11 +01:00
|
|
|
if( r == ERROR_NO_MORE_ITEMS )
|
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-06-02 12:29:28 +02:00
|
|
|
/* return a single record from a query */
|
2019-06-13 08:42:35 +02:00
|
|
|
MSIRECORD * WINAPIV MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR fmt, ... )
|
2005-06-02 12:29:28 +02:00
|
|
|
{
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
UINT r;
|
2005-09-12 13:13:05 +02:00
|
|
|
int size = 100, res;
|
|
|
|
LPWSTR query;
|
2005-06-02 12:29:28 +02:00
|
|
|
|
2005-09-12 13:13:05 +02:00
|
|
|
/* construct the string */
|
|
|
|
for (;;)
|
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
__ms_va_list va;
|
2005-09-20 13:59:14 +02:00
|
|
|
query = msi_alloc( size*sizeof(WCHAR) );
|
2019-06-13 08:42:35 +02:00
|
|
|
__ms_va_start(va, fmt);
|
|
|
|
res = vswprintf(query, size, fmt, va);
|
|
|
|
__ms_va_end(va);
|
2005-09-12 13:13:05 +02:00
|
|
|
if (res == -1) size *= 2;
|
|
|
|
else if (res >= size) size = res + 1;
|
|
|
|
else break;
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( query );
|
2005-09-12 13:13:05 +02:00
|
|
|
}
|
|
|
|
/* perform the query */
|
|
|
|
r = MSI_DatabaseOpenViewW(db, query, &view);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(query);
|
2005-06-02 12:29:28 +02:00
|
|
|
|
|
|
|
if( r == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
MSI_ViewExecute( view, NULL );
|
|
|
|
MSI_ViewFetch( view, &rec );
|
|
|
|
MSI_ViewClose( view );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
}
|
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb,
|
|
|
|
LPCWSTR szQuery, MSIHANDLE *phView)
|
|
|
|
{
|
|
|
|
MSIDATABASE *db;
|
|
|
|
MSIQUERY *query = NULL;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%s %p\n", debugstr_w(szQuery), phView);
|
|
|
|
|
2018-04-19 01:40:04 +02:00
|
|
|
if (!phView)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (!szQuery)
|
|
|
|
return ERROR_BAD_QUERY_SYNTAX;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
|
|
|
|
if( !db )
|
2007-11-12 01:13:08 +01:00
|
|
|
{
|
2018-04-19 01:40:04 +02:00
|
|
|
MSIHANDLE remote, remote_view;
|
2007-11-12 01:13:08 +01:00
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
if (!(remote = msi_get_remote(hdb)))
|
2007-11-12 01:13:08 +01:00
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_DatabaseOpenView(remote, szQuery, &remote_view);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-04-19 01:40:04 +02:00
|
|
|
if (!ret)
|
|
|
|
*phView = alloc_msi_remote_handle(remote_view);
|
|
|
|
return ret;
|
2007-11-12 01:13:08 +01:00
|
|
|
}
|
2004-07-10 00:25:34 +02:00
|
|
|
|
|
|
|
ret = MSI_DatabaseOpenViewW( db, szQuery, &query );
|
|
|
|
if( ret == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
*phView = alloc_msihandle( &query->hdr );
|
2006-08-28 18:44:35 +02:00
|
|
|
if (! *phView)
|
|
|
|
ret = ERROR_NOT_ENOUGH_MEMORY;
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release( &query->hdr );
|
|
|
|
}
|
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-01-29 05:11:10 +01:00
|
|
|
UINT msi_view_refresh_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD *rec)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
|
|
|
UINT row_count = 0, col_count = 0, i, ival, ret, type;
|
|
|
|
|
2007-07-27 02:40:38 +02:00
|
|
|
TRACE("%p %p %d %p\n", db, view, row, rec);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2007-07-27 02:40:38 +02:00
|
|
|
ret = view->ops->get_dimensions(view, &row_count, &col_count);
|
|
|
|
if (ret)
|
2003-08-13 03:27:48 +02:00
|
|
|
return ret;
|
2007-07-27 02:40:38 +02:00
|
|
|
|
|
|
|
if (!col_count)
|
2003-08-13 03:27:48 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2007-07-27 02:40:38 +02:00
|
|
|
for (i = 1; i <= col_count; i++)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2009-10-18 18:41:41 +02:00
|
|
|
ret = view->ops->get_column_info(view, i, NULL, &type, NULL, NULL);
|
2007-07-27 02:40:38 +02:00
|
|
|
if (ret)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2007-07-27 02:40:38 +02:00
|
|
|
ERR("Error getting column type for %d\n", i);
|
2003-08-13 03:27:48 +02:00
|
|
|
continue;
|
|
|
|
}
|
2007-07-27 02:40:38 +02:00
|
|
|
|
|
|
|
if (MSITYPE_IS_BINARY(type))
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2007-07-27 02:40:38 +02:00
|
|
|
IStream *stm = NULL;
|
|
|
|
|
|
|
|
ret = view->ops->fetch_stream(view, row, i, &stm);
|
|
|
|
if ((ret == ERROR_SUCCESS) && stm)
|
2004-07-06 20:56:12 +02:00
|
|
|
{
|
2019-01-29 05:11:10 +01:00
|
|
|
MSI_RecordSetIStream(rec, i, stm);
|
2007-07-27 02:40:38 +02:00
|
|
|
IStream_Release(stm);
|
2004-07-06 20:56:12 +02:00
|
|
|
}
|
2007-07-27 02:40:38 +02:00
|
|
|
else
|
2008-07-08 06:59:07 +02:00
|
|
|
WARN("failed to get stream\n");
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2007-07-27 02:40:38 +02:00
|
|
|
continue;
|
|
|
|
}
|
2004-06-29 05:41:28 +02:00
|
|
|
|
2007-07-27 02:40:38 +02:00
|
|
|
ret = view->ops->fetch_int(view, row, i, &ival);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ERR("Error fetching data for %d\n", i);
|
|
|
|
continue;
|
|
|
|
}
|
2004-07-06 20:56:12 +02:00
|
|
|
|
2007-07-27 02:40:38 +02:00
|
|
|
if (! (type & MSITYPE_VALID))
|
|
|
|
ERR("Invalid type!\n");
|
|
|
|
|
|
|
|
if (type & MSITYPE_STRING)
|
|
|
|
{
|
2012-10-29 12:14:19 +01:00
|
|
|
int len;
|
2019-01-29 05:11:10 +01:00
|
|
|
const WCHAR *sval = msi_string_lookup(db->strings, ival, &len);
|
|
|
|
msi_record_set_string(rec, i, sval, len);
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-27 02:40:38 +02:00
|
|
|
if ((type & MSI_DATASIZEMASK) == 2)
|
2019-01-29 05:11:10 +01:00
|
|
|
MSI_RecordSetInteger(rec, i, ival ? ival - (1<<15) : MSI_NULL_INTEGER);
|
2003-08-13 03:27:48 +02:00
|
|
|
else
|
2019-01-29 05:11:10 +01:00
|
|
|
MSI_RecordSetInteger(rec, i, ival - (1u<<31));
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-01-29 05:11:10 +01:00
|
|
|
UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec)
|
|
|
|
{
|
|
|
|
UINT row_count = 0, col_count = 0, r;
|
|
|
|
MSIRECORD *object;
|
|
|
|
|
|
|
|
TRACE("view %p, row %u, rec %p.\n", view, row, rec);
|
|
|
|
|
|
|
|
if ((r = view->ops->get_dimensions(view, &row_count, &col_count)))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
if (row >= row_count)
|
|
|
|
return ERROR_NO_MORE_ITEMS;
|
|
|
|
|
|
|
|
if (!(object = MSI_CreateRecord( col_count )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if ((r = msi_view_refresh_row(db, view, row, object)))
|
|
|
|
msiobj_release( &object->hdr );
|
|
|
|
else
|
|
|
|
*rec = object;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-07-27 02:40:38 +02:00
|
|
|
UINT MSI_ViewFetch(MSIQUERY *query, MSIRECORD **prec)
|
|
|
|
{
|
|
|
|
MSIVIEW *view;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", query, prec );
|
|
|
|
|
|
|
|
view = query->view;
|
|
|
|
if( !view )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
r = msi_view_get_row(query->db, view, query->row, prec);
|
|
|
|
if (r == ERROR_SUCCESS)
|
2009-02-26 04:44:46 +01:00
|
|
|
{
|
2007-07-27 02:40:38 +02:00
|
|
|
query->row ++;
|
2018-10-12 16:44:03 +02:00
|
|
|
(*prec)->cookie = (UINT64)(ULONG_PTR)query;
|
2018-04-18 02:11:28 +02:00
|
|
|
MSI_RecordSetInteger(*prec, 0, 1);
|
2009-02-26 04:44:46 +01:00
|
|
|
}
|
2007-07-27 02:40:38 +02:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
|
|
|
MSIQUERY *query;
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
UINT ret;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %p\n", hView, record);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2006-06-11 02:51:29 +02:00
|
|
|
if( !record )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
*record = 0;
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
|
2018-04-19 01:40:06 +02:00
|
|
|
if (!query)
|
|
|
|
{
|
|
|
|
struct wire_record *wire_rec = NULL;
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote(hView)))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_ViewFetch(remote, &wire_rec);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-04-19 01:40:06 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
ret = unmarshal_record(wire_rec, record);
|
|
|
|
free_remote_record(wire_rec);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2004-07-10 00:25:34 +02:00
|
|
|
ret = MSI_ViewFetch( query, &rec );
|
|
|
|
if( ret == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
*record = alloc_msihandle( &rec->hdr );
|
2006-08-28 18:44:35 +02:00
|
|
|
if (! *record)
|
|
|
|
ret = ERROR_NOT_ENOUGH_MEMORY;
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
}
|
|
|
|
msiobj_release( &query->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_ViewClose(MSIQUERY *query)
|
|
|
|
{
|
|
|
|
MSIVIEW *view;
|
|
|
|
|
|
|
|
TRACE("%p\n", query );
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
view = query->view;
|
|
|
|
if( !view )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
if( !view->ops->close )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
return view->ops->close( view );
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
UINT WINAPI MsiViewClose(MSIHANDLE hView)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
|
|
|
MSIQUERY *query;
|
2004-07-10 00:25:34 +02:00
|
|
|
UINT ret;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d\n", hView );
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
|
2018-04-20 06:44:13 +02:00
|
|
|
if (!query)
|
|
|
|
{
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote(hView)))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_ViewClose(remote);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
|
|
|
return ret;
|
2018-04-20 06:44:13 +02:00
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
ret = MSI_ViewClose( query );
|
|
|
|
msiobj_release( &query->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_ViewExecute(MSIQUERY *query, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
MSIVIEW *view;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", query, rec);
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
view = query->view;
|
|
|
|
if( !view )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
if( !view->ops->execute )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
query->row = 0;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
return view->ops->execute( view, rec );
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
|
|
|
|
{
|
|
|
|
MSIQUERY *query;
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
UINT ret;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %d\n", hView, hRec);
|
2004-07-10 00:25:34 +02:00
|
|
|
|
|
|
|
if( hRec )
|
|
|
|
{
|
|
|
|
rec = msihandle2msiinfo( hRec, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !rec )
|
2018-04-19 01:40:05 +02:00
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
|
|
|
|
if( !query )
|
|
|
|
{
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote(hView)))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_ViewExecute(remote, rec ? (struct wire_record *)&rec->count : NULL);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
2018-04-19 01:40:05 +02:00
|
|
|
|
|
|
|
if (rec)
|
|
|
|
msiobj_release(&rec->hdr);
|
|
|
|
return ret;
|
2004-07-10 00:25:34 +02:00
|
|
|
}
|
|
|
|
|
2005-01-21 11:16:30 +01:00
|
|
|
msiobj_lock( &rec->hdr );
|
2004-07-10 00:25:34 +02:00
|
|
|
ret = MSI_ViewExecute( query, rec );
|
2005-01-21 11:16:30 +01:00
|
|
|
msiobj_unlock( &rec->hdr );
|
|
|
|
|
2005-03-10 12:15:40 +01:00
|
|
|
msiobj_release( &query->hdr );
|
2004-07-10 00:25:34 +02:00
|
|
|
if( rec )
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
|
|
|
|
return ret;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2009-03-02 06:41:39 +01:00
|
|
|
static UINT msi_set_record_type_string( MSIRECORD *rec, UINT field,
|
|
|
|
UINT type, BOOL temporary )
|
2005-09-28 13:59:40 +02:00
|
|
|
{
|
|
|
|
static const WCHAR fmt[] = { '%','d',0 };
|
|
|
|
WCHAR szType[0x10];
|
|
|
|
|
|
|
|
if (MSITYPE_IS_BINARY(type))
|
|
|
|
szType[0] = 'v';
|
|
|
|
else if (type & MSITYPE_LOCALIZABLE)
|
|
|
|
szType[0] = 'l';
|
2011-12-23 13:54:26 +01:00
|
|
|
else if (type & MSITYPE_UNKNOWN)
|
|
|
|
szType[0] = 'f';
|
2005-09-28 13:59:40 +02:00
|
|
|
else if (type & MSITYPE_STRING)
|
2009-03-02 06:41:39 +01:00
|
|
|
{
|
|
|
|
if (temporary)
|
|
|
|
szType[0] = 'g';
|
|
|
|
else
|
|
|
|
szType[0] = 's';
|
|
|
|
}
|
2005-09-28 13:59:40 +02:00
|
|
|
else
|
2009-03-02 06:41:39 +01:00
|
|
|
{
|
|
|
|
if (temporary)
|
|
|
|
szType[0] = 'j';
|
|
|
|
else
|
|
|
|
szType[0] = 'i';
|
|
|
|
}
|
|
|
|
|
2005-09-28 13:59:40 +02:00
|
|
|
if (type & MSITYPE_NULLABLE)
|
|
|
|
szType[0] &= ~0x20;
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
swprintf( &szType[1], ARRAY_SIZE(szType) - 1, fmt, (type&0xff) );
|
2005-09-28 13:59:40 +02:00
|
|
|
|
|
|
|
TRACE("type %04x -> %s\n", type, debugstr_w(szType) );
|
|
|
|
|
|
|
|
return MSI_RecordSetStringW( rec, field, szType );
|
|
|
|
}
|
|
|
|
|
2006-08-31 12:50:11 +02:00
|
|
|
UINT MSI_ViewGetColumnInfo( MSIQUERY *query, MSICOLINFO info, MSIRECORD **prec )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-02-08 14:44:25 +01:00
|
|
|
UINT r = ERROR_FUNCTION_FAILED, i, count = 0, type;
|
2006-08-31 12:50:11 +02:00
|
|
|
MSIRECORD *rec;
|
|
|
|
MSIVIEW *view = query->view;
|
2011-07-27 10:53:10 +02:00
|
|
|
LPCWSTR name;
|
2009-03-02 06:41:39 +01:00
|
|
|
BOOL temporary;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
if( !view )
|
2006-08-31 12:50:11 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
if( !view->ops->get_dimensions )
|
2006-08-31 12:50:11 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-02-08 14:44:25 +01:00
|
|
|
r = view->ops->get_dimensions( view, NULL, &count );
|
2006-08-31 12:50:11 +02:00
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
if( !count )
|
2006-08-31 12:50:11 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-02-08 14:44:25 +01:00
|
|
|
rec = MSI_CreateRecord( count );
|
|
|
|
if( !rec )
|
2006-08-31 12:50:11 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
for( i=0; i<count; i++ )
|
|
|
|
{
|
|
|
|
name = NULL;
|
2011-07-27 10:53:10 +02:00
|
|
|
r = view->ops->get_column_info( view, i+1, &name, &type, &temporary, NULL );
|
2005-02-08 14:44:25 +01:00
|
|
|
if( r != ERROR_SUCCESS )
|
2003-08-13 03:27:48 +02:00
|
|
|
continue;
|
2005-09-28 13:59:40 +02:00
|
|
|
if (info == MSICOLINFO_NAMES)
|
|
|
|
MSI_RecordSetStringW( rec, i+1, name );
|
|
|
|
else
|
2009-03-02 06:41:39 +01:00
|
|
|
msi_set_record_type_string( rec, i+1, type, temporary );
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
2006-08-31 12:50:11 +02:00
|
|
|
*prec = rec;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2006-08-31 12:50:11 +02:00
|
|
|
UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hRec)
|
|
|
|
{
|
|
|
|
MSIQUERY *query = NULL;
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
UINT r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %d %p\n", hView, info, hRec);
|
2006-08-31 12:50:11 +02:00
|
|
|
|
|
|
|
if( !hRec )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if( info != MSICOLINFO_NAMES && info != MSICOLINFO_TYPES )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
|
2018-04-20 06:44:14 +02:00
|
|
|
if (!query)
|
|
|
|
{
|
|
|
|
struct wire_record *wire_rec = NULL;
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote(hView)))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_ViewGetColumnInfo(remote, info, &wire_rec);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-04-20 06:44:14 +02:00
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
r = unmarshal_record(wire_rec, hRec);
|
|
|
|
free_remote_record(wire_rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2006-08-31 12:50:11 +02:00
|
|
|
|
|
|
|
r = MSI_ViewGetColumnInfo( query, info, &rec );
|
|
|
|
if ( r == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
*hRec = alloc_msihandle( &rec->hdr );
|
|
|
|
if ( !*hRec )
|
|
|
|
r = ERROR_NOT_ENOUGH_MEMORY;
|
2005-02-08 14:44:25 +01:00
|
|
|
msiobj_release( &rec->hdr );
|
2006-08-31 12:50:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
msiobj_release( &query->hdr );
|
2005-02-08 14:44:25 +01:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-04-21 13:55:24 +02:00
|
|
|
UINT MSI_ViewModify( MSIQUERY *query, MSIMODIFY mode, MSIRECORD *rec )
|
|
|
|
{
|
|
|
|
MSIVIEW *view = NULL;
|
2007-11-05 10:35:13 +01:00
|
|
|
UINT r;
|
2007-04-21 13:55:24 +02:00
|
|
|
|
|
|
|
if ( !query || !rec )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
view = query->view;
|
|
|
|
if ( !view || !view->ops->modify)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2018-10-12 16:44:03 +02:00
|
|
|
if ( mode == MSIMODIFY_UPDATE && rec->cookie != (UINT64)(ULONG_PTR)query )
|
2009-02-26 04:44:46 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2019-01-24 07:07:33 +01:00
|
|
|
r = view->ops->modify( view, mode, rec, query->row - 1 );
|
2007-11-05 10:35:13 +01:00
|
|
|
if (mode == MSIMODIFY_DELETE && r == ERROR_SUCCESS)
|
|
|
|
query->row--;
|
|
|
|
|
|
|
|
return r;
|
2007-04-21 13:55:24 +02:00
|
|
|
}
|
|
|
|
|
2005-02-08 14:44:25 +01:00
|
|
|
UINT WINAPI MsiViewModify( MSIHANDLE hView, MSIMODIFY eModifyMode,
|
|
|
|
MSIHANDLE hRecord)
|
|
|
|
{
|
|
|
|
MSIQUERY *query = NULL;
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %x %d\n", hView, eModifyMode, hRecord);
|
2005-02-08 14:44:25 +01:00
|
|
|
|
2018-04-20 06:44:15 +02:00
|
|
|
rec = msihandle2msiinfo( hRecord, MSIHANDLETYPE_RECORD );
|
|
|
|
|
|
|
|
if (!rec)
|
2005-02-08 14:44:25 +01:00
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-04-20 06:44:15 +02:00
|
|
|
query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
|
|
|
|
if (!query)
|
|
|
|
{
|
|
|
|
struct wire_record *wire_refreshed = NULL;
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote(hView)))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_ViewModify(remote, eModifyMode,
|
|
|
|
(struct wire_record *)&rec->count, &wire_refreshed);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-04-20 06:44:15 +02:00
|
|
|
if (!r && (eModifyMode == MSIMODIFY_REFRESH || eModifyMode == MSIMODIFY_SEEK))
|
|
|
|
{
|
|
|
|
r = copy_remote_record(wire_refreshed, hRecord);
|
|
|
|
free_remote_record(wire_refreshed);
|
|
|
|
}
|
|
|
|
|
|
|
|
msiobj_release(&rec->hdr);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-04-21 13:55:24 +02:00
|
|
|
r = MSI_ViewModify( query, eModifyMode, rec );
|
2005-02-08 14:44:25 +01:00
|
|
|
|
2005-03-10 12:15:40 +01:00
|
|
|
msiobj_release( &query->hdr );
|
2018-04-20 06:44:15 +02:00
|
|
|
msiobj_release(&rec->hdr);
|
2005-02-08 14:44:25 +01:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2011-06-07 10:34:49 +02:00
|
|
|
MSIDBERROR WINAPI MsiViewGetErrorW( MSIHANDLE handle, LPWSTR buffer, LPDWORD buflen )
|
2005-06-10 21:52:13 +02:00
|
|
|
{
|
2011-06-07 10:34:49 +02:00
|
|
|
MSIQUERY *query;
|
|
|
|
const WCHAR *column;
|
|
|
|
MSIDBERROR r;
|
2005-06-10 21:52:13 +02:00
|
|
|
|
2011-06-07 10:34:49 +02:00
|
|
|
TRACE("%u %p %p\n", handle, buffer, buflen);
|
2005-06-10 21:52:13 +02:00
|
|
|
|
2011-06-07 10:34:49 +02:00
|
|
|
if (!buflen)
|
2005-06-10 21:52:13 +02:00
|
|
|
return MSIDBERROR_INVALIDARG;
|
|
|
|
|
2019-03-27 00:56:17 +01:00
|
|
|
if (!(query = msihandle2msiinfo(handle, MSIHANDLETYPE_VIEW)))
|
|
|
|
{
|
|
|
|
WCHAR *remote_column = NULL;
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote(handle)))
|
|
|
|
return MSIDBERROR_INVALIDARG;
|
|
|
|
|
|
|
|
if (!*buflen)
|
|
|
|
return MSIDBERROR_FUNCTIONERROR;
|
|
|
|
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_ViewGetError(remote, &remote_column);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY;
|
|
|
|
|
|
|
|
if (msi_strncpyW(remote_column ? remote_column : szEmpty, -1, buffer, buflen) == ERROR_MORE_DATA)
|
|
|
|
r = MSIDBERROR_MOREDATA;
|
|
|
|
|
|
|
|
if (remote_column)
|
|
|
|
midl_user_free(remote_column);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2005-06-10 21:52:13 +02:00
|
|
|
|
2011-06-07 10:34:49 +02:00
|
|
|
if ((r = query->view->error)) column = query->view->error_column;
|
|
|
|
else column = szEmpty;
|
|
|
|
|
2019-03-27 00:56:16 +01:00
|
|
|
if (msi_strncpyW(column, -1, buffer, buflen) == ERROR_MORE_DATA)
|
|
|
|
r = MSIDBERROR_MOREDATA;
|
|
|
|
|
2005-06-10 21:52:13 +02:00
|
|
|
msiobj_release( &query->hdr );
|
2005-08-24 12:57:49 +02:00
|
|
|
return r;
|
2005-06-10 21:52:13 +02:00
|
|
|
}
|
|
|
|
|
2011-06-07 10:34:49 +02:00
|
|
|
MSIDBERROR WINAPI MsiViewGetErrorA( MSIHANDLE handle, LPSTR buffer, LPDWORD buflen )
|
2005-06-10 21:52:13 +02:00
|
|
|
{
|
2011-06-07 10:34:49 +02:00
|
|
|
MSIQUERY *query;
|
|
|
|
const WCHAR *column;
|
|
|
|
MSIDBERROR r;
|
2005-06-10 21:52:13 +02:00
|
|
|
|
2011-06-07 10:34:49 +02:00
|
|
|
TRACE("%u %p %p\n", handle, buffer, buflen);
|
2005-06-10 21:52:13 +02:00
|
|
|
|
2011-06-07 10:34:49 +02:00
|
|
|
if (!buflen)
|
2005-06-10 21:52:13 +02:00
|
|
|
return MSIDBERROR_INVALIDARG;
|
|
|
|
|
2019-03-27 00:56:17 +01:00
|
|
|
if (!(query = msihandle2msiinfo(handle, MSIHANDLETYPE_VIEW)))
|
|
|
|
{
|
|
|
|
WCHAR *remote_column = NULL;
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote(handle)))
|
|
|
|
return MSIDBERROR_INVALIDARG;
|
|
|
|
|
|
|
|
if (!*buflen)
|
|
|
|
return MSIDBERROR_FUNCTIONERROR;
|
|
|
|
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_ViewGetError(remote, &remote_column);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY;
|
|
|
|
|
|
|
|
if (msi_strncpyWtoA(remote_column ? remote_column : szEmpty, -1, buffer, buflen, FALSE) == ERROR_MORE_DATA)
|
|
|
|
r = MSIDBERROR_MOREDATA;
|
|
|
|
|
|
|
|
if (remote_column)
|
|
|
|
midl_user_free(remote_column);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2005-06-10 21:52:13 +02:00
|
|
|
|
2011-06-07 10:34:49 +02:00
|
|
|
if ((r = query->view->error)) column = query->view->error_column;
|
|
|
|
else column = szEmpty;
|
|
|
|
|
2019-03-27 00:56:16 +01:00
|
|
|
if (msi_strncpyWtoA(column, -1, buffer, buflen, FALSE) == ERROR_MORE_DATA)
|
|
|
|
r = MSIDBERROR_MOREDATA;
|
|
|
|
|
2005-06-10 21:52:13 +02:00
|
|
|
msiobj_release( &query->hdr );
|
2005-08-24 12:57:49 +02:00
|
|
|
return r;
|
2005-06-10 21:52:13 +02:00
|
|
|
}
|
|
|
|
|
2006-01-04 14:51:05 +01:00
|
|
|
MSIHANDLE WINAPI MsiGetLastErrorRecord( void )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db, const WCHAR *transform, int error_cond )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2018-11-09 14:50:34 +01:00
|
|
|
HRESULT hr;
|
2006-10-11 09:27:15 +02:00
|
|
|
UINT ret = ERROR_FUNCTION_FAILED;
|
2018-11-09 14:50:34 +01:00
|
|
|
IStorage *stg;
|
2006-10-11 09:27:15 +02:00
|
|
|
STATSTG stat;
|
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
TRACE( "%p %s %08x\n", db, debugstr_w(transform), error_cond );
|
2005-09-26 11:55:38 +02:00
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
if (*transform == ':')
|
2010-07-23 09:43:11 +02:00
|
|
|
{
|
2018-11-09 14:50:34 +01:00
|
|
|
hr = IStorage_OpenStorage( db->storage, transform + 1, NULL, STGM_SHARE_EXCLUSIVE, NULL, 0, &stg );
|
|
|
|
if (FAILED( hr ))
|
|
|
|
{
|
|
|
|
WARN( "failed to open substorage transform 0x%08x\n", hr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = StgOpenStorage( transform, NULL, STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg );
|
|
|
|
if (FAILED( hr ))
|
|
|
|
{
|
|
|
|
WARN( "failed to open file transform 0x%08x\n", hr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
2010-07-23 09:43:11 +02:00
|
|
|
}
|
2006-10-11 09:27:15 +02:00
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
hr = IStorage_Stat( stg, &stat, STATFLAG_NONAME );
|
|
|
|
if (FAILED( hr )) goto end;
|
|
|
|
if (!IsEqualGUID( &stat.clsid, &CLSID_MsiTransform )) goto end;
|
|
|
|
if (TRACE_ON( msi )) enum_stream_names( stg );
|
2005-09-26 11:55:38 +02:00
|
|
|
|
2020-06-25 20:08:43 +02:00
|
|
|
ret = msi_table_apply_transform( db, stg, error_cond );
|
2005-09-26 11:55:38 +02:00
|
|
|
|
2006-10-11 09:27:15 +02:00
|
|
|
end:
|
2005-09-26 11:55:38 +02:00
|
|
|
IStorage_Release( stg );
|
2006-10-11 09:27:15 +02:00
|
|
|
return ret;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
UINT WINAPI MsiDatabaseApplyTransformW( MSIHANDLE hdb, const WCHAR *transform, int error_cond )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-09-26 11:55:38 +02:00
|
|
|
MSIDATABASE *db;
|
|
|
|
UINT r;
|
|
|
|
|
2020-06-25 20:08:43 +02:00
|
|
|
if (error_cond & ~MSITRANSFORM_ERROR_VIEWTRANSFORM) FIXME( "ignoring error conditions\n" );
|
2018-11-09 14:50:34 +01:00
|
|
|
|
2019-03-26 04:42:02 +01:00
|
|
|
if (!(db = msihandle2msiinfo(hdb, MSIHANDLETYPE_DATABASE)))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
2005-09-26 11:55:38 +02:00
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
r = MSI_DatabaseApplyTransformW( db, transform, error_cond );
|
2005-09-26 11:55:38 +02:00
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
UINT WINAPI MsiDatabaseApplyTransformA( MSIHANDLE hdb, const char *transform, int error_cond )
|
2005-09-26 11:55:38 +02:00
|
|
|
{
|
2018-11-09 14:50:34 +01:00
|
|
|
WCHAR *wstr;
|
2005-09-26 11:55:38 +02:00
|
|
|
UINT ret;
|
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
TRACE( "%d %s %08x\n", hdb, debugstr_a(transform), error_cond );
|
2005-09-26 11:55:38 +02:00
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
wstr = strdupAtoW( transform );
|
|
|
|
if (transform && !wstr)
|
2005-09-26 11:55:38 +02:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
2018-11-09 14:50:34 +01:00
|
|
|
ret = MsiDatabaseApplyTransformW( hdb, wstr, error_cond );
|
2005-09-26 11:55:38 +02:00
|
|
|
msi_free( wstr );
|
|
|
|
return ret;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiDatabaseGenerateTransformA( MSIHANDLE hdb, MSIHANDLE hdbref,
|
|
|
|
LPCSTR szTransformFile, int iReserved1, int iReserved2 )
|
|
|
|
{
|
2009-01-04 14:14:15 +01:00
|
|
|
FIXME("%d %d %s %d %d\n", hdb, hdbref,
|
2003-08-13 03:27:48 +02:00
|
|
|
debugstr_a(szTransformFile), iReserved1, iReserved2);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiDatabaseGenerateTransformW( MSIHANDLE hdb, MSIHANDLE hdbref,
|
|
|
|
LPCWSTR szTransformFile, int iReserved1, int iReserved2 )
|
|
|
|
{
|
2009-01-04 14:14:15 +01:00
|
|
|
FIXME("%d %d %s %d %d\n", hdb, hdbref,
|
2003-08-13 03:27:48 +02:00
|
|
|
debugstr_w(szTransformFile), iReserved1, iReserved2);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiDatabaseCommit( MSIHANDLE hdb )
|
|
|
|
{
|
2004-03-18 05:04:08 +01:00
|
|
|
MSIDATABASE *db;
|
|
|
|
UINT r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d\n", hdb);
|
2004-03-18 05:04:08 +01:00
|
|
|
|
|
|
|
db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
|
|
|
|
if( !db )
|
2007-11-12 01:13:08 +01:00
|
|
|
{
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2007-11-12 01:13:08 +01:00
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
if (!(remote = msi_get_remote(hdb)))
|
2007-11-12 01:13:08 +01:00
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2010-02-04 00:20:37 +01:00
|
|
|
WARN("not allowed during a custom action!\n");
|
2007-11-12 01:13:08 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2004-03-18 05:04:08 +01:00
|
|
|
|
2019-11-04 22:05:42 +01:00
|
|
|
if (db->mode == MSI_OPEN_READONLY)
|
2011-07-27 22:04:26 +02:00
|
|
|
{
|
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-03-18 05:04:08 +01:00
|
|
|
/* FIXME: lock the database */
|
|
|
|
|
2015-02-13 13:39:38 +01:00
|
|
|
r = msi_commit_streams( db );
|
|
|
|
if (r != ERROR_SUCCESS) ERR("Failed to commit streams!\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = MSI_CommitTables( db );
|
|
|
|
if (r != ERROR_SUCCESS) ERR("Failed to commit tables!\n");
|
|
|
|
}
|
2004-03-18 05:04:08 +01:00
|
|
|
|
|
|
|
/* FIXME: unlock the database */
|
|
|
|
|
2005-01-20 21:34:29 +01:00
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
|
2006-09-12 17:47:10 +02:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msi_free( db->deletefile );
|
|
|
|
db->deletefile = NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-18 05:04:08 +01:00
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-02-16 17:05:11 +01:00
|
|
|
struct msi_primary_key_record_info
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-02-16 17:05:11 +01:00
|
|
|
DWORD n;
|
|
|
|
MSIRECORD *rec;
|
|
|
|
};
|
|
|
|
|
|
|
|
static UINT msi_primary_key_iterator( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
struct msi_primary_key_record_info *info = param;
|
2009-02-26 04:44:09 +01:00
|
|
|
LPCWSTR name, table;
|
2005-02-16 17:05:11 +01:00
|
|
|
DWORD type;
|
|
|
|
|
|
|
|
type = MSI_RecordGetInteger( rec, 4 );
|
|
|
|
if( type & MSITYPE_KEY )
|
|
|
|
{
|
|
|
|
info->n++;
|
|
|
|
if( info->rec )
|
|
|
|
{
|
2009-02-26 04:44:09 +01:00
|
|
|
if ( info->n == 1 )
|
|
|
|
{
|
|
|
|
table = MSI_RecordGetString( rec, 1 );
|
|
|
|
MSI_RecordSetStringW( info->rec, 0, table);
|
|
|
|
}
|
|
|
|
|
2005-02-16 17:05:11 +01:00
|
|
|
name = MSI_RecordGetString( rec, 3 );
|
|
|
|
MSI_RecordSetStringW( info->rec, info->n, name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-02-16 17:05:11 +01:00
|
|
|
UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *db,
|
|
|
|
LPCWSTR table, MSIRECORD **prec )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-02-16 17:05:11 +01:00
|
|
|
static const WCHAR sql[] = {
|
|
|
|
's','e','l','e','c','t',' ','*',' ',
|
|
|
|
'f','r','o','m',' ','`','_','C','o','l','u','m','n','s','`',' ',
|
|
|
|
'w','h','e','r','e',' ',
|
|
|
|
'`','T','a','b','l','e','`',' ','=',' ','\'','%','s','\'',0 };
|
|
|
|
struct msi_primary_key_record_info info;
|
|
|
|
MSIQUERY *query = NULL;
|
|
|
|
UINT r;
|
2008-04-21 23:23:21 +02:00
|
|
|
|
2010-09-02 13:20:36 +02:00
|
|
|
if (!TABLE_Exists( db, table ))
|
|
|
|
return ERROR_INVALID_TABLE;
|
|
|
|
|
2005-02-16 17:05:11 +01:00
|
|
|
r = MSI_OpenQuery( db, &query, sql, table );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
|
|
|
|
/* count the number of primary key records */
|
|
|
|
info.n = 0;
|
|
|
|
info.rec = 0;
|
|
|
|
r = MSI_IterateRecords( query, 0, msi_primary_key_iterator, &info );
|
|
|
|
if( r == ERROR_SUCCESS )
|
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("Found %d primary keys\n", info.n );
|
2005-02-16 17:05:11 +01:00
|
|
|
|
|
|
|
/* allocate a record and fill in the names of the tables */
|
|
|
|
info.rec = MSI_CreateRecord( info.n );
|
|
|
|
info.n = 0;
|
|
|
|
r = MSI_IterateRecords( query, 0, msi_primary_key_iterator, &info );
|
|
|
|
if( r == ERROR_SUCCESS )
|
|
|
|
*prec = info.rec;
|
|
|
|
else
|
|
|
|
msiobj_release( &info.rec->hdr );
|
|
|
|
}
|
|
|
|
msiobj_release( &query->hdr );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiDatabaseGetPrimaryKeysW( MSIHANDLE hdb,
|
|
|
|
LPCWSTR table, MSIHANDLE* phRec )
|
|
|
|
{
|
|
|
|
MSIRECORD *rec = NULL;
|
|
|
|
MSIDATABASE *db;
|
|
|
|
UINT r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s %p\n", hdb, debugstr_w(table), phRec);
|
2005-02-16 17:05:11 +01:00
|
|
|
|
|
|
|
db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
|
|
|
|
if( !db )
|
2007-11-12 01:13:08 +01:00
|
|
|
{
|
2018-04-20 06:44:17 +02:00
|
|
|
struct wire_record *wire_rec = NULL;
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2007-11-12 01:13:08 +01:00
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
if (!(remote = msi_get_remote(hdb)))
|
2007-11-12 01:13:08 +01:00
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_DatabaseGetPrimaryKeys(remote, table, &wire_rec);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-04-20 06:44:17 +02:00
|
|
|
if (!r)
|
2007-11-12 01:13:08 +01:00
|
|
|
{
|
2018-04-20 06:44:17 +02:00
|
|
|
r = unmarshal_record(wire_rec, phRec);
|
|
|
|
free_remote_record(wire_rec);
|
2007-11-12 01:13:08 +01:00
|
|
|
}
|
|
|
|
|
2018-04-20 06:44:17 +02:00
|
|
|
return r;
|
2007-11-12 01:13:08 +01:00
|
|
|
}
|
2005-02-16 17:05:11 +01:00
|
|
|
|
|
|
|
r = MSI_DatabaseGetPrimaryKeys( db, table, &rec );
|
|
|
|
if( r == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
*phRec = alloc_msihandle( &rec->hdr );
|
2006-08-28 18:44:35 +02:00
|
|
|
if (! *phRec)
|
|
|
|
r = ERROR_NOT_ENOUGH_MEMORY;
|
2005-02-16 17:05:11 +01:00
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
}
|
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiDatabaseGetPrimaryKeysA(MSIHANDLE hdb,
|
|
|
|
LPCSTR table, MSIHANDLE* phRec)
|
|
|
|
{
|
|
|
|
LPWSTR szwTable = NULL;
|
|
|
|
UINT r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s %p\n", hdb, debugstr_a(table), phRec);
|
2005-02-16 17:05:11 +01:00
|
|
|
|
|
|
|
if( table )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwTable = strdupAtoW( table );
|
|
|
|
if( !szwTable )
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2005-02-16 17:05:11 +01:00
|
|
|
}
|
|
|
|
r = MsiDatabaseGetPrimaryKeysW( hdb, szwTable, phRec );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( szwTable );
|
2005-02-16 17:05:11 +01:00
|
|
|
|
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
2003-10-30 23:47:42 +01:00
|
|
|
|
2006-01-10 12:09:11 +01:00
|
|
|
MSICONDITION WINAPI MsiDatabaseIsTablePersistentA(
|
2006-09-08 11:01:54 +02:00
|
|
|
MSIHANDLE hDatabase, LPCSTR szTableName)
|
2005-01-21 11:16:30 +01:00
|
|
|
{
|
2006-01-10 12:09:11 +01:00
|
|
|
LPWSTR szwTableName = NULL;
|
|
|
|
MSICONDITION r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%x %s\n", hDatabase, debugstr_a(szTableName));
|
2006-01-10 12:09:11 +01:00
|
|
|
|
|
|
|
if( szTableName )
|
|
|
|
{
|
|
|
|
szwTableName = strdupAtoW( szTableName );
|
|
|
|
if( !szwTableName )
|
|
|
|
return MSICONDITION_ERROR;
|
|
|
|
}
|
|
|
|
r = MsiDatabaseIsTablePersistentW( hDatabase, szwTableName );
|
|
|
|
msi_free( szwTableName );
|
|
|
|
|
|
|
|
return r;
|
2005-01-21 11:16:30 +01:00
|
|
|
}
|
|
|
|
|
2006-01-10 12:09:11 +01:00
|
|
|
MSICONDITION WINAPI MsiDatabaseIsTablePersistentW(
|
2006-09-08 11:01:54 +02:00
|
|
|
MSIHANDLE hDatabase, LPCWSTR szTableName)
|
2005-01-21 11:16:30 +01:00
|
|
|
{
|
2006-09-13 11:46:13 +02:00
|
|
|
MSIDATABASE *db;
|
|
|
|
MSICONDITION r;
|
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%x %s\n", hDatabase, debugstr_w(szTableName));
|
2006-09-13 11:46:13 +02:00
|
|
|
|
|
|
|
db = msihandle2msiinfo( hDatabase, MSIHANDLETYPE_DATABASE );
|
|
|
|
if( !db )
|
2007-11-12 01:13:08 +01:00
|
|
|
{
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2007-11-12 01:13:08 +01:00
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
if (!(remote = msi_get_remote(hDatabase)))
|
2007-11-12 01:13:08 +01:00
|
|
|
return MSICONDITION_ERROR;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_DatabaseIsTablePersistent(remote, szTableName);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = MSICONDITION_ERROR;
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
|
|
|
return r;
|
2007-11-12 01:13:08 +01:00
|
|
|
}
|
2006-09-13 11:46:13 +02:00
|
|
|
|
|
|
|
r = MSI_DatabaseIsTablePersistent( db, szTableName );
|
|
|
|
|
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
|
|
|
|
return r;
|
2005-01-21 11:16:30 +01:00
|
|
|
}
|
2018-04-19 01:40:05 +02:00
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_ViewClose(MSIHANDLE view)
|
2018-04-20 06:44:13 +02:00
|
|
|
{
|
|
|
|
return MsiViewClose(view);
|
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_ViewExecute(MSIHANDLE view, struct wire_record *remote_rec)
|
2018-04-19 01:40:05 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE rec = 0;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if ((r = unmarshal_record(remote_rec, &rec)))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MsiViewExecute(view, rec);
|
|
|
|
|
|
|
|
MsiCloseHandle(rec);
|
|
|
|
return r;
|
|
|
|
}
|
2018-04-19 01:40:06 +02:00
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_ViewFetch(MSIHANDLE view, struct wire_record **rec)
|
2018-04-19 01:40:06 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE handle;
|
|
|
|
UINT r = MsiViewFetch(view, &handle);
|
|
|
|
*rec = NULL;
|
|
|
|
if (!r)
|
|
|
|
*rec = marshal_record(handle);
|
|
|
|
MsiCloseHandle(handle);
|
|
|
|
return r;
|
|
|
|
}
|
2018-04-20 06:44:14 +02:00
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_ViewGetColumnInfo(MSIHANDLE view, MSICOLINFO info, struct wire_record **rec)
|
2018-04-20 06:44:14 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE handle;
|
|
|
|
UINT r = MsiViewGetColumnInfo(view, info, &handle);
|
|
|
|
*rec = NULL;
|
|
|
|
if (!r)
|
|
|
|
*rec = marshal_record(handle);
|
|
|
|
MsiCloseHandle(handle);
|
|
|
|
return r;
|
|
|
|
}
|
2018-04-20 06:44:15 +02:00
|
|
|
|
2019-03-27 00:56:17 +01:00
|
|
|
MSIDBERROR __cdecl s_remote_ViewGetError(MSIHANDLE view, LPWSTR *column)
|
|
|
|
{
|
|
|
|
WCHAR empty[1];
|
|
|
|
DWORD size = 1;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = MsiViewGetErrorW(view, empty, &size);
|
|
|
|
if (r == MSIDBERROR_MOREDATA)
|
|
|
|
{
|
|
|
|
if (!(*column = midl_user_allocate(++size * sizeof(WCHAR))))
|
|
|
|
return MSIDBERROR_FUNCTIONERROR;
|
|
|
|
r = MsiViewGetErrorW(view, *column, &size);
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_ViewModify(MSIHANDLE view, MSIMODIFY mode,
|
2018-04-20 06:44:15 +02:00
|
|
|
struct wire_record *remote_rec, struct wire_record **remote_refreshed)
|
|
|
|
{
|
|
|
|
MSIHANDLE handle = 0;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if ((r = unmarshal_record(remote_rec, &handle)))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MsiViewModify(view, mode, handle);
|
|
|
|
*remote_refreshed = NULL;
|
|
|
|
if (!r && (mode == MSIMODIFY_REFRESH || mode == MSIMODIFY_SEEK))
|
|
|
|
*remote_refreshed = marshal_record(handle);
|
|
|
|
|
|
|
|
MsiCloseHandle(handle);
|
|
|
|
return r;
|
|
|
|
}
|