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