msi: Implement MsiGetMode for MSIRUNMODE_SCHEDULED, MSIRUNMODE_COMMIT and MSIRUNMODE_...
[wine/testsucceed.git] / dlls / msi / msipriv.h
blob3dd0cb33d44df16c853989fc78160698ab330402
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 "msi.h"
30 #include "msiquery.h"
31 #include "objbase.h"
32 #include "objidl.h"
33 #include "winnls.h"
34 #include "wine/list.h"
36 #define MSI_DATASIZEMASK 0x00ff
37 #define MSITYPE_VALID 0x0100
38 #define MSITYPE_LOCALIZABLE 0x200
39 #define MSITYPE_STRING 0x0800
40 #define MSITYPE_NULLABLE 0x1000
41 #define MSITYPE_KEY 0x2000
43 /* Word Count masks */
44 #define MSIWORDCOUNT_SHORTFILENAMES 0x0001
45 #define MSIWORDCOUNT_COMPRESSED 0x0002
46 #define MSIWORDCOUNT_ADMINISTRATIVE 0x0004
47 #define MSIWORDCOUNT_PRIVILEGES 0x0008
49 /* Install UI level mask for AND operation to exclude flags */
50 #define INSTALLUILEVEL_MASK 0x0007
52 #define MSITYPE_IS_BINARY(type) (((type) & ~MSITYPE_NULLABLE) == (MSITYPE_STRING|MSITYPE_VALID))
54 struct tagMSITABLE;
55 typedef struct tagMSITABLE MSITABLE;
57 struct string_table;
58 typedef struct string_table string_table;
60 struct tagMSIOBJECTHDR;
61 typedef struct tagMSIOBJECTHDR MSIOBJECTHDR;
63 typedef VOID (*msihandledestructor)( MSIOBJECTHDR * );
65 struct tagMSIOBJECTHDR
67 UINT magic;
68 UINT type;
69 LONG refcount;
70 msihandledestructor destructor;
73 typedef struct tagMSIDATABASE
75 MSIOBJECTHDR hdr;
76 IStorage *storage;
77 string_table *strings;
78 UINT bytes_per_strref;
79 LPWSTR path;
80 LPWSTR deletefile;
81 LPCWSTR mode;
82 struct list tables;
83 struct list transforms;
84 } MSIDATABASE;
86 typedef struct tagMSIVIEW MSIVIEW;
88 typedef struct tagMSIQUERY
90 MSIOBJECTHDR hdr;
91 MSIVIEW *view;
92 UINT row;
93 MSIDATABASE *db;
94 struct list mem;
95 } MSIQUERY;
97 /* maybe we can use a Variant instead of doing it ourselves? */
98 typedef struct tagMSIFIELD
100 UINT type;
101 union
103 INT iVal;
104 LPWSTR szwVal;
105 IStream *stream;
106 } u;
107 } MSIFIELD;
109 typedef struct tagMSIRECORD
111 MSIOBJECTHDR hdr;
112 UINT count; /* as passed to MsiCreateRecord */
113 MSIFIELD fields[1]; /* nb. array size is count+1 */
114 } MSIRECORD;
116 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
118 typedef struct tagMSIVIEWOPS
121 * fetch_int - reads one integer from {row,col} in the table
123 * This function should be called after the execute method.
124 * Data returned by the function should not change until
125 * close or delete is called.
126 * To get a string value, query the database's string table with
127 * the integer value returned from this function.
129 UINT (*fetch_int)( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val );
132 * fetch_stream - gets a stream from {row,col} in the table
134 * This function is similar to fetch_int, except fetches a
135 * stream instead of an integer.
137 UINT (*fetch_stream)( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm );
140 * set_row - sets values in a row as specified by mask
142 * Similar semantics to fetch_int
144 UINT (*set_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask );
147 * Inserts a new row into the database from the records contents
149 UINT (*insert_row)( struct tagMSIVIEW *view, MSIRECORD *record, BOOL temporary );
152 * Deletes a row from the database
154 UINT (*delete_row)( struct tagMSIVIEW *view, UINT row );
157 * execute - loads the underlying data into memory so it can be read
159 UINT (*execute)( struct tagMSIVIEW *view, MSIRECORD *record );
162 * close - clears the data read by execute from memory
164 UINT (*close)( struct tagMSIVIEW *view );
167 * get_dimensions - returns the number of rows or columns in a table.
169 * The number of rows can only be queried after the execute method
170 * is called. The number of columns can be queried at any time.
172 UINT (*get_dimensions)( struct tagMSIVIEW *view, UINT *rows, UINT *cols );
175 * get_column_info - returns the name and type of a specific column
177 * The name is HeapAlloc'ed by this function and should be freed by
178 * the caller.
179 * The column information can be queried at any time.
181 UINT (*get_column_info)( struct tagMSIVIEW *view, UINT n, LPWSTR *name, UINT *type );
184 * modify - not yet implemented properly
186 UINT (*modify)( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *record );
189 * delete - destroys the structure completely
191 UINT (*delete)( struct tagMSIVIEW * );
194 * find_matching_rows - iterates through rows that match a value
196 * If the column type is a string then a string ID should be passed in.
197 * If the value to be looked up is an integer then no transformation of
198 * the input value is required, except if the column is a string, in which
199 * case a string ID should be passed in.
200 * The handle is an input/output parameter that keeps track of the current
201 * position in the iteration. It must be initialised to zero before the
202 * first call and continued to be passed in to subsequent calls.
204 UINT (*find_matching_rows)( struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle );
205 } MSIVIEWOPS;
207 struct tagMSIVIEW
209 MSIOBJECTHDR hdr;
210 const MSIVIEWOPS *ops;
213 struct msi_dialog_tag;
214 typedef struct msi_dialog_tag msi_dialog;
216 typedef struct tagMSIPACKAGE
218 MSIOBJECTHDR hdr;
219 MSIDATABASE *db;
220 struct list components;
221 struct list features;
222 struct list files;
223 struct list tempfiles;
224 struct list folders;
225 LPWSTR ActionFormat;
226 LPWSTR LastAction;
228 struct list classes;
229 struct list extensions;
230 struct list progids;
231 struct list mimes;
232 struct list appids;
234 struct tagMSISCRIPT *script;
236 struct list RunningActions;
238 LPWSTR BaseURL;
239 LPWSTR PackagePath;
240 LPWSTR ProductCode;
242 UINT CurrentInstallState;
243 msi_dialog *dialog;
244 LPWSTR next_dialog;
245 float center_x;
246 float center_y;
248 UINT WordCount;
250 struct list subscriptions;
252 unsigned char scheduled_action_running : 1;
253 unsigned char commit_action_running : 1;
254 unsigned char rollback_action_running : 1;
255 } MSIPACKAGE;
257 typedef struct tagMSIPREVIEW
259 MSIOBJECTHDR hdr;
260 MSIPACKAGE *package;
261 msi_dialog *dialog;
262 } MSIPREVIEW;
264 #define MSI_MAX_PROPS 20
266 typedef struct tagMSISUMMARYINFO
268 MSIOBJECTHDR hdr;
269 IStorage *storage;
270 DWORD update_count;
271 PROPVARIANT property[MSI_MAX_PROPS];
272 } MSISUMMARYINFO;
274 typedef struct tagMSIFEATURE
276 struct list entry;
277 LPWSTR Feature;
278 LPWSTR Feature_Parent;
279 LPWSTR Title;
280 LPWSTR Description;
281 INT Display;
282 INT Level;
283 LPWSTR Directory;
284 INT Attributes;
285 INSTALLSTATE Installed;
286 INSTALLSTATE ActionRequest;
287 INSTALLSTATE Action;
288 struct list Children;
289 struct list Components;
290 INT Cost;
291 } MSIFEATURE;
293 typedef struct tagMSICOMPONENT
295 struct list entry;
296 DWORD magic;
297 LPWSTR Component;
298 LPWSTR ComponentId;
299 LPWSTR Directory;
300 INT Attributes;
301 LPWSTR Condition;
302 LPWSTR KeyPath;
303 INSTALLSTATE Installed;
304 INSTALLSTATE ActionRequest;
305 INSTALLSTATE Action;
306 BOOL ForceLocalState;
307 BOOL Enabled;
308 INT Cost;
309 INT RefCount;
310 LPWSTR FullKeypath;
311 LPWSTR AdvertiseString;
313 unsigned int hasAdvertiseFeature:1;
314 unsigned int hasLocalFeature:1;
315 unsigned int hasSourceFeature:1;
316 } MSICOMPONENT;
318 typedef struct tagComponentList
320 struct list entry;
321 MSICOMPONENT *component;
322 } ComponentList;
324 typedef struct tagFeatureList
326 struct list entry;
327 MSIFEATURE *feature;
328 } FeatureList;
330 typedef struct tagMSIFOLDER
332 struct list entry;
333 LPWSTR Directory;
334 LPWSTR Parent;
335 LPWSTR TargetDefault;
336 LPWSTR SourceLongPath;
337 LPWSTR SourceShortPath;
339 LPWSTR ResolvedTarget;
340 LPWSTR ResolvedSource;
341 LPWSTR Property; /* initially set property */
342 INT State;
343 /* 0 = uninitialized */
344 /* 1 = existing */
345 /* 2 = created remove if empty */
346 /* 3 = created persist if empty */
347 INT Cost;
348 INT Space;
349 } MSIFOLDER;
351 typedef enum _msi_file_state {
352 msifs_invalid,
353 msifs_missing,
354 msifs_overwrite,
355 msifs_present,
356 msifs_installed,
357 msifs_skipped,
358 } msi_file_state;
360 typedef struct tagMSIFILE
362 struct list entry;
363 LPWSTR File;
364 MSICOMPONENT *Component;
365 LPWSTR FileName;
366 LPWSTR ShortName;
367 LPWSTR LongName;
368 INT FileSize;
369 LPWSTR Version;
370 LPWSTR Language;
371 INT Attributes;
372 INT Sequence;
373 msi_file_state state;
374 LPWSTR SourcePath;
375 LPWSTR TargetPath;
376 BOOL IsCompressed;
377 } MSIFILE;
379 typedef struct tagMSITEMPFILE
381 struct list entry;
382 LPWSTR Path;
383 } MSITEMPFILE;
385 typedef struct tagMSIAPPID
387 struct list entry;
388 LPWSTR AppID; /* Primary key */
389 LPWSTR RemoteServerName;
390 LPWSTR LocalServer;
391 LPWSTR ServiceParameters;
392 LPWSTR DllSurrogate;
393 BOOL ActivateAtStorage;
394 BOOL RunAsInteractiveUser;
395 } MSIAPPID;
397 typedef struct tagMSIPROGID MSIPROGID;
399 typedef struct tagMSICLASS
401 struct list entry;
402 LPWSTR clsid; /* Primary Key */
403 LPWSTR Context; /* Primary Key */
404 MSICOMPONENT *Component;
405 MSIPROGID *ProgID;
406 LPWSTR ProgIDText;
407 LPWSTR Description;
408 MSIAPPID *AppID;
409 LPWSTR FileTypeMask;
410 LPWSTR IconPath;
411 LPWSTR DefInprocHandler;
412 LPWSTR DefInprocHandler32;
413 LPWSTR Argument;
414 MSIFEATURE *Feature;
415 INT Attributes;
416 /* not in the table, set during installation */
417 BOOL Installed;
418 } MSICLASS;
420 typedef struct tagMSIMIME MSIMIME;
422 typedef struct tagMSIEXTENSION
424 struct list entry;
425 LPWSTR Extension; /* Primary Key */
426 MSICOMPONENT *Component;
427 MSIPROGID *ProgID;
428 LPWSTR ProgIDText;
429 MSIMIME *Mime;
430 MSIFEATURE *Feature;
431 /* not in the table, set during installation */
432 BOOL Installed;
433 struct list verbs;
434 } MSIEXTENSION;
436 struct tagMSIPROGID
438 struct list entry;
439 LPWSTR ProgID; /* Primary Key */
440 MSIPROGID *Parent;
441 MSICLASS *Class;
442 LPWSTR Description;
443 LPWSTR IconPath;
444 /* not in the table, set during installation */
445 BOOL InstallMe;
446 MSIPROGID *CurVer;
447 MSIPROGID *VersionInd;
450 typedef struct tagMSIVERB
452 struct list entry;
453 LPWSTR Verb;
454 INT Sequence;
455 LPWSTR Command;
456 LPWSTR Argument;
457 } MSIVERB;
459 struct tagMSIMIME
461 struct list entry;
462 LPWSTR ContentType; /* Primary Key */
463 MSIEXTENSION *Extension;
464 LPWSTR clsid;
465 MSICLASS *Class;
466 /* not in the table, set during installation */
467 BOOL InstallMe;
470 enum SCRIPTS {
471 INSTALL_SCRIPT = 0,
472 COMMIT_SCRIPT = 1,
473 ROLLBACK_SCRIPT = 2,
474 TOTAL_SCRIPTS = 3
477 #define SEQUENCE_UI 0x1
478 #define SEQUENCE_EXEC 0x2
479 #define SEQUENCE_INSTALL 0x10
481 typedef struct tagMSISCRIPT
483 LPWSTR *Actions[TOTAL_SCRIPTS];
484 UINT ActionCount[TOTAL_SCRIPTS];
485 BOOL ExecuteSequenceRun;
486 BOOL CurrentlyScripting;
487 UINT InWhatSequence;
488 LPWSTR *UniqueActions;
489 UINT UniqueActionsCount;
490 } MSISCRIPT;
492 #define MSIHANDLETYPE_ANY 0
493 #define MSIHANDLETYPE_DATABASE 1
494 #define MSIHANDLETYPE_SUMMARYINFO 2
495 #define MSIHANDLETYPE_VIEW 3
496 #define MSIHANDLETYPE_RECORD 4
497 #define MSIHANDLETYPE_PACKAGE 5
498 #define MSIHANDLETYPE_PREVIEW 6
500 #define MSI_MAJORVERSION 3
501 #define MSI_MINORVERSION 1
502 #define MSI_BUILDNUMBER 4000
504 #define GUID_SIZE 39
506 #define MSIHANDLE_MAGIC 0x4d434923
508 DEFINE_GUID(CLSID_IMsiServer, 0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
509 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
510 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
511 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
513 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
515 /* handle unicode/ascii output in the Msi* API functions */
516 typedef struct {
517 BOOL unicode;
518 union {
519 LPSTR a;
520 LPWSTR w;
521 } str;
522 } awstring;
524 typedef struct {
525 BOOL unicode;
526 union {
527 LPCSTR a;
528 LPCWSTR w;
529 } str;
530 } awcstring;
532 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
534 /* msi server interface */
535 extern ITypeLib *get_msi_typelib( LPWSTR *path );
537 /* handle functions */
538 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
539 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
540 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
541 extern void msiobj_addref(MSIOBJECTHDR *);
542 extern int msiobj_release(MSIOBJECTHDR *);
543 extern void msiobj_lock(MSIOBJECTHDR *);
544 extern void msiobj_unlock(MSIOBJECTHDR *);
545 extern void msi_free_handle_table(void);
547 extern void free_cached_tables( MSIDATABASE *db );
548 extern void msi_free_transforms( MSIDATABASE *db );
549 extern UINT MSI_CommitTables( MSIDATABASE *db );
552 /* string table functions */
553 enum StringPersistence
555 StringPersistent = 0,
556 StringNonPersistent = 1
559 extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
560 extern UINT msi_id2stringW( const string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
561 extern UINT msi_id2stringA( const string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
563 extern UINT msi_string2idW( const string_table *st, LPCWSTR buffer, UINT *id );
564 extern UINT msi_string2idA( const string_table *st, LPCSTR str, UINT *id );
565 extern VOID msi_destroy_stringtable( string_table *st );
566 extern UINT msi_strcmp( const string_table *st, UINT lval, UINT rval, UINT *res );
567 extern const WCHAR *msi_string_lookup_id( const string_table *st, UINT id );
568 extern HRESULT msi_init_string_table( IStorage *stg );
569 extern string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref );
570 extern UINT msi_save_string_table( const string_table *st, IStorage *storage );
573 extern void msi_table_set_strref(UINT bytes_per_strref);
574 extern BOOL TABLE_Exists( MSIDATABASE *db, LPCWSTR name );
575 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
577 extern UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname,
578 USHORT **pdata, UINT *psz );
579 extern UINT read_stream_data( IStorage *stg, LPCWSTR stname,
580 USHORT **pdata, UINT *psz );
581 extern UINT write_stream_data( IStorage *stg, LPCWSTR stname,
582 LPCVOID data, UINT sz, BOOL bTable );
584 /* transform functions */
585 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
586 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
587 LPCWSTR szTransformFile, int iErrorCond );
588 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
590 /* action internals */
591 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
592 extern void ACTION_free_package_structures( MSIPACKAGE* );
593 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
594 extern UINT ACTION_ForceReboot(MSIPACKAGE *package);
595 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
596 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
598 /* record internals */
599 extern UINT MSI_RecordSetIStream( MSIRECORD *, unsigned int, IStream *);
600 extern UINT MSI_RecordGetIStream( MSIRECORD *, unsigned int, IStream **);
601 extern const WCHAR *MSI_RecordGetString( const MSIRECORD *, unsigned int );
602 extern MSIRECORD *MSI_CreateRecord( unsigned int );
603 extern UINT MSI_RecordSetInteger( MSIRECORD *, unsigned int, int );
604 extern UINT MSI_RecordSetStringW( MSIRECORD *, unsigned int, LPCWSTR );
605 extern UINT MSI_RecordSetStringA( MSIRECORD *, unsigned int, LPCSTR );
606 extern BOOL MSI_RecordIsNull( MSIRECORD *, unsigned int );
607 extern UINT MSI_RecordGetStringW( MSIRECORD * , unsigned int, LPWSTR, DWORD *);
608 extern UINT MSI_RecordGetStringA( MSIRECORD *, unsigned int, LPSTR, DWORD *);
609 extern int MSI_RecordGetInteger( MSIRECORD *, unsigned int );
610 extern UINT MSI_RecordReadStream( MSIRECORD *, unsigned int, char *, DWORD *);
611 extern unsigned int MSI_RecordGetFieldCount( const MSIRECORD *rec );
612 extern UINT MSI_RecordSetStream( MSIRECORD *, unsigned int, IStream * );
613 extern UINT MSI_RecordDataSize( MSIRECORD *, unsigned int );
614 extern UINT MSI_RecordStreamToFile( MSIRECORD *, unsigned int, LPCWSTR );
615 extern UINT MSI_RecordCopyField( MSIRECORD *, unsigned int, MSIRECORD *, unsigned int );
617 /* stream internals */
618 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
619 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
620 extern void enum_stream_names( IStorage *stg );
621 extern BOOL decode_streamname(LPCWSTR in, LPWSTR out);
622 extern LPWSTR encode_streamname(BOOL bTable, LPCWSTR in);
624 /* database internals */
625 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
626 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
627 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
628 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
629 extern UINT MSI_IterateRecords( MSIQUERY *, DWORD *, record_func, LPVOID );
630 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
631 extern UINT MSI_DatabaseImport( MSIDATABASE *, LPCWSTR, LPCWSTR );
632 extern UINT MSI_DatabaseExport( MSIDATABASE *, LPCWSTR, LPCWSTR, LPCWSTR );
633 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
635 /* view internals */
636 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
637 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
638 extern UINT MSI_ViewClose( MSIQUERY* );
639 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
640 extern UINT MSI_ViewModify( MSIQUERY *, MSIMODIFY, MSIRECORD * );
641 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, UINT * );
644 /* install internals */
645 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
647 /* package internals */
648 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPCWSTR );
649 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage );
650 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
651 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
652 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
653 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, DWORD * );
654 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, DWORD* );
655 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
656 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
657 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
658 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
659 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
661 /* for deformating */
662 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, DWORD * );
663 extern UINT MSI_FormatRecordA( MSIPACKAGE *, MSIRECORD *, LPSTR, DWORD * );
665 /* registry data encoding/decoding functions */
666 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
667 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
668 extern BOOL encode_base85_guid(GUID *,LPWSTR);
669 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
670 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
671 extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
672 extern UINT MSIREG_OpenFeatures(HKEY* key);
673 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
674 extern UINT MSIREG_OpenComponents(HKEY* key);
675 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
676 extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
677 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
678 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
679 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
680 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
681 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
683 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
684 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
686 extern DWORD msi_version_str_to_dword(LPCWSTR p);
687 extern LPWSTR msi_version_dword_to_str(DWORD version);
689 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
690 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
691 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
692 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
694 /* msi dialog interface */
695 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
696 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
697 extern UINT msi_dialog_run_message_loop( msi_dialog* );
698 extern void msi_dialog_end_dialog( msi_dialog* );
699 extern void msi_dialog_check_messages( HANDLE );
700 extern void msi_dialog_do_preview( msi_dialog* );
701 extern void msi_dialog_destroy( msi_dialog* );
702 extern BOOL msi_dialog_register_class( void );
703 extern void msi_dialog_unregister_class( void );
704 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
705 extern UINT msi_dialog_reset( msi_dialog *dialog );
706 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
707 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
708 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
709 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
711 /* preview */
712 extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
713 extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
715 /* summary information */
716 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
717 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
718 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
720 /* undocumented functions */
721 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
722 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, DWORD * );
723 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, DWORD * );
724 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
725 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
727 /* UI globals */
728 extern INSTALLUILEVEL gUILevel;
729 extern HWND gUIhwnd;
730 extern INSTALLUI_HANDLERA gUIHandlerA;
731 extern INSTALLUI_HANDLERW gUIHandlerW;
732 extern DWORD gUIFilter;
733 extern LPVOID gUIContext;
734 extern WCHAR gszLogFile[MAX_PATH];
735 extern HINSTANCE msi_hInstance;
737 /* action related functions */
738 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script, BOOL force);
739 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action, UINT script);
740 extern void ACTION_FinishCustomActions( const MSIPACKAGE* package);
741 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, UINT script, BOOL execute);
743 static inline void msi_feature_set_state( MSIFEATURE *feature, INSTALLSTATE state )
745 feature->ActionRequest = state;
746 feature->Action = state;
749 static inline void msi_component_set_state( MSICOMPONENT *comp, INSTALLSTATE state )
751 comp->ActionRequest = state;
752 comp->Action = state;
755 /* actions in other modules */
756 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
757 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
758 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
759 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
760 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
761 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
762 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
763 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
764 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
765 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
767 /* Helpers */
768 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
769 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
770 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
771 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
772 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
773 BOOL set_prop, BOOL load_prop, MSIFOLDER **folder);
774 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
775 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
776 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
777 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
778 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
779 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
780 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
781 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
782 extern LPWSTR build_directory_name(DWORD , ...);
783 extern BOOL create_full_pathW(const WCHAR *path);
784 extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE);
785 extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE);
786 extern void reduce_to_longfilename(WCHAR*);
787 extern void reduce_to_shortfilename(WCHAR*);
788 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
789 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
790 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
791 extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
792 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
793 extern UINT msi_create_component_directories( MSIPACKAGE *package );
794 extern void msi_ui_error( DWORD msg_id, DWORD type );
796 /* control event stuff */
797 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
798 MSIRECORD *data);
799 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
800 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
801 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
802 LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
803 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
804 LPCWSTR control, LPCWSTR attribute );
806 /* OLE automation */
807 extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj);
808 extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch);
809 extern HRESULT load_type_info(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid);
811 /* Scripting */
812 extern DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action);
814 /* User Interface messages from the actions */
815 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
816 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
818 /* string consts use a number of places and defined in helpers.c*/
819 extern const WCHAR cszSourceDir[];
820 extern const WCHAR cszSOURCEDIR[];
821 extern const WCHAR szProductCode[];
822 extern const WCHAR cszRootDrive[];
823 extern const WCHAR cszbs[];
825 /* memory allocation macro functions */
826 static inline void *msi_alloc( size_t len )
828 return HeapAlloc( GetProcessHeap(), 0, len );
831 static inline void *msi_alloc_zero( size_t len )
833 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
836 static inline void *msi_realloc( void *mem, size_t len )
838 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
841 static inline void *msi_realloc_zero( void *mem, size_t len )
843 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
846 static inline BOOL msi_free( void *mem )
848 return HeapFree( GetProcessHeap(), 0, mem );
851 static inline char *strdupWtoA( LPCWSTR str )
853 LPSTR ret = NULL;
854 DWORD len;
856 if (!str) return ret;
857 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
858 ret = msi_alloc( len );
859 if (ret)
860 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
861 return ret;
864 static inline LPWSTR strdupAtoW( LPCSTR str )
866 LPWSTR ret = NULL;
867 DWORD len;
869 if (!str) return ret;
870 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
871 ret = msi_alloc( len * sizeof(WCHAR) );
872 if (ret)
873 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
874 return ret;
877 static inline LPWSTR strdupW( LPCWSTR src )
879 LPWSTR dest;
880 if (!src) return NULL;
881 dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
882 if (dest)
883 lstrcpyW(dest, src);
884 return dest;
887 #endif /* __WINE_MSI_PRIVATE__ */