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