2003-08-13 03:27:48 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
2005-03-18 15:01:39 +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
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2019-03-15 10:03:57 +01:00
|
|
|
#include "stdio.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
2003-09-27 04:24:31 +02:00
|
|
|
#include "winnls.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "wine/debug.h"
|
2018-09-08 03:17:22 +02:00
|
|
|
#include "wine/exception.h"
|
2009-04-13 12:24:46 +02:00
|
|
|
#include "wine/unicode.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "msi.h"
|
|
|
|
#include "msiquery.h"
|
2005-03-18 15:01:39 +01:00
|
|
|
#include "msidefs.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "objidl.h"
|
2008-02-27 09:39:21 +01:00
|
|
|
#include "propvarutil.h"
|
2018-04-16 03:52:10 +02:00
|
|
|
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winemsi.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
#include "pshpack1.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD wByteOrder;
|
|
|
|
WORD wFormat;
|
|
|
|
DWORD dwOSVer;
|
|
|
|
CLSID clsID;
|
|
|
|
DWORD reserved;
|
|
|
|
} PROPERTYSETHEADER;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
FMTID fmtid;
|
|
|
|
DWORD dwOffset;
|
|
|
|
} FORMATIDOFFSET;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DWORD cbSection;
|
|
|
|
DWORD cProperties;
|
|
|
|
} PROPERTYSECTIONHEADER;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DWORD propid;
|
|
|
|
DWORD dwOffset;
|
|
|
|
} PROPERTYIDOFFSET;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DWORD type;
|
|
|
|
union {
|
|
|
|
INT i4;
|
|
|
|
SHORT i2;
|
|
|
|
FILETIME ft;
|
|
|
|
struct {
|
|
|
|
DWORD len;
|
|
|
|
BYTE str[1];
|
|
|
|
} str;
|
|
|
|
} u;
|
|
|
|
} PROPERTY_DATA;
|
|
|
|
|
|
|
|
#include "poppack.h"
|
|
|
|
|
2008-02-27 09:39:21 +01:00
|
|
|
static HRESULT (WINAPI *pPropVariantChangeType)
|
|
|
|
(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
|
|
|
|
PROPVAR_CHANGE_FLAGS flags, VARTYPE vt);
|
|
|
|
|
2005-04-20 16:24:14 +02:00
|
|
|
#define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER))
|
|
|
|
|
2005-03-19 18:08:34 +01:00
|
|
|
static void free_prop( PROPVARIANT *prop )
|
|
|
|
{
|
|
|
|
if (prop->vt == VT_LPSTR )
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( prop->u.pszVal );
|
2005-03-19 18:08:34 +01:00
|
|
|
prop->vt = VT_EMPTY;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static void MSI_CloseSummaryInfo( MSIOBJECTHDR *arg )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-03-18 15:01:39 +01:00
|
|
|
MSISUMMARYINFO *si = (MSISUMMARYINFO *) arg;
|
2005-03-19 18:08:34 +01:00
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for( i = 0; i < MSI_MAX_PROPS; i++ )
|
|
|
|
free_prop( &si->property[i] );
|
2006-10-23 18:11:30 +02:00
|
|
|
IStorage_Release( si->storage );
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
static UINT get_type( UINT uiProperty )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-03-18 15:01:39 +01:00
|
|
|
switch( uiProperty )
|
|
|
|
{
|
|
|
|
case PID_CODEPAGE:
|
|
|
|
return VT_I2;
|
2006-10-23 18:11:30 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
case PID_SUBJECT:
|
|
|
|
case PID_AUTHOR:
|
|
|
|
case PID_KEYWORDS:
|
|
|
|
case PID_COMMENTS:
|
|
|
|
case PID_TEMPLATE:
|
|
|
|
case PID_LASTAUTHOR:
|
|
|
|
case PID_REVNUMBER:
|
|
|
|
case PID_APPNAME:
|
|
|
|
case PID_TITLE:
|
|
|
|
return VT_LPSTR;
|
|
|
|
|
|
|
|
case PID_LASTPRINTED:
|
|
|
|
case PID_CREATE_DTM:
|
|
|
|
case PID_LASTSAVE_DTM:
|
|
|
|
return VT_FILETIME;
|
|
|
|
|
|
|
|
case PID_WORDCOUNT:
|
|
|
|
case PID_CHARCOUNT:
|
|
|
|
case PID_SECURITY:
|
|
|
|
case PID_PAGECOUNT:
|
|
|
|
return VT_I4;
|
|
|
|
}
|
|
|
|
return VT_EMPTY;
|
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2007-06-12 22:51:36 +02:00
|
|
|
static UINT get_property_count( const PROPVARIANT *property )
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
|
|
|
UINT i, n = 0;
|
|
|
|
|
|
|
|
if( !property )
|
|
|
|
return n;
|
2005-03-19 18:08:34 +01:00
|
|
|
for( i = 0; i < MSI_MAX_PROPS; i++ )
|
2005-03-18 15:01:39 +01:00
|
|
|
if( property[i].vt != VT_EMPTY )
|
|
|
|
n++;
|
|
|
|
return n;
|
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2008-02-27 09:39:21 +01:00
|
|
|
static UINT propvar_changetype(PROPVARIANT *changed, PROPVARIANT *property, VARTYPE vt)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HMODULE propsys = LoadLibraryA("propsys.dll");
|
|
|
|
pPropVariantChangeType = (void *)GetProcAddress(propsys, "PropVariantChangeType");
|
|
|
|
|
|
|
|
if (!pPropVariantChangeType)
|
|
|
|
{
|
|
|
|
ERR("PropVariantChangeType function missing!\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pPropVariantChangeType(changed, property, 0, vt);
|
|
|
|
return (hr == S_OK) ? ERROR_SUCCESS : ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
/* FIXME: doesn't deal with endian conversion */
|
2005-04-20 16:24:14 +02:00
|
|
|
static void read_properties_from_data( PROPVARIANT *prop, LPBYTE data, DWORD sz )
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
|
|
|
UINT type;
|
2008-10-20 23:06:20 +02:00
|
|
|
DWORD i, size;
|
2005-03-18 15:01:39 +01:00
|
|
|
PROPERTY_DATA *propdata;
|
2008-02-27 09:39:21 +01:00
|
|
|
PROPVARIANT property, *ptr;
|
|
|
|
PROPVARIANT changed;
|
2005-04-20 16:24:14 +02:00
|
|
|
PROPERTYIDOFFSET *idofs;
|
|
|
|
PROPERTYSECTIONHEADER *section_hdr;
|
|
|
|
|
|
|
|
section_hdr = (PROPERTYSECTIONHEADER*) &data[0];
|
|
|
|
idofs = (PROPERTYIDOFFSET*) &data[SECT_HDR_SIZE];
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
/* now set all the properties */
|
2005-04-20 16:24:14 +02:00
|
|
|
for( i = 0; i < section_hdr->cProperties; i++ )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2008-02-27 09:39:21 +01:00
|
|
|
if( idofs[i].propid >= MSI_MAX_PROPS )
|
|
|
|
{
|
|
|
|
ERR("Unknown property ID %d\n", idofs[i].propid );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
type = get_type( idofs[i].propid );
|
|
|
|
if( type == VT_EMPTY )
|
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
ERR("propid %d has unknown type\n", idofs[i].propid);
|
2005-03-18 15:01:39 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-04-20 16:24:14 +02:00
|
|
|
propdata = (PROPERTY_DATA*) &data[ idofs[i].dwOffset ];
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
/* check we don't run off the end of the data */
|
|
|
|
size = sz - idofs[i].dwOffset - sizeof(DWORD);
|
|
|
|
if( sizeof(DWORD) > size ||
|
2008-02-27 09:39:21 +01:00
|
|
|
( propdata->type == VT_FILETIME && sizeof(FILETIME) > size ) ||
|
|
|
|
( propdata->type == VT_LPSTR && (propdata->u.str.len + sizeof(DWORD)) > size ) )
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
|
|
|
ERR("not enough data\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-27 09:39:21 +01:00
|
|
|
property.vt = propdata->type;
|
|
|
|
if( propdata->type == VT_LPSTR )
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
2005-09-20 13:57:19 +02:00
|
|
|
LPSTR str = msi_alloc( propdata->u.str.len );
|
2005-03-18 15:01:39 +01:00
|
|
|
memcpy( str, propdata->u.str.str, propdata->u.str.len );
|
|
|
|
str[ propdata->u.str.len - 1 ] = 0;
|
2008-02-27 09:39:21 +01:00
|
|
|
property.u.pszVal = str;
|
|
|
|
}
|
|
|
|
else if( propdata->type == VT_FILETIME )
|
|
|
|
property.u.filetime = propdata->u.ft;
|
|
|
|
else if( propdata->type == VT_I2 )
|
|
|
|
property.u.iVal = propdata->u.i2;
|
|
|
|
else if( propdata->type == VT_I4 )
|
|
|
|
property.u.lVal = propdata->u.i4;
|
|
|
|
|
|
|
|
/* check the type is the same as we expect */
|
|
|
|
if( type != propdata->type )
|
|
|
|
{
|
|
|
|
propvar_changetype(&changed, &property, type);
|
|
|
|
ptr = &changed;
|
2005-03-18 15:01:39 +01:00
|
|
|
}
|
2008-02-27 09:39:21 +01:00
|
|
|
else
|
|
|
|
ptr = &property;
|
|
|
|
|
2008-03-06 23:33:47 +01:00
|
|
|
prop[ idofs[i].propid ] = *ptr;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
2005-03-18 15:01:39 +01:00
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
static UINT load_summary_info( MSISUMMARYINFO *si, IStream *stm )
|
|
|
|
{
|
|
|
|
PROPERTYSETHEADER set_hdr;
|
|
|
|
FORMATIDOFFSET format_hdr;
|
|
|
|
PROPERTYSECTIONHEADER section_hdr;
|
|
|
|
LPBYTE data = NULL;
|
|
|
|
LARGE_INTEGER ofs;
|
|
|
|
ULONG count, sz;
|
|
|
|
HRESULT r;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
TRACE("%p %p\n", si, stm);
|
|
|
|
|
|
|
|
/* read the header */
|
|
|
|
sz = sizeof set_hdr;
|
|
|
|
r = IStream_Read( stm, &set_hdr, sz, &count );
|
|
|
|
if( FAILED(r) || count != sz )
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
if( set_hdr.wByteOrder != 0xfffe )
|
|
|
|
{
|
|
|
|
ERR("property set not big-endian %04X\n", set_hdr.wByteOrder);
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sz = sizeof format_hdr;
|
|
|
|
r = IStream_Read( stm, &format_hdr, sz, &count );
|
|
|
|
if( FAILED(r) || count != sz )
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
/* check the format id is correct */
|
|
|
|
if( !IsEqualGUID( &FMTID_SummaryInformation, &format_hdr.fmtid ) )
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
/* seek to the location of the section */
|
|
|
|
ofs.QuadPart = format_hdr.dwOffset;
|
|
|
|
r = IStream_Seek( stm, ofs, STREAM_SEEK_SET, NULL );
|
|
|
|
if( FAILED(r) )
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
/* read the section itself */
|
2005-04-20 16:24:14 +02:00
|
|
|
sz = SECT_HDR_SIZE;
|
2005-03-18 15:01:39 +01:00
|
|
|
r = IStream_Read( stm, §ion_hdr, sz, &count );
|
|
|
|
if( FAILED(r) || count != sz )
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
if( section_hdr.cProperties > MSI_MAX_PROPS )
|
|
|
|
{
|
2006-10-05 06:41:22 +02:00
|
|
|
ERR("too many properties %d\n", section_hdr.cProperties);
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
}
|
|
|
|
|
2005-09-20 13:57:19 +02:00
|
|
|
data = msi_alloc( section_hdr.cbSection);
|
2005-04-20 16:24:14 +02:00
|
|
|
if( !data )
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
2005-04-20 16:24:14 +02:00
|
|
|
memcpy( data, §ion_hdr, SECT_HDR_SIZE );
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
/* read all the data in one go */
|
2005-04-20 16:24:14 +02:00
|
|
|
sz = section_hdr.cbSection - SECT_HDR_SIZE;
|
|
|
|
r = IStream_Read( stm, &data[ SECT_HDR_SIZE ], sz, &count );
|
2005-03-18 15:01:39 +01:00
|
|
|
if( SUCCEEDED(r) && count == sz )
|
2005-04-20 16:24:14 +02:00
|
|
|
read_properties_from_data( si->property, data, sz + SECT_HDR_SIZE );
|
|
|
|
else
|
2006-10-05 06:41:22 +02:00
|
|
|
ERR("failed to read properties %d %d\n", count, sz);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( data );
|
2015-03-16 10:55:58 +01:00
|
|
|
return ERROR_SUCCESS;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
static DWORD write_dword( LPBYTE data, DWORD ofs, DWORD val )
|
|
|
|
{
|
|
|
|
if( data )
|
|
|
|
{
|
|
|
|
data[ofs++] = val&0xff;
|
|
|
|
data[ofs++] = (val>>8)&0xff;
|
|
|
|
data[ofs++] = (val>>16)&0xff;
|
|
|
|
data[ofs++] = (val>>24)&0xff;
|
|
|
|
}
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
2007-06-12 22:51:36 +02:00
|
|
|
static DWORD write_filetime( LPBYTE data, DWORD ofs, const FILETIME *ft )
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
|
|
|
write_dword( data, ofs, ft->dwLowDateTime );
|
|
|
|
write_dword( data, ofs + 4, ft->dwHighDateTime );
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD write_string( LPBYTE data, DWORD ofs, LPCSTR str )
|
|
|
|
{
|
|
|
|
DWORD len = lstrlenA( str ) + 1;
|
|
|
|
write_dword( data, ofs, len );
|
|
|
|
if( data )
|
2005-07-06 12:33:30 +02:00
|
|
|
memcpy( &data[ofs + 4], str, len );
|
2005-03-18 15:01:39 +01:00
|
|
|
return (7 + len) & ~3;
|
|
|
|
}
|
|
|
|
|
2007-06-12 22:51:36 +02:00
|
|
|
static UINT write_property_to_data( const PROPVARIANT *prop, LPBYTE data )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-03-18 15:01:39 +01:00
|
|
|
DWORD sz = 0;
|
|
|
|
|
|
|
|
if( prop->vt == VT_EMPTY )
|
|
|
|
return sz;
|
|
|
|
|
|
|
|
/* add the type */
|
|
|
|
sz += write_dword( data, sz, prop->vt );
|
|
|
|
switch( prop->vt )
|
|
|
|
{
|
|
|
|
case VT_I2:
|
|
|
|
sz += write_dword( data, sz, prop->u.iVal );
|
|
|
|
break;
|
|
|
|
case VT_I4:
|
|
|
|
sz += write_dword( data, sz, prop->u.lVal );
|
|
|
|
break;
|
|
|
|
case VT_FILETIME:
|
|
|
|
sz += write_filetime( data, sz, &prop->u.filetime );
|
|
|
|
break;
|
|
|
|
case VT_LPSTR:
|
|
|
|
sz += write_string( data, sz, prop->u.pszVal );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return sz;
|
|
|
|
}
|
|
|
|
|
2007-06-12 22:51:36 +02:00
|
|
|
static UINT save_summary_info( const MSISUMMARYINFO * si, IStream *stm )
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
|
|
|
UINT ret = ERROR_FUNCTION_FAILED;
|
|
|
|
PROPERTYSETHEADER set_hdr;
|
|
|
|
FORMATIDOFFSET format_hdr;
|
|
|
|
PROPERTYSECTIONHEADER section_hdr;
|
|
|
|
PROPERTYIDOFFSET idofs[MSI_MAX_PROPS];
|
|
|
|
LPBYTE data = NULL;
|
|
|
|
ULONG count, sz;
|
2003-08-13 03:27:48 +02:00
|
|
|
HRESULT r;
|
2008-04-21 23:23:21 +02:00
|
|
|
int i;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
/* write the header */
|
|
|
|
sz = sizeof set_hdr;
|
|
|
|
memset( &set_hdr, 0, sz );
|
|
|
|
set_hdr.wByteOrder = 0xfffe;
|
|
|
|
set_hdr.wFormat = 0;
|
|
|
|
set_hdr.dwOSVer = 0x00020005; /* build 5, platform id 2 */
|
|
|
|
/* set_hdr.clsID is {00000000-0000-0000-0000-000000000000} */
|
|
|
|
set_hdr.reserved = 1;
|
|
|
|
r = IStream_Write( stm, &set_hdr, sz, &count );
|
|
|
|
if( FAILED(r) || count != sz )
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* write the format header */
|
|
|
|
sz = sizeof format_hdr;
|
2008-03-06 23:33:47 +01:00
|
|
|
format_hdr.fmtid = FMTID_SummaryInformation;
|
2005-03-18 15:01:39 +01:00
|
|
|
format_hdr.dwOffset = sizeof format_hdr + sizeof set_hdr;
|
|
|
|
r = IStream_Write( stm, &format_hdr, sz, &count );
|
|
|
|
if( FAILED(r) || count != sz )
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* add up how much space the data will take and calculate the offsets */
|
|
|
|
section_hdr.cbSection = sizeof section_hdr;
|
|
|
|
section_hdr.cbSection += (get_property_count( si->property ) * sizeof idofs[0]);
|
|
|
|
section_hdr.cProperties = 0;
|
|
|
|
for( i = 0; i < MSI_MAX_PROPS; i++ )
|
|
|
|
{
|
|
|
|
sz = write_property_to_data( &si->property[i], NULL );
|
|
|
|
if( !sz )
|
|
|
|
continue;
|
|
|
|
idofs[ section_hdr.cProperties ].propid = i;
|
|
|
|
idofs[ section_hdr.cProperties ].dwOffset = section_hdr.cbSection;
|
|
|
|
section_hdr.cProperties++;
|
|
|
|
section_hdr.cbSection += sz;
|
|
|
|
}
|
|
|
|
|
2005-09-20 13:57:19 +02:00
|
|
|
data = msi_alloc_zero( section_hdr.cbSection );
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
sz = 0;
|
|
|
|
memcpy( &data[sz], §ion_hdr, sizeof section_hdr );
|
|
|
|
sz += sizeof section_hdr;
|
|
|
|
|
|
|
|
memcpy( &data[sz], idofs, section_hdr.cProperties * sizeof idofs[0] );
|
|
|
|
sz += section_hdr.cProperties * sizeof idofs[0];
|
|
|
|
|
|
|
|
/* write out the data */
|
|
|
|
for( i = 0; i < MSI_MAX_PROPS; i++ )
|
|
|
|
sz += write_property_to_data( &si->property[i], &data[sz] );
|
|
|
|
|
|
|
|
r = IStream_Write( stm, data, sz, &count );
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( data );
|
2005-03-18 15:01:39 +01:00
|
|
|
if( FAILED(r) || count != sz )
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
static MSISUMMARYINFO *create_suminfo( IStorage *stg, UINT update_count )
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
|
|
|
MSISUMMARYINFO *si;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
if (!(si = alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO, sizeof(MSISUMMARYINFO), MSI_CloseSummaryInfo )))
|
|
|
|
return NULL;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
si->update_count = update_count;
|
2006-10-23 18:11:30 +02:00
|
|
|
IStorage_AddRef( stg );
|
|
|
|
si->storage = stg;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
return si;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT msi_get_suminfo( IStorage *stg, UINT uiUpdateCount, MSISUMMARYINFO **ret )
|
|
|
|
{
|
|
|
|
IStream *stm;
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("%p, %u\n", stg, uiUpdateCount);
|
|
|
|
|
|
|
|
if (!(si = create_suminfo( stg, uiUpdateCount ))) return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = IStorage_OpenStream( si->storage, szSumInfo, 0, STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &stm );
|
|
|
|
if (FAILED( hr ))
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2015-03-16 10:55:58 +01:00
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
r = load_summary_info( si, stm );
|
|
|
|
IStream_Release( stm );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = si;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-03-25 14:31:47 +01:00
|
|
|
UINT msi_get_db_suminfo( MSIDATABASE *db, UINT uiUpdateCount, MSISUMMARYINFO **ret )
|
2015-03-16 10:55:58 +01:00
|
|
|
{
|
|
|
|
IStream *stm;
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (!(si = create_suminfo( db->storage, uiUpdateCount ))) return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r = msi_get_stream( db, szSumInfo, &stm );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = load_summary_info( si, stm );
|
|
|
|
IStream_Release( stm );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = si;
|
|
|
|
return ERROR_SUCCESS;
|
2005-10-26 12:10:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase,
|
|
|
|
LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle )
|
|
|
|
{
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
MSIDATABASE *db;
|
2015-03-16 10:55:58 +01:00
|
|
|
UINT ret;
|
2005-10-26 12:10:50 +02:00
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s %d %p\n", hDatabase, debugstr_w(szDatabase),
|
2005-10-26 12:10:50 +02:00
|
|
|
uiUpdateCount, pHandle);
|
|
|
|
|
|
|
|
if( !pHandle )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2010-09-29 09:58:12 +02:00
|
|
|
if( szDatabase && szDatabase[0] )
|
2005-10-26 12:10:50 +02:00
|
|
|
{
|
2009-09-09 20:11:48 +02:00
|
|
|
LPCWSTR persist = uiUpdateCount ? MSIDBOPEN_TRANSACT : MSIDBOPEN_READONLY;
|
|
|
|
|
|
|
|
ret = MSI_OpenDatabaseW( szDatabase, persist, &db );
|
2005-10-26 12:10:50 +02:00
|
|
|
if( ret != ERROR_SUCCESS )
|
|
|
|
return ret;
|
|
|
|
}
|
2004-07-10 00:25:34 +02:00
|
|
|
else
|
2005-10-26 12:10:50 +02:00
|
|
|
{
|
|
|
|
db = msihandle2msiinfo( hDatabase, MSIHANDLETYPE_DATABASE );
|
|
|
|
if( !db )
|
2007-11-12 01:13:08 +01:00
|
|
|
{
|
2018-04-20 06:44:18 +02:00
|
|
|
MSIHANDLE remote, remote_suminfo;
|
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 ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_DatabaseGetSummaryInformation(remote, uiUpdateCount, &remote_suminfo);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-04-20 06:44:18 +02:00
|
|
|
if (!ret)
|
|
|
|
*pHandle = alloc_msi_remote_handle(remote_suminfo);
|
2007-11-12 01:13:08 +01:00
|
|
|
|
2018-04-20 06:44:18 +02:00
|
|
|
return ret;
|
2007-11-12 01:13:08 +01:00
|
|
|
}
|
2005-10-26 12:10:50 +02:00
|
|
|
}
|
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
ret = msi_get_suminfo( db->storage, uiUpdateCount, &si );
|
|
|
|
if (ret != ERROR_SUCCESS)
|
2015-03-25 14:31:47 +01:00
|
|
|
ret = msi_get_db_suminfo( db, uiUpdateCount, &si );
|
2015-03-16 10:55:58 +01:00
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if ((si = create_suminfo( db->storage, uiUpdateCount )))
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret == ERROR_SUCCESS)
|
2005-10-26 12:10:50 +02:00
|
|
|
{
|
|
|
|
*pHandle = alloc_msihandle( &si->hdr );
|
|
|
|
if( *pHandle )
|
|
|
|
ret = ERROR_SUCCESS;
|
2006-08-28 18:44:35 +02:00
|
|
|
else
|
|
|
|
ret = ERROR_NOT_ENOUGH_MEMORY;
|
2005-10-26 12:10:50 +02:00
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2011-06-26 17:17:38 +02:00
|
|
|
msiobj_release( &db->hdr );
|
2003-08-13 03:27:48 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase,
|
|
|
|
LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-03-18 15:01:39 +01:00
|
|
|
LPWSTR szwDatabase = NULL;
|
|
|
|
UINT ret;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %s %d %p\n", hDatabase, debugstr_a(szDatabase),
|
2005-03-18 15:01:39 +01:00
|
|
|
uiUpdateCount, pHandle);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
if( szDatabase )
|
|
|
|
{
|
|
|
|
szwDatabase = strdupAtoW( szDatabase );
|
|
|
|
if( !szwDatabase )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, pHandle);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( szwDatabase );
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
return ret;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
2007-08-09 10:41:41 +02:00
|
|
|
UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, PUINT pCount)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-03-18 15:01:39 +01:00
|
|
|
MSISUMMARYINFO *si;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("%d %p\n", hSummaryInfo, pCount);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
si = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
|
|
|
|
if( !si )
|
2018-09-08 05:45:35 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE remote;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote( hSummaryInfo )))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_SummaryInfoGetPropertyCount( remote, pCount );
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
if( pCount )
|
|
|
|
*pCount = get_property_count( si->property );
|
|
|
|
msiobj_release( &si->hdr );
|
2003-08-13 03:27:48 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
static UINT get_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT *puiDataType, INT *piValue,
|
|
|
|
FILETIME *pftValue, awstring *str, DWORD *pcchValueBuf)
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
|
|
|
PROPVARIANT *prop;
|
2005-09-06 12:23:12 +02:00
|
|
|
UINT ret = ERROR_SUCCESS;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
|
|
|
prop = &si->property[uiProperty];
|
|
|
|
|
2005-04-20 16:24:14 +02:00
|
|
|
if( puiDataType )
|
|
|
|
*puiDataType = prop->vt;
|
|
|
|
|
|
|
|
switch( prop->vt )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-03-18 15:01:39 +01:00
|
|
|
case VT_I2:
|
|
|
|
if( piValue )
|
|
|
|
*piValue = prop->u.iVal;
|
|
|
|
break;
|
2003-08-13 03:27:48 +02:00
|
|
|
case VT_I4:
|
|
|
|
if( piValue )
|
2005-03-18 15:01:39 +01:00
|
|
|
*piValue = prop->u.lVal;
|
2003-08-13 03:27:48 +02:00
|
|
|
break;
|
|
|
|
case VT_LPSTR:
|
2005-03-18 15:01:39 +01:00
|
|
|
if( pcchValueBuf )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2005-03-18 15:01:39 +01:00
|
|
|
DWORD len = 0;
|
|
|
|
|
|
|
|
if( str->unicode )
|
|
|
|
{
|
2009-10-23 10:49:44 +02:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, prop->u.pszVal, -1, NULL, 0 ) - 1;
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, prop->u.pszVal, -1, str->str.w, *pcchValueBuf );
|
2005-03-18 15:01:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len = lstrlenA( prop->u.pszVal );
|
|
|
|
if( str->str.a )
|
|
|
|
lstrcpynA(str->str.a, prop->u.pszVal, *pcchValueBuf );
|
|
|
|
}
|
2005-09-06 12:23:12 +02:00
|
|
|
if (len >= *pcchValueBuf)
|
|
|
|
ret = ERROR_MORE_DATA;
|
2005-03-18 15:01:39 +01:00
|
|
|
*pcchValueBuf = len;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VT_FILETIME:
|
|
|
|
if( pftValue )
|
2008-03-06 23:33:47 +01:00
|
|
|
*pftValue = prop->u.filetime;
|
2003-08-13 03:27:48 +02:00
|
|
|
break;
|
|
|
|
case VT_EMPTY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unknown property variant type\n");
|
|
|
|
break;
|
|
|
|
}
|
2005-09-06 12:23:12 +02:00
|
|
|
return ret;
|
2005-03-18 15:01:39 +01:00
|
|
|
}
|
|
|
|
|
2005-10-26 12:10:50 +02:00
|
|
|
LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty )
|
|
|
|
{
|
|
|
|
PROPVARIANT *prop;
|
|
|
|
|
|
|
|
if ( uiProperty >= MSI_MAX_PROPS )
|
|
|
|
return NULL;
|
|
|
|
prop = &si->property[uiProperty];
|
|
|
|
if( prop->vt != VT_LPSTR )
|
|
|
|
return NULL;
|
|
|
|
return strdupAtoW( prop->u.pszVal );
|
|
|
|
}
|
|
|
|
|
2010-10-06 15:44:08 +02:00
|
|
|
INT msi_suminfo_get_int32( MSISUMMARYINFO *si, UINT uiProperty )
|
|
|
|
{
|
|
|
|
PROPVARIANT *prop;
|
|
|
|
|
|
|
|
if ( uiProperty >= MSI_MAX_PROPS )
|
|
|
|
return -1;
|
|
|
|
prop = &si->property[uiProperty];
|
|
|
|
if( prop->vt != VT_I4 )
|
|
|
|
return -1;
|
|
|
|
return prop->u.lVal;
|
|
|
|
}
|
|
|
|
|
2006-10-23 18:12:13 +02:00
|
|
|
LPWSTR msi_get_suminfo_product( IStorage *stg )
|
|
|
|
{
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
LPWSTR prod;
|
2015-03-16 10:55:58 +01:00
|
|
|
UINT r;
|
2006-10-23 18:12:13 +02:00
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
r = msi_get_suminfo( stg, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-23 18:12:13 +02:00
|
|
|
{
|
|
|
|
ERR("no summary information!\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
prod = msi_suminfo_dup_string( si, PID_REVNUMBER );
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return prod;
|
|
|
|
}
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
UINT WINAPI MsiSummaryInfoGetPropertyA(
|
2007-08-09 10:41:41 +02:00
|
|
|
MSIHANDLE handle, UINT uiProperty, PUINT puiDataType, LPINT piValue,
|
|
|
|
FILETIME *pftValue, LPSTR szValueBuf, LPDWORD pcchValueBuf)
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
2015-03-25 14:32:17 +01:00
|
|
|
MSISUMMARYINFO *si;
|
2005-03-18 15:01:39 +01:00
|
|
|
awstring str;
|
2015-03-25 14:32:17 +01:00
|
|
|
UINT r;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
TRACE("%u, %u, %p, %p, %p, %p, %p\n", handle, uiProperty, puiDataType,
|
2005-03-18 15:01:39 +01:00
|
|
|
piValue, pftValue, szValueBuf, pcchValueBuf );
|
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
if (uiProperty >= MSI_MAX_PROPS)
|
|
|
|
{
|
|
|
|
if (puiDataType) *puiDataType = VT_EMPTY;
|
|
|
|
return ERROR_UNKNOWN_PROPERTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO )))
|
2018-09-08 05:46:24 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE remote;
|
|
|
|
WCHAR *buf = NULL;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote( handle )))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_SummaryInfoGetProperty( remote, uiProperty, puiDataType, piValue, pftValue, &buf );
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-09-19 07:27:57 +02:00
|
|
|
if (!r && buf)
|
|
|
|
{
|
2018-09-08 05:46:24 +02:00
|
|
|
r = msi_strncpyWtoA( buf, -1, szValueBuf, pcchValueBuf, TRUE );
|
2018-09-19 07:27:57 +02:00
|
|
|
}
|
2018-09-08 05:46:24 +02:00
|
|
|
|
|
|
|
midl_user_free( buf );
|
|
|
|
return r;
|
|
|
|
}
|
2015-03-25 14:32:17 +01:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
str.unicode = FALSE;
|
|
|
|
str.str.a = szValueBuf;
|
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
r = get_prop( si, uiProperty, puiDataType, piValue, pftValue, &str, pcchValueBuf );
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiSummaryInfoGetPropertyW(
|
2007-08-09 10:41:41 +02:00
|
|
|
MSIHANDLE handle, UINT uiProperty, PUINT puiDataType, LPINT piValue,
|
|
|
|
FILETIME *pftValue, LPWSTR szValueBuf, LPDWORD pcchValueBuf)
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
2015-03-25 14:32:17 +01:00
|
|
|
MSISUMMARYINFO *si;
|
2005-03-18 15:01:39 +01:00
|
|
|
awstring str;
|
2015-03-25 14:32:17 +01:00
|
|
|
UINT r;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
TRACE("%u, %u, %p, %p, %p, %p, %p\n", handle, uiProperty, puiDataType,
|
2005-03-18 15:01:39 +01:00
|
|
|
piValue, pftValue, szValueBuf, pcchValueBuf );
|
2005-01-24 12:24:35 +01:00
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
if (uiProperty >= MSI_MAX_PROPS)
|
|
|
|
{
|
|
|
|
if (puiDataType) *puiDataType = VT_EMPTY;
|
|
|
|
return ERROR_UNKNOWN_PROPERTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO )))
|
2018-09-08 05:46:24 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE remote;
|
|
|
|
WCHAR *buf = NULL;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote( handle )))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_SummaryInfoGetProperty( remote, uiProperty, puiDataType, piValue, pftValue, &buf );
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-09-19 07:27:57 +02:00
|
|
|
if (!r && buf)
|
2018-09-08 05:46:24 +02:00
|
|
|
r = msi_strncpyW( buf, -1, szValueBuf, pcchValueBuf );
|
|
|
|
|
|
|
|
midl_user_free( buf );
|
|
|
|
return r;
|
|
|
|
}
|
2015-03-25 14:32:17 +01:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
str.unicode = TRUE;
|
|
|
|
str.str.w = szValueBuf;
|
2005-01-24 12:24:35 +01:00
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
r = get_prop( si, uiProperty, puiDataType, piValue, pftValue, &str, pcchValueBuf );
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
2005-03-18 15:01:39 +01:00
|
|
|
}
|
|
|
|
|
2009-04-13 12:24:46 +02:00
|
|
|
static UINT set_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT type,
|
2015-03-25 14:32:17 +01:00
|
|
|
INT iValue, FILETIME *pftValue, awcstring *str )
|
2005-03-18 15:01:39 +01:00
|
|
|
{
|
|
|
|
PROPVARIANT *prop;
|
2009-04-13 12:24:46 +02:00
|
|
|
UINT len;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
TRACE("%p, %u, %u, %d, %p, %p\n", si, uiProperty, type, iValue, pftValue, str );
|
2005-01-24 12:24:35 +01:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
prop = &si->property[uiProperty];
|
2005-01-24 12:24:35 +01:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
if( prop->vt == VT_EMPTY )
|
2005-03-10 12:15:40 +01:00
|
|
|
{
|
2005-03-18 15:01:39 +01:00
|
|
|
if( !si->update_count )
|
2009-04-13 12:24:46 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
si->update_count--;
|
2005-03-10 12:15:40 +01:00
|
|
|
}
|
2005-03-18 15:01:39 +01:00
|
|
|
else if( prop->vt != type )
|
2009-04-13 12:24:46 +02:00
|
|
|
return ERROR_SUCCESS;
|
2005-01-24 12:24:35 +01:00
|
|
|
|
2005-03-19 18:08:34 +01:00
|
|
|
free_prop( prop );
|
|
|
|
prop->vt = type;
|
2005-03-18 15:01:39 +01:00
|
|
|
switch( type )
|
2005-01-24 12:24:35 +01:00
|
|
|
{
|
|
|
|
case VT_I4:
|
2005-03-18 15:01:39 +01:00
|
|
|
prop->u.lVal = iValue;
|
2005-01-24 12:24:35 +01:00
|
|
|
break;
|
2005-03-18 15:01:39 +01:00
|
|
|
case VT_I2:
|
|
|
|
prop->u.iVal = iValue;
|
2005-01-24 12:24:35 +01:00
|
|
|
break;
|
|
|
|
case VT_FILETIME:
|
2008-03-06 23:33:47 +01:00
|
|
|
prop->u.filetime = *pftValue;
|
2005-01-24 12:24:35 +01:00
|
|
|
break;
|
2005-03-18 15:01:39 +01:00
|
|
|
case VT_LPSTR:
|
|
|
|
if( str->unicode )
|
|
|
|
{
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
|
|
|
|
NULL, 0, NULL, NULL );
|
2005-09-20 13:57:19 +02:00
|
|
|
prop->u.pszVal = msi_alloc( len );
|
2005-03-18 15:01:39 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
|
|
|
|
prop->u.pszVal, len, NULL, NULL );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len = lstrlenA( str->str.a ) + 1;
|
2005-09-20 13:57:19 +02:00
|
|
|
prop->u.pszVal = msi_alloc( len );
|
2005-03-18 15:01:39 +01:00
|
|
|
lstrcpyA( prop->u.pszVal, str->str.a );
|
|
|
|
}
|
2005-01-24 12:24:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-13 12:24:46 +02:00
|
|
|
return ERROR_SUCCESS;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
2005-02-01 15:21:03 +01:00
|
|
|
|
2018-09-19 07:28:34 +02:00
|
|
|
static UINT msi_set_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT uiDataType,
|
|
|
|
INT iValue, FILETIME *pftValue, awcstring *str )
|
2005-02-01 15:21:03 +01:00
|
|
|
{
|
2018-09-19 07:28:34 +02:00
|
|
|
UINT type = get_type( uiProperty );
|
2009-04-13 12:24:46 +02:00
|
|
|
if( type == VT_EMPTY || type != uiDataType )
|
|
|
|
return ERROR_DATATYPE_MISMATCH;
|
|
|
|
|
2018-09-19 07:28:34 +02:00
|
|
|
if( uiDataType == VT_LPSTR && !str->str.a )
|
2009-04-13 12:24:46 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if( uiDataType == VT_FILETIME && !pftValue )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2018-09-19 07:28:34 +02:00
|
|
|
return set_prop( si, uiProperty, type, iValue, pftValue, str );
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiSummaryInfoSetPropertyW( MSIHANDLE handle, UINT uiProperty, UINT uiDataType,
|
|
|
|
INT iValue, FILETIME *pftValue, LPCWSTR szValue )
|
|
|
|
{
|
|
|
|
awcstring str;
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%u, %u, %u, %d, %p, %s\n", handle, uiProperty, uiDataType, iValue, pftValue,
|
|
|
|
debugstr_w(szValue) );
|
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
if (!(si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO )))
|
2018-09-08 05:45:15 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if ((remote = msi_get_remote( handle )))
|
|
|
|
{
|
|
|
|
WARN("MsiSummaryInfoSetProperty not allowed during a custom action!\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2009-04-13 12:24:46 +02:00
|
|
|
return ERROR_INVALID_HANDLE;
|
2018-09-08 05:45:15 +02:00
|
|
|
}
|
2009-04-13 12:24:46 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
str.unicode = TRUE;
|
|
|
|
str.str.w = szValue;
|
2009-04-13 12:24:46 +02:00
|
|
|
|
2018-09-19 07:28:34 +02:00
|
|
|
ret = msi_set_prop( si, uiProperty, uiDataType, iValue, pftValue, &str );
|
2009-04-13 12:24:46 +02:00
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return ret;
|
2005-02-01 15:21:03 +01:00
|
|
|
}
|
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
UINT WINAPI MsiSummaryInfoSetPropertyA( MSIHANDLE handle, UINT uiProperty, UINT uiDataType,
|
|
|
|
INT iValue, FILETIME *pftValue, LPCSTR szValue )
|
2005-02-01 15:21:03 +01:00
|
|
|
{
|
2005-05-30 13:12:24 +02:00
|
|
|
awcstring str;
|
2009-04-13 12:24:46 +02:00
|
|
|
MSISUMMARYINFO *si;
|
2018-09-19 07:28:34 +02:00
|
|
|
UINT ret;
|
2005-03-18 15:01:39 +01:00
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
TRACE("%u, %u, %u, %d, %p, %s\n", handle, uiProperty, uiDataType, iValue, pftValue,
|
|
|
|
debugstr_a(szValue) );
|
2005-03-18 15:01:39 +01:00
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
if (!(si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO )))
|
2018-09-08 05:45:15 +02:00
|
|
|
{
|
|
|
|
MSIHANDLE remote;
|
|
|
|
|
|
|
|
if ((remote = msi_get_remote( handle )))
|
|
|
|
{
|
|
|
|
WARN("MsiSummaryInfoSetProperty not allowed during a custom action!\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2009-04-13 12:24:46 +02:00
|
|
|
return ERROR_INVALID_HANDLE;
|
2018-09-08 05:45:15 +02:00
|
|
|
}
|
2009-04-13 12:24:46 +02:00
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
str.unicode = FALSE;
|
|
|
|
str.str.a = szValue;
|
2009-04-13 12:24:46 +02:00
|
|
|
|
2018-09-19 07:28:34 +02:00
|
|
|
ret = msi_set_prop( si, uiProperty, uiDataType, iValue, pftValue, &str );
|
2009-04-13 12:24:46 +02:00
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return ret;
|
2005-02-01 15:21:03 +01:00
|
|
|
}
|
|
|
|
|
2009-04-13 12:24:46 +02:00
|
|
|
static UINT suminfo_persist( MSISUMMARYINFO *si )
|
2005-02-01 15:21:03 +01:00
|
|
|
{
|
2009-04-13 12:24:46 +02:00
|
|
|
UINT ret = ERROR_FUNCTION_FAILED;
|
2005-03-18 15:01:39 +01:00
|
|
|
IStream *stm = NULL;
|
|
|
|
DWORD grfMode;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
grfMode = STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
|
2006-10-23 18:11:30 +02:00
|
|
|
r = IStorage_CreateStream( si->storage, szSumInfo, grfMode, 0, 0, &stm );
|
2005-03-18 15:01:39 +01:00
|
|
|
if( SUCCEEDED(r) )
|
|
|
|
{
|
|
|
|
ret = save_summary_info( si, stm );
|
|
|
|
IStream_Release( stm );
|
|
|
|
}
|
2009-04-13 12:24:46 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void parse_filetime( LPCWSTR str, FILETIME *ft )
|
|
|
|
{
|
|
|
|
SYSTEMTIME lt, utc;
|
|
|
|
const WCHAR *p = str;
|
|
|
|
WCHAR *end;
|
|
|
|
|
|
|
|
memset( <, 0, sizeof(lt) );
|
|
|
|
|
|
|
|
/* YYYY/MM/DD hh:mm:ss */
|
|
|
|
|
|
|
|
while (isspaceW( *p )) p++;
|
|
|
|
|
|
|
|
lt.wYear = strtolW( p, &end, 10 );
|
|
|
|
if (*end != '/') return;
|
|
|
|
p = end + 1;
|
|
|
|
|
|
|
|
lt.wMonth = strtolW( p, &end, 10 );
|
|
|
|
if (*end != '/') return;
|
|
|
|
p = end + 1;
|
|
|
|
|
|
|
|
lt.wDay = strtolW( p, &end, 10 );
|
|
|
|
if (*end != ' ') return;
|
|
|
|
p = end + 1;
|
|
|
|
|
|
|
|
while (isspaceW( *p )) p++;
|
|
|
|
|
|
|
|
lt.wHour = strtolW( p, &end, 10 );
|
|
|
|
if (*end != ':') return;
|
|
|
|
p = end + 1;
|
|
|
|
|
|
|
|
lt.wMinute = strtolW( p, &end, 10 );
|
|
|
|
if (*end != ':') return;
|
|
|
|
p = end + 1;
|
|
|
|
|
|
|
|
lt.wSecond = strtolW( p, &end, 10 );
|
|
|
|
|
|
|
|
TzSpecificLocalTimeToSystemTime( NULL, <, &utc );
|
|
|
|
SystemTimeToFileTime( &utc, ft );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT parse_prop( LPCWSTR prop, LPCWSTR value, UINT *pid, INT *int_value,
|
|
|
|
FILETIME *ft_value, awcstring *str_value )
|
|
|
|
{
|
|
|
|
*pid = atoiW( prop );
|
|
|
|
switch (*pid)
|
|
|
|
{
|
|
|
|
case PID_CODEPAGE:
|
|
|
|
case PID_WORDCOUNT:
|
|
|
|
case PID_CHARCOUNT:
|
|
|
|
case PID_SECURITY:
|
|
|
|
case PID_PAGECOUNT:
|
|
|
|
*int_value = atoiW( value );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PID_LASTPRINTED:
|
|
|
|
case PID_CREATE_DTM:
|
|
|
|
case PID_LASTSAVE_DTM:
|
|
|
|
parse_filetime( value, ft_value );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PID_SUBJECT:
|
|
|
|
case PID_AUTHOR:
|
|
|
|
case PID_KEYWORDS:
|
|
|
|
case PID_COMMENTS:
|
|
|
|
case PID_TEMPLATE:
|
|
|
|
case PID_LASTAUTHOR:
|
|
|
|
case PID_REVNUMBER:
|
|
|
|
case PID_APPNAME:
|
|
|
|
case PID_TITLE:
|
|
|
|
str_value->str.w = value;
|
|
|
|
str_value->unicode = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WARN("unhandled prop id %u\n", *pid);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT msi_add_suminfo( MSIDATABASE *db, LPWSTR **records, int num_records, int num_columns )
|
|
|
|
{
|
2015-03-16 10:55:58 +01:00
|
|
|
UINT r;
|
2013-02-16 22:09:17 +01:00
|
|
|
int i, j;
|
2009-04-13 12:24:46 +02:00
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
r = msi_get_suminfo( db->storage, num_records * (num_columns / 2), &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
2009-04-13 12:24:46 +02:00
|
|
|
{
|
2015-03-16 10:55:58 +01:00
|
|
|
if (!(si = create_suminfo( db->storage, num_records * (num_columns / 2) )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
r = ERROR_SUCCESS;
|
2009-04-13 12:24:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < num_records; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < num_columns; j += 2)
|
|
|
|
{
|
|
|
|
UINT pid;
|
|
|
|
INT int_value = 0;
|
|
|
|
FILETIME ft_value;
|
|
|
|
awcstring str_value;
|
|
|
|
|
|
|
|
r = parse_prop( records[i][j], records[i][j + 1], &pid, &int_value, &ft_value, &str_value );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
r = set_prop( si, pid, get_type(pid), int_value, &ft_value, &str_value );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
r = suminfo_persist( si );
|
|
|
|
|
2005-03-18 15:01:39 +01:00
|
|
|
msiobj_release( &si->hdr );
|
2009-04-13 12:24:46 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2019-03-15 10:03:57 +01:00
|
|
|
static UINT save_prop( MSISUMMARYINFO *si, HANDLE handle, UINT row )
|
|
|
|
{
|
|
|
|
static const char fmt_systemtime[] = "%04u/%02u/%02u %02u:%02u:%02u";
|
|
|
|
char data[36]; /* largest string: YYYY/MM/DD hh:mm:ss */
|
|
|
|
static const char fmt_begin[] = "%u\t";
|
|
|
|
static const char data_end[] = "\r\n";
|
|
|
|
static const char fmt_int[] = "%u";
|
|
|
|
UINT r, data_type, len;
|
|
|
|
SYSTEMTIME system_time;
|
|
|
|
FILETIME file_time;
|
|
|
|
INT int_value;
|
|
|
|
awstring str;
|
|
|
|
DWORD sz;
|
|
|
|
|
|
|
|
str.unicode = FALSE;
|
|
|
|
str.str.a = NULL;
|
|
|
|
len = 0;
|
|
|
|
r = get_prop( si, row, &data_type, &int_value, &file_time, &str, &len );
|
|
|
|
if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
|
|
|
|
return r;
|
|
|
|
if (data_type == VT_EMPTY)
|
|
|
|
return ERROR_SUCCESS; /* property not set */
|
|
|
|
sz = sprintf( data, fmt_begin, row );
|
|
|
|
if (!WriteFile( handle, data, sz, &sz, NULL ))
|
|
|
|
return ERROR_WRITE_FAULT;
|
|
|
|
|
|
|
|
switch( data_type )
|
|
|
|
{
|
|
|
|
case VT_I2:
|
|
|
|
case VT_I4:
|
|
|
|
sz = sprintf( data, fmt_int, int_value );
|
|
|
|
if (!WriteFile( handle, data, sz, &sz, NULL ))
|
|
|
|
return ERROR_WRITE_FAULT;
|
|
|
|
break;
|
|
|
|
case VT_LPSTR:
|
|
|
|
len++;
|
|
|
|
if (!(str.str.a = msi_alloc( len )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
r = get_prop( si, row, NULL, NULL, NULL, &str, &len );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msi_free( str.str.a );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
sz = len;
|
|
|
|
if (!WriteFile( handle, str.str.a, sz, &sz, NULL ))
|
|
|
|
{
|
|
|
|
msi_free( str.str.a );
|
|
|
|
return ERROR_WRITE_FAULT;
|
|
|
|
}
|
|
|
|
msi_free( str.str.a );
|
|
|
|
break;
|
|
|
|
case VT_FILETIME:
|
|
|
|
if (!FileTimeToSystemTime( &file_time, &system_time ))
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
sz = sprintf( data, fmt_systemtime, system_time.wYear, system_time.wMonth,
|
|
|
|
system_time.wDay, system_time.wHour, system_time.wMinute,
|
|
|
|
system_time.wSecond );
|
|
|
|
if (!WriteFile( handle, data, sz, &sz, NULL ))
|
|
|
|
return ERROR_WRITE_FAULT;
|
|
|
|
break;
|
|
|
|
case VT_EMPTY:
|
|
|
|
/* cannot reach here, property not set */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME( "Unknown property variant type\n" );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
sz = ARRAY_SIZE(data_end) - 1;
|
|
|
|
if (!WriteFile( handle, data_end, sz, &sz, NULL ))
|
|
|
|
return ERROR_WRITE_FAULT;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT msi_export_suminfo( MSIDATABASE *db, HANDLE handle )
|
|
|
|
{
|
|
|
|
UINT i, r, num_rows;
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
|
|
|
|
r = msi_get_suminfo( db->storage, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
r = msi_get_db_suminfo( db, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
num_rows = get_property_count( si->property );
|
|
|
|
if (!num_rows)
|
|
|
|
{
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < num_rows; i++)
|
|
|
|
{
|
|
|
|
r = save_prop( si, handle, i );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-04-13 12:24:46 +02:00
|
|
|
UINT WINAPI MsiSummaryInfoPersist( MSIHANDLE handle )
|
|
|
|
{
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%d\n", handle );
|
2005-03-18 15:01:39 +01:00
|
|
|
|
2009-04-13 12:24:46 +02:00
|
|
|
si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
|
|
|
|
if( !si )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
ret = suminfo_persist( si );
|
|
|
|
|
|
|
|
msiobj_release( &si->hdr );
|
2005-03-18 15:01:39 +01:00
|
|
|
return ret;
|
2005-02-01 15:21:03 +01:00
|
|
|
}
|
2011-06-10 10:12:50 +02:00
|
|
|
|
|
|
|
UINT WINAPI MsiCreateTransformSummaryInfoA( MSIHANDLE db, MSIHANDLE db_ref, LPCSTR transform, int error, int validation )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
WCHAR *transformW = NULL;
|
|
|
|
|
|
|
|
TRACE("%u, %u, %s, %d, %d\n", db, db_ref, debugstr_a(transform), error, validation);
|
|
|
|
|
|
|
|
if (transform && !(transformW = strdupAtoW( transform )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r = MsiCreateTransformSummaryInfoW( db, db_ref, transformW, error, validation );
|
|
|
|
msi_free( transformW );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiCreateTransformSummaryInfoW( MSIHANDLE db, MSIHANDLE db_ref, LPCWSTR transform, int error, int validation )
|
|
|
|
{
|
|
|
|
FIXME("%u, %u, %s, %d, %d\n", db, db_ref, debugstr_w(transform), error, validation);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
2015-03-25 14:32:17 +01:00
|
|
|
|
|
|
|
UINT msi_load_suminfo_properties( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR packagecodeW[] = {'P','a','c','k','a','g','e','C','o','d','e',0};
|
|
|
|
MSISUMMARYINFO *si;
|
|
|
|
WCHAR *package_code;
|
|
|
|
UINT r, len;
|
|
|
|
awstring str;
|
|
|
|
INT count;
|
|
|
|
|
|
|
|
r = msi_get_suminfo( package->db->storage, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = msi_get_db_suminfo( package->db, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Unable to open summary information stream %u\n", r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
str.unicode = TRUE;
|
|
|
|
str.str.w = NULL;
|
|
|
|
len = 0;
|
|
|
|
r = get_prop( si, PID_REVNUMBER, NULL, NULL, NULL, &str, &len );
|
|
|
|
if (r != ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
WARN("Unable to query revision number %u\n", r);
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
len++;
|
|
|
|
if (!(package_code = msi_alloc( len * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
|
|
|
|
str.str.w = package_code;
|
|
|
|
|
|
|
|
r = get_prop( si, PID_REVNUMBER, NULL, NULL, NULL, &str, &len );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msi_free( package_code );
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = msi_set_property( package->db, packagecodeW, package_code, len );
|
|
|
|
msi_free( package_code );
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
get_prop( si, PID_WORDCOUNT, NULL, &count, NULL, NULL, NULL );
|
|
|
|
package->WordCount = count;
|
|
|
|
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
2018-09-08 05:45:35 +02:00
|
|
|
|
|
|
|
UINT __cdecl s_remote_SummaryInfoGetPropertyCount( MSIHANDLE suminfo, UINT *count )
|
|
|
|
{
|
|
|
|
return MsiSummaryInfoGetPropertyCount( suminfo, count );
|
|
|
|
}
|
2018-09-08 05:46:24 +02:00
|
|
|
|
|
|
|
UINT __cdecl s_remote_SummaryInfoGetProperty( MSIHANDLE suminfo, UINT property, UINT *type,
|
|
|
|
INT *value, FILETIME *ft, LPWSTR *buf )
|
|
|
|
{
|
|
|
|
WCHAR empty[1];
|
|
|
|
DWORD size = 0;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = MsiSummaryInfoGetPropertyW( suminfo, property, type, value, ft, empty, &size );
|
|
|
|
if (r == ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
size++;
|
|
|
|
*buf = midl_user_allocate( size * sizeof(WCHAR) );
|
|
|
|
if (!*buf) return ERROR_OUTOFMEMORY;
|
|
|
|
r = MsiSummaryInfoGetPropertyW( suminfo, property, type, value, ft, *buf, &size );
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|