- make sure to free the string table when closing the database
[wine] / dlls / msi / suminfo.c
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2002, 2005 Mike McCormack for CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <stdarg.h>
22
23 #define COBJMACROS
24 #define NONAMELESSUNION
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winreg.h"
29 #include "winnls.h"
30 #include "shlwapi.h"
31 #include "wine/debug.h"
32 #include "msi.h"
33 #include "msiquery.h"
34 #include "msidefs.h"
35 #include "msipriv.h"
36 #include "objidl.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(msi);
39
40 #define MSI_MAX_PROPS 20
41
42 #include "pshpack1.h"
43
44 typedef struct { 
45     WORD wByteOrder;
46     WORD wFormat;
47     DWORD dwOSVer;
48     CLSID clsID;
49     DWORD reserved;
50 } PROPERTYSETHEADER;
51
52 typedef struct { 
53     FMTID fmtid;
54     DWORD dwOffset;
55 } FORMATIDOFFSET;
56
57 typedef struct { 
58     DWORD cbSection;
59     DWORD cProperties;
60 } PROPERTYSECTIONHEADER; 
61  
62 typedef struct { 
63     DWORD propid;
64     DWORD dwOffset;
65 } PROPERTYIDOFFSET; 
66
67 typedef struct {
68     DWORD type;
69     union {
70         INT i4;
71         SHORT i2;
72         FILETIME ft;
73         struct {
74             DWORD len;
75             BYTE str[1];
76         } str;
77     } u;
78 } PROPERTY_DATA;
79  
80 #include "poppack.h"
81
82 #define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER))
83
84 typedef struct {
85     BOOL unicode;
86     union {
87        LPSTR a;
88        LPWSTR w;
89     } str;
90 } awstring;
91
92 typedef struct tagMSISUMMARYINFO
93 {
94     MSIOBJECTHDR hdr;
95     MSIDATABASE *db;
96     DWORD update_count;
97     PROPVARIANT property[MSI_MAX_PROPS];
98 } MSISUMMARYINFO;
99
100 static const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y',
101                        'I','n','f','o','r','m','a','t','i','o','n',0 };
102
103 static void free_prop( PROPVARIANT *prop )
104 {
105     if (prop->vt == VT_LPSTR )
106         HeapFree( GetProcessHeap(), 0, prop->u.pszVal );
107     prop->vt = VT_EMPTY;
108 }
109
110 static void MSI_CloseSummaryInfo( MSIOBJECTHDR *arg )
111 {
112     MSISUMMARYINFO *si = (MSISUMMARYINFO *) arg;
113     DWORD i;
114
115     for( i = 0; i < MSI_MAX_PROPS; i++ )
116         free_prop( &si->property[i] );
117     msiobj_release( &si->db->hdr );
118 }
119
120 static UINT get_type( UINT uiProperty )
121 {
122     switch( uiProperty )
123     {
124     case PID_CODEPAGE:
125          return VT_I2;
126     
127     case PID_SUBJECT:
128     case PID_AUTHOR:
129     case PID_KEYWORDS:
130     case PID_COMMENTS:
131     case PID_TEMPLATE:
132     case PID_LASTAUTHOR:
133     case PID_REVNUMBER:
134     case PID_APPNAME:
135     case PID_TITLE:
136          return VT_LPSTR;
137
138     case PID_LASTPRINTED:
139     case PID_CREATE_DTM:
140     case PID_LASTSAVE_DTM:
141          return VT_FILETIME;
142
143     case PID_WORDCOUNT:
144     case PID_CHARCOUNT:
145     case PID_SECURITY:
146     case PID_PAGECOUNT:
147          return VT_I4;
148     }
149     return VT_EMPTY;
150 }
151
152 static UINT get_property_count( PROPVARIANT *property )
153 {
154     UINT i, n = 0;
155
156     if( !property )
157         return n;
158     for( i = 0; i < MSI_MAX_PROPS; i++ )
159         if( property[i].vt != VT_EMPTY )
160             n++;
161     return n;
162 }
163
164 /* FIXME: doesn't deal with endian conversion */
165 static void read_properties_from_data( PROPVARIANT *prop, LPBYTE data, DWORD sz )
166 {
167     UINT type;
168     DWORD i;
169     int size;
170     PROPERTY_DATA *propdata;
171     PROPVARIANT *property;
172     PROPERTYIDOFFSET *idofs;
173     PROPERTYSECTIONHEADER *section_hdr;
174
175     section_hdr = (PROPERTYSECTIONHEADER*) &data[0];
176     idofs = (PROPERTYIDOFFSET*) &data[SECT_HDR_SIZE];
177
178     /* now set all the properties */
179     for( i = 0; i < section_hdr->cProperties; i++ )
180     {
181         type = get_type( idofs[i].propid );
182         if( type == VT_EMPTY )
183         {
184             ERR("propid %ld has unknown type\n", idofs[i].propid);
185             break;
186         }
187
188         propdata = (PROPERTY_DATA*) &data[ idofs[i].dwOffset ];
189
190         /* check the type is the same as we expect */
191         if( type != propdata->type )
192         {
193             ERR("wrong type %d != %ld\n", type, propdata->type);
194             break;
195         }
196
197         /* check we don't run off the end of the data */
198         size = sz - idofs[i].dwOffset - sizeof(DWORD);
199         if( sizeof(DWORD) > size ||
200             ( type == VT_FILETIME && sizeof(FILETIME) > size ) ||
201             ( type == VT_LPSTR && (propdata->u.str.len + sizeof(DWORD)) > size ) )
202         {
203             ERR("not enough data\n");
204             break;
205         }
206
207         if( idofs[i].propid >= MSI_MAX_PROPS )
208         {
209             ERR("Unknown property ID %ld\n", idofs[i].propid );
210             break;
211         }
212
213         property = &prop[ idofs[i].propid ];
214         property->vt = type;
215
216         if( type == VT_LPSTR )
217         {
218             LPSTR str = HeapAlloc( GetProcessHeap(), 0, propdata->u.str.len );
219             memcpy( str, propdata->u.str.str, propdata->u.str.len );
220             str[ propdata->u.str.len - 1 ] = 0;
221             property->u.pszVal = str;
222         }
223         else if( type == VT_FILETIME )
224             property->u.filetime = propdata->u.ft;
225         else if( type == VT_I2 )
226             property->u.iVal = propdata->u.i2;
227         else if( type == VT_I4 )
228             property->u.lVal = propdata->u.i4;
229     }
230 }
231
232 static UINT load_summary_info( MSISUMMARYINFO *si, IStream *stm )
233 {
234     UINT ret = ERROR_FUNCTION_FAILED;
235     PROPERTYSETHEADER set_hdr;
236     FORMATIDOFFSET format_hdr;
237     PROPERTYSECTIONHEADER section_hdr;
238     LPBYTE data = NULL;
239     LARGE_INTEGER ofs;
240     ULONG count, sz;
241     HRESULT r;
242
243     TRACE("%p %p\n", si, stm);
244
245     /* read the header */
246     sz = sizeof set_hdr;
247     r = IStream_Read( stm, &set_hdr, sz, &count );
248     if( FAILED(r) || count != sz )
249         return ret;
250
251     if( set_hdr.wByteOrder != 0xfffe )
252     {
253         ERR("property set not big-endian %04X\n", set_hdr.wByteOrder);
254         return ret;
255     }
256
257     sz = sizeof format_hdr;
258     r = IStream_Read( stm, &format_hdr, sz, &count );
259     if( FAILED(r) || count != sz )
260         return ret;
261
262     /* check the format id is correct */
263     if( !IsEqualGUID( &FMTID_SummaryInformation, &format_hdr.fmtid ) )
264         return ret;
265
266     /* seek to the location of the section */
267     ofs.QuadPart = format_hdr.dwOffset;
268     r = IStream_Seek( stm, ofs, STREAM_SEEK_SET, NULL );
269     if( FAILED(r) )
270         return ret;
271
272     /* read the section itself */
273     sz = SECT_HDR_SIZE;
274     r = IStream_Read( stm, &section_hdr, sz, &count );
275     if( FAILED(r) || count != sz )
276         return ret;
277
278     if( section_hdr.cProperties > MSI_MAX_PROPS )
279     {
280         ERR("too many properties %ld\n", section_hdr.cProperties);
281         return ret;
282     }
283
284     data = HeapAlloc( GetProcessHeap(), 0, section_hdr.cbSection);
285     if( !data )
286         return ret;
287
288     memcpy( data, &section_hdr, SECT_HDR_SIZE );
289
290     /* read all the data in one go */
291     sz = section_hdr.cbSection - SECT_HDR_SIZE;
292     r = IStream_Read( stm, &data[ SECT_HDR_SIZE ], sz, &count );
293     if( SUCCEEDED(r) && count == sz )
294         read_properties_from_data( si->property, data, sz + SECT_HDR_SIZE );
295     else
296         ERR("failed to read properties %ld %ld\n", count, sz);
297
298     HeapFree( GetProcessHeap(), 0, data );
299     return ret;
300 }
301
302 static DWORD write_dword( LPBYTE data, DWORD ofs, DWORD val )
303 {
304     if( data )
305     {
306         data[ofs++] = val&0xff;
307         data[ofs++] = (val>>8)&0xff;
308         data[ofs++] = (val>>16)&0xff;
309         data[ofs++] = (val>>24)&0xff;
310     }
311     return 4;
312 }
313
314 static DWORD write_filetime( LPBYTE data, DWORD ofs, LPFILETIME ft )
315 {
316     write_dword( data, ofs, ft->dwLowDateTime );
317     write_dword( data, ofs + 4, ft->dwHighDateTime );
318     return 8;
319 }
320
321 static DWORD write_string( LPBYTE data, DWORD ofs, LPCSTR str )
322 {
323     DWORD len = lstrlenA( str ) + 1;
324     write_dword( data, ofs, len );
325     if( data )
326         lstrcpyA( &data[ofs + 4], str );
327     return (7 + len) & ~3;
328 }
329
330 static UINT write_property_to_data( PROPVARIANT *prop, LPBYTE data )
331 {
332     DWORD sz = 0;
333
334     if( prop->vt == VT_EMPTY )
335         return sz;
336
337     /* add the type */
338     sz += write_dword( data, sz, prop->vt );
339     switch( prop->vt )
340     {
341     case VT_I2:
342         sz += write_dword( data, sz, prop->u.iVal );
343         break;
344     case VT_I4:
345         sz += write_dword( data, sz, prop->u.lVal );
346         break;
347     case VT_FILETIME:
348         sz += write_filetime( data, sz, &prop->u.filetime );
349         break;
350     case VT_LPSTR:
351         sz += write_string( data, sz, prop->u.pszVal );
352         break;
353     }
354     return sz;
355 }
356
357 static UINT save_summary_info( MSISUMMARYINFO * si, IStream *stm )
358 {
359     UINT ret = ERROR_FUNCTION_FAILED;
360     PROPERTYSETHEADER set_hdr;
361     FORMATIDOFFSET format_hdr;
362     PROPERTYSECTIONHEADER section_hdr;
363     PROPERTYIDOFFSET idofs[MSI_MAX_PROPS];
364     LPBYTE data = NULL;
365     ULONG count, sz;
366     HRESULT r;
367     int i, n;
368
369     /* write the header */
370     sz = sizeof set_hdr;
371     memset( &set_hdr, 0, sz );
372     set_hdr.wByteOrder = 0xfffe;
373     set_hdr.wFormat = 0;
374     set_hdr.dwOSVer = 0x00020005; /* build 5, platform id 2 */
375     /* set_hdr.clsID is {00000000-0000-0000-0000-000000000000} */
376     set_hdr.reserved = 1;
377     r = IStream_Write( stm, &set_hdr, sz, &count );
378     if( FAILED(r) || count != sz )
379         return ret;
380
381     /* write the format header */
382     sz = sizeof format_hdr;
383     memcpy( &format_hdr.fmtid, &FMTID_SummaryInformation, sizeof (FMTID) );
384     format_hdr.dwOffset = sizeof format_hdr + sizeof set_hdr;
385     r = IStream_Write( stm, &format_hdr, sz, &count );
386     if( FAILED(r) || count != sz )
387         return ret;
388
389     /* add up how much space the data will take and calculate the offsets */
390     section_hdr.cbSection = sizeof section_hdr;
391     section_hdr.cbSection += (get_property_count( si->property ) * sizeof idofs[0]);
392     section_hdr.cProperties = 0;
393     n = 0;
394     for( i = 0; i < MSI_MAX_PROPS; i++ )
395     {
396         sz = write_property_to_data( &si->property[i], NULL );
397         if( !sz )
398             continue;
399         idofs[ section_hdr.cProperties ].propid = i;
400         idofs[ section_hdr.cProperties ].dwOffset = section_hdr.cbSection;
401         section_hdr.cProperties++;
402         section_hdr.cbSection += sz;
403     }
404
405     data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, section_hdr.cbSection );
406
407     sz = 0;
408     memcpy( &data[sz], &section_hdr, sizeof section_hdr );
409     sz += sizeof section_hdr;
410
411     memcpy( &data[sz], idofs, section_hdr.cProperties * sizeof idofs[0] );
412     sz += section_hdr.cProperties * sizeof idofs[0];
413
414     /* write out the data */
415     for( i = 0; i < MSI_MAX_PROPS; i++ )
416         sz += write_property_to_data( &si->property[i], &data[sz] );
417
418     r = IStream_Write( stm, data, sz, &count );
419     HeapFree( GetProcessHeap(), 0, data );
420     if( FAILED(r) || count != sz )
421         return ret;
422
423     return ERROR_SUCCESS;
424 }
425
426 UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase, 
427               LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle )
428 {
429     UINT ret = ERROR_SUCCESS;
430     IStream *stm = NULL;
431     MSISUMMARYINFO *si;
432     MSIHANDLE handle;
433     MSIDATABASE *db;
434     DWORD grfMode;
435     HRESULT r;
436
437     TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase),
438            uiUpdateCount, pHandle);
439
440     if( !pHandle )
441         return ERROR_INVALID_PARAMETER;
442
443     if( szDatabase )
444     {
445         UINT res;
446
447         res = MSI_OpenDatabaseW(szDatabase, NULL, &db);
448         if( res != ERROR_SUCCESS )
449             return res;
450     }
451     else
452     {
453         db = msihandle2msiinfo(hDatabase, MSIHANDLETYPE_DATABASE);
454         if( !db )
455             return ERROR_INVALID_PARAMETER;
456     }
457
458     si = alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO, 
459                   sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo );
460     if( !si )
461     {
462         ret = ERROR_FUNCTION_FAILED;
463         goto end;
464     }
465
466     msiobj_addref( &db->hdr );
467     si->db = db;
468     memset( &si->property, 0, sizeof si->property );
469     si->update_count = uiUpdateCount;
470
471     /* read the stream... if we fail, we'll start with an empty property set */
472     grfMode = STGM_READ | STGM_SHARE_EXCLUSIVE;
473     r = IStorage_OpenStream( si->db->storage, szSumInfo, 0, grfMode, 0, &stm );
474     if( SUCCEEDED(r) )
475     {
476         load_summary_info( si, stm );
477         IStream_Release( stm );
478     }
479
480     handle = alloc_msihandle( &si->hdr );
481     if( handle )
482         *pHandle = handle;
483     else
484         ret = ERROR_FUNCTION_FAILED;
485     msiobj_release( &si->hdr );
486
487 end:
488     if( db )
489         msiobj_release( &db->hdr );
490
491     return ret;
492 }
493
494 UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase, 
495               LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle)
496 {
497     LPWSTR szwDatabase = NULL;
498     UINT ret;
499
500     TRACE("%ld %s %d %p\n", hDatabase, debugstr_a(szDatabase), 
501           uiUpdateCount, pHandle);
502
503     if( szDatabase )
504     {
505         szwDatabase = strdupAtoW( szDatabase );
506         if( !szwDatabase )
507             return ERROR_FUNCTION_FAILED;
508     }
509
510     ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, pHandle);
511
512     HeapFree( GetProcessHeap(), 0, szwDatabase );
513
514     return ret;
515 }
516
517 UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, UINT *pCount)
518 {
519     MSISUMMARYINFO *si;
520
521     TRACE("%ld %p\n",hSummaryInfo, pCount);
522
523     si = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
524     if( !si )
525         return ERROR_INVALID_HANDLE;
526
527     if( pCount )
528         *pCount = get_property_count( si->property );
529     msiobj_release( &si->hdr );
530
531     return ERROR_SUCCESS;
532 }
533
534 static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
535           INT *piValue, FILETIME *pftValue, awstring *str, DWORD *pcchValueBuf)
536 {
537     MSISUMMARYINFO *si;
538     PROPVARIANT *prop;
539
540     TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
541           piValue, pftValue, str, pcchValueBuf);
542
543     si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
544     if( !si )
545         return ERROR_INVALID_HANDLE;
546
547     prop = &si->property[uiProperty];
548
549     if( puiDataType )
550         *puiDataType = prop->vt;
551
552     switch( prop->vt )
553     {
554     case VT_I2:
555         if( piValue )
556             *piValue = prop->u.iVal;
557         break;
558     case VT_I4:
559         if( piValue )
560             *piValue = prop->u.lVal;
561         break;
562     case VT_LPSTR:
563         if( pcchValueBuf )
564         {
565             DWORD len = 0;
566
567             if( str->unicode )
568             {
569                 len = MultiByteToWideChar( CP_ACP, 0, prop->u.pszVal, -1,
570                                            str->str.w, *pcchValueBuf );
571             }
572             else
573             {
574                 len = lstrlenA( prop->u.pszVal );
575                 if( str->str.a )
576                     lstrcpynA(str->str.a, prop->u.pszVal, *pcchValueBuf );
577             }
578             *pcchValueBuf = len;
579         }
580         break;
581     case VT_FILETIME:
582         if( pftValue )
583             memcpy(pftValue, &prop->u.filetime, sizeof (FILETIME) );
584         break;
585     case VT_EMPTY:
586         break;
587     default:
588         FIXME("Unknown property variant type\n");
589         break;
590     }
591     msiobj_release( &si->hdr );
592     return ERROR_SUCCESS;
593 }
594
595 UINT WINAPI MsiSummaryInfoGetPropertyA(
596       MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, INT *piValue,
597       FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf)
598 {
599     awstring str;
600
601     TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
602           piValue, pftValue, szValueBuf, pcchValueBuf );
603
604     str.unicode = FALSE;
605     str.str.a = szValueBuf;
606
607     return get_prop( handle, uiProperty, puiDataType, piValue,
608                      pftValue, &str, pcchValueBuf );
609 }
610
611 UINT WINAPI MsiSummaryInfoGetPropertyW(
612       MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, INT *piValue,
613       FILETIME *pftValue, LPWSTR szValueBuf, DWORD *pcchValueBuf)
614 {
615     awstring str;
616
617     TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
618           piValue, pftValue, szValueBuf, pcchValueBuf );
619
620     str.unicode = TRUE;
621     str.str.w = szValueBuf;
622
623     return get_prop( handle, uiProperty, puiDataType, piValue,
624                      pftValue, &str, pcchValueBuf );
625 }
626
627 static UINT set_prop( MSIHANDLE handle, UINT uiProperty, UINT uiDataType,
628                INT iValue, FILETIME* pftValue, awstring *str )
629 {
630     MSISUMMARYINFO *si;
631     PROPVARIANT *prop;
632     UINT type, len, ret = ERROR_SUCCESS;
633
634     TRACE("%ld %u %u %i %p %p\n", handle, uiProperty, uiDataType,
635           iValue, pftValue, str );
636
637     type = get_type( uiProperty );
638     if( type == VT_EMPTY || type != uiDataType )
639         return ERROR_DATATYPE_MISMATCH;
640
641     if( uiDataType == VT_LPSTR && !str->str.w )
642         return ERROR_INVALID_PARAMETER;
643
644     if( uiDataType == VT_FILETIME && !pftValue )
645         return ERROR_INVALID_PARAMETER;
646
647     si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
648     if( !si )
649         return ERROR_INVALID_HANDLE;
650
651     prop = &si->property[uiProperty];
652
653     if( prop->vt == VT_EMPTY )
654     {
655         if( !si->update_count )
656         {
657             ret = ERROR_FUNCTION_FAILED;
658             goto end;
659         }
660         si->update_count--;
661     }
662     else if( prop->vt != type )
663         goto end;
664
665     free_prop( prop );
666     prop->vt = type;
667     switch( type )
668     {
669     case VT_I4:
670         prop->u.lVal = iValue;
671         break;
672     case VT_I2:
673         prop->u.iVal = iValue;
674         break;
675     case VT_FILETIME:
676         memcpy( &prop->u.filetime, pftValue, sizeof prop->u.filetime );
677         break;
678     case VT_LPSTR:
679         if( str->unicode )
680         {
681             len = WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
682                                        NULL, 0, NULL, NULL );
683             prop->u.pszVal = HeapAlloc( GetProcessHeap(), 0, len );
684             WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
685                                  prop->u.pszVal, len, NULL, NULL );
686         }
687         else
688         {
689             len = lstrlenA( str->str.a ) + 1;
690             prop->u.pszVal = HeapAlloc( GetProcessHeap(), 0, len );
691             lstrcpyA( prop->u.pszVal, str->str.a );
692         }
693         break;
694     }
695
696 end:
697     msiobj_release( &si->hdr );
698     return ret;
699 }
700
701 UINT WINAPI MsiSummaryInfoSetPropertyW( MSIHANDLE handle, UINT uiProperty,
702                UINT uiDataType, INT iValue, FILETIME* pftValue, LPWSTR szValue )
703 {
704     awstring str;
705
706     TRACE("%ld %u %u %i %p %s\n", handle, uiProperty, uiDataType,
707           iValue, pftValue, debugstr_w(szValue) );
708
709     str.unicode = TRUE;
710     str.str.w = szValue;
711     return set_prop( handle, uiProperty, uiDataType, iValue, pftValue, &str );
712 }
713
714 UINT WINAPI MsiSummaryInfoSetPropertyA( MSIHANDLE handle, UINT uiProperty,
715                UINT uiDataType, INT iValue, FILETIME* pftValue, LPSTR szValue )
716 {
717     awstring str;
718
719     TRACE("%ld %u %u %i %p %s\n", handle, uiProperty, uiDataType,
720           iValue, pftValue, debugstr_a(szValue) );
721
722     str.unicode = FALSE;
723     str.str.a = szValue;
724     return set_prop( handle, uiProperty, uiDataType, iValue, pftValue, &str );
725 }
726
727 UINT WINAPI MsiSummaryInfoPersist( MSIHANDLE handle )
728 {
729     IStream *stm = NULL;
730     MSISUMMARYINFO *si;
731     DWORD grfMode;
732     HRESULT r;
733     UINT ret = ERROR_FUNCTION_FAILED;
734
735     TRACE("%ld\n", handle );
736
737     si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
738     if( !si )
739         return ERROR_INVALID_HANDLE;
740
741     grfMode = STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
742     r = IStorage_CreateStream( si->db->storage, szSumInfo, grfMode, 0, 0, &stm );
743     if( SUCCEEDED(r) )
744     {
745         ret = save_summary_info( si, stm );
746         IStream_Release( stm );
747     }
748     msiobj_release( &si->hdr );
749
750     return ret;
751 }