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