wintrust: Use helper function for setting confidence in SoftpubCheckCert.
[wine] / dlls / msi / msipriv.h
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2002-2005 Mike McCormack for CodeWeavers
5  * Copyright 2005 Aric Stewart for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #ifndef __WINE_MSI_PRIVATE__
23 #define __WINE_MSI_PRIVATE__
24
25 #include <stdarg.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "fdi.h"
30 #include "msi.h"
31 #include "msiquery.h"
32 #include "objbase.h"
33 #include "objidl.h"
34 #include "winnls.h"
35 #include "wine/list.h"
36 #include "wine/debug.h"
37
38 #define MSI_DATASIZEMASK 0x00ff
39 #define MSITYPE_VALID    0x0100
40 #define MSITYPE_LOCALIZABLE 0x200
41 #define MSITYPE_STRING   0x0800
42 #define MSITYPE_NULLABLE 0x1000
43 #define MSITYPE_KEY      0x2000
44 #define MSITYPE_TEMPORARY 0x4000
45
46
47 /* Install UI level mask for AND operation to exclude flags */
48 #define INSTALLUILEVEL_MASK             0x0007
49
50 #define MSITYPE_IS_BINARY(type) (((type) & ~MSITYPE_NULLABLE) == (MSITYPE_STRING|MSITYPE_VALID))
51
52 struct tagMSITABLE;
53 typedef struct tagMSITABLE MSITABLE;
54
55 struct string_table;
56 typedef struct string_table string_table;
57
58 struct tagMSIOBJECTHDR;
59 typedef struct tagMSIOBJECTHDR MSIOBJECTHDR;
60
61 typedef VOID (*msihandledestructor)( MSIOBJECTHDR * );
62
63 struct tagMSIOBJECTHDR
64 {
65     UINT magic;
66     UINT type;
67     LONG refcount;
68     msihandledestructor destructor;
69 };
70
71 typedef struct tagMSIDATABASE
72 {
73     MSIOBJECTHDR hdr;
74     IStorage *storage;
75     string_table *strings;
76     UINT bytes_per_strref;
77     LPWSTR path;
78     LPWSTR deletefile;
79     LPCWSTR mode;
80     struct list tables;
81     struct list transforms;
82 } MSIDATABASE;
83
84 typedef struct tagMSIVIEW MSIVIEW;
85
86 typedef struct tagMSIQUERY
87 {
88     MSIOBJECTHDR hdr;
89     MSIVIEW *view;
90     UINT row;
91     MSIDATABASE *db;
92     struct list mem;
93 } MSIQUERY;
94
95 /* maybe we can use a Variant instead of doing it ourselves? */
96 typedef struct tagMSIFIELD
97 {
98     UINT type;
99     union
100     {
101         INT iVal;
102         LPWSTR szwVal;
103         IStream *stream;
104     } u;
105 } MSIFIELD;
106
107 typedef struct tagMSIRECORD
108 {
109     MSIOBJECTHDR hdr;
110     UINT count;       /* as passed to MsiCreateRecord */
111     MSIFIELD fields[1]; /* nb. array size is count+1 */
112 } MSIRECORD;
113
114 typedef struct tagMSISOURCELISTINFO
115 {
116     struct list entry;
117     DWORD context;
118     DWORD options;
119     LPCWSTR property;
120     LPWSTR value;
121 } MSISOURCELISTINFO;
122
123 typedef struct tagMSIMEDIADISK
124 {
125     struct list entry;
126     DWORD context;
127     DWORD options;
128     DWORD disk_id;
129     LPWSTR volume_label;
130     LPWSTR disk_prompt;
131 } MSIMEDIADISK;
132
133 typedef struct tagMSIMEDIAINFO
134 {
135     UINT disk_id;
136     UINT type;
137     UINT last_sequence;
138     LPWSTR disk_prompt;
139     LPWSTR cabinet;
140     LPWSTR first_volume;
141     LPWSTR volume_label;
142     BOOL is_continuous;
143     BOOL is_extracted;
144     WCHAR source[MAX_PATH];
145 } MSIMEDIAINFO;
146
147 typedef struct _column_info
148 {
149     LPCWSTR table;
150     LPCWSTR column;
151     INT   type;
152     BOOL   temporary;
153     struct expr *val;
154     struct _column_info *next;
155 } column_info;
156
157 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
158
159 typedef struct tagMSIVIEWOPS
160 {
161     /*
162      * fetch_int - reads one integer from {row,col} in the table
163      *
164      *  This function should be called after the execute method.
165      *  Data returned by the function should not change until
166      *   close or delete is called.
167      *  To get a string value, query the database's string table with
168      *   the integer value returned from this function.
169      */
170     UINT (*fetch_int)( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val );
171
172     /*
173      * fetch_stream - gets a stream from {row,col} in the table
174      *
175      *  This function is similar to fetch_int, except fetches a
176      *    stream instead of an integer.
177      */
178     UINT (*fetch_stream)( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm );
179
180     /*
181      * get_row - gets values from a row
182      *
183      */
184     UINT (*get_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec );
185
186     /*
187      * set_row - sets values in a row as specified by mask
188      *
189      *  Similar semantics to fetch_int
190      */
191     UINT (*set_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask );
192
193     /*
194      * Inserts a new row into the database from the records contents
195      */
196     UINT (*insert_row)( struct tagMSIVIEW *view, MSIRECORD *record, BOOL temporary );
197
198     /*
199      * Deletes a row from the database
200      */
201     UINT (*delete_row)( struct tagMSIVIEW *view, UINT row );
202
203     /*
204      * execute - loads the underlying data into memory so it can be read
205      */
206     UINT (*execute)( struct tagMSIVIEW *view, MSIRECORD *record );
207
208     /*
209      * close - clears the data read by execute from memory
210      */
211     UINT (*close)( struct tagMSIVIEW *view );
212
213     /*
214      * get_dimensions - returns the number of rows or columns in a table.
215      *
216      *  The number of rows can only be queried after the execute method
217      *   is called. The number of columns can be queried at any time.
218      */
219     UINT (*get_dimensions)( struct tagMSIVIEW *view, UINT *rows, UINT *cols );
220
221     /*
222      * get_column_info - returns the name and type of a specific column
223      *
224      *  The name is HeapAlloc'ed by this function and should be freed by
225      *   the caller.
226      *  The column information can be queried at any time.
227      */
228     UINT (*get_column_info)( struct tagMSIVIEW *view, UINT n, LPWSTR *name, UINT *type );
229
230     /*
231      * modify - not yet implemented properly
232      */
233     UINT (*modify)( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *record, UINT row );
234
235     /*
236      * delete - destroys the structure completely
237      */
238     UINT (*delete)( struct tagMSIVIEW * );
239
240     /*
241      * find_matching_rows - iterates through rows that match a value
242      *
243      * If the column type is a string then a string ID should be passed in.
244      *  If the value to be looked up is an integer then no transformation of
245      *  the input value is required, except if the column is a string, in which
246      *  case a string ID should be passed in.
247      * The handle is an input/output parameter that keeps track of the current
248      *  position in the iteration. It must be initialised to zero before the
249      *  first call and continued to be passed in to subsequent calls.
250      */
251     UINT (*find_matching_rows)( struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle );
252
253     /*
254      * add_ref - increases the reference count of the table
255      */
256     UINT (*add_ref)( struct tagMSIVIEW *view );
257
258     /*
259      * release - decreases the reference count of the table
260      */
261     UINT (*release)( struct tagMSIVIEW *view );
262
263     /*
264      * add_column - adds a column to the table
265      */
266     UINT (*add_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number, LPCWSTR column, UINT type, BOOL hold );
267
268     /*
269      * remove_column - removes the column represented by table name and column number from the table
270      */
271     UINT (*remove_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number );
272
273     /*
274      * sort - orders the table by columns
275      */
276     UINT (*sort)( struct tagMSIVIEW *view, column_info *columns );
277 } MSIVIEWOPS;
278
279 struct tagMSIVIEW
280 {
281     MSIOBJECTHDR hdr;
282     const MSIVIEWOPS *ops;
283 };
284
285 struct msi_dialog_tag;
286 typedef struct msi_dialog_tag msi_dialog;
287
288 typedef struct tagMSIPACKAGE
289 {
290     MSIOBJECTHDR hdr;
291     MSIDATABASE *db;
292     struct list components;
293     struct list features;
294     struct list files;
295     struct list tempfiles;
296     struct list folders;
297     LPWSTR ActionFormat;
298     LPWSTR LastAction;
299
300     struct list classes;
301     struct list extensions;
302     struct list progids;
303     struct list mimes;
304     struct list appids;
305
306     struct tagMSISCRIPT *script;
307
308     struct list RunningActions;
309
310     LPWSTR BaseURL;
311     LPWSTR PackagePath;
312     LPWSTR ProductCode;
313
314     UINT CurrentInstallState;
315     msi_dialog *dialog;
316     LPWSTR next_dialog;
317     float center_x;
318     float center_y;
319
320     UINT WordCount;
321     UINT Context;
322
323     struct list subscriptions;
324
325     struct list sourcelist_info;
326     struct list sourcelist_media;
327
328     unsigned char scheduled_action_running : 1;
329     unsigned char commit_action_running : 1;
330     unsigned char rollback_action_running : 1;
331 } MSIPACKAGE;
332
333 typedef struct tagMSIPREVIEW
334 {
335     MSIOBJECTHDR hdr;
336     MSIPACKAGE *package;
337     msi_dialog *dialog;
338 } MSIPREVIEW;
339
340 #define MSI_MAX_PROPS 20
341
342 typedef struct tagMSISUMMARYINFO
343 {
344     MSIOBJECTHDR hdr;
345     IStorage *storage;
346     DWORD update_count;
347     PROPVARIANT property[MSI_MAX_PROPS];
348 } MSISUMMARYINFO;
349
350 typedef struct tagMSIFEATURE
351 {
352     struct list entry;
353     LPWSTR Feature;
354     LPWSTR Feature_Parent;
355     LPWSTR Title;
356     LPWSTR Description;
357     INT Display;
358     INT Level;
359     LPWSTR Directory;
360     INT Attributes;
361     INSTALLSTATE Installed;
362     INSTALLSTATE ActionRequest;
363     INSTALLSTATE Action;
364     struct list Children;
365     struct list Components;
366     INT Cost;
367 } MSIFEATURE;
368
369 typedef struct tagMSICOMPONENT
370 {
371     struct list entry;
372     DWORD magic;
373     LPWSTR Component;
374     LPWSTR ComponentId;
375     LPWSTR Directory;
376     INT Attributes;
377     LPWSTR Condition;
378     LPWSTR KeyPath;
379     INSTALLSTATE Installed;
380     INSTALLSTATE ActionRequest;
381     INSTALLSTATE Action;
382     BOOL ForceLocalState;
383     BOOL Enabled;
384     INT  Cost;
385     INT  RefCount;
386     LPWSTR FullKeypath;
387     LPWSTR AdvertiseString;
388
389     unsigned int anyAbsent:1;
390     unsigned int hasAdvertiseFeature:1;
391     unsigned int hasLocalFeature:1;
392     unsigned int hasSourceFeature:1;
393 } MSICOMPONENT;
394
395 typedef struct tagComponentList
396 {
397     struct list entry;
398     MSICOMPONENT *component;
399 } ComponentList;
400
401 typedef struct tagFeatureList
402 {
403     struct list entry;
404     MSIFEATURE *feature;
405 } FeatureList;
406
407 typedef struct tagMSIFOLDER
408 {
409     struct list entry;
410     LPWSTR Directory;
411     LPWSTR Parent;
412     LPWSTR TargetDefault;
413     LPWSTR SourceLongPath;
414     LPWSTR SourceShortPath;
415
416     LPWSTR ResolvedTarget;
417     LPWSTR ResolvedSource;
418     LPWSTR Property;   /* initially set property */
419     INT   State;
420         /* 0 = uninitialized */
421         /* 1 = existing */
422         /* 2 = created remove if empty */
423         /* 3 = created persist if empty */
424     INT   Cost;
425     INT   Space;
426 } MSIFOLDER;
427
428 typedef enum _msi_file_state {
429     msifs_invalid,
430     msifs_missing,
431     msifs_overwrite,
432     msifs_present,
433     msifs_installed,
434     msifs_skipped,
435 } msi_file_state;
436
437 typedef struct tagMSIFILE
438 {
439     struct list entry;
440     LPWSTR File;
441     MSICOMPONENT *Component;
442     LPWSTR FileName;
443     LPWSTR ShortName;
444     LPWSTR LongName;
445     INT FileSize;
446     LPWSTR Version;
447     LPWSTR Language;
448     INT Attributes;
449     INT Sequence;
450     msi_file_state state;
451     LPWSTR  SourcePath;
452     LPWSTR  TargetPath;
453     BOOL IsCompressed;
454     MSIFILEHASHINFO hash;
455 } MSIFILE;
456
457 typedef struct tagMSITEMPFILE
458 {
459     struct list entry;
460     LPWSTR Path;
461 } MSITEMPFILE;
462
463 typedef struct tagMSIAPPID
464 {
465     struct list entry;
466     LPWSTR AppID; /* Primary key */
467     LPWSTR RemoteServerName;
468     LPWSTR LocalServer;
469     LPWSTR ServiceParameters;
470     LPWSTR DllSurrogate;
471     BOOL ActivateAtStorage;
472     BOOL RunAsInteractiveUser;
473 } MSIAPPID;
474
475 typedef struct tagMSIPROGID MSIPROGID;
476
477 typedef struct tagMSICLASS
478 {
479     struct list entry;
480     LPWSTR clsid;     /* Primary Key */
481     LPWSTR Context;   /* Primary Key */
482     MSICOMPONENT *Component;
483     MSIPROGID *ProgID;
484     LPWSTR ProgIDText;
485     LPWSTR Description;
486     MSIAPPID *AppID;
487     LPWSTR FileTypeMask;
488     LPWSTR IconPath;
489     LPWSTR DefInprocHandler;
490     LPWSTR DefInprocHandler32;
491     LPWSTR Argument;
492     MSIFEATURE *Feature;
493     INT Attributes;
494     /* not in the table, set during installation */
495     BOOL Installed;
496 } MSICLASS;
497
498 typedef struct tagMSIMIME MSIMIME;
499
500 typedef struct tagMSIEXTENSION
501 {
502     struct list entry;
503     LPWSTR Extension;  /* Primary Key */
504     MSICOMPONENT *Component;
505     MSIPROGID *ProgID;
506     LPWSTR ProgIDText;
507     MSIMIME *Mime;
508     MSIFEATURE *Feature;
509     /* not in the table, set during installation */
510     BOOL Installed;
511     struct list verbs;
512 } MSIEXTENSION;
513
514 struct tagMSIPROGID
515 {
516     struct list entry;
517     LPWSTR ProgID;  /* Primary Key */
518     MSIPROGID *Parent;
519     MSICLASS *Class;
520     LPWSTR Description;
521     LPWSTR IconPath;
522     /* not in the table, set during installation */
523     BOOL InstallMe;
524     MSIPROGID *CurVer;
525     MSIPROGID *VersionInd;
526 };
527
528 typedef struct tagMSIVERB
529 {
530     struct list entry;
531     LPWSTR Verb;
532     INT Sequence;
533     LPWSTR Command;
534     LPWSTR Argument;
535 } MSIVERB;
536
537 struct tagMSIMIME
538 {
539     struct list entry;
540     LPWSTR ContentType;  /* Primary Key */
541     MSIEXTENSION *Extension;
542     LPWSTR clsid;
543     MSICLASS *Class;
544     /* not in the table, set during installation */
545     BOOL InstallMe;
546 };
547
548 enum SCRIPTS {
549     INSTALL_SCRIPT = 0,
550     COMMIT_SCRIPT = 1,
551     ROLLBACK_SCRIPT = 2,
552     TOTAL_SCRIPTS = 3
553 };
554
555 #define SEQUENCE_UI       0x1
556 #define SEQUENCE_EXEC     0x2
557 #define SEQUENCE_INSTALL  0x10
558
559 typedef struct tagMSISCRIPT
560 {
561     LPWSTR  *Actions[TOTAL_SCRIPTS];
562     UINT    ActionCount[TOTAL_SCRIPTS];
563     BOOL    ExecuteSequenceRun;
564     BOOL    CurrentlyScripting;
565     UINT    InWhatSequence;
566     LPWSTR  *UniqueActions;
567     UINT    UniqueActionsCount;
568 } MSISCRIPT;
569
570 #define MSIHANDLETYPE_ANY 0
571 #define MSIHANDLETYPE_DATABASE 1
572 #define MSIHANDLETYPE_SUMMARYINFO 2
573 #define MSIHANDLETYPE_VIEW 3
574 #define MSIHANDLETYPE_RECORD 4
575 #define MSIHANDLETYPE_PACKAGE 5
576 #define MSIHANDLETYPE_PREVIEW 6
577
578 #define MSI_MAJORVERSION 3
579 #define MSI_MINORVERSION 1
580 #define MSI_BUILDNUMBER 4000
581
582 #define GUID_SIZE 39
583 #define SQUISH_GUID_SIZE 33
584
585 #define MSIHANDLE_MAGIC 0x4d434923
586
587 DEFINE_GUID(CLSID_IMsiServer,   0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
588 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
589 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
590 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
591
592 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
593
594 DEFINE_GUID(CLSID_IWineMsiRemoteCustomAction,0xBA26E6FA,0x4F27,0x4f56,0x95,0x3A,0x3F,0x90,0x27,0x20,0x18,0xAA);
595 DEFINE_GUID(CLSID_IWineMsiRemotePackage,0x902b3592,0x9d08,0x4dfd,0xa5,0x93,0xd0,0x7c,0x52,0x54,0x64,0x21);
596
597 /* handle unicode/ascii output in the Msi* API functions */
598 typedef struct {
599     BOOL unicode;
600     union {
601        LPSTR a;
602        LPWSTR w;
603     } str;
604 } awstring;
605
606 typedef struct {
607     BOOL unicode;
608     union {
609        LPCSTR a;
610        LPCWSTR w;
611     } str;
612 } awcstring;
613
614 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
615
616 /* msi server interface */
617 extern ITypeLib *get_msi_typelib( LPWSTR *path );
618 extern HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj );
619 extern HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj );
620 extern HRESULT create_msi_remote_database( IUnknown *pOuter, LPVOID *ppObj );
621 extern IUnknown *msi_get_remote(MSIHANDLE handle);
622
623 /* handle functions */
624 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
625 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
626 extern MSIHANDLE alloc_msi_remote_handle( IUnknown *unk );
627 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
628 extern void msiobj_addref(MSIOBJECTHDR *);
629 extern int msiobj_release(MSIOBJECTHDR *);
630 extern void msiobj_lock(MSIOBJECTHDR *);
631 extern void msiobj_unlock(MSIOBJECTHDR *);
632 extern void msi_free_handle_table(void);
633
634 extern void free_cached_tables( MSIDATABASE *db );
635 extern void msi_free_transforms( MSIDATABASE *db );
636 extern UINT MSI_CommitTables( MSIDATABASE *db );
637
638
639 /* string table functions */
640 enum StringPersistence
641 {
642     StringPersistent = 0,
643     StringNonPersistent = 1
644 };
645
646 extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
647 extern UINT msi_id2stringW( const string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
648 extern UINT msi_id2stringA( const string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
649
650 extern UINT msi_string2idW( const string_table *st, LPCWSTR buffer, UINT *id );
651 extern UINT msi_string2idA( const string_table *st, LPCSTR str, UINT *id );
652 extern VOID msi_destroy_stringtable( string_table *st );
653 extern UINT msi_strcmp( const string_table *st, UINT lval, UINT rval, UINT *res );
654 extern const WCHAR *msi_string_lookup_id( const string_table *st, UINT id );
655 extern HRESULT msi_init_string_table( IStorage *stg );
656 extern string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref );
657 extern UINT msi_save_string_table( const string_table *st, IStorage *storage );
658
659 extern BOOL TABLE_Exists( MSIDATABASE *db, LPCWSTR name );
660 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
661
662 extern UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname,
663                                   USHORT **pdata, UINT *psz );
664 extern UINT read_stream_data( IStorage *stg, LPCWSTR stname, BOOL table,
665                               BYTE **pdata, UINT *psz );
666 extern UINT write_stream_data( IStorage *stg, LPCWSTR stname,
667                                LPCVOID data, UINT sz, BOOL bTable );
668
669 /* transform functions */
670 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
671 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
672                  LPCWSTR szTransformFile, int iErrorCond );
673 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
674
675 /* action internals */
676 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
677 extern void ACTION_free_package_structures( MSIPACKAGE* );
678 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
679 extern UINT ACTION_ForceReboot(MSIPACKAGE *package);
680 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
681 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
682 extern UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine );
683
684 /* record internals */
685 extern UINT MSI_RecordSetIStream( MSIRECORD *, UINT, IStream *);
686 extern UINT MSI_RecordGetIStream( MSIRECORD *, UINT, IStream **);
687 extern const WCHAR *MSI_RecordGetString( const MSIRECORD *, UINT );
688 extern MSIRECORD *MSI_CreateRecord( UINT );
689 extern UINT MSI_RecordSetInteger( MSIRECORD *, UINT, int );
690 extern UINT MSI_RecordSetStringW( MSIRECORD *, UINT, LPCWSTR );
691 extern UINT MSI_RecordSetStringA( MSIRECORD *, UINT, LPCSTR );
692 extern BOOL MSI_RecordIsNull( MSIRECORD *, UINT );
693 extern UINT MSI_RecordGetStringW( MSIRECORD * , UINT, LPWSTR, LPDWORD);
694 extern UINT MSI_RecordGetStringA( MSIRECORD *, UINT, LPSTR, LPDWORD);
695 extern int MSI_RecordGetInteger( MSIRECORD *, UINT );
696 extern UINT MSI_RecordReadStream( MSIRECORD *, UINT, char *, LPDWORD);
697 extern UINT MSI_RecordGetFieldCount( const MSIRECORD *rec );
698 extern UINT MSI_RecordSetStream( MSIRECORD *, UINT, IStream * );
699 extern UINT MSI_RecordDataSize( MSIRECORD *, UINT );
700 extern UINT MSI_RecordStreamToFile( MSIRECORD *, UINT, LPCWSTR );
701 extern UINT MSI_RecordCopyField( MSIRECORD *, UINT, MSIRECORD *, UINT );
702
703 /* stream internals */
704 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
705 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
706 extern void enum_stream_names( IStorage *stg );
707 extern BOOL decode_streamname(LPCWSTR in, LPWSTR out);
708 extern LPWSTR encode_streamname(BOOL bTable, LPCWSTR in);
709
710 /* database internals */
711 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
712 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
713 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
714 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
715 extern UINT MSI_IterateRecords( MSIQUERY *, LPDWORD, record_func, LPVOID );
716 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
717 extern UINT MSI_DatabaseImport( MSIDATABASE *, LPCWSTR, LPCWSTR );
718 extern UINT MSI_DatabaseExport( MSIDATABASE *, LPCWSTR, LPCWSTR, LPCWSTR );
719 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
720
721 /* view internals */
722 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
723 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
724 extern UINT MSI_ViewClose( MSIQUERY* );
725 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
726 extern UINT MSI_ViewModify( MSIQUERY *, MSIMODIFY, MSIRECORD * );
727 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, UINT * );
728 extern UINT msi_view_get_row(MSIDATABASE *, MSIVIEW *, UINT, MSIRECORD **);
729
730 /* install internals */
731 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
732
733 /* package internals */
734 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPCWSTR );
735 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage );
736 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
737 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
738 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
739 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, LPDWORD );
740 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, LPDWORD );
741 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
742 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
743 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
744 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
745 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
746 extern UINT msi_package_add_info(MSIPACKAGE *, DWORD, DWORD, LPCWSTR, LPWSTR);
747 extern UINT msi_package_add_media_disk(MSIPACKAGE *, DWORD, DWORD, DWORD, LPWSTR, LPWSTR);
748 extern UINT msi_clone_properties(MSIPACKAGE *);
749
750 /* for deformating */
751 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, LPDWORD );
752
753 /* registry data encoding/decoding functions */
754 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
755 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
756 extern BOOL encode_base85_guid(GUID *,LPWSTR);
757 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
758 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
759 extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
760 extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
761 extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
762 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
763 extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
764 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
765 extern UINT MSIREG_OpenLocalUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
766 extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
767 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
768 extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
769 extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
770 extern UINT MSIREG_OpenLocalUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
771 extern UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
772 extern UINT MSIREG_OpenLocalSystemInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
773 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
774 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
775 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
776 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
777 extern UINT MSIREG_DeleteProductKey(LPCWSTR szProduct);
778 extern UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct);
779 extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct);
780 extern UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
781 extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
782 extern UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
783 extern UINT MSIREG_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
784 extern UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
785 extern UINT MSIREG_OpenManagedFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
786 extern UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
787 extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
788 extern UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent);
789 extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent);
790 extern UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode);
791 extern UINT MSIREG_OpenClassesUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create);
792 extern UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode);
793 extern UINT MSIREG_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode);
794
795 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
796 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
797
798 extern DWORD msi_version_str_to_dword(LPCWSTR p);
799 extern LPWSTR msi_version_dword_to_str(DWORD version);
800
801 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
802 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
803 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
804 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
805
806 /* msi dialog interface */
807 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
808 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
809 extern UINT msi_dialog_run_message_loop( msi_dialog* );
810 extern void msi_dialog_end_dialog( msi_dialog* );
811 extern void msi_dialog_check_messages( HANDLE );
812 extern void msi_dialog_do_preview( msi_dialog* );
813 extern void msi_dialog_destroy( msi_dialog* );
814 extern BOOL msi_dialog_register_class( void );
815 extern void msi_dialog_unregister_class( void );
816 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
817 extern UINT msi_dialog_reset( msi_dialog *dialog );
818 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
819 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
820 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
821 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
822
823 /* preview */
824 extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
825 extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
826
827 /* summary information */
828 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
829 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
830 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
831
832 /* undocumented functions */
833 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
834 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, LPDWORD );
835 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, LPDWORD );
836 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
837 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
838
839 /* UI globals */
840 extern INSTALLUILEVEL gUILevel;
841 extern HWND gUIhwnd;
842 extern INSTALLUI_HANDLERA gUIHandlerA;
843 extern INSTALLUI_HANDLERW gUIHandlerW;
844 extern DWORD gUIFilter;
845 extern LPVOID gUIContext;
846 extern WCHAR gszLogFile[MAX_PATH];
847 extern HINSTANCE msi_hInstance;
848
849 /* action related functions */
850 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script, BOOL force);
851 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action, UINT script);
852 extern void ACTION_FinishCustomActions( const MSIPACKAGE* package);
853 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, UINT script, BOOL execute);
854
855 static inline void msi_feature_set_state(MSIPACKAGE *package,
856                                          MSIFEATURE *feature,
857                                          INSTALLSTATE state)
858 {
859     if (!package->ProductCode)
860     {
861         feature->ActionRequest = state;
862         feature->Action = state;
863     }
864     else if (state == INSTALLSTATE_ABSENT)
865     {
866         switch (feature->Installed)
867         {
868             case INSTALLSTATE_ABSENT:
869                 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
870                 feature->Action = INSTALLSTATE_UNKNOWN;
871                 break;
872             default:
873                 feature->ActionRequest = state;
874                 feature->Action = state;
875         }
876     }
877     else if (state == INSTALLSTATE_SOURCE)
878     {
879         switch (feature->Installed)
880         {
881             case INSTALLSTATE_ABSENT:
882             case INSTALLSTATE_SOURCE:
883                 feature->ActionRequest = state;
884                 feature->Action = state;
885                 break;
886             case INSTALLSTATE_LOCAL:
887                 feature->ActionRequest = INSTALLSTATE_LOCAL;
888                 feature->Action = INSTALLSTATE_LOCAL;
889                 break;
890             default:
891                 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
892                 feature->Action = INSTALLSTATE_UNKNOWN;
893         }
894     }
895     else
896     {
897         feature->ActionRequest = state;
898         feature->Action = state;
899     }
900 }
901
902 static inline void msi_component_set_state(MSIPACKAGE *package,
903                                            MSICOMPONENT *comp,
904                                            INSTALLSTATE state)
905 {
906     if (!package->ProductCode)
907     {
908         comp->ActionRequest = state;
909         comp->Action = state;
910     }
911     else if (state == INSTALLSTATE_ABSENT)
912     {
913         switch (comp->Installed)
914         {
915             case INSTALLSTATE_LOCAL:
916             case INSTALLSTATE_SOURCE:
917             case INSTALLSTATE_DEFAULT:
918                 comp->ActionRequest = state;
919                 comp->Action = state;
920                 break;
921             default:
922                 comp->ActionRequest = INSTALLSTATE_UNKNOWN;
923                 comp->Action = INSTALLSTATE_UNKNOWN;
924         }
925     }
926     else if (state == INSTALLSTATE_SOURCE)
927     {
928         if (comp->Installed == INSTALLSTATE_ABSENT ||
929             (comp->Installed == INSTALLSTATE_SOURCE && comp->hasLocalFeature))
930         {
931             comp->ActionRequest = state;
932             comp->Action = state;
933         }
934         else
935         {
936             comp->ActionRequest = INSTALLSTATE_UNKNOWN;
937             comp->Action = INSTALLSTATE_UNKNOWN;
938         }
939     }
940     else
941     {
942         comp->ActionRequest = state;
943         comp->Action = state;
944     }
945 }
946
947 /* actions in other modules */
948 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
949 extern UINT ACTION_CCPSearch(MSIPACKAGE *package);
950 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
951 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
952 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
953 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
954 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
955 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
956 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
957 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
958 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
959
960 /* Helpers */
961 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
962 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
963 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
964 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
965 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
966                       BOOL set_prop, BOOL load_prop, MSIFOLDER **folder);
967 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
968 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
969 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
970 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
971 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
972 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
973 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
974 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
975 extern LPWSTR build_directory_name(DWORD , ...);
976 extern BOOL create_full_pathW(const WCHAR *path);
977 extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE);
978 extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE);
979 extern void reduce_to_longfilename(WCHAR*);
980 extern void reduce_to_shortfilename(WCHAR*);
981 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
982 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
983 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
984 extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
985 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
986 extern UINT msi_create_component_directories( MSIPACKAGE *package );
987 extern void msi_ui_error( DWORD msg_id, DWORD type );
988 extern UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
989                         MSIINSTALLCONTEXT context, DWORD options, LPCWSTR value);
990
991 /* media */
992
993 typedef BOOL (*PMSICABEXTRACTCB)(MSIPACKAGE *, LPCWSTR, DWORD, LPWSTR *, DWORD *, PVOID);
994
995 #define MSICABEXTRACT_BEGINEXTRACT  0x01
996 #define MSICABEXTRACT_FILEEXTRACTED 0x02
997
998 typedef struct
999 {
1000     MSIPACKAGE* package;
1001     MSIMEDIAINFO *mi;
1002     PMSICABEXTRACTCB cb;
1003     LPWSTR curfile;
1004     PVOID user;
1005 } MSICABDATA;
1006
1007 extern UINT ready_media(MSIPACKAGE *package, MSIFILE *file, MSIMEDIAINFO *mi);
1008 extern UINT msi_load_media_info(MSIPACKAGE *package, MSIFILE *file, MSIMEDIAINFO *mi);
1009 extern void msi_free_media_info(MSIMEDIAINFO *mi);
1010 extern BOOL msi_cabextract(MSIPACKAGE* package, MSIMEDIAINFO *mi, LPVOID data);
1011 extern UINT find_published_source(MSIPACKAGE *package, MSIMEDIAINFO *mi);
1012
1013 /* control event stuff */
1014 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
1015                                       MSIRECORD *data);
1016 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
1017 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
1018 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
1019                                       LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
1020 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
1021                                       LPCWSTR control, LPCWSTR attribute );
1022
1023 /* OLE automation */
1024 extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj);
1025 extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch);
1026 extern HRESULT load_type_info(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid);
1027
1028 /* Scripting */
1029 extern DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action);
1030
1031 /* User Interface messages from the actions */
1032 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
1033 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
1034
1035 /* string consts use a number of places  and defined in helpers.c*/
1036 extern const WCHAR cszSourceDir[];
1037 extern const WCHAR cszSOURCEDIR[];
1038 extern const WCHAR szProductCode[];
1039 extern const WCHAR cszRootDrive[];
1040 extern const WCHAR cszbs[];
1041
1042 /* memory allocation macro functions */
1043 static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
1044 static inline void *msi_alloc( size_t len )
1045 {
1046     return HeapAlloc( GetProcessHeap(), 0, len );
1047 }
1048
1049 static void *msi_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
1050 static inline void *msi_alloc_zero( size_t len )
1051 {
1052     return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
1053 }
1054
1055 static void *msi_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
1056 static inline void *msi_realloc( void *mem, size_t len )
1057 {
1058     return HeapReAlloc( GetProcessHeap(), 0, mem, len );
1059 }
1060
1061 static void *msi_realloc_zero( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
1062 static inline void *msi_realloc_zero( void *mem, size_t len )
1063 {
1064     return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
1065 }
1066
1067 static inline BOOL msi_free( void *mem )
1068 {
1069     return HeapFree( GetProcessHeap(), 0, mem );
1070 }
1071
1072 static inline char *strdupWtoA( LPCWSTR str )
1073 {
1074     LPSTR ret = NULL;
1075     DWORD len;
1076
1077     if (!str) return ret;
1078     len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
1079     ret = msi_alloc( len );
1080     if (ret)
1081         WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
1082     return ret;
1083 }
1084
1085 static inline LPWSTR strdupAtoW( LPCSTR str )
1086 {
1087     LPWSTR ret = NULL;
1088     DWORD len;
1089
1090     if (!str) return ret;
1091     len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
1092     ret = msi_alloc( len * sizeof(WCHAR) );
1093     if (ret)
1094         MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
1095     return ret;
1096 }
1097
1098 static inline LPWSTR strdupW( LPCWSTR src )
1099 {
1100     LPWSTR dest;
1101     if (!src) return NULL;
1102     dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
1103     if (dest)
1104         lstrcpyW(dest, src);
1105     return dest;
1106 }
1107
1108 #endif /* __WINE_MSI_PRIVATE__ */