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