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