2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002-2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
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.
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.
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
22 #ifndef __WINE_MSI_PRIVATE__
23 #define __WINE_MSI_PRIVATE__
35 #include "wine/list.h"
36 #include "wine/debug.h"
38 #define MSI_DATASIZEMASK 0x00ff
39 #define MSITYPE_VALID 0x0100
40 #define MSITYPE_LOCALIZABLE 0x200
41 #define MSITYPE_STRING 0x0800
42 #define MSITYPE_NULLABLE 0x1000
43 #define MSITYPE_KEY 0x2000
44 #define MSITYPE_TEMPORARY 0x4000
47 /* Install UI level mask for AND operation to exclude flags */
48 #define INSTALLUILEVEL_MASK 0x0007
50 #define MSITYPE_IS_BINARY(type) (((type) & ~MSITYPE_NULLABLE) == (MSITYPE_STRING|MSITYPE_VALID))
53 typedef struct tagMSITABLE MSITABLE;
56 typedef struct string_table string_table;
58 struct tagMSIOBJECTHDR;
59 typedef struct tagMSIOBJECTHDR MSIOBJECTHDR;
61 typedef VOID (*msihandledestructor)( MSIOBJECTHDR * );
63 struct tagMSIOBJECTHDR
68 msihandledestructor destructor;
71 typedef struct tagMSIDATABASE
75 string_table *strings;
76 UINT bytes_per_strref;
81 struct list transforms;
84 typedef struct tagMSIVIEW MSIVIEW;
86 typedef struct tagMSIQUERY
95 /* maybe we can use a Variant instead of doing it ourselves? */
96 typedef struct tagMSIFIELD
107 typedef struct tagMSIRECORD
110 UINT count; /* as passed to MsiCreateRecord */
111 MSIFIELD fields[1]; /* nb. array size is count+1 */
114 typedef struct tagMSISOURCELISTINFO
123 typedef struct tagMSIMEDIADISK
133 typedef struct tagMSIMEDIAINFO
144 WCHAR source[MAX_PATH];
147 typedef struct _column_info
154 struct _column_info *next;
157 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
159 typedef struct tagMSIVIEWOPS
162 * fetch_int - reads one integer from {row,col} in the table
164 * This function should be called after the execute method.
165 * Data returned by the function should not change until
166 * close or delete is called.
167 * To get a string value, query the database's string table with
168 * the integer value returned from this function.
170 UINT (*fetch_int)( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val );
173 * fetch_stream - gets a stream from {row,col} in the table
175 * This function is similar to fetch_int, except fetches a
176 * stream instead of an integer.
178 UINT (*fetch_stream)( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm );
181 * get_row - gets values from a row
184 UINT (*get_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec );
187 * set_row - sets values in a row as specified by mask
189 * Similar semantics to fetch_int
191 UINT (*set_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask );
194 * Inserts a new row into the database from the records contents
196 UINT (*insert_row)( struct tagMSIVIEW *view, MSIRECORD *record, BOOL temporary );
199 * Deletes a row from the database
201 UINT (*delete_row)( struct tagMSIVIEW *view, UINT row );
204 * execute - loads the underlying data into memory so it can be read
206 UINT (*execute)( struct tagMSIVIEW *view, MSIRECORD *record );
209 * close - clears the data read by execute from memory
211 UINT (*close)( struct tagMSIVIEW *view );
214 * get_dimensions - returns the number of rows or columns in a table.
216 * The number of rows can only be queried after the execute method
217 * is called. The number of columns can be queried at any time.
219 UINT (*get_dimensions)( struct tagMSIVIEW *view, UINT *rows, UINT *cols );
222 * get_column_info - returns the name and type of a specific column
224 * The name is HeapAlloc'ed by this function and should be freed by
226 * The column information can be queried at any time.
228 UINT (*get_column_info)( struct tagMSIVIEW *view, UINT n, LPWSTR *name, UINT *type );
231 * modify - not yet implemented properly
233 UINT (*modify)( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *record, UINT row );
236 * delete - destroys the structure completely
238 UINT (*delete)( struct tagMSIVIEW * );
241 * find_matching_rows - iterates through rows that match a value
243 * If the column type is a string then a string ID should be passed in.
244 * If the value to be looked up is an integer then no transformation of
245 * the input value is required, except if the column is a string, in which
246 * case a string ID should be passed in.
247 * The handle is an input/output parameter that keeps track of the current
248 * position in the iteration. It must be initialised to zero before the
249 * first call and continued to be passed in to subsequent calls.
251 UINT (*find_matching_rows)( struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle );
254 * add_ref - increases the reference count of the table
256 UINT (*add_ref)( struct tagMSIVIEW *view );
259 * release - decreases the reference count of the table
261 UINT (*release)( struct tagMSIVIEW *view );
264 * add_column - adds a column to the table
266 UINT (*add_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number, LPCWSTR column, UINT type, BOOL hold );
269 * remove_column - removes the column represented by table name and column number from the table
271 UINT (*remove_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number );
274 * sort - orders the table by columns
276 UINT (*sort)( struct tagMSIVIEW *view, column_info *columns );
279 * drop - drops the table from the database
281 UINT (*drop)( struct tagMSIVIEW *view );
287 const MSIVIEWOPS *ops;
290 struct msi_dialog_tag;
291 typedef struct msi_dialog_tag msi_dialog;
293 typedef struct tagMSIPACKAGE
297 struct list components;
298 struct list features;
300 struct list tempfiles;
306 struct list extensions;
311 struct tagMSISCRIPT *script;
313 struct list RunningActions;
319 UINT CurrentInstallState;
328 struct list subscriptions;
330 struct list sourcelist_info;
331 struct list sourcelist_media;
333 unsigned char scheduled_action_running : 1;
334 unsigned char commit_action_running : 1;
335 unsigned char rollback_action_running : 1;
338 typedef struct tagMSIPREVIEW
345 #define MSI_MAX_PROPS 20
347 typedef struct tagMSISUMMARYINFO
352 PROPVARIANT property[MSI_MAX_PROPS];
355 typedef struct tagMSIFEATURE
359 LPWSTR Feature_Parent;
366 INSTALLSTATE Installed;
367 INSTALLSTATE ActionRequest;
369 struct list Children;
370 struct list Components;
374 typedef struct tagMSICOMPONENT
384 INSTALLSTATE Installed;
385 INSTALLSTATE ActionRequest;
387 BOOL ForceLocalState;
392 LPWSTR AdvertiseString;
394 unsigned int anyAbsent:1;
395 unsigned int hasAdvertiseFeature:1;
396 unsigned int hasLocalFeature:1;
397 unsigned int hasSourceFeature:1;
400 typedef struct tagComponentList
403 MSICOMPONENT *component;
406 typedef struct tagFeatureList
412 typedef struct tagMSIFOLDER
417 LPWSTR TargetDefault;
418 LPWSTR SourceLongPath;
419 LPWSTR SourceShortPath;
421 LPWSTR ResolvedTarget;
422 LPWSTR ResolvedSource;
423 LPWSTR Property; /* initially set property */
425 /* 0 = uninitialized */
427 /* 2 = created remove if empty */
428 /* 3 = created persist if empty */
433 typedef enum _msi_file_state {
442 typedef struct tagMSIFILE
446 MSICOMPONENT *Component;
455 msi_file_state state;
458 MSIFILEHASHINFO hash;
461 typedef struct tagMSITEMPFILE
467 typedef struct tagMSIAPPID
470 LPWSTR AppID; /* Primary key */
471 LPWSTR RemoteServerName;
473 LPWSTR ServiceParameters;
475 BOOL ActivateAtStorage;
476 BOOL RunAsInteractiveUser;
479 typedef struct tagMSIPROGID MSIPROGID;
481 typedef struct tagMSICLASS
484 LPWSTR clsid; /* Primary Key */
485 LPWSTR Context; /* Primary Key */
486 MSICOMPONENT *Component;
493 LPWSTR DefInprocHandler;
494 LPWSTR DefInprocHandler32;
498 /* not in the table, set during installation */
502 typedef struct tagMSIMIME MSIMIME;
504 typedef struct tagMSIEXTENSION
507 LPWSTR Extension; /* Primary Key */
508 MSICOMPONENT *Component;
513 /* not in the table, set during installation */
521 LPWSTR ProgID; /* Primary Key */
526 /* not in the table, set during installation */
529 MSIPROGID *VersionInd;
532 typedef struct tagMSIVERB
544 LPWSTR ContentType; /* Primary Key */
545 MSIEXTENSION *Extension;
548 /* not in the table, set during installation */
559 #define SEQUENCE_UI 0x1
560 #define SEQUENCE_EXEC 0x2
561 #define SEQUENCE_INSTALL 0x10
563 typedef struct tagMSISCRIPT
565 LPWSTR *Actions[TOTAL_SCRIPTS];
566 UINT ActionCount[TOTAL_SCRIPTS];
567 BOOL ExecuteSequenceRun;
568 BOOL CurrentlyScripting;
570 LPWSTR *UniqueActions;
571 UINT UniqueActionsCount;
574 #define MSIHANDLETYPE_ANY 0
575 #define MSIHANDLETYPE_DATABASE 1
576 #define MSIHANDLETYPE_SUMMARYINFO 2
577 #define MSIHANDLETYPE_VIEW 3
578 #define MSIHANDLETYPE_RECORD 4
579 #define MSIHANDLETYPE_PACKAGE 5
580 #define MSIHANDLETYPE_PREVIEW 6
582 #define MSI_MAJORVERSION 3
583 #define MSI_MINORVERSION 1
584 #define MSI_BUILDNUMBER 4000
587 #define SQUISH_GUID_SIZE 33
589 #define MSIHANDLE_MAGIC 0x4d434923
591 DEFINE_GUID(CLSID_IMsiServer, 0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
592 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
593 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
594 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
596 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
598 DEFINE_GUID(CLSID_IWineMsiRemoteCustomAction,0xBA26E6FA,0x4F27,0x4f56,0x95,0x3A,0x3F,0x90,0x27,0x20,0x18,0xAA);
599 DEFINE_GUID(CLSID_IWineMsiRemotePackage,0x902b3592,0x9d08,0x4dfd,0xa5,0x93,0xd0,0x7c,0x52,0x54,0x64,0x21);
601 /* handle unicode/ascii output in the Msi* API functions */
618 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
620 /* msi server interface */
621 extern ITypeLib *get_msi_typelib( LPWSTR *path );
622 extern HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj );
623 extern HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj );
624 extern HRESULT create_msi_remote_database( IUnknown *pOuter, LPVOID *ppObj );
625 extern IUnknown *msi_get_remote(MSIHANDLE handle);
627 /* handle functions */
628 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
629 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
630 extern MSIHANDLE alloc_msi_remote_handle( IUnknown *unk );
631 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
632 extern void msiobj_addref(MSIOBJECTHDR *);
633 extern int msiobj_release(MSIOBJECTHDR *);
634 extern void msiobj_lock(MSIOBJECTHDR *);
635 extern void msiobj_unlock(MSIOBJECTHDR *);
636 extern void msi_free_handle_table(void);
638 extern void free_cached_tables( MSIDATABASE *db );
639 extern void msi_free_transforms( MSIDATABASE *db );
640 extern UINT MSI_CommitTables( MSIDATABASE *db );
643 /* string table functions */
644 enum StringPersistence
646 StringPersistent = 0,
647 StringNonPersistent = 1
650 extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
651 extern UINT msi_id2stringW( const string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
652 extern UINT msi_id2stringA( const string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
654 extern UINT msi_string2idW( const string_table *st, LPCWSTR buffer, UINT *id );
655 extern UINT msi_string2idA( const string_table *st, LPCSTR str, UINT *id );
656 extern VOID msi_destroy_stringtable( string_table *st );
657 extern UINT msi_strcmp( const string_table *st, UINT lval, UINT rval, UINT *res );
658 extern const WCHAR *msi_string_lookup_id( const string_table *st, UINT id );
659 extern HRESULT msi_init_string_table( IStorage *stg );
660 extern string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref );
661 extern UINT msi_save_string_table( const string_table *st, IStorage *storage );
663 extern BOOL TABLE_Exists( MSIDATABASE *db, LPCWSTR name );
664 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
666 extern UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname,
667 USHORT **pdata, UINT *psz );
668 extern UINT read_stream_data( IStorage *stg, LPCWSTR stname, BOOL table,
669 BYTE **pdata, UINT *psz );
670 extern UINT write_stream_data( IStorage *stg, LPCWSTR stname,
671 LPCVOID data, UINT sz, BOOL bTable );
673 /* transform functions */
674 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
675 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
676 LPCWSTR szTransformFile, int iErrorCond );
677 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
679 /* action internals */
680 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
681 extern void ACTION_free_package_structures( MSIPACKAGE* );
682 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
683 extern UINT ACTION_ForceReboot(MSIPACKAGE *package);
684 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
685 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
686 extern UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine );
688 /* record internals */
689 extern UINT MSI_RecordSetIStream( MSIRECORD *, UINT, IStream *);
690 extern UINT MSI_RecordGetIStream( MSIRECORD *, UINT, IStream **);
691 extern const WCHAR *MSI_RecordGetString( const MSIRECORD *, UINT );
692 extern MSIRECORD *MSI_CreateRecord( UINT );
693 extern UINT MSI_RecordSetInteger( MSIRECORD *, UINT, int );
694 extern UINT MSI_RecordSetStringW( MSIRECORD *, UINT, LPCWSTR );
695 extern UINT MSI_RecordSetStringA( MSIRECORD *, UINT, LPCSTR );
696 extern BOOL MSI_RecordIsNull( MSIRECORD *, UINT );
697 extern UINT MSI_RecordGetStringW( MSIRECORD * , UINT, LPWSTR, LPDWORD);
698 extern UINT MSI_RecordGetStringA( MSIRECORD *, UINT, LPSTR, LPDWORD);
699 extern int MSI_RecordGetInteger( MSIRECORD *, UINT );
700 extern UINT MSI_RecordReadStream( MSIRECORD *, UINT, char *, LPDWORD);
701 extern UINT MSI_RecordGetFieldCount( const MSIRECORD *rec );
702 extern UINT MSI_RecordSetStream( MSIRECORD *, UINT, IStream * );
703 extern UINT MSI_RecordDataSize( MSIRECORD *, UINT );
704 extern UINT MSI_RecordStreamToFile( MSIRECORD *, UINT, LPCWSTR );
705 extern UINT MSI_RecordCopyField( MSIRECORD *, UINT, MSIRECORD *, UINT );
707 /* stream internals */
708 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
709 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
710 extern void enum_stream_names( IStorage *stg );
711 extern BOOL decode_streamname(LPCWSTR in, LPWSTR out);
712 extern LPWSTR encode_streamname(BOOL bTable, LPCWSTR in);
714 /* database internals */
715 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
716 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
717 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
718 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
719 extern UINT MSI_IterateRecords( MSIQUERY *, LPDWORD, record_func, LPVOID );
720 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
721 extern UINT MSI_DatabaseImport( MSIDATABASE *, LPCWSTR, LPCWSTR );
722 extern UINT MSI_DatabaseExport( MSIDATABASE *, LPCWSTR, LPCWSTR, LPCWSTR );
723 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
726 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
727 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
728 extern UINT MSI_ViewClose( MSIQUERY* );
729 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
730 extern UINT MSI_ViewModify( MSIQUERY *, MSIMODIFY, MSIRECORD * );
731 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, UINT * );
732 extern UINT msi_view_get_row(MSIDATABASE *, MSIVIEW *, UINT, MSIRECORD **);
734 /* install internals */
735 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
737 /* package internals */
738 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPCWSTR );
739 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage );
740 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
741 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
742 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
743 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, LPDWORD );
744 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, LPDWORD );
745 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
746 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
747 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
748 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
749 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
750 extern UINT msi_package_add_info(MSIPACKAGE *, DWORD, DWORD, LPCWSTR, LPWSTR);
751 extern UINT msi_package_add_media_disk(MSIPACKAGE *, DWORD, DWORD, DWORD, LPWSTR, LPWSTR);
752 extern UINT msi_clone_properties(MSIPACKAGE *);
754 /* for deformating */
755 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, LPDWORD );
757 /* registry data encoding/decoding functions */
758 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
759 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
760 extern BOOL encode_base85_guid(GUID *,LPWSTR);
761 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
762 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
763 extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
764 extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
765 extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
766 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
767 extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
768 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
769 extern UINT MSIREG_OpenLocalUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
770 extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
771 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
772 extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
773 extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
774 extern UINT MSIREG_OpenLocalUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
775 extern UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
776 extern UINT MSIREG_OpenLocalSystemInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
777 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
778 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
779 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
780 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
781 extern UINT MSIREG_DeleteProductKey(LPCWSTR szProduct);
782 extern UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct);
783 extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct);
784 extern UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
785 extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
786 extern UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
787 extern UINT MSIREG_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
788 extern UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
789 extern UINT MSIREG_OpenManagedFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
790 extern UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
791 extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
792 extern UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent);
793 extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent);
794 extern UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode);
795 extern UINT MSIREG_OpenClassesUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create);
796 extern UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode);
797 extern UINT MSIREG_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode);
799 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
800 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
802 extern DWORD msi_version_str_to_dword(LPCWSTR p);
803 extern LPWSTR msi_version_dword_to_str(DWORD version);
805 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
806 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
807 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
808 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
810 /* msi dialog interface */
811 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
812 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
813 extern UINT msi_dialog_run_message_loop( msi_dialog* );
814 extern void msi_dialog_end_dialog( msi_dialog* );
815 extern void msi_dialog_check_messages( HANDLE );
816 extern void msi_dialog_do_preview( msi_dialog* );
817 extern void msi_dialog_destroy( msi_dialog* );
818 extern BOOL msi_dialog_register_class( void );
819 extern void msi_dialog_unregister_class( void );
820 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
821 extern UINT msi_dialog_reset( msi_dialog *dialog );
822 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
823 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
824 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
825 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
828 extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
829 extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
831 /* summary information */
832 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
833 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
834 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
836 /* undocumented functions */
837 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
838 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, LPDWORD );
839 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, LPDWORD );
840 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
841 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
844 extern INSTALLUILEVEL gUILevel;
846 extern INSTALLUI_HANDLERA gUIHandlerA;
847 extern INSTALLUI_HANDLERW gUIHandlerW;
848 extern DWORD gUIFilter;
849 extern LPVOID gUIContext;
850 extern WCHAR gszLogFile[MAX_PATH];
851 extern HINSTANCE msi_hInstance;
853 /* action related functions */
854 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script, BOOL force);
855 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action, UINT script);
856 extern void ACTION_FinishCustomActions( const MSIPACKAGE* package);
857 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, UINT script, BOOL execute);
859 static inline void msi_feature_set_state(MSIPACKAGE *package,
863 if (!package->ProductCode)
865 feature->ActionRequest = state;
866 feature->Action = state;
868 else if (state == INSTALLSTATE_ABSENT)
870 switch (feature->Installed)
872 case INSTALLSTATE_ABSENT:
873 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
874 feature->Action = INSTALLSTATE_UNKNOWN;
877 feature->ActionRequest = state;
878 feature->Action = state;
881 else if (state == INSTALLSTATE_SOURCE)
883 switch (feature->Installed)
885 case INSTALLSTATE_ABSENT:
886 case INSTALLSTATE_SOURCE:
887 feature->ActionRequest = state;
888 feature->Action = state;
890 case INSTALLSTATE_LOCAL:
891 feature->ActionRequest = INSTALLSTATE_LOCAL;
892 feature->Action = INSTALLSTATE_LOCAL;
895 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
896 feature->Action = INSTALLSTATE_UNKNOWN;
901 feature->ActionRequest = state;
902 feature->Action = state;
906 static inline void msi_component_set_state(MSIPACKAGE *package,
910 if (!package->ProductCode)
912 comp->ActionRequest = state;
913 comp->Action = state;
915 else if (state == INSTALLSTATE_ABSENT)
917 switch (comp->Installed)
919 case INSTALLSTATE_LOCAL:
920 case INSTALLSTATE_SOURCE:
921 case INSTALLSTATE_DEFAULT:
922 comp->ActionRequest = state;
923 comp->Action = state;
926 comp->ActionRequest = INSTALLSTATE_UNKNOWN;
927 comp->Action = INSTALLSTATE_UNKNOWN;
930 else if (state == INSTALLSTATE_SOURCE)
932 if (comp->Installed == INSTALLSTATE_ABSENT ||
933 (comp->Installed == INSTALLSTATE_SOURCE && comp->hasLocalFeature))
935 comp->ActionRequest = state;
936 comp->Action = state;
940 comp->ActionRequest = INSTALLSTATE_UNKNOWN;
941 comp->Action = INSTALLSTATE_UNKNOWN;
946 comp->ActionRequest = state;
947 comp->Action = state;
951 /* actions in other modules */
952 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
953 extern UINT ACTION_CCPSearch(MSIPACKAGE *package);
954 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
955 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
956 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
957 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
958 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
959 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
960 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
961 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
962 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
965 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
966 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
967 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
968 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
969 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
970 BOOL set_prop, BOOL load_prop, MSIFOLDER **folder);
971 extern LPWSTR resolve_file_source(MSIPACKAGE *package, MSIFILE *file);
972 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
973 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
974 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
975 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
976 extern void msi_reset_folders( MSIPACKAGE *package, BOOL source );
977 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
978 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
979 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
980 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
981 extern LPWSTR build_directory_name(DWORD , ...);
982 extern BOOL create_full_pathW(const WCHAR *path);
983 extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE);
984 extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE);
985 extern void reduce_to_longfilename(WCHAR*);
986 extern void reduce_to_shortfilename(WCHAR*);
987 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
988 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
989 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
990 extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
991 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
992 extern UINT msi_create_component_directories( MSIPACKAGE *package );
993 extern void msi_ui_error( DWORD msg_id, DWORD type );
994 extern UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
995 MSIINSTALLCONTEXT context, DWORD options, LPCWSTR value);
999 typedef BOOL (*PMSICABEXTRACTCB)(MSIPACKAGE *, LPCWSTR, DWORD, LPWSTR *, DWORD *, PVOID);
1001 #define MSICABEXTRACT_BEGINEXTRACT 0x01
1002 #define MSICABEXTRACT_FILEEXTRACTED 0x02
1006 MSIPACKAGE* package;
1008 PMSICABEXTRACTCB cb;
1013 extern UINT ready_media(MSIPACKAGE *package, MSIFILE *file, MSIMEDIAINFO *mi);
1014 extern UINT msi_load_media_info(MSIPACKAGE *package, MSIFILE *file, MSIMEDIAINFO *mi);
1015 extern void msi_free_media_info(MSIMEDIAINFO *mi);
1016 extern BOOL msi_cabextract(MSIPACKAGE* package, MSIMEDIAINFO *mi, LPVOID data);
1017 extern UINT find_published_source(MSIPACKAGE *package, MSIMEDIAINFO *mi);
1019 /* control event stuff */
1020 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
1022 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
1023 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
1024 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
1025 LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
1026 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
1027 LPCWSTR control, LPCWSTR attribute );
1029 /* OLE automation */
1030 extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj);
1031 extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch);
1032 extern HRESULT load_type_info(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid);
1035 extern DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action);
1037 /* User Interface messages from the actions */
1038 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
1039 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
1041 /* string consts use a number of places and defined in helpers.c*/
1042 extern const WCHAR cszSourceDir[];
1043 extern const WCHAR cszSOURCEDIR[];
1044 extern const WCHAR szProductCode[];
1045 extern const WCHAR cszRootDrive[];
1046 extern const WCHAR cszbs[];
1048 /* memory allocation macro functions */
1049 static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
1050 static inline void *msi_alloc( size_t len )
1052 return HeapAlloc( GetProcessHeap(), 0, len );
1055 static void *msi_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
1056 static inline void *msi_alloc_zero( size_t len )
1058 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
1061 static void *msi_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
1062 static inline void *msi_realloc( void *mem, size_t len )
1064 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
1067 static void *msi_realloc_zero( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
1068 static inline void *msi_realloc_zero( void *mem, size_t len )
1070 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
1073 static inline BOOL msi_free( void *mem )
1075 return HeapFree( GetProcessHeap(), 0, mem );
1078 static inline char *strdupWtoA( LPCWSTR str )
1083 if (!str) return ret;
1084 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
1085 ret = msi_alloc( len );
1087 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
1091 static inline LPWSTR strdupAtoW( LPCSTR str )
1096 if (!str) return ret;
1097 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
1098 ret = msi_alloc( len * sizeof(WCHAR) );
1100 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
1104 static inline LPWSTR strdupW( LPCWSTR src )
1107 if (!src) return NULL;
1108 dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
1110 lstrcpyW(dest, src);
1114 #endif /* __WINE_MSI_PRIVATE__ */