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