msi: Move string loading and saving to string.c.
[wine/wine64.git] / dlls / msi / msipriv.h
blob670719c8ad0e4f507c68bce93b2fc32431d7ea90
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 LPWSTR path;
79 LPWSTR deletefile;
80 LPCWSTR mode;
81 struct list tables;
82 struct list transforms;
83 } MSIDATABASE;
85 typedef struct tagMSIVIEW MSIVIEW;
87 typedef struct tagMSIQUERY
89 MSIOBJECTHDR hdr;
90 MSIVIEW *view;
91 UINT row;
92 MSIDATABASE *db;
93 struct list mem;
94 } MSIQUERY;
96 /* maybe we can use a Variant instead of doing it ourselves? */
97 typedef struct tagMSIFIELD
99 UINT type;
100 union
102 INT iVal;
103 LPWSTR szwVal;
104 IStream *stream;
105 } u;
106 } MSIFIELD;
108 typedef struct tagMSIRECORD
110 MSIOBJECTHDR hdr;
111 UINT count; /* as passed to MsiCreateRecord */
112 MSIFIELD fields[1]; /* nb. array size is count+1 */
113 } MSIRECORD;
115 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
117 typedef struct tagMSIVIEWOPS
120 * fetch_int - reads one integer from {row,col} in the table
122 * This function should be called after the execute method.
123 * Data returned by the function should not change until
124 * close or delete is called.
125 * To get a string value, query the database's string table with
126 * the integer value returned from this function.
128 UINT (*fetch_int)( struct tagMSIVIEW *, UINT row, UINT col, UINT *val );
131 * fetch_stream - gets a stream from {row,col} in the table
133 * This function is similar to fetch_int, except fetches a
134 * stream instead of an integer.
136 UINT (*fetch_stream)( struct tagMSIVIEW *, UINT row, UINT col, IStream **stm );
139 * set_row - sets values in a row as specified by mask
141 * Similar semantics to fetch_int
143 UINT (*set_row)( struct tagMSIVIEW *, UINT row, MSIRECORD *rec, UINT mask );
146 * Inserts a new row into the database from the records contents
148 UINT (*insert_row)( struct tagMSIVIEW *, MSIRECORD * );
151 * execute - loads the underlying data into memory so it can be read
153 UINT (*execute)( struct tagMSIVIEW *, MSIRECORD * );
156 * close - clears the data read by execute from memory
158 UINT (*close)( struct tagMSIVIEW * );
161 * get_dimensions - returns the number of rows or columns in a table.
163 * The number of rows can only be queried after the execute method
164 * is called. The number of columns can be queried at any time.
166 UINT (*get_dimensions)( struct tagMSIVIEW *, UINT *rows, UINT *cols );
169 * get_column_info - returns the name and type of a specific column
171 * The name is HeapAlloc'ed by this function and should be freed by
172 * the caller.
173 * The column information can be queried at any time.
175 UINT (*get_column_info)( struct tagMSIVIEW *, UINT n, LPWSTR *name, UINT *type );
178 * modify - not yet implemented properly
180 UINT (*modify)( struct tagMSIVIEW *, MSIMODIFY, MSIRECORD * );
183 * delete - destroys the structure completely
185 UINT (*delete)( struct tagMSIVIEW * );
188 * find_matching_rows - iterates through rows that match a value
190 * If the column type is a string then a string ID should be passed in.
191 * If the value to be looked up is an integer then no transformation of
192 * the input value is required, except if the column is a string, in which
193 * case a string ID should be passed in.
194 * The handle is an input/output parameter that keeps track of the current
195 * position in the iteration. It must be initialised to zero before the
196 * first call and continued to be passed in to subsequent calls.
198 UINT (*find_matching_rows)( struct tagMSIVIEW *, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle );
199 } MSIVIEWOPS;
201 struct tagMSIVIEW
203 MSIOBJECTHDR hdr;
204 const MSIVIEWOPS *ops;
207 struct msi_dialog_tag;
208 typedef struct msi_dialog_tag msi_dialog;
210 typedef struct tagMSIPACKAGE
212 MSIOBJECTHDR hdr;
213 MSIDATABASE *db;
214 struct list components;
215 struct list features;
216 struct list files;
217 struct list tempfiles;
218 struct list folders;
219 LPWSTR ActionFormat;
220 LPWSTR LastAction;
222 struct list classes;
223 struct list extensions;
224 struct list progids;
225 struct list mimes;
226 struct list appids;
228 struct tagMSISCRIPT *script;
230 struct list RunningActions;
232 LPWSTR BaseURL;
233 LPWSTR PackagePath;
234 LPWSTR ProductCode;
236 UINT CurrentInstallState;
237 msi_dialog *dialog;
238 LPWSTR next_dialog;
239 float center_x;
240 float center_y;
242 UINT WordCount;
244 struct list subscriptions;
245 } MSIPACKAGE;
247 typedef struct tagMSIPREVIEW
249 MSIOBJECTHDR hdr;
250 MSIPACKAGE *package;
251 msi_dialog *dialog;
252 } MSIPREVIEW;
254 #define MSI_MAX_PROPS 20
256 typedef struct tagMSISUMMARYINFO
258 MSIOBJECTHDR hdr;
259 IStorage *storage;
260 DWORD update_count;
261 PROPVARIANT property[MSI_MAX_PROPS];
262 } MSISUMMARYINFO;
264 typedef struct tagMSIFEATURE
266 struct list entry;
267 LPWSTR Feature;
268 LPWSTR Feature_Parent;
269 LPWSTR Title;
270 LPWSTR Description;
271 INT Display;
272 INT Level;
273 LPWSTR Directory;
274 INT Attributes;
275 INSTALLSTATE Installed;
276 INSTALLSTATE ActionRequest;
277 INSTALLSTATE Action;
278 struct list Children;
279 struct list Components;
280 INT Cost;
281 } MSIFEATURE;
283 typedef struct tagMSICOMPONENT
285 struct list entry;
286 DWORD magic;
287 LPWSTR Component;
288 LPWSTR ComponentId;
289 LPWSTR Directory;
290 INT Attributes;
291 LPWSTR Condition;
292 LPWSTR KeyPath;
293 INSTALLSTATE Installed;
294 INSTALLSTATE ActionRequest;
295 INSTALLSTATE Action;
296 BOOL ForceLocalState;
297 BOOL Enabled;
298 INT Cost;
299 INT RefCount;
300 LPWSTR FullKeypath;
301 LPWSTR AdvertiseString;
303 int hasAdvertiseFeature:1;
304 int hasLocalFeature:1;
305 int hasSourceFeature:1;
306 } MSICOMPONENT;
308 typedef struct tagComponentList
310 struct list entry;
311 MSICOMPONENT *component;
312 } ComponentList;
314 typedef struct tagFeatureList
316 struct list entry;
317 MSIFEATURE *feature;
318 } FeatureList;
320 typedef struct tagMSIFOLDER
322 struct list entry;
323 LPWSTR Directory;
324 LPWSTR Parent;
325 LPWSTR TargetDefault;
326 LPWSTR SourceLongPath;
327 LPWSTR SourceShortPath;
329 LPWSTR ResolvedTarget;
330 LPWSTR ResolvedSource;
331 LPWSTR Property; /* initially set property */
332 INT State;
333 /* 0 = uninitialized */
334 /* 1 = existing */
335 /* 2 = created remove if empty */
336 /* 3 = created persist if empty */
337 INT Cost;
338 INT Space;
339 } MSIFOLDER;
341 typedef enum _msi_file_state {
342 msifs_invalid,
343 msifs_missing,
344 msifs_overwrite,
345 msifs_present,
346 msifs_installed,
347 msifs_skipped,
348 } msi_file_state;
350 typedef struct tagMSIFILE
352 struct list entry;
353 LPWSTR File;
354 MSICOMPONENT *Component;
355 LPWSTR FileName;
356 LPWSTR ShortName;
357 LPWSTR LongName;
358 INT FileSize;
359 LPWSTR Version;
360 LPWSTR Language;
361 INT Attributes;
362 INT Sequence;
363 msi_file_state state;
364 LPWSTR SourcePath;
365 LPWSTR TargetPath;
366 BOOL IsCompressed;
367 } MSIFILE;
369 typedef struct tagMSITEMPFILE
371 struct list entry;
372 LPWSTR Path;
373 } MSITEMPFILE;
375 typedef struct tagMSIAPPID
377 struct list entry;
378 LPWSTR AppID; /* Primary key */
379 LPWSTR RemoteServerName;
380 LPWSTR LocalServer;
381 LPWSTR ServiceParameters;
382 LPWSTR DllSurrogate;
383 BOOL ActivateAtStorage;
384 BOOL RunAsInteractiveUser;
385 } MSIAPPID;
387 typedef struct tagMSIPROGID MSIPROGID;
389 typedef struct tagMSICLASS
391 struct list entry;
392 LPWSTR clsid; /* Primary Key */
393 LPWSTR Context; /* Primary Key */
394 MSICOMPONENT *Component;
395 MSIPROGID *ProgID;
396 LPWSTR ProgIDText;
397 LPWSTR Description;
398 MSIAPPID *AppID;
399 LPWSTR FileTypeMask;
400 LPWSTR IconPath;
401 LPWSTR DefInprocHandler;
402 LPWSTR DefInprocHandler32;
403 LPWSTR Argument;
404 MSIFEATURE *Feature;
405 INT Attributes;
406 /* not in the table, set during installation */
407 BOOL Installed;
408 } MSICLASS;
410 typedef struct tagMSIMIME MSIMIME;
412 typedef struct tagMSIEXTENSION
414 struct list entry;
415 LPWSTR Extension; /* Primary Key */
416 MSICOMPONENT *Component;
417 MSIPROGID *ProgID;
418 LPWSTR ProgIDText;
419 MSIMIME *Mime;
420 MSIFEATURE *Feature;
421 /* not in the table, set during installation */
422 BOOL Installed;
423 struct list verbs;
424 } MSIEXTENSION;
426 struct tagMSIPROGID
428 struct list entry;
429 LPWSTR ProgID; /* Primary Key */
430 MSIPROGID *Parent;
431 MSICLASS *Class;
432 LPWSTR Description;
433 LPWSTR IconPath;
434 /* not in the table, set during installation */
435 BOOL InstallMe;
436 MSIPROGID *CurVer;
437 MSIPROGID *VersionInd;
440 typedef struct tagMSIVERB
442 struct list entry;
443 LPWSTR Verb;
444 INT Sequence;
445 LPWSTR Command;
446 LPWSTR Argument;
447 } MSIVERB;
449 struct tagMSIMIME
451 struct list entry;
452 LPWSTR ContentType; /* Primary Key */
453 MSIEXTENSION *Extension;
454 LPWSTR clsid;
455 MSICLASS *Class;
456 /* not in the table, set during installation */
457 BOOL InstallMe;
460 enum SCRIPTS {
461 INSTALL_SCRIPT = 0,
462 COMMIT_SCRIPT = 1,
463 ROLLBACK_SCRIPT = 2,
464 TOTAL_SCRIPTS = 3
467 #define SEQUENCE_UI 0x1
468 #define SEQUENCE_EXEC 0x2
469 #define SEQUENCE_INSTALL 0x10
471 typedef struct tagMSISCRIPT
473 LPWSTR *Actions[TOTAL_SCRIPTS];
474 UINT ActionCount[TOTAL_SCRIPTS];
475 BOOL ExecuteSequenceRun;
476 BOOL CurrentlyScripting;
477 UINT InWhatSequence;
478 LPWSTR *UniqueActions;
479 UINT UniqueActionsCount;
480 } MSISCRIPT;
482 #define MSIHANDLETYPE_ANY 0
483 #define MSIHANDLETYPE_DATABASE 1
484 #define MSIHANDLETYPE_SUMMARYINFO 2
485 #define MSIHANDLETYPE_VIEW 3
486 #define MSIHANDLETYPE_RECORD 4
487 #define MSIHANDLETYPE_PACKAGE 5
488 #define MSIHANDLETYPE_PREVIEW 6
490 #define MSI_MAJORVERSION 3
491 #define MSI_MINORVERSION 1
492 #define MSI_BUILDNUMBER 4000
494 #define GUID_SIZE 39
496 #define MSIHANDLE_MAGIC 0x4d434923
498 DEFINE_GUID(CLSID_IMsiServer, 0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
499 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
500 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
501 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
503 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
505 /* handle unicode/ascii output in the Msi* API functions */
506 typedef struct {
507 BOOL unicode;
508 union {
509 LPSTR a;
510 LPWSTR w;
511 } str;
512 } awstring;
514 typedef struct {
515 BOOL unicode;
516 union {
517 LPCSTR a;
518 LPCWSTR w;
519 } str;
520 } awcstring;
522 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
524 /* msi server interface */
525 extern ITypeLib *get_msi_typelib( LPWSTR *path );
527 /* handle functions */
528 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
529 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
530 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
531 extern void msiobj_addref(MSIOBJECTHDR *);
532 extern int msiobj_release(MSIOBJECTHDR *);
533 extern void msiobj_lock(MSIOBJECTHDR *);
534 extern void msiobj_unlock(MSIOBJECTHDR *);
535 extern void msi_free_handle_table(void);
537 extern void free_cached_tables( MSIDATABASE *db );
538 extern void msi_free_transforms( MSIDATABASE *db );
539 extern UINT MSI_CommitTables( MSIDATABASE *db );
542 /* string table functions */
543 enum StringPersistence
545 StringPersistent = 0,
546 StringNonPersistent = 1
549 extern BOOL msi_addstring( string_table *st, UINT string_no, const CHAR *data, int len, UINT refcount, enum StringPersistence persistence );
550 extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
551 extern UINT msi_id2stringW( string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
552 extern UINT msi_id2stringA( string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
554 extern UINT msi_string2idW( string_table *st, LPCWSTR buffer, UINT *id );
555 extern UINT msi_string2idA( string_table *st, LPCSTR str, UINT *id );
556 extern string_table *msi_init_stringtable( int entries, UINT codepage );
557 extern VOID msi_destroy_stringtable( string_table *st );
558 extern UINT msi_string_count( string_table *st );
559 extern UINT msi_id_persistent_refcount( string_table *st, UINT i );
560 extern UINT msi_string_totalsize( string_table *st, UINT *datasize, UINT *poolsize );
561 extern UINT msi_strcmp( string_table *st, UINT lval, UINT rval, UINT *res );
562 extern const WCHAR *msi_string_lookup_id( string_table *st, UINT id );
563 extern UINT msi_string_get_codepage( string_table *st );
564 extern HRESULT msi_init_string_table( IStorage *stg );
565 extern string_table *msi_load_string_table( IStorage *stg );
566 extern UINT msi_save_string_table( string_table *st, IStorage *storage );
569 extern BOOL TABLE_Exists( MSIDATABASE *db, LPCWSTR name );
570 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
572 extern UINT read_raw_stream_data( MSIDATABASE*, LPCWSTR stname,
573 USHORT **pdata, UINT *psz );
574 extern UINT read_stream_data( IStorage *stg, LPCWSTR stname,
575 USHORT **pdata, UINT *psz );
576 extern UINT write_stream_data( IStorage *stg, LPCWSTR stname,
577 LPVOID data, UINT sz );
579 /* transform functions */
580 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
581 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
582 LPCWSTR szTransformFile, int iErrorCond );
583 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
585 /* action internals */
586 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
587 extern void ACTION_free_package_structures( MSIPACKAGE* );
588 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
589 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
590 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
592 /* record internals */
593 extern UINT MSI_RecordSetIStream( MSIRECORD *, unsigned int, IStream *);
594 extern UINT MSI_RecordGetIStream( MSIRECORD *, unsigned int, IStream **);
595 extern const WCHAR *MSI_RecordGetString( MSIRECORD *, unsigned int );
596 extern MSIRECORD *MSI_CreateRecord( unsigned int );
597 extern UINT MSI_RecordSetInteger( MSIRECORD *, unsigned int, int );
598 extern UINT MSI_RecordSetStringW( MSIRECORD *, unsigned int, LPCWSTR );
599 extern UINT MSI_RecordSetStringA( MSIRECORD *, unsigned int, LPCSTR );
600 extern BOOL MSI_RecordIsNull( MSIRECORD *, unsigned int );
601 extern UINT MSI_RecordGetStringW( MSIRECORD * , unsigned int, LPWSTR, DWORD *);
602 extern UINT MSI_RecordGetStringA( MSIRECORD *, unsigned int, LPSTR, DWORD *);
603 extern int MSI_RecordGetInteger( MSIRECORD *, unsigned int );
604 extern UINT MSI_RecordReadStream( MSIRECORD *, unsigned int, char *, DWORD *);
605 extern unsigned int MSI_RecordGetFieldCount( MSIRECORD *rec );
606 extern UINT MSI_RecordSetStream( MSIRECORD *, unsigned int, IStream * );
607 extern UINT MSI_RecordDataSize( MSIRECORD *, unsigned int );
608 extern UINT MSI_RecordStreamToFile( MSIRECORD *, unsigned int, LPCWSTR );
609 extern UINT MSI_RecordCopyField( MSIRECORD *, unsigned int, MSIRECORD *, unsigned int );
611 /* stream internals */
612 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
613 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
614 extern void enum_stream_names( IStorage *stg );
616 /* database internals */
617 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
618 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
619 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
620 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
621 extern UINT MSI_IterateRecords( MSIQUERY *, DWORD *, record_func, LPVOID );
622 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
623 extern UINT MSI_DatabaseImport( MSIDATABASE *, LPCWSTR, LPCWSTR );
624 extern UINT MSI_DatabaseExport( MSIDATABASE *, LPCWSTR, LPCWSTR, LPCWSTR );
625 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
627 /* view internals */
628 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
629 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
630 extern UINT MSI_ViewClose( MSIQUERY* );
631 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
632 extern UINT MSI_ViewModify( MSIQUERY *, MSIMODIFY, MSIRECORD * );
633 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, UINT * );
636 /* install internals */
637 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
639 /* package internals */
640 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPWSTR );
641 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE ** );
642 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
643 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
644 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
645 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, DWORD * );
646 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, DWORD* );
647 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
648 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
649 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
650 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
651 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
653 /* for deformating */
654 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, DWORD * );
655 extern UINT MSI_FormatRecordA( MSIPACKAGE *, MSIRECORD *, LPSTR, DWORD * );
657 /* registry data encoding/decoding functions */
658 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
659 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
660 extern BOOL encode_base85_guid(GUID *,LPWSTR);
661 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
662 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
663 extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
664 extern UINT MSIREG_OpenFeatures(HKEY* key);
665 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
666 extern UINT MSIREG_OpenComponents(HKEY* key);
667 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
668 extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
669 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
670 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
671 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
672 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
673 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
675 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
676 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
678 extern DWORD msi_version_str_to_dword(LPCWSTR p);
679 extern LPWSTR msi_version_dword_to_str(DWORD version);
681 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
682 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
683 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
684 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
686 /* msi dialog interface */
687 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
688 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
689 extern UINT msi_dialog_run_message_loop( msi_dialog* );
690 extern void msi_dialog_end_dialog( msi_dialog* );
691 extern void msi_dialog_check_messages( HANDLE );
692 extern void msi_dialog_do_preview( msi_dialog* );
693 extern void msi_dialog_destroy( msi_dialog* );
694 extern BOOL msi_dialog_register_class( void );
695 extern void msi_dialog_unregister_class( void );
696 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
697 extern UINT msi_dialog_reset( msi_dialog *dialog );
698 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
699 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
700 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
701 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
703 /* preview */
704 extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
705 extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
707 /* summary information */
708 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
709 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
710 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
712 /* undocumented functions */
713 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
714 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, DWORD * );
715 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, DWORD * );
716 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
717 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
719 /* UI globals */
720 extern INSTALLUILEVEL gUILevel;
721 extern HWND gUIhwnd;
722 extern INSTALLUI_HANDLERA gUIHandlerA;
723 extern INSTALLUI_HANDLERW gUIHandlerW;
724 extern DWORD gUIFilter;
725 extern LPVOID gUIContext;
726 extern WCHAR gszLogFile[MAX_PATH];
727 extern HINSTANCE msi_hInstance;
729 /* action related functions */
730 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, BOOL force);
731 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action);
732 extern void ACTION_FinishCustomActions( MSIPACKAGE* package);
733 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, BOOL execute);
735 static inline void msi_feature_set_state( MSIFEATURE *feature, INSTALLSTATE state )
737 feature->ActionRequest = state;
738 feature->Action = state;
741 static inline void msi_component_set_state( MSICOMPONENT *comp, INSTALLSTATE state )
743 comp->ActionRequest = state;
744 comp->Action = state;
747 /* actions in other modules */
748 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
749 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
750 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
751 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
752 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
753 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
754 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
755 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
756 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
757 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
759 /* Helpers */
760 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
761 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
762 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
763 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
764 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
765 BOOL set_prop, BOOL load_prop, MSIFOLDER **folder);
766 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
767 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
768 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
769 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
770 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
771 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
772 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
773 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
774 extern LPWSTR build_directory_name(DWORD , ...);
775 extern BOOL create_full_pathW(const WCHAR *path);
776 extern BOOL ACTION_VerifyComponentForAction(MSICOMPONENT*, INSTALLSTATE);
777 extern BOOL ACTION_VerifyFeatureForAction(MSIFEATURE*, INSTALLSTATE);
778 extern void reduce_to_longfilename(WCHAR*);
779 extern void reduce_to_shortfilename(WCHAR*);
780 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
781 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
782 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
783 extern BOOL check_unique_action(MSIPACKAGE *, LPCWSTR);
784 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
785 extern UINT msi_create_component_directories( MSIPACKAGE *package );
786 extern void msi_ui_error( DWORD msg_id, DWORD type );
788 /* control event stuff */
789 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
790 MSIRECORD *data);
791 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
792 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
793 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
794 LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
795 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
796 LPCWSTR control, LPCWSTR attribute );
798 /* User Interface messages from the actions */
799 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
800 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
802 /* string consts use a number of places and defined in helpers.c*/
803 extern const WCHAR cszSourceDir[];
804 extern const WCHAR cszSOURCEDIR[];
805 extern const WCHAR szProductCode[];
806 extern const WCHAR cszRootDrive[];
807 extern const WCHAR cszbs[];
809 /* memory allocation macro functions */
810 static inline void *msi_alloc( size_t len )
812 return HeapAlloc( GetProcessHeap(), 0, len );
815 static inline void *msi_alloc_zero( size_t len )
817 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
820 static inline void *msi_realloc( void *mem, size_t len )
822 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
825 static inline void *msi_realloc_zero( void *mem, size_t len )
827 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
830 static inline BOOL msi_free( void *mem )
832 return HeapFree( GetProcessHeap(), 0, mem );
835 static inline char *strdupWtoA( LPCWSTR str )
837 LPSTR ret = NULL;
838 DWORD len;
840 if (!str) return ret;
841 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
842 ret = msi_alloc( len );
843 if (ret)
844 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
845 return ret;
848 static inline LPWSTR strdupAtoW( LPCSTR str )
850 LPWSTR ret = NULL;
851 DWORD len;
853 if (!str) return ret;
854 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
855 ret = msi_alloc( len * sizeof(WCHAR) );
856 if (ret)
857 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
858 return ret;
861 static inline LPWSTR strdupW( LPCWSTR src )
863 LPWSTR dest;
864 if (!src) return NULL;
865 dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
866 if (dest)
867 lstrcpyW(dest, src);
868 return dest;
871 #endif /* __WINE_MSI_PRIVATE__ */