mshtml: Use heap_alloc_zero for allocating node objects.
[wine/wine-jacek.git] / dlls / msi / msipriv.h
blob58877ba08a26a27da6b0f79c2b0c942d197e97f1
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
42 #define MSITYPE_TEMPORARY 0x4000
44 /* Word Count masks */
45 #define MSIWORDCOUNT_SHORTFILENAMES 0x0001
46 #define MSIWORDCOUNT_COMPRESSED 0x0002
47 #define MSIWORDCOUNT_ADMINISTRATIVE 0x0004
48 #define MSIWORDCOUNT_PRIVILEGES 0x0008
50 /* Install UI level mask for AND operation to exclude flags */
51 #define INSTALLUILEVEL_MASK 0x0007
53 #define MSITYPE_IS_BINARY(type) (((type) & ~MSITYPE_NULLABLE) == (MSITYPE_STRING|MSITYPE_VALID))
55 struct tagMSITABLE;
56 typedef struct tagMSITABLE MSITABLE;
58 struct string_table;
59 typedef struct string_table string_table;
61 struct tagMSIOBJECTHDR;
62 typedef struct tagMSIOBJECTHDR MSIOBJECTHDR;
64 typedef VOID (*msihandledestructor)( MSIOBJECTHDR * );
66 struct tagMSIOBJECTHDR
68 UINT magic;
69 UINT type;
70 LONG refcount;
71 msihandledestructor destructor;
74 typedef struct tagMSIDATABASE
76 MSIOBJECTHDR hdr;
77 IStorage *storage;
78 string_table *strings;
79 UINT bytes_per_strref;
80 LPWSTR path;
81 LPWSTR deletefile;
82 LPCWSTR mode;
83 struct list tables;
84 struct list transforms;
85 } MSIDATABASE;
87 typedef struct tagMSIVIEW MSIVIEW;
89 typedef struct tagMSIQUERY
91 MSIOBJECTHDR hdr;
92 MSIVIEW *view;
93 UINT row;
94 MSIDATABASE *db;
95 struct list mem;
96 } MSIQUERY;
98 /* maybe we can use a Variant instead of doing it ourselves? */
99 typedef struct tagMSIFIELD
101 UINT type;
102 union
104 INT iVal;
105 LPWSTR szwVal;
106 IStream *stream;
107 } u;
108 } MSIFIELD;
110 typedef struct tagMSIRECORD
112 MSIOBJECTHDR hdr;
113 UINT count; /* as passed to MsiCreateRecord */
114 MSIFIELD fields[1]; /* nb. array size is count+1 */
115 } MSIRECORD;
117 typedef struct tagMSISOURCELISTINFO
119 struct list entry;
120 DWORD context;
121 DWORD options;
122 LPCWSTR property;
123 LPWSTR value;
124 } MSISOURCELISTINFO;
126 typedef struct tagMSIMEDIADISK
128 struct list entry;
129 DWORD context;
130 DWORD options;
131 DWORD disk_id;
132 LPWSTR volume_label;
133 LPWSTR disk_prompt;
134 } MSIMEDIADISK;
136 typedef struct _column_info
138 LPCWSTR table;
139 LPCWSTR column;
140 INT type;
141 BOOL temporary;
142 struct expr *val;
143 struct _column_info *next;
144 } column_info;
146 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
148 typedef struct tagMSIVIEWOPS
151 * fetch_int - reads one integer from {row,col} in the table
153 * This function should be called after the execute method.
154 * Data returned by the function should not change until
155 * close or delete is called.
156 * To get a string value, query the database's string table with
157 * the integer value returned from this function.
159 UINT (*fetch_int)( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val );
162 * fetch_stream - gets a stream from {row,col} in the table
164 * This function is similar to fetch_int, except fetches a
165 * stream instead of an integer.
167 UINT (*fetch_stream)( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm );
170 * get_row - gets values from a row
173 UINT (*get_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec );
176 * set_row - sets values in a row as specified by mask
178 * Similar semantics to fetch_int
180 UINT (*set_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask );
183 * Inserts a new row into the database from the records contents
185 UINT (*insert_row)( struct tagMSIVIEW *view, MSIRECORD *record, BOOL temporary );
188 * Deletes a row from the database
190 UINT (*delete_row)( struct tagMSIVIEW *view, UINT row );
193 * execute - loads the underlying data into memory so it can be read
195 UINT (*execute)( struct tagMSIVIEW *view, MSIRECORD *record );
198 * close - clears the data read by execute from memory
200 UINT (*close)( struct tagMSIVIEW *view );
203 * get_dimensions - returns the number of rows or columns in a table.
205 * The number of rows can only be queried after the execute method
206 * is called. The number of columns can be queried at any time.
208 UINT (*get_dimensions)( struct tagMSIVIEW *view, UINT *rows, UINT *cols );
211 * get_column_info - returns the name and type of a specific column
213 * The name is HeapAlloc'ed by this function and should be freed by
214 * the caller.
215 * The column information can be queried at any time.
217 UINT (*get_column_info)( struct tagMSIVIEW *view, UINT n, LPWSTR *name, UINT *type );
220 * modify - not yet implemented properly
222 UINT (*modify)( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *record, UINT row );
225 * delete - destroys the structure completely
227 UINT (*delete)( struct tagMSIVIEW * );
230 * find_matching_rows - iterates through rows that match a value
232 * If the column type is a string then a string ID should be passed in.
233 * If the value to be looked up is an integer then no transformation of
234 * the input value is required, except if the column is a string, in which
235 * case a string ID should be passed in.
236 * The handle is an input/output parameter that keeps track of the current
237 * position in the iteration. It must be initialised to zero before the
238 * first call and continued to be passed in to subsequent calls.
240 UINT (*find_matching_rows)( struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle );
243 * add_ref - increases the reference count of the table
245 UINT (*add_ref)( struct tagMSIVIEW *view );
248 * release - decreases the reference count of the table
250 UINT (*release)( struct tagMSIVIEW *view );
253 * add_column - adds a column to the table
255 UINT (*add_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number, LPCWSTR column, UINT type, BOOL hold );
258 * remove_column - removes the column represented by table name and column number from the table
260 UINT (*remove_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number );
263 * sort - orders the table by columns
265 UINT (*sort)( struct tagMSIVIEW *view, column_info *columns );
266 } MSIVIEWOPS;
268 struct tagMSIVIEW
270 MSIOBJECTHDR hdr;
271 const MSIVIEWOPS *ops;
274 struct msi_dialog_tag;
275 typedef struct msi_dialog_tag msi_dialog;
277 typedef struct tagMSIPACKAGE
279 MSIOBJECTHDR hdr;
280 MSIDATABASE *db;
281 struct list components;
282 struct list features;
283 struct list files;
284 struct list tempfiles;
285 struct list folders;
286 LPWSTR ActionFormat;
287 LPWSTR LastAction;
289 struct list classes;
290 struct list extensions;
291 struct list progids;
292 struct list mimes;
293 struct list appids;
295 struct tagMSISCRIPT *script;
297 struct list RunningActions;
299 LPWSTR BaseURL;
300 LPWSTR PackagePath;
301 LPWSTR ProductCode;
303 UINT CurrentInstallState;
304 msi_dialog *dialog;
305 LPWSTR next_dialog;
306 float center_x;
307 float center_y;
309 UINT WordCount;
310 UINT Context;
312 struct list subscriptions;
314 struct list sourcelist_info;
315 struct list sourcelist_media;
317 unsigned char scheduled_action_running : 1;
318 unsigned char commit_action_running : 1;
319 unsigned char rollback_action_running : 1;
320 } MSIPACKAGE;
322 typedef struct tagMSIPREVIEW
324 MSIOBJECTHDR hdr;
325 MSIPACKAGE *package;
326 msi_dialog *dialog;
327 } MSIPREVIEW;
329 #define MSI_MAX_PROPS 20
331 typedef struct tagMSISUMMARYINFO
333 MSIOBJECTHDR hdr;
334 IStorage *storage;
335 DWORD update_count;
336 PROPVARIANT property[MSI_MAX_PROPS];
337 } MSISUMMARYINFO;
339 typedef struct tagMSIFEATURE
341 struct list entry;
342 LPWSTR Feature;
343 LPWSTR Feature_Parent;
344 LPWSTR Title;
345 LPWSTR Description;
346 INT Display;
347 INT Level;
348 LPWSTR Directory;
349 INT Attributes;
350 INSTALLSTATE Installed;
351 INSTALLSTATE ActionRequest;
352 INSTALLSTATE Action;
353 struct list Children;
354 struct list Components;
355 INT Cost;
356 } MSIFEATURE;
358 typedef struct tagMSICOMPONENT
360 struct list entry;
361 DWORD magic;
362 LPWSTR Component;
363 LPWSTR ComponentId;
364 LPWSTR Directory;
365 INT Attributes;
366 LPWSTR Condition;
367 LPWSTR KeyPath;
368 INSTALLSTATE Installed;
369 INSTALLSTATE ActionRequest;
370 INSTALLSTATE Action;
371 BOOL ForceLocalState;
372 BOOL Enabled;
373 INT Cost;
374 INT RefCount;
375 LPWSTR FullKeypath;
376 LPWSTR AdvertiseString;
378 unsigned int anyAbsent:1;
379 unsigned int hasAdvertiseFeature:1;
380 unsigned int hasLocalFeature:1;
381 unsigned int hasSourceFeature:1;
382 } MSICOMPONENT;
384 typedef struct tagComponentList
386 struct list entry;
387 MSICOMPONENT *component;
388 } ComponentList;
390 typedef struct tagFeatureList
392 struct list entry;
393 MSIFEATURE *feature;
394 } FeatureList;
396 typedef struct tagMSIFOLDER
398 struct list entry;
399 LPWSTR Directory;
400 LPWSTR Parent;
401 LPWSTR TargetDefault;
402 LPWSTR SourceLongPath;
403 LPWSTR SourceShortPath;
405 LPWSTR ResolvedTarget;
406 LPWSTR ResolvedSource;
407 LPWSTR Property; /* initially set property */
408 INT State;
409 /* 0 = uninitialized */
410 /* 1 = existing */
411 /* 2 = created remove if empty */
412 /* 3 = created persist if empty */
413 INT Cost;
414 INT Space;
415 } MSIFOLDER;
417 typedef enum _msi_file_state {
418 msifs_invalid,
419 msifs_missing,
420 msifs_overwrite,
421 msifs_present,
422 msifs_installed,
423 msifs_skipped,
424 } msi_file_state;
426 typedef struct tagMSIFILE
428 struct list entry;
429 LPWSTR File;
430 MSICOMPONENT *Component;
431 LPWSTR FileName;
432 LPWSTR ShortName;
433 LPWSTR LongName;
434 INT FileSize;
435 LPWSTR Version;
436 LPWSTR Language;
437 INT Attributes;
438 INT Sequence;
439 msi_file_state state;
440 LPWSTR SourcePath;
441 LPWSTR TargetPath;
442 BOOL IsCompressed;
443 MSIFILEHASHINFO hash;
444 } MSIFILE;
446 typedef struct tagMSITEMPFILE
448 struct list entry;
449 LPWSTR Path;
450 } MSITEMPFILE;
452 typedef struct tagMSIAPPID
454 struct list entry;
455 LPWSTR AppID; /* Primary key */
456 LPWSTR RemoteServerName;
457 LPWSTR LocalServer;
458 LPWSTR ServiceParameters;
459 LPWSTR DllSurrogate;
460 BOOL ActivateAtStorage;
461 BOOL RunAsInteractiveUser;
462 } MSIAPPID;
464 typedef struct tagMSIPROGID MSIPROGID;
466 typedef struct tagMSICLASS
468 struct list entry;
469 LPWSTR clsid; /* Primary Key */
470 LPWSTR Context; /* Primary Key */
471 MSICOMPONENT *Component;
472 MSIPROGID *ProgID;
473 LPWSTR ProgIDText;
474 LPWSTR Description;
475 MSIAPPID *AppID;
476 LPWSTR FileTypeMask;
477 LPWSTR IconPath;
478 LPWSTR DefInprocHandler;
479 LPWSTR DefInprocHandler32;
480 LPWSTR Argument;
481 MSIFEATURE *Feature;
482 INT Attributes;
483 /* not in the table, set during installation */
484 BOOL Installed;
485 } MSICLASS;
487 typedef struct tagMSIMIME MSIMIME;
489 typedef struct tagMSIEXTENSION
491 struct list entry;
492 LPWSTR Extension; /* Primary Key */
493 MSICOMPONENT *Component;
494 MSIPROGID *ProgID;
495 LPWSTR ProgIDText;
496 MSIMIME *Mime;
497 MSIFEATURE *Feature;
498 /* not in the table, set during installation */
499 BOOL Installed;
500 struct list verbs;
501 } MSIEXTENSION;
503 struct tagMSIPROGID
505 struct list entry;
506 LPWSTR ProgID; /* Primary Key */
507 MSIPROGID *Parent;
508 MSICLASS *Class;
509 LPWSTR Description;
510 LPWSTR IconPath;
511 /* not in the table, set during installation */
512 BOOL InstallMe;
513 MSIPROGID *CurVer;
514 MSIPROGID *VersionInd;
517 typedef struct tagMSIVERB
519 struct list entry;
520 LPWSTR Verb;
521 INT Sequence;
522 LPWSTR Command;
523 LPWSTR Argument;
524 } MSIVERB;
526 struct tagMSIMIME
528 struct list entry;
529 LPWSTR ContentType; /* Primary Key */
530 MSIEXTENSION *Extension;
531 LPWSTR clsid;
532 MSICLASS *Class;
533 /* not in the table, set during installation */
534 BOOL InstallMe;
537 enum SCRIPTS {
538 INSTALL_SCRIPT = 0,
539 COMMIT_SCRIPT = 1,
540 ROLLBACK_SCRIPT = 2,
541 TOTAL_SCRIPTS = 3
544 #define SEQUENCE_UI 0x1
545 #define SEQUENCE_EXEC 0x2
546 #define SEQUENCE_INSTALL 0x10
548 typedef struct tagMSISCRIPT
550 LPWSTR *Actions[TOTAL_SCRIPTS];
551 UINT ActionCount[TOTAL_SCRIPTS];
552 BOOL ExecuteSequenceRun;
553 BOOL CurrentlyScripting;
554 UINT InWhatSequence;
555 LPWSTR *UniqueActions;
556 UINT UniqueActionsCount;
557 } MSISCRIPT;
559 #define MSIHANDLETYPE_ANY 0
560 #define MSIHANDLETYPE_DATABASE 1
561 #define MSIHANDLETYPE_SUMMARYINFO 2
562 #define MSIHANDLETYPE_VIEW 3
563 #define MSIHANDLETYPE_RECORD 4
564 #define MSIHANDLETYPE_PACKAGE 5
565 #define MSIHANDLETYPE_PREVIEW 6
567 #define MSI_MAJORVERSION 3
568 #define MSI_MINORVERSION 1
569 #define MSI_BUILDNUMBER 4000
571 #define GUID_SIZE 39
572 #define SQUISH_GUID_SIZE 33
574 #define MSIHANDLE_MAGIC 0x4d434923
576 DEFINE_GUID(CLSID_IMsiServer, 0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
577 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
578 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
579 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
581 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
583 DEFINE_GUID(CLSID_IWineMsiRemoteCustomAction,0xBA26E6FA,0x4F27,0x4f56,0x95,0x3A,0x3F,0x90,0x27,0x20,0x18,0xAA);
584 DEFINE_GUID(CLSID_IWineMsiRemotePackage,0x902b3592,0x9d08,0x4dfd,0xa5,0x93,0xd0,0x7c,0x52,0x54,0x64,0x21);
586 /* handle unicode/ascii output in the Msi* API functions */
587 typedef struct {
588 BOOL unicode;
589 union {
590 LPSTR a;
591 LPWSTR w;
592 } str;
593 } awstring;
595 typedef struct {
596 BOOL unicode;
597 union {
598 LPCSTR a;
599 LPCWSTR w;
600 } str;
601 } awcstring;
603 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
605 /* msi server interface */
606 extern ITypeLib *get_msi_typelib( LPWSTR *path );
607 extern HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj );
608 extern HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj );
609 extern HRESULT create_msi_remote_database( IUnknown *pOuter, LPVOID *ppObj );
610 extern IUnknown *msi_get_remote(MSIHANDLE handle);
612 /* handle functions */
613 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
614 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
615 extern MSIHANDLE alloc_msi_remote_handle( IUnknown *unk );
616 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
617 extern void msiobj_addref(MSIOBJECTHDR *);
618 extern int msiobj_release(MSIOBJECTHDR *);
619 extern void msiobj_lock(MSIOBJECTHDR *);
620 extern void msiobj_unlock(MSIOBJECTHDR *);
621 extern void msi_free_handle_table(void);
623 extern void free_cached_tables( MSIDATABASE *db );
624 extern void msi_free_transforms( MSIDATABASE *db );
625 extern UINT MSI_CommitTables( MSIDATABASE *db );
628 /* string table functions */
629 enum StringPersistence
631 StringPersistent = 0,
632 StringNonPersistent = 1
635 extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
636 extern UINT msi_id2stringW( const string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
637 extern UINT msi_id2stringA( const string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
639 extern UINT msi_string2idW( const string_table *st, LPCWSTR buffer, UINT *id );
640 extern UINT msi_string2idA( const string_table *st, LPCSTR str, UINT *id );
641 extern VOID msi_destroy_stringtable( string_table *st );
642 extern UINT msi_strcmp( const string_table *st, UINT lval, UINT rval, UINT *res );
643 extern const WCHAR *msi_string_lookup_id( const string_table *st, UINT id );
644 extern HRESULT msi_init_string_table( IStorage *stg );
645 extern string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref );
646 extern UINT msi_save_string_table( const string_table *st, IStorage *storage );
649 extern void msi_table_set_strref(UINT bytes_per_strref);
650 extern BOOL TABLE_Exists( MSIDATABASE *db, LPCWSTR name );
651 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
653 extern UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname,
654 USHORT **pdata, UINT *psz );
655 extern UINT read_stream_data( IStorage *stg, LPCWSTR stname, BOOL table,
656 BYTE **pdata, UINT *psz );
657 extern UINT write_stream_data( IStorage *stg, LPCWSTR stname,
658 LPCVOID data, UINT sz, BOOL bTable );
660 /* transform functions */
661 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
662 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
663 LPCWSTR szTransformFile, int iErrorCond );
664 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
666 /* action internals */
667 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
668 extern void ACTION_free_package_structures( MSIPACKAGE* );
669 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
670 extern UINT ACTION_ForceReboot(MSIPACKAGE *package);
671 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
672 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
673 extern UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine );
675 /* record internals */
676 extern UINT MSI_RecordSetIStream( MSIRECORD *, UINT, IStream *);
677 extern UINT MSI_RecordGetIStream( MSIRECORD *, UINT, IStream **);
678 extern const WCHAR *MSI_RecordGetString( const MSIRECORD *, UINT );
679 extern MSIRECORD *MSI_CreateRecord( UINT );
680 extern UINT MSI_RecordSetInteger( MSIRECORD *, UINT, int );
681 extern UINT MSI_RecordSetStringW( MSIRECORD *, UINT, LPCWSTR );
682 extern UINT MSI_RecordSetStringA( MSIRECORD *, UINT, LPCSTR );
683 extern BOOL MSI_RecordIsNull( MSIRECORD *, UINT );
684 extern UINT MSI_RecordGetStringW( MSIRECORD * , UINT, LPWSTR, LPDWORD);
685 extern UINT MSI_RecordGetStringA( MSIRECORD *, UINT, LPSTR, LPDWORD);
686 extern int MSI_RecordGetInteger( MSIRECORD *, UINT );
687 extern UINT MSI_RecordReadStream( MSIRECORD *, UINT, char *, LPDWORD);
688 extern UINT MSI_RecordGetFieldCount( const MSIRECORD *rec );
689 extern UINT MSI_RecordSetStream( MSIRECORD *, UINT, IStream * );
690 extern UINT MSI_RecordDataSize( MSIRECORD *, UINT );
691 extern UINT MSI_RecordStreamToFile( MSIRECORD *, UINT, LPCWSTR );
692 extern UINT MSI_RecordCopyField( MSIRECORD *, UINT, MSIRECORD *, UINT );
694 /* stream internals */
695 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
696 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
697 extern void enum_stream_names( IStorage *stg );
698 extern BOOL decode_streamname(LPCWSTR in, LPWSTR out);
699 extern LPWSTR encode_streamname(BOOL bTable, LPCWSTR in);
701 /* database internals */
702 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
703 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
704 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
705 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
706 extern UINT MSI_IterateRecords( MSIQUERY *, LPDWORD, record_func, LPVOID );
707 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
708 extern UINT MSI_DatabaseImport( MSIDATABASE *, LPCWSTR, LPCWSTR );
709 extern UINT MSI_DatabaseExport( MSIDATABASE *, LPCWSTR, LPCWSTR, LPCWSTR );
710 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
712 /* view internals */
713 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
714 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
715 extern UINT MSI_ViewClose( MSIQUERY* );
716 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
717 extern UINT MSI_ViewModify( MSIQUERY *, MSIMODIFY, MSIRECORD * );
718 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, UINT * );
719 extern UINT msi_view_get_row(MSIDATABASE *, MSIVIEW *, UINT, MSIRECORD **);
721 /* install internals */
722 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
724 /* package internals */
725 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPCWSTR );
726 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage );
727 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
728 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
729 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
730 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, LPDWORD );
731 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, LPDWORD );
732 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
733 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
734 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
735 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
736 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
737 extern UINT msi_package_add_info(MSIPACKAGE *, DWORD, DWORD, LPCWSTR, LPWSTR);
738 extern UINT msi_package_add_media_disk(MSIPACKAGE *, DWORD, DWORD, DWORD, LPWSTR, LPWSTR);
739 extern UINT msi_clone_properties(MSIPACKAGE *);
741 /* for deformating */
742 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, LPDWORD );
744 /* registry data encoding/decoding functions */
745 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
746 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
747 extern BOOL encode_base85_guid(GUID *,LPWSTR);
748 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
749 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
750 extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
751 extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
752 extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
753 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
754 extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
755 extern UINT MSIREG_OpenComponents(HKEY* key);
756 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
757 extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
758 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
759 extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
760 extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
761 extern UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
762 extern UINT MSIREG_OpenLocalSystemInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
763 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
764 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
765 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
766 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
767 extern UINT MSIREG_DeleteProductKey(LPCWSTR szProduct);
768 extern UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct);
769 extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct);
770 extern UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
771 extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
772 extern UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
773 extern UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
774 extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
775 extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent);
777 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
778 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
780 extern DWORD msi_version_str_to_dword(LPCWSTR p);
781 extern LPWSTR msi_version_dword_to_str(DWORD version);
783 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
784 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
785 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
786 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
788 /* msi dialog interface */
789 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
790 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
791 extern UINT msi_dialog_run_message_loop( msi_dialog* );
792 extern void msi_dialog_end_dialog( msi_dialog* );
793 extern void msi_dialog_check_messages( HANDLE );
794 extern void msi_dialog_do_preview( msi_dialog* );
795 extern void msi_dialog_destroy( msi_dialog* );
796 extern BOOL msi_dialog_register_class( void );
797 extern void msi_dialog_unregister_class( void );
798 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
799 extern UINT msi_dialog_reset( msi_dialog *dialog );
800 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
801 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
802 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
803 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
805 /* preview */
806 extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
807 extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
809 /* summary information */
810 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
811 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
812 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
814 /* undocumented functions */
815 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
816 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, LPDWORD );
817 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, LPDWORD );
818 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
819 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
821 /* UI globals */
822 extern INSTALLUILEVEL gUILevel;
823 extern HWND gUIhwnd;
824 extern INSTALLUI_HANDLERA gUIHandlerA;
825 extern INSTALLUI_HANDLERW gUIHandlerW;
826 extern DWORD gUIFilter;
827 extern LPVOID gUIContext;
828 extern WCHAR gszLogFile[MAX_PATH];
829 extern HINSTANCE msi_hInstance;
831 /* action related functions */
832 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script, BOOL force);
833 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action, UINT script);
834 extern void ACTION_FinishCustomActions( const MSIPACKAGE* package);
835 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, UINT script, BOOL execute);
837 static inline void msi_feature_set_state( MSIFEATURE *feature, INSTALLSTATE state )
839 feature->ActionRequest = state;
840 feature->Action = state;
843 static inline void msi_component_set_state( MSICOMPONENT *comp, INSTALLSTATE state )
845 comp->ActionRequest = state;
846 comp->Action = state;
849 /* actions in other modules */
850 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
851 extern UINT ACTION_CCPSearch(MSIPACKAGE *package);
852 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
853 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
854 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
855 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
856 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
857 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
858 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
859 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
860 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
862 /* Helpers */
863 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
864 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
865 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
866 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
867 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
868 BOOL set_prop, BOOL load_prop, MSIFOLDER **folder);
869 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
870 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
871 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
872 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
873 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
874 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
875 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
876 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
877 extern LPWSTR build_directory_name(DWORD , ...);
878 extern BOOL create_full_pathW(const WCHAR *path);
879 extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE);
880 extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE);
881 extern void reduce_to_longfilename(WCHAR*);
882 extern void reduce_to_shortfilename(WCHAR*);
883 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
884 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
885 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
886 extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
887 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
888 extern UINT msi_create_component_directories( MSIPACKAGE *package );
889 extern void msi_ui_error( DWORD msg_id, DWORD type );
890 extern UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
891 MSIINSTALLCONTEXT context, DWORD options, LPCWSTR value);
893 /* control event stuff */
894 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
895 MSIRECORD *data);
896 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
897 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
898 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
899 LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
900 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
901 LPCWSTR control, LPCWSTR attribute );
903 /* OLE automation */
904 extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj);
905 extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch);
906 extern HRESULT load_type_info(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid);
908 /* Scripting */
909 extern DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action);
911 /* User Interface messages from the actions */
912 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
913 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
915 /* string consts use a number of places and defined in helpers.c*/
916 extern const WCHAR cszSourceDir[];
917 extern const WCHAR cszSOURCEDIR[];
918 extern const WCHAR szProductCode[];
919 extern const WCHAR cszRootDrive[];
920 extern const WCHAR cszbs[];
922 /* memory allocation macro functions */
923 static inline void *msi_alloc( size_t len )
925 return HeapAlloc( GetProcessHeap(), 0, len );
928 static inline void *msi_alloc_zero( size_t len )
930 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
933 static inline void *msi_realloc( void *mem, size_t len )
935 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
938 static inline void *msi_realloc_zero( void *mem, size_t len )
940 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
943 static inline BOOL msi_free( void *mem )
945 return HeapFree( GetProcessHeap(), 0, mem );
948 static inline char *strdupWtoA( LPCWSTR str )
950 LPSTR ret = NULL;
951 DWORD len;
953 if (!str) return ret;
954 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
955 ret = msi_alloc( len );
956 if (ret)
957 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
958 return ret;
961 static inline LPWSTR strdupAtoW( LPCSTR str )
963 LPWSTR ret = NULL;
964 DWORD len;
966 if (!str) return ret;
967 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
968 ret = msi_alloc( len * sizeof(WCHAR) );
969 if (ret)
970 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
971 return ret;
974 static inline LPWSTR strdupW( LPCWSTR src )
976 LPWSTR dest;
977 if (!src) return NULL;
978 dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
979 if (dest)
980 lstrcpyW(dest, src);
981 return dest;
984 #endif /* __WINE_MSI_PRIVATE__ */