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