push 283761c2088bbce3f1b27f01dcb83707e81913bc
[wine/hacks.git] / dlls / msi / msipriv.h
blob19d0b0d3fd587207389e164f4c8ec53b77892645
1 /*
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__
25 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "fdi.h"
30 #include "msi.h"
31 #include "msiquery.h"
32 #include "objbase.h"
33 #include "objidl.h"
34 #include "winnls.h"
35 #include "wine/list.h"
37 #define MSI_DATASIZEMASK 0x00ff
38 #define MSITYPE_VALID 0x0100
39 #define MSITYPE_LOCALIZABLE 0x200
40 #define MSITYPE_STRING 0x0800
41 #define MSITYPE_NULLABLE 0x1000
42 #define MSITYPE_KEY 0x2000
43 #define MSITYPE_TEMPORARY 0x4000
45 /* Word Count masks */
46 #define MSIWORDCOUNT_SHORTFILENAMES 0x0001
47 #define MSIWORDCOUNT_COMPRESSED 0x0002
48 #define MSIWORDCOUNT_ADMINISTRATIVE 0x0004
49 #define MSIWORDCOUNT_PRIVILEGES 0x0008
51 /* Install UI level mask for AND operation to exclude flags */
52 #define INSTALLUILEVEL_MASK 0x0007
54 #define MSITYPE_IS_BINARY(type) (((type) & ~MSITYPE_NULLABLE) == (MSITYPE_STRING|MSITYPE_VALID))
56 struct tagMSITABLE;
57 typedef struct tagMSITABLE MSITABLE;
59 struct string_table;
60 typedef struct string_table string_table;
62 struct tagMSIOBJECTHDR;
63 typedef struct tagMSIOBJECTHDR MSIOBJECTHDR;
65 typedef VOID (*msihandledestructor)( MSIOBJECTHDR * );
67 struct tagMSIOBJECTHDR
69 UINT magic;
70 UINT type;
71 LONG refcount;
72 msihandledestructor destructor;
75 typedef struct tagMSIDATABASE
77 MSIOBJECTHDR hdr;
78 IStorage *storage;
79 string_table *strings;
80 UINT bytes_per_strref;
81 LPWSTR path;
82 LPWSTR deletefile;
83 LPCWSTR mode;
84 struct list tables;
85 struct list transforms;
86 } MSIDATABASE;
88 typedef struct tagMSIVIEW MSIVIEW;
90 typedef struct tagMSIQUERY
92 MSIOBJECTHDR hdr;
93 MSIVIEW *view;
94 UINT row;
95 MSIDATABASE *db;
96 struct list mem;
97 } MSIQUERY;
99 /* maybe we can use a Variant instead of doing it ourselves? */
100 typedef struct tagMSIFIELD
102 UINT type;
103 union
105 INT iVal;
106 LPWSTR szwVal;
107 IStream *stream;
108 } u;
109 } MSIFIELD;
111 typedef struct tagMSIRECORD
113 MSIOBJECTHDR hdr;
114 UINT count; /* as passed to MsiCreateRecord */
115 MSIFIELD fields[1]; /* nb. array size is count+1 */
116 } MSIRECORD;
118 typedef struct tagMSISOURCELISTINFO
120 struct list entry;
121 DWORD context;
122 DWORD options;
123 LPCWSTR property;
124 LPWSTR value;
125 } MSISOURCELISTINFO;
127 typedef struct tagMSIMEDIADISK
129 struct list entry;
130 DWORD context;
131 DWORD options;
132 DWORD disk_id;
133 LPWSTR volume_label;
134 LPWSTR disk_prompt;
135 } MSIMEDIADISK;
137 typedef struct tagMSIMEDIAINFO
139 UINT disk_id;
140 UINT type;
141 UINT last_sequence;
142 LPWSTR disk_prompt;
143 LPWSTR cabinet;
144 LPWSTR first_volume;
145 LPWSTR volume_label;
146 BOOL is_continuous;
147 BOOL is_extracted;
148 WCHAR source[MAX_PATH];
149 } MSIMEDIAINFO;
151 typedef struct _column_info
153 LPCWSTR table;
154 LPCWSTR column;
155 INT type;
156 BOOL temporary;
157 struct expr *val;
158 struct _column_info *next;
159 } column_info;
161 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
163 typedef struct tagMSIVIEWOPS
166 * fetch_int - reads one integer from {row,col} in the table
168 * This function should be called after the execute method.
169 * Data returned by the function should not change until
170 * close or delete is called.
171 * To get a string value, query the database's string table with
172 * the integer value returned from this function.
174 UINT (*fetch_int)( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val );
177 * fetch_stream - gets a stream from {row,col} in the table
179 * This function is similar to fetch_int, except fetches a
180 * stream instead of an integer.
182 UINT (*fetch_stream)( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm );
185 * get_row - gets values from a row
188 UINT (*get_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec );
191 * set_row - sets values in a row as specified by mask
193 * Similar semantics to fetch_int
195 UINT (*set_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask );
198 * Inserts a new row into the database from the records contents
200 UINT (*insert_row)( struct tagMSIVIEW *view, MSIRECORD *record, BOOL temporary );
203 * Deletes a row from the database
205 UINT (*delete_row)( struct tagMSIVIEW *view, UINT row );
208 * execute - loads the underlying data into memory so it can be read
210 UINT (*execute)( struct tagMSIVIEW *view, MSIRECORD *record );
213 * close - clears the data read by execute from memory
215 UINT (*close)( struct tagMSIVIEW *view );
218 * get_dimensions - returns the number of rows or columns in a table.
220 * The number of rows can only be queried after the execute method
221 * is called. The number of columns can be queried at any time.
223 UINT (*get_dimensions)( struct tagMSIVIEW *view, UINT *rows, UINT *cols );
226 * get_column_info - returns the name and type of a specific column
228 * The name is HeapAlloc'ed by this function and should be freed by
229 * the caller.
230 * The column information can be queried at any time.
232 UINT (*get_column_info)( struct tagMSIVIEW *view, UINT n, LPWSTR *name, UINT *type );
235 * modify - not yet implemented properly
237 UINT (*modify)( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *record, UINT row );
240 * delete - destroys the structure completely
242 UINT (*delete)( struct tagMSIVIEW * );
245 * find_matching_rows - iterates through rows that match a value
247 * If the column type is a string then a string ID should be passed in.
248 * If the value to be looked up is an integer then no transformation of
249 * the input value is required, except if the column is a string, in which
250 * case a string ID should be passed in.
251 * The handle is an input/output parameter that keeps track of the current
252 * position in the iteration. It must be initialised to zero before the
253 * first call and continued to be passed in to subsequent calls.
255 UINT (*find_matching_rows)( struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle );
258 * add_ref - increases the reference count of the table
260 UINT (*add_ref)( struct tagMSIVIEW *view );
263 * release - decreases the reference count of the table
265 UINT (*release)( struct tagMSIVIEW *view );
268 * add_column - adds a column to the table
270 UINT (*add_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number, LPCWSTR column, UINT type, BOOL hold );
273 * remove_column - removes the column represented by table name and column number from the table
275 UINT (*remove_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number );
278 * sort - orders the table by columns
280 UINT (*sort)( struct tagMSIVIEW *view, column_info *columns );
281 } MSIVIEWOPS;
283 struct tagMSIVIEW
285 MSIOBJECTHDR hdr;
286 const MSIVIEWOPS *ops;
289 struct msi_dialog_tag;
290 typedef struct msi_dialog_tag msi_dialog;
292 typedef struct tagMSIPACKAGE
294 MSIOBJECTHDR hdr;
295 MSIDATABASE *db;
296 struct list components;
297 struct list features;
298 struct list files;
299 struct list tempfiles;
300 struct list folders;
301 LPWSTR ActionFormat;
302 LPWSTR LastAction;
304 struct list classes;
305 struct list extensions;
306 struct list progids;
307 struct list mimes;
308 struct list appids;
310 struct tagMSISCRIPT *script;
312 struct list RunningActions;
314 LPWSTR BaseURL;
315 LPWSTR PackagePath;
316 LPWSTR ProductCode;
318 UINT CurrentInstallState;
319 msi_dialog *dialog;
320 LPWSTR next_dialog;
321 float center_x;
322 float center_y;
324 UINT WordCount;
325 UINT Context;
327 struct list subscriptions;
329 struct list sourcelist_info;
330 struct list sourcelist_media;
332 unsigned char scheduled_action_running : 1;
333 unsigned char commit_action_running : 1;
334 unsigned char rollback_action_running : 1;
335 } MSIPACKAGE;
337 typedef struct tagMSIPREVIEW
339 MSIOBJECTHDR hdr;
340 MSIPACKAGE *package;
341 msi_dialog *dialog;
342 } MSIPREVIEW;
344 #define MSI_MAX_PROPS 20
346 typedef struct tagMSISUMMARYINFO
348 MSIOBJECTHDR hdr;
349 IStorage *storage;
350 DWORD update_count;
351 PROPVARIANT property[MSI_MAX_PROPS];
352 } MSISUMMARYINFO;
354 typedef struct tagMSIFEATURE
356 struct list entry;
357 LPWSTR Feature;
358 LPWSTR Feature_Parent;
359 LPWSTR Title;
360 LPWSTR Description;
361 INT Display;
362 INT Level;
363 LPWSTR Directory;
364 INT Attributes;
365 INSTALLSTATE Installed;
366 INSTALLSTATE ActionRequest;
367 INSTALLSTATE Action;
368 struct list Children;
369 struct list Components;
370 INT Cost;
371 } MSIFEATURE;
373 typedef struct tagMSICOMPONENT
375 struct list entry;
376 DWORD magic;
377 LPWSTR Component;
378 LPWSTR ComponentId;
379 LPWSTR Directory;
380 INT Attributes;
381 LPWSTR Condition;
382 LPWSTR KeyPath;
383 INSTALLSTATE Installed;
384 INSTALLSTATE ActionRequest;
385 INSTALLSTATE Action;
386 BOOL ForceLocalState;
387 BOOL Enabled;
388 INT Cost;
389 INT RefCount;
390 LPWSTR FullKeypath;
391 LPWSTR AdvertiseString;
393 unsigned int anyAbsent:1;
394 unsigned int hasAdvertiseFeature:1;
395 unsigned int hasLocalFeature:1;
396 unsigned int hasSourceFeature:1;
397 } MSICOMPONENT;
399 typedef struct tagComponentList
401 struct list entry;
402 MSICOMPONENT *component;
403 } ComponentList;
405 typedef struct tagFeatureList
407 struct list entry;
408 MSIFEATURE *feature;
409 } FeatureList;
411 typedef struct tagMSIFOLDER
413 struct list entry;
414 LPWSTR Directory;
415 LPWSTR Parent;
416 LPWSTR TargetDefault;
417 LPWSTR SourceLongPath;
418 LPWSTR SourceShortPath;
420 LPWSTR ResolvedTarget;
421 LPWSTR ResolvedSource;
422 LPWSTR Property; /* initially set property */
423 INT State;
424 /* 0 = uninitialized */
425 /* 1 = existing */
426 /* 2 = created remove if empty */
427 /* 3 = created persist if empty */
428 INT Cost;
429 INT Space;
430 } MSIFOLDER;
432 typedef enum _msi_file_state {
433 msifs_invalid,
434 msifs_missing,
435 msifs_overwrite,
436 msifs_present,
437 msifs_installed,
438 msifs_skipped,
439 } msi_file_state;
441 typedef struct tagMSIFILE
443 struct list entry;
444 LPWSTR File;
445 MSICOMPONENT *Component;
446 LPWSTR FileName;
447 LPWSTR ShortName;
448 LPWSTR LongName;
449 INT FileSize;
450 LPWSTR Version;
451 LPWSTR Language;
452 INT Attributes;
453 INT Sequence;
454 msi_file_state state;
455 LPWSTR SourcePath;
456 LPWSTR TargetPath;
457 BOOL IsCompressed;
458 MSIFILEHASHINFO hash;
459 } MSIFILE;
461 typedef struct tagMSITEMPFILE
463 struct list entry;
464 LPWSTR Path;
465 } MSITEMPFILE;
467 typedef struct tagMSIAPPID
469 struct list entry;
470 LPWSTR AppID; /* Primary key */
471 LPWSTR RemoteServerName;
472 LPWSTR LocalServer;
473 LPWSTR ServiceParameters;
474 LPWSTR DllSurrogate;
475 BOOL ActivateAtStorage;
476 BOOL RunAsInteractiveUser;
477 } MSIAPPID;
479 typedef struct tagMSIPROGID MSIPROGID;
481 typedef struct tagMSICLASS
483 struct list entry;
484 LPWSTR clsid; /* Primary Key */
485 LPWSTR Context; /* Primary Key */
486 MSICOMPONENT *Component;
487 MSIPROGID *ProgID;
488 LPWSTR ProgIDText;
489 LPWSTR Description;
490 MSIAPPID *AppID;
491 LPWSTR FileTypeMask;
492 LPWSTR IconPath;
493 LPWSTR DefInprocHandler;
494 LPWSTR DefInprocHandler32;
495 LPWSTR Argument;
496 MSIFEATURE *Feature;
497 INT Attributes;
498 /* not in the table, set during installation */
499 BOOL Installed;
500 } MSICLASS;
502 typedef struct tagMSIMIME MSIMIME;
504 typedef struct tagMSIEXTENSION
506 struct list entry;
507 LPWSTR Extension; /* Primary Key */
508 MSICOMPONENT *Component;
509 MSIPROGID *ProgID;
510 LPWSTR ProgIDText;
511 MSIMIME *Mime;
512 MSIFEATURE *Feature;
513 /* not in the table, set during installation */
514 BOOL Installed;
515 struct list verbs;
516 } MSIEXTENSION;
518 struct tagMSIPROGID
520 struct list entry;
521 LPWSTR ProgID; /* Primary Key */
522 MSIPROGID *Parent;
523 MSICLASS *Class;
524 LPWSTR Description;
525 LPWSTR IconPath;
526 /* not in the table, set during installation */
527 BOOL InstallMe;
528 MSIPROGID *CurVer;
529 MSIPROGID *VersionInd;
532 typedef struct tagMSIVERB
534 struct list entry;
535 LPWSTR Verb;
536 INT Sequence;
537 LPWSTR Command;
538 LPWSTR Argument;
539 } MSIVERB;
541 struct tagMSIMIME
543 struct list entry;
544 LPWSTR ContentType; /* Primary Key */
545 MSIEXTENSION *Extension;
546 LPWSTR clsid;
547 MSICLASS *Class;
548 /* not in the table, set during installation */
549 BOOL InstallMe;
552 enum SCRIPTS {
553 INSTALL_SCRIPT = 0,
554 COMMIT_SCRIPT = 1,
555 ROLLBACK_SCRIPT = 2,
556 TOTAL_SCRIPTS = 3
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;
569 UINT InWhatSequence;
570 LPWSTR *UniqueActions;
571 UINT UniqueActionsCount;
572 } MSISCRIPT;
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
586 #define GUID_SIZE 39
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 */
602 typedef struct {
603 BOOL unicode;
604 union {
605 LPSTR a;
606 LPWSTR w;
607 } str;
608 } awstring;
610 typedef struct {
611 BOOL unicode;
612 union {
613 LPCSTR a;
614 LPCWSTR w;
615 } str;
616 } awcstring;
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 );
664 extern void msi_table_set_strref(UINT bytes_per_strref);
665 extern BOOL TABLE_Exists( MSIDATABASE *db, LPCWSTR name );
666 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
668 extern UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname,
669 USHORT **pdata, UINT *psz );
670 extern UINT read_stream_data( IStorage *stg, LPCWSTR stname, BOOL table,
671 BYTE **pdata, UINT *psz );
672 extern UINT write_stream_data( IStorage *stg, LPCWSTR stname,
673 LPCVOID data, UINT sz, BOOL bTable );
675 /* transform functions */
676 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
677 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
678 LPCWSTR szTransformFile, int iErrorCond );
679 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
681 /* action internals */
682 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
683 extern void ACTION_free_package_structures( MSIPACKAGE* );
684 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
685 extern UINT ACTION_ForceReboot(MSIPACKAGE *package);
686 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
687 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
688 extern UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine );
690 /* record internals */
691 extern UINT MSI_RecordSetIStream( MSIRECORD *, UINT, IStream *);
692 extern UINT MSI_RecordGetIStream( MSIRECORD *, UINT, IStream **);
693 extern const WCHAR *MSI_RecordGetString( const MSIRECORD *, UINT );
694 extern MSIRECORD *MSI_CreateRecord( UINT );
695 extern UINT MSI_RecordSetInteger( MSIRECORD *, UINT, int );
696 extern UINT MSI_RecordSetStringW( MSIRECORD *, UINT, LPCWSTR );
697 extern UINT MSI_RecordSetStringA( MSIRECORD *, UINT, LPCSTR );
698 extern BOOL MSI_RecordIsNull( MSIRECORD *, UINT );
699 extern UINT MSI_RecordGetStringW( MSIRECORD * , UINT, LPWSTR, LPDWORD);
700 extern UINT MSI_RecordGetStringA( MSIRECORD *, UINT, LPSTR, LPDWORD);
701 extern int MSI_RecordGetInteger( MSIRECORD *, UINT );
702 extern UINT MSI_RecordReadStream( MSIRECORD *, UINT, char *, LPDWORD);
703 extern UINT MSI_RecordGetFieldCount( const MSIRECORD *rec );
704 extern UINT MSI_RecordSetStream( MSIRECORD *, UINT, IStream * );
705 extern UINT MSI_RecordDataSize( MSIRECORD *, UINT );
706 extern UINT MSI_RecordStreamToFile( MSIRECORD *, UINT, LPCWSTR );
707 extern UINT MSI_RecordCopyField( MSIRECORD *, UINT, MSIRECORD *, UINT );
709 /* stream internals */
710 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
711 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
712 extern void enum_stream_names( IStorage *stg );
713 extern BOOL decode_streamname(LPCWSTR in, LPWSTR out);
714 extern LPWSTR encode_streamname(BOOL bTable, LPCWSTR in);
716 /* database internals */
717 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
718 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
719 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
720 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
721 extern UINT MSI_IterateRecords( MSIQUERY *, LPDWORD, record_func, LPVOID );
722 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
723 extern UINT MSI_DatabaseImport( MSIDATABASE *, LPCWSTR, LPCWSTR );
724 extern UINT MSI_DatabaseExport( MSIDATABASE *, LPCWSTR, LPCWSTR, LPCWSTR );
725 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
727 /* view internals */
728 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
729 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
730 extern UINT MSI_ViewClose( MSIQUERY* );
731 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
732 extern UINT MSI_ViewModify( MSIQUERY *, MSIMODIFY, MSIRECORD * );
733 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, UINT * );
734 extern UINT msi_view_get_row(MSIDATABASE *, MSIVIEW *, UINT, MSIRECORD **);
736 /* install internals */
737 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
739 /* package internals */
740 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPCWSTR );
741 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage );
742 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
743 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
744 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
745 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, LPDWORD );
746 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, LPDWORD );
747 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
748 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
749 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
750 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
751 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
752 extern UINT msi_package_add_info(MSIPACKAGE *, DWORD, DWORD, LPCWSTR, LPWSTR);
753 extern UINT msi_package_add_media_disk(MSIPACKAGE *, DWORD, DWORD, DWORD, LPWSTR, LPWSTR);
754 extern UINT msi_clone_properties(MSIPACKAGE *);
756 /* for deformating */
757 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, LPDWORD );
759 /* registry data encoding/decoding functions */
760 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
761 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
762 extern BOOL encode_base85_guid(GUID *,LPWSTR);
763 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
764 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
765 extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
766 extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
767 extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
768 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
769 extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
770 extern UINT MSIREG_OpenComponents(HKEY* key);
771 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
772 extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
773 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
774 extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
775 extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
776 extern UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
777 extern UINT MSIREG_OpenLocalSystemInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
778 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
779 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
780 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
781 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
782 extern UINT MSIREG_DeleteProductKey(LPCWSTR szProduct);
783 extern UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct);
784 extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct);
785 extern UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
786 extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
787 extern UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
788 extern UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
789 extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
790 extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent);
792 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
793 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
795 extern DWORD msi_version_str_to_dword(LPCWSTR p);
796 extern LPWSTR msi_version_dword_to_str(DWORD version);
798 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
799 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
800 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
801 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
803 /* msi dialog interface */
804 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
805 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
806 extern UINT msi_dialog_run_message_loop( msi_dialog* );
807 extern void msi_dialog_end_dialog( msi_dialog* );
808 extern void msi_dialog_check_messages( HANDLE );
809 extern void msi_dialog_do_preview( msi_dialog* );
810 extern void msi_dialog_destroy( msi_dialog* );
811 extern BOOL msi_dialog_register_class( void );
812 extern void msi_dialog_unregister_class( void );
813 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
814 extern UINT msi_dialog_reset( msi_dialog *dialog );
815 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
816 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
817 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
818 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
820 /* preview */
821 extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
822 extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
824 /* summary information */
825 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
826 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
827 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
829 /* undocumented functions */
830 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
831 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, LPDWORD );
832 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, LPDWORD );
833 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
834 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
836 /* UI globals */
837 extern INSTALLUILEVEL gUILevel;
838 extern HWND gUIhwnd;
839 extern INSTALLUI_HANDLERA gUIHandlerA;
840 extern INSTALLUI_HANDLERW gUIHandlerW;
841 extern DWORD gUIFilter;
842 extern LPVOID gUIContext;
843 extern WCHAR gszLogFile[MAX_PATH];
844 extern HINSTANCE msi_hInstance;
846 /* action related functions */
847 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script, BOOL force);
848 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action, UINT script);
849 extern void ACTION_FinishCustomActions( const MSIPACKAGE* package);
850 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, UINT script, BOOL execute);
852 static inline void msi_feature_set_state( MSIFEATURE *feature, INSTALLSTATE state )
854 feature->ActionRequest = state;
855 feature->Action = state;
858 static inline void msi_component_set_state( MSICOMPONENT *comp, INSTALLSTATE state )
860 comp->ActionRequest = state;
861 comp->Action = state;
864 /* actions in other modules */
865 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
866 extern UINT ACTION_CCPSearch(MSIPACKAGE *package);
867 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
868 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
869 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
870 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
871 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
872 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
873 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
874 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
875 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
877 /* Helpers */
878 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
879 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
880 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
881 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
882 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
883 BOOL set_prop, BOOL load_prop, MSIFOLDER **folder);
884 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
885 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
886 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
887 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
888 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
889 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
890 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
891 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
892 extern LPWSTR build_directory_name(DWORD , ...);
893 extern BOOL create_full_pathW(const WCHAR *path);
894 extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE);
895 extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE);
896 extern void reduce_to_longfilename(WCHAR*);
897 extern void reduce_to_shortfilename(WCHAR*);
898 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
899 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
900 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
901 extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
902 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
903 extern UINT msi_create_component_directories( MSIPACKAGE *package );
904 extern void msi_ui_error( DWORD msg_id, DWORD type );
905 extern UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
906 MSIINSTALLCONTEXT context, DWORD options, LPCWSTR value);
907 extern UINT msi_load_media_info(MSIPACKAGE *package, MSIFILE *file, MSIMEDIAINFO *mi);
908 extern void msi_free_media_info(MSIMEDIAINFO *mi);
909 extern BOOL msi_cabextract(MSIPACKAGE* package, MSIMEDIAINFO *mi, PFNFDINOTIFY notify, LPVOID data);
910 extern UINT msi_extract_file(MSIPACKAGE *package, MSIFILE *file, LPWSTR destdir);
911 extern UINT find_published_source(MSIPACKAGE *package, MSIMEDIAINFO *mi);
913 /* control event stuff */
914 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
915 MSIRECORD *data);
916 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
917 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
918 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
919 LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
920 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
921 LPCWSTR control, LPCWSTR attribute );
923 /* OLE automation */
924 extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj);
925 extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch);
926 extern HRESULT load_type_info(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid);
928 /* Scripting */
929 extern DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action);
931 /* User Interface messages from the actions */
932 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
933 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
935 /* string consts use a number of places and defined in helpers.c*/
936 extern const WCHAR cszSourceDir[];
937 extern const WCHAR cszSOURCEDIR[];
938 extern const WCHAR szProductCode[];
939 extern const WCHAR cszRootDrive[];
940 extern const WCHAR cszbs[];
942 /* memory allocation macro functions */
943 static inline void *msi_alloc( size_t len )
945 return HeapAlloc( GetProcessHeap(), 0, len );
948 static inline void *msi_alloc_zero( size_t len )
950 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
953 static inline void *msi_realloc( void *mem, size_t len )
955 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
958 static inline void *msi_realloc_zero( void *mem, size_t len )
960 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
963 static inline BOOL msi_free( void *mem )
965 return HeapFree( GetProcessHeap(), 0, mem );
968 static inline char *strdupWtoA( LPCWSTR str )
970 LPSTR ret = NULL;
971 DWORD len;
973 if (!str) return ret;
974 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
975 ret = msi_alloc( len );
976 if (ret)
977 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
978 return ret;
981 static inline LPWSTR strdupAtoW( LPCSTR str )
983 LPWSTR ret = NULL;
984 DWORD len;
986 if (!str) return ret;
987 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
988 ret = msi_alloc( len * sizeof(WCHAR) );
989 if (ret)
990 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
991 return ret;
994 static inline LPWSTR strdupW( LPCWSTR src )
996 LPWSTR dest;
997 if (!src) return NULL;
998 dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
999 if (dest)
1000 lstrcpyW(dest, src);
1001 return dest;
1004 #endif /* __WINE_MSI_PRIVATE__ */