sync msi with wine 1.1.35
[reactos.git] / reactos / dll / win32 / msi / msipriv.h
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
3 *
4 * Copyright 2002-2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #ifndef __WINE_MSI_PRIVATE__
23 #define __WINE_MSI_PRIVATE__
24
25 #include <stdarg.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "fdi.h"
30 #include "msi.h"
31 #include "msiquery.h"
32 #include "objbase.h"
33 #include "objidl.h"
34 #include "winnls.h"
35 #include "wine/list.h"
36 #include "wine/debug.h"
37
38 #define MSI_DATASIZEMASK 0x00ff
39 #define MSITYPE_VALID 0x0100
40 #define MSITYPE_LOCALIZABLE 0x200
41 #define MSITYPE_STRING 0x0800
42 #define MSITYPE_NULLABLE 0x1000
43 #define MSITYPE_KEY 0x2000
44 #define MSITYPE_TEMPORARY 0x4000
45
46
47 /* Install UI level mask for AND operation to exclude flags */
48 #define INSTALLUILEVEL_MASK 0x0007
49
50 #define MSITYPE_IS_BINARY(type) (((type) & ~MSITYPE_NULLABLE) == (MSITYPE_STRING|MSITYPE_VALID))
51
52 struct tagMSITABLE;
53 typedef struct tagMSITABLE MSITABLE;
54
55 struct string_table;
56 typedef struct string_table string_table;
57
58 struct tagMSIOBJECTHDR;
59 typedef struct tagMSIOBJECTHDR MSIOBJECTHDR;
60
61 typedef VOID (*msihandledestructor)( MSIOBJECTHDR * );
62
63 struct tagMSIOBJECTHDR
64 {
65 UINT magic;
66 UINT type;
67 LONG refcount;
68 msihandledestructor destructor;
69 };
70
71 typedef struct tagMSIDATABASE
72 {
73 MSIOBJECTHDR hdr;
74 IStorage *storage;
75 string_table *strings;
76 UINT bytes_per_strref;
77 LPWSTR path;
78 LPWSTR deletefile;
79 LPWSTR localfile;
80 LPCWSTR mode;
81 struct list tables;
82 struct list transforms;
83 struct list streams;
84 } MSIDATABASE;
85
86 typedef struct tagMSIVIEW MSIVIEW;
87
88 typedef struct tagMSIQUERY
89 {
90 MSIOBJECTHDR hdr;
91 MSIVIEW *view;
92 UINT row;
93 MSIDATABASE *db;
94 struct list mem;
95 } MSIQUERY;
96
97 /* maybe we can use a Variant instead of doing it ourselves? */
98 typedef struct tagMSIFIELD
99 {
100 UINT type;
101 union
102 {
103 INT iVal;
104 LPWSTR szwVal;
105 IStream *stream;
106 } u;
107 } MSIFIELD;
108
109 typedef struct tagMSIRECORD
110 {
111 MSIOBJECTHDR hdr;
112 UINT count; /* as passed to MsiCreateRecord */
113 MSIFIELD fields[1]; /* nb. array size is count+1 */
114 } MSIRECORD;
115
116 typedef struct tagMSISOURCELISTINFO
117 {
118 struct list entry;
119 DWORD context;
120 DWORD options;
121 LPCWSTR property;
122 LPWSTR value;
123 } MSISOURCELISTINFO;
124
125 typedef struct tagMSIMEDIADISK
126 {
127 struct list entry;
128 DWORD context;
129 DWORD options;
130 DWORD disk_id;
131 LPWSTR volume_label;
132 LPWSTR disk_prompt;
133 } MSIMEDIADISK;
134
135 typedef struct tagMSIMEDIAINFO
136 {
137 UINT disk_id;
138 UINT type;
139 UINT last_sequence;
140 LPWSTR disk_prompt;
141 LPWSTR cabinet;
142 LPWSTR first_volume;
143 LPWSTR volume_label;
144 BOOL is_continuous;
145 BOOL is_extracted;
146 WCHAR source[MAX_PATH];
147 } MSIMEDIAINFO;
148
149 typedef struct tagMSIPATCHINFO
150 {
151 LPWSTR patchcode;
152 LPWSTR transforms;
153 } MSIPATCHINFO;
154
155 typedef struct _column_info
156 {
157 LPCWSTR table;
158 LPCWSTR column;
159 INT type;
160 BOOL temporary;
161 struct expr *val;
162 struct _column_info *next;
163 } column_info;
164
165 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
166
167 typedef struct tagMSIVIEWOPS
168 {
169 /*
170 * fetch_int - reads one integer from {row,col} in the table
171 *
172 * This function should be called after the execute method.
173 * Data returned by the function should not change until
174 * close or delete is called.
175 * To get a string value, query the database's string table with
176 * the integer value returned from this function.
177 */
178 UINT (*fetch_int)( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val );
179
180 /*
181 * fetch_stream - gets a stream from {row,col} in the table
182 *
183 * This function is similar to fetch_int, except fetches a
184 * stream instead of an integer.
185 */
186 UINT (*fetch_stream)( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm );
187
188 /*
189 * get_row - gets values from a row
190 *
191 */
192 UINT (*get_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec );
193
194 /*
195 * set_row - sets values in a row as specified by mask
196 *
197 * Similar semantics to fetch_int
198 */
199 UINT (*set_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask );
200
201 /*
202 * Inserts a new row into the database from the records contents
203 */
204 UINT (*insert_row)( struct tagMSIVIEW *view, MSIRECORD *record, UINT row, BOOL temporary );
205
206 /*
207 * Deletes a row from the database
208 */
209 UINT (*delete_row)( struct tagMSIVIEW *view, UINT row );
210
211 /*
212 * execute - loads the underlying data into memory so it can be read
213 */
214 UINT (*execute)( struct tagMSIVIEW *view, MSIRECORD *record );
215
216 /*
217 * close - clears the data read by execute from memory
218 */
219 UINT (*close)( struct tagMSIVIEW *view );
220
221 /*
222 * get_dimensions - returns the number of rows or columns in a table.
223 *
224 * The number of rows can only be queried after the execute method
225 * is called. The number of columns can be queried at any time.
226 */
227 UINT (*get_dimensions)( struct tagMSIVIEW *view, UINT *rows, UINT *cols );
228
229 /*
230 * get_column_info - returns the name and type of a specific column
231 *
232 * The name and tablename is HeapAlloc'ed by this function and should be
233 * freed by the caller.
234 * The column information can be queried at any time.
235 */
236 UINT (*get_column_info)( struct tagMSIVIEW *view, UINT n, LPWSTR *name, UINT *type, BOOL *temporary, LPWSTR *tableName);
237
238 /*
239 * modify - not yet implemented properly
240 */
241 UINT (*modify)( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *record, UINT row );
242
243 /*
244 * delete - destroys the structure completely
245 */
246 UINT (*delete)( struct tagMSIVIEW * );
247
248 /*
249 * find_matching_rows - iterates through rows that match a value
250 *
251 * If the column type is a string then a string ID should be passed in.
252 * If the value to be looked up is an integer then no transformation of
253 * the input value is required, except if the column is a string, in which
254 * case a string ID should be passed in.
255 * The handle is an input/output parameter that keeps track of the current
256 * position in the iteration. It must be initialised to zero before the
257 * first call and continued to be passed in to subsequent calls.
258 */
259 UINT (*find_matching_rows)( struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle );
260
261 /*
262 * add_ref - increases the reference count of the table
263 */
264 UINT (*add_ref)( struct tagMSIVIEW *view );
265
266 /*
267 * release - decreases the reference count of the table
268 */
269 UINT (*release)( struct tagMSIVIEW *view );
270
271 /*
272 * add_column - adds a column to the table
273 */
274 UINT (*add_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number, LPCWSTR column, UINT type, BOOL hold );
275
276 /*
277 * remove_column - removes the column represented by table name and column number from the table
278 */
279 UINT (*remove_column)( struct tagMSIVIEW *view, LPCWSTR table, UINT number );
280
281 /*
282 * sort - orders the table by columns
283 */
284 UINT (*sort)( struct tagMSIVIEW *view, column_info *columns );
285
286 /*
287 * drop - drops the table from the database
288 */
289 UINT (*drop)( struct tagMSIVIEW *view );
290 } MSIVIEWOPS;
291
292 struct tagMSIVIEW
293 {
294 MSIOBJECTHDR hdr;
295 const MSIVIEWOPS *ops;
296 };
297
298 struct msi_dialog_tag;
299 typedef struct msi_dialog_tag msi_dialog;
300
301 typedef struct tagMSIPACKAGE
302 {
303 MSIOBJECTHDR hdr;
304 MSIDATABASE *db;
305 MSIPATCHINFO *patch;
306 struct list components;
307 struct list features;
308 struct list files;
309 struct list tempfiles;
310 struct list folders;
311 LPWSTR ActionFormat;
312 LPWSTR LastAction;
313
314 struct list classes;
315 struct list extensions;
316 struct list progids;
317 struct list mimes;
318 struct list appids;
319
320 struct tagMSISCRIPT *script;
321
322 struct list RunningActions;
323
324 LPWSTR BaseURL;
325 LPWSTR PackagePath;
326 LPWSTR ProductCode;
327
328 UINT CurrentInstallState;
329 msi_dialog *dialog;
330 LPWSTR next_dialog;
331 float center_x;
332 float center_y;
333
334 UINT WordCount;
335 UINT Context;
336
337 struct list subscriptions;
338
339 struct list sourcelist_info;
340 struct list sourcelist_media;
341
342 unsigned char scheduled_action_running : 1;
343 unsigned char commit_action_running : 1;
344 unsigned char rollback_action_running : 1;
345 unsigned char need_reboot : 1;
346 } MSIPACKAGE;
347
348 typedef struct tagMSIPREVIEW
349 {
350 MSIOBJECTHDR hdr;
351 MSIPACKAGE *package;
352 msi_dialog *dialog;
353 } MSIPREVIEW;
354
355 #define MSI_MAX_PROPS 20
356
357 typedef struct tagMSISUMMARYINFO
358 {
359 MSIOBJECTHDR hdr;
360 IStorage *storage;
361 DWORD update_count;
362 PROPVARIANT property[MSI_MAX_PROPS];
363 } MSISUMMARYINFO;
364
365 typedef struct tagMSIFEATURE
366 {
367 struct list entry;
368 LPWSTR Feature;
369 LPWSTR Feature_Parent;
370 LPWSTR Title;
371 LPWSTR Description;
372 INT Display;
373 INT Level;
374 LPWSTR Directory;
375 INT Attributes;
376 INSTALLSTATE Installed;
377 INSTALLSTATE ActionRequest;
378 INSTALLSTATE Action;
379 struct list Children;
380 struct list Components;
381 INT Cost;
382 } MSIFEATURE;
383
384 typedef struct tagMSICOMPONENT
385 {
386 struct list entry;
387 DWORD magic;
388 LPWSTR Component;
389 LPWSTR ComponentId;
390 LPWSTR Directory;
391 INT Attributes;
392 LPWSTR Condition;
393 LPWSTR KeyPath;
394 INSTALLSTATE Installed;
395 INSTALLSTATE ActionRequest;
396 INSTALLSTATE Action;
397 BOOL ForceLocalState;
398 BOOL Enabled;
399 INT Cost;
400 INT RefCount;
401 LPWSTR FullKeypath;
402 LPWSTR AdvertiseString;
403
404 unsigned int anyAbsent:1;
405 unsigned int hasAdvertiseFeature:1;
406 unsigned int hasLocalFeature:1;
407 unsigned int hasSourceFeature:1;
408 } MSICOMPONENT;
409
410 typedef struct tagComponentList
411 {
412 struct list entry;
413 MSICOMPONENT *component;
414 } ComponentList;
415
416 typedef struct tagFeatureList
417 {
418 struct list entry;
419 MSIFEATURE *feature;
420 } FeatureList;
421
422 typedef struct tagMSIFOLDER
423 {
424 struct list entry;
425 LPWSTR Directory;
426 LPWSTR Parent;
427 LPWSTR TargetDefault;
428 LPWSTR SourceLongPath;
429 LPWSTR SourceShortPath;
430
431 LPWSTR ResolvedTarget;
432 LPWSTR ResolvedSource;
433 LPWSTR Property; /* initially set property */
434 INT State;
435 /* 0 = uninitialized */
436 /* 1 = existing */
437 /* 2 = created remove if empty */
438 /* 3 = created persist if empty */
439 INT Cost;
440 INT Space;
441 } MSIFOLDER;
442
443 typedef enum _msi_file_state {
444 msifs_invalid,
445 msifs_missing,
446 msifs_overwrite,
447 msifs_present,
448 msifs_installed,
449 msifs_skipped,
450 } msi_file_state;
451
452 typedef struct tagMSIFILE
453 {
454 struct list entry;
455 LPWSTR File;
456 MSICOMPONENT *Component;
457 LPWSTR FileName;
458 LPWSTR ShortName;
459 LPWSTR LongName;
460 INT FileSize;
461 LPWSTR Version;
462 LPWSTR Language;
463 INT Attributes;
464 INT Sequence;
465 msi_file_state state;
466 LPWSTR TargetPath;
467 BOOL IsCompressed;
468 MSIFILEHASHINFO hash;
469 } MSIFILE;
470
471 typedef struct tagMSITEMPFILE
472 {
473 struct list entry;
474 LPWSTR Path;
475 } MSITEMPFILE;
476
477 typedef struct tagMSIAPPID
478 {
479 struct list entry;
480 LPWSTR AppID; /* Primary key */
481 LPWSTR RemoteServerName;
482 LPWSTR LocalServer;
483 LPWSTR ServiceParameters;
484 LPWSTR DllSurrogate;
485 BOOL ActivateAtStorage;
486 BOOL RunAsInteractiveUser;
487 } MSIAPPID;
488
489 typedef struct tagMSIPROGID MSIPROGID;
490
491 typedef struct tagMSICLASS
492 {
493 struct list entry;
494 LPWSTR clsid; /* Primary Key */
495 LPWSTR Context; /* Primary Key */
496 MSICOMPONENT *Component;
497 MSIPROGID *ProgID;
498 LPWSTR ProgIDText;
499 LPWSTR Description;
500 MSIAPPID *AppID;
501 LPWSTR FileTypeMask;
502 LPWSTR IconPath;
503 LPWSTR DefInprocHandler;
504 LPWSTR DefInprocHandler32;
505 LPWSTR Argument;
506 MSIFEATURE *Feature;
507 INT Attributes;
508 /* not in the table, set during installation */
509 BOOL Installed;
510 } MSICLASS;
511
512 typedef struct tagMSIMIME MSIMIME;
513
514 typedef struct tagMSIEXTENSION
515 {
516 struct list entry;
517 LPWSTR Extension; /* Primary Key */
518 MSICOMPONENT *Component;
519 MSIPROGID *ProgID;
520 LPWSTR ProgIDText;
521 MSIMIME *Mime;
522 MSIFEATURE *Feature;
523 /* not in the table, set during installation */
524 BOOL Installed;
525 struct list verbs;
526 } MSIEXTENSION;
527
528 struct tagMSIPROGID
529 {
530 struct list entry;
531 LPWSTR ProgID; /* Primary Key */
532 MSIPROGID *Parent;
533 MSICLASS *Class;
534 LPWSTR Description;
535 LPWSTR IconPath;
536 /* not in the table, set during installation */
537 BOOL InstallMe;
538 MSIPROGID *CurVer;
539 MSIPROGID *VersionInd;
540 };
541
542 typedef struct tagMSIVERB
543 {
544 struct list entry;
545 LPWSTR Verb;
546 INT Sequence;
547 LPWSTR Command;
548 LPWSTR Argument;
549 } MSIVERB;
550
551 struct tagMSIMIME
552 {
553 struct list entry;
554 LPWSTR ContentType; /* Primary Key */
555 MSIEXTENSION *Extension;
556 LPWSTR clsid;
557 MSICLASS *Class;
558 /* not in the table, set during installation */
559 BOOL InstallMe;
560 };
561
562 enum SCRIPTS {
563 INSTALL_SCRIPT = 0,
564 COMMIT_SCRIPT = 1,
565 ROLLBACK_SCRIPT = 2,
566 TOTAL_SCRIPTS = 3
567 };
568
569 #define SEQUENCE_UI 0x1
570 #define SEQUENCE_EXEC 0x2
571 #define SEQUENCE_INSTALL 0x10
572
573 typedef struct tagMSISCRIPT
574 {
575 LPWSTR *Actions[TOTAL_SCRIPTS];
576 UINT ActionCount[TOTAL_SCRIPTS];
577 BOOL ExecuteSequenceRun;
578 BOOL CurrentlyScripting;
579 UINT InWhatSequence;
580 LPWSTR *UniqueActions;
581 UINT UniqueActionsCount;
582 } MSISCRIPT;
583
584 #define MSIHANDLETYPE_ANY 0
585 #define MSIHANDLETYPE_DATABASE 1
586 #define MSIHANDLETYPE_SUMMARYINFO 2
587 #define MSIHANDLETYPE_VIEW 3
588 #define MSIHANDLETYPE_RECORD 4
589 #define MSIHANDLETYPE_PACKAGE 5
590 #define MSIHANDLETYPE_PREVIEW 6
591
592 #define MSI_MAJORVERSION 3
593 #define MSI_MINORVERSION 1
594 #define MSI_BUILDNUMBER 4000
595
596 #define GUID_SIZE 39
597 #define SQUISH_GUID_SIZE 33
598
599 #define MSIHANDLE_MAGIC 0x4d434923
600
601 DEFINE_GUID(CLSID_IMsiServer, 0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
602 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
603 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
604 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
605
606 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
607
608 DEFINE_GUID(CLSID_IWineMsiRemoteCustomAction,0xBA26E6FA,0x4F27,0x4f56,0x95,0x3A,0x3F,0x90,0x27,0x20,0x18,0xAA);
609 DEFINE_GUID(CLSID_IWineMsiRemotePackage,0x902b3592,0x9d08,0x4dfd,0xa5,0x93,0xd0,0x7c,0x52,0x54,0x64,0x21);
610
611 DEFINE_GUID(CLSID_MsiTransform, 0x000c1082,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
612 DEFINE_GUID(CLSID_MsiDatabase, 0x000c1084,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
613 DEFINE_GUID(CLSID_MsiPatch, 0x000c1086,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
614
615 /* handle unicode/ascii output in the Msi* API functions */
616 typedef struct {
617 BOOL unicode;
618 union {
619 LPSTR a;
620 LPWSTR w;
621 } str;
622 } awstring;
623
624 typedef struct {
625 BOOL unicode;
626 union {
627 LPCSTR a;
628 LPCWSTR w;
629 } str;
630 } awcstring;
631
632 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
633
634 /* msi server interface */
635 extern ITypeLib *get_msi_typelib( LPWSTR *path );
636 extern HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj );
637 extern HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj );
638 extern HRESULT create_msi_remote_database( IUnknown *pOuter, LPVOID *ppObj );
639 extern IUnknown *msi_get_remote(MSIHANDLE handle);
640
641 /* handle functions */
642 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
643 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
644 extern MSIHANDLE alloc_msi_remote_handle( IUnknown *unk );
645 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
646 extern void msiobj_addref(MSIOBJECTHDR *);
647 extern int msiobj_release(MSIOBJECTHDR *);
648 extern void msiobj_lock(MSIOBJECTHDR *);
649 extern void msiobj_unlock(MSIOBJECTHDR *);
650 extern void msi_free_handle_table(void);
651
652 extern void free_cached_tables( MSIDATABASE *db );
653 extern UINT MSI_CommitTables( MSIDATABASE *db );
654
655
656 /* string table functions */
657 enum StringPersistence
658 {
659 StringPersistent = 0,
660 StringNonPersistent = 1
661 };
662
663 extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
664
665 extern UINT msi_string2idW( const string_table *st, LPCWSTR buffer, UINT *id );
666 extern VOID msi_destroy_stringtable( string_table *st );
667 extern const WCHAR *msi_string_lookup_id( const string_table *st, UINT id );
668 extern HRESULT msi_init_string_table( IStorage *stg );
669 extern string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref );
670 extern UINT msi_save_string_table( const string_table *st, IStorage *storage );
671
672 extern BOOL TABLE_Exists( MSIDATABASE *db, LPCWSTR name );
673 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
674
675 extern UINT read_raw_stream_data( MSIDATABASE *db, LPCWSTR stname,
676 USHORT **pdata, UINT *psz );
677 extern UINT read_stream_data( IStorage *stg, LPCWSTR stname, BOOL table,
678 BYTE **pdata, UINT *psz );
679 extern UINT write_stream_data( IStorage *stg, LPCWSTR stname,
680 LPCVOID data, UINT sz, BOOL bTable );
681
682 /* transform functions */
683 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
684 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
685 LPCWSTR szTransformFile, int iErrorCond );
686 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
687
688 extern UINT msi_check_patch_applicable( MSIPACKAGE *package, MSISUMMARYINFO *si );
689
690 /* action internals */
691 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
692 extern void ACTION_free_package_structures( MSIPACKAGE* );
693 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
694 extern UINT ACTION_ForceReboot(MSIPACKAGE *package);
695 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
696 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
697 extern UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine,
698 BOOL preserve_case );
699
700 /* record internals */
701 extern void MSI_CloseRecord( MSIOBJECTHDR * );
702 extern UINT MSI_RecordSetIStream( MSIRECORD *, UINT, IStream *);
703 extern UINT MSI_RecordGetIStream( MSIRECORD *, UINT, IStream **);
704 extern const WCHAR *MSI_RecordGetString( const MSIRECORD *, UINT );
705 extern MSIRECORD *MSI_CreateRecord( UINT );
706 extern UINT MSI_RecordSetInteger( MSIRECORD *, UINT, int );
707 extern UINT MSI_RecordSetStringW( MSIRECORD *, UINT, LPCWSTR );
708 extern BOOL MSI_RecordIsNull( MSIRECORD *, UINT );
709 extern UINT MSI_RecordGetStringW( MSIRECORD * , UINT, LPWSTR, LPDWORD);
710 extern UINT MSI_RecordGetStringA( MSIRECORD *, UINT, LPSTR, LPDWORD);
711 extern int MSI_RecordGetInteger( MSIRECORD *, UINT );
712 extern UINT MSI_RecordReadStream( MSIRECORD *, UINT, char *, LPDWORD);
713 extern UINT MSI_RecordSetStream(MSIRECORD *, UINT, IStream *);
714 extern UINT MSI_RecordGetFieldCount( const MSIRECORD *rec );
715 extern UINT MSI_RecordStreamToFile( MSIRECORD *, UINT, LPCWSTR );
716 extern UINT MSI_RecordSetStreamFromFileW( MSIRECORD *, UINT, LPCWSTR );
717 extern UINT MSI_RecordCopyField( MSIRECORD *, UINT, MSIRECORD *, UINT );
718 extern MSIRECORD *MSI_CloneRecord( MSIRECORD * );
719 extern BOOL MSI_RecordsAreEqual( MSIRECORD *, MSIRECORD * );
720
721 /* stream internals */
722 extern void enum_stream_names( IStorage *stg );
723 extern LPWSTR encode_streamname(BOOL bTable, LPCWSTR in);
724 extern BOOL decode_streamname(LPCWSTR in, LPWSTR out);
725
726 /* database internals */
727 extern UINT db_get_raw_stream( MSIDATABASE *, LPCWSTR, IStream ** );
728 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
729 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
730 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
731 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
732 extern UINT MSI_IterateRecords( MSIQUERY *, LPDWORD, record_func, LPVOID );
733 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
734 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
735
736 /* view internals */
737 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
738 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
739 extern UINT MSI_ViewClose( MSIQUERY* );
740 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
741 extern UINT MSI_ViewModify( MSIQUERY *, MSIMODIFY, MSIRECORD * );
742 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, LPCWSTR, UINT * );
743 extern UINT msi_view_get_row(MSIDATABASE *, MSIVIEW *, UINT, MSIRECORD **);
744
745 /* install internals */
746 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
747
748 /* package internals */
749 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPCWSTR );
750 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage );
751 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
752 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
753 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
754 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, LPDWORD );
755 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, LPDWORD );
756 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
757 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
758 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
759 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
760 extern UINT msi_download_file( LPCWSTR szUrl, LPWSTR filename );
761 extern UINT msi_package_add_info(MSIPACKAGE *, DWORD, DWORD, LPCWSTR, LPWSTR);
762 extern UINT msi_package_add_media_disk(MSIPACKAGE *, DWORD, DWORD, DWORD, LPWSTR, LPWSTR);
763 extern UINT msi_clone_properties(MSIPACKAGE *);
764 extern UINT MSI_GetFeatureCost(MSIPACKAGE *, MSIFEATURE *, MSICOSTTREE, INSTALLSTATE, LPINT);
765
766 /* for deformating */
767 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, LPDWORD );
768
769 /* registry data encoding/decoding functions */
770 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
771 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
772 extern BOOL encode_base85_guid(GUID *,LPWSTR);
773 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
774 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
775 extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
776 extern UINT MSIREG_OpenProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
777 MSIINSTALLCONTEXT context, HKEY* key, BOOL create);
778 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
779 HKEY *key, BOOL create);
780 extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
781 UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
782 HKEY *key, BOOL create);
783 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
784 extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid,
785 HKEY *key, BOOL create);
786 extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
787 extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext,
788 LPCWSTR szUserSid, HKEY *key, BOOL create);
789 extern UINT MSIREG_OpenUserDataPatchKey(LPCWSTR szPatch, MSIINSTALLCONTEXT dwContext,
790 HKEY *key, BOOL create);
791 extern UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext,
792 LPCWSTR szUserSid, HKEY *key, BOOL create);
793 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
794 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
795 extern UINT MSIREG_DeleteProductKey(LPCWSTR szProduct);
796 extern UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct);
797 extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct);
798 extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
799 extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid);
800 extern UINT MSIREG_DeleteUserUpgradeCodesKey(LPCWSTR szUpgradeCode);
801 extern UINT MSIREG_OpenClassesUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create);
802 extern UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode);
803 extern UINT MSIREG_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode);
804
805 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
806 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
807
808 extern DWORD msi_version_str_to_dword(LPCWSTR p);
809
810 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
811 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
812 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
813 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
814
815 /* msi dialog interface */
816 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
817 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
818 extern UINT msi_dialog_run_message_loop( msi_dialog* );
819 extern void msi_dialog_end_dialog( msi_dialog* );
820 extern void msi_dialog_check_messages( HANDLE );
821 extern void msi_dialog_do_preview( msi_dialog* );
822 extern void msi_dialog_destroy( msi_dialog* );
823 extern void msi_dialog_unregister_class( void );
824 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
825 extern UINT msi_dialog_reset( msi_dialog *dialog );
826 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
827 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
828 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
829 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
830
831 /* summary information */
832 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
833 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
834 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
835 extern UINT msi_add_suminfo( MSIDATABASE *db, LPWSTR **records, int num_records, int num_columns );
836
837 /* undocumented functions */
838 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
839 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, LPDWORD );
840 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, LPDWORD );
841 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
842 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
843
844 /* UI globals */
845 extern INSTALLUILEVEL gUILevel;
846 extern HWND gUIhwnd;
847 extern INSTALLUI_HANDLERA gUIHandlerA;
848 extern INSTALLUI_HANDLERW gUIHandlerW;
849 extern INSTALLUI_HANDLER_RECORD gUIHandlerRecord;
850 extern DWORD gUIFilter;
851 extern LPVOID gUIContext;
852 extern WCHAR gszLogFile[MAX_PATH];
853 extern HINSTANCE msi_hInstance;
854
855 /* action related functions */
856 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script, BOOL force);
857 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action, UINT script);
858 extern void ACTION_FinishCustomActions( const MSIPACKAGE* package);
859 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, UINT script, BOOL execute);
860
861 static inline void msi_feature_set_state(MSIPACKAGE *package,
862 MSIFEATURE *feature,
863 INSTALLSTATE state)
864 {
865 if (!package->ProductCode)
866 {
867 feature->ActionRequest = state;
868 feature->Action = state;
869 }
870 else if (state == INSTALLSTATE_ABSENT)
871 {
872 switch (feature->Installed)
873 {
874 case INSTALLSTATE_ABSENT:
875 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
876 feature->Action = INSTALLSTATE_UNKNOWN;
877 break;
878 default:
879 feature->ActionRequest = state;
880 feature->Action = state;
881 }
882 }
883 else if (state == INSTALLSTATE_SOURCE)
884 {
885 switch (feature->Installed)
886 {
887 case INSTALLSTATE_ABSENT:
888 case INSTALLSTATE_SOURCE:
889 feature->ActionRequest = state;
890 feature->Action = state;
891 break;
892 case INSTALLSTATE_LOCAL:
893 feature->ActionRequest = INSTALLSTATE_LOCAL;
894 feature->Action = INSTALLSTATE_LOCAL;
895 break;
896 default:
897 feature->ActionRequest = INSTALLSTATE_UNKNOWN;
898 feature->Action = INSTALLSTATE_UNKNOWN;
899 }
900 }
901 else
902 {
903 feature->ActionRequest = state;
904 feature->Action = state;
905 }
906 }
907
908 static inline void msi_component_set_state(MSIPACKAGE *package,
909 MSICOMPONENT *comp,
910 INSTALLSTATE state)
911 {
912 if (!package->ProductCode)
913 {
914 comp->ActionRequest = state;
915 comp->Action = state;
916 }
917 else if (state == INSTALLSTATE_ABSENT)
918 {
919 switch (comp->Installed)
920 {
921 case INSTALLSTATE_LOCAL:
922 case INSTALLSTATE_SOURCE:
923 case INSTALLSTATE_DEFAULT:
924 comp->ActionRequest = state;
925 comp->Action = state;
926 break;
927 default:
928 comp->ActionRequest = INSTALLSTATE_UNKNOWN;
929 comp->Action = INSTALLSTATE_UNKNOWN;
930 }
931 }
932 else if (state == INSTALLSTATE_SOURCE)
933 {
934 if (comp->Installed == INSTALLSTATE_ABSENT ||
935 (comp->Installed == INSTALLSTATE_SOURCE && comp->hasLocalFeature))
936 {
937 comp->ActionRequest = state;
938 comp->Action = state;
939 }
940 else
941 {
942 comp->ActionRequest = INSTALLSTATE_UNKNOWN;
943 comp->Action = INSTALLSTATE_UNKNOWN;
944 }
945 }
946 else
947 {
948 comp->ActionRequest = state;
949 comp->Action = state;
950 }
951 }
952
953 /* actions in other modules */
954 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
955 extern UINT ACTION_CCPSearch(MSIPACKAGE *package);
956 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
957 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
958 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
959 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
960 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
961 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
962 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
963 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
964 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
965
966 /* Helpers */
967 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
968 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
969 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
970 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
971 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
972 BOOL set_prop, BOOL load_prop, MSIFOLDER **folder);
973 extern LPWSTR resolve_file_source(MSIPACKAGE *package, MSIFILE *file);
974 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
975 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
976 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
977 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
978 extern void msi_reset_folders( MSIPACKAGE *package, BOOL source );
979 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
980 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
981 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
982 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
983 extern LPWSTR build_directory_name(DWORD , ...);
984 extern BOOL create_full_pathW(const WCHAR *path);
985 extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE);
986 extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE);
987 extern void reduce_to_longfilename(WCHAR*);
988 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
989 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
990 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
991 extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
992 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
993 extern UINT msi_create_component_directories( MSIPACKAGE *package );
994 extern UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
995 MSIINSTALLCONTEXT context, DWORD options, LPCWSTR value);
996
997 /* media */
998
999 typedef BOOL (*PMSICABEXTRACTCB)(MSIPACKAGE *, LPCWSTR, DWORD, LPWSTR *, DWORD *, PVOID);
1000
1001 #define MSICABEXTRACT_BEGINEXTRACT 0x01
1002 #define MSICABEXTRACT_FILEEXTRACTED 0x02
1003
1004 typedef struct
1005 {
1006 MSIPACKAGE* package;
1007 MSIMEDIAINFO *mi;
1008 PMSICABEXTRACTCB cb;
1009 LPWSTR curfile;
1010 PVOID user;
1011 } MSICABDATA;
1012
1013 extern UINT ready_media(MSIPACKAGE *package, MSIFILE *file, MSIMEDIAINFO *mi);
1014 extern void msi_free_media_info(MSIMEDIAINFO *mi);
1015 extern BOOL msi_cabextract(MSIPACKAGE* package, MSIMEDIAINFO *mi, LPVOID data);
1016
1017 /* control event stuff */
1018 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
1019 MSIRECORD *data);
1020 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
1021 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
1022 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
1023 LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
1024
1025 /* OLE automation */
1026 extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj);
1027 extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch);
1028 extern HRESULT load_type_info(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid);
1029
1030 /* Scripting */
1031 extern DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action);
1032
1033 /* User Interface messages from the actions */
1034 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
1035 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
1036
1037 /* common strings */
1038 static const WCHAR cszSourceDir[] = {'S','o','u','r','c','e','D','i','r',0};
1039 static const WCHAR cszSOURCEDIR[] = {'S','O','U','R','C','E','D','I','R',0};
1040 static const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0};
1041 static const WCHAR szLocalSid[] = {'S','-','1','-','5','-','1','8',0};
1042 static const WCHAR szEmpty[] = {0};
1043 static const WCHAR szAll[] = {'A','L','L',0};
1044 static const WCHAR szOne[] = {'1',0};
1045 static const WCHAR szZero[] = {'0',0};
1046 static const WCHAR szSpace[] = {' ',0};
1047 static const WCHAR szBackSlash[] = {'\\',0};
1048 static const WCHAR szForwardSlash[] = {'/',0};
1049 static const WCHAR szDot[] = {'.',0};
1050 static const WCHAR szDotDot[] = {'.','.',0};
1051 static const WCHAR szSemiColon[] = {';',0};
1052 static const WCHAR szPreselected[] = {'P','r','e','s','e','l','e','c','t','e','d',0};
1053 static const WCHAR szPatches[] = {'P','a','t','c','h','e','s',0};
1054 static const WCHAR szState[] = {'S','t','a','t','e',0};
1055 static const WCHAR szMsi[] = {'m','s','i',0};
1056 static const WCHAR szPatch[] = {'P','A','T','C','H',0};
1057 static const WCHAR szSourceList[] = {'S','o','u','r','c','e','L','i','s','t',0};
1058 static const WCHAR szInstalled[] = {'I','n','s','t','a','l','l','e','d',0};
1059 static const WCHAR szReinstall[] = {'R','E','I','N','S','T','A','L','L',0};
1060 static const WCHAR szReinstallMode[] = {'R','E','I','N','S','T','A','L','L','M','O','D','E',0};
1061 static const WCHAR szRemove[] = {'R','E','M','O','V','E',0};
1062 static const WCHAR szUserSID[] = {'U','s','e','r','S','I','D',0};
1063 static const WCHAR szProductCode[] = {'P','r','o','d','u','c','t','C','o','d','e',0};
1064 static const WCHAR szRegisterClassInfo[] = {'R','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0};
1065 static const WCHAR szRegisterProgIdInfo[] = {'R','e','g','i','s','t','e','r','P','r','o','g','I','d','I','n','f','o',0};
1066 static const WCHAR szRegisterExtensionInfo[] = {'R','e','g','i','s','t','e','r','E','x','t','e','n','s','i','o','n','I','n','f','o',0};
1067 static const WCHAR szRegisterMIMEInfo[] = {'R','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
1068 static const WCHAR szDuplicateFiles[] = {'D','u','p','l','i','c','a','t','e','F','i','l','e','s',0};
1069 static const WCHAR szInstallFiles[] = {'I','n','s','t','a','l','l','F','i','l','e','s',0};
1070 static const WCHAR szRemoveFiles[] = {'R','e','m','o','v','e','F','i','l','e','s',0};
1071 static const WCHAR szFindRelatedProducts[] = {'F','i','n','d','R','e','l','a','t','e','d','P','r','o','d','u','c','t','s',0};
1072 static const WCHAR szAllUsers[] = {'A','L','L','U','S','E','R','S',0};
1073 static const WCHAR szCustomActionData[] = {'C','u','s','t','o','m','A','c','t','i','o','n','D','a','t','a',0};
1074 static const WCHAR szUILevel[] = {'U','I','L','e','v','e','l',0};
1075
1076 /* memory allocation macro functions */
1077 static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
1078 static inline void *msi_alloc( size_t len )
1079 {
1080 return HeapAlloc( GetProcessHeap(), 0, len );
1081 }
1082
1083 static void *msi_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
1084 static inline void *msi_alloc_zero( size_t len )
1085 {
1086 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
1087 }
1088
1089 static void *msi_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
1090 static inline void *msi_realloc( void *mem, size_t len )
1091 {
1092 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
1093 }
1094
1095 static void *msi_realloc_zero( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
1096 static inline void *msi_realloc_zero( void *mem, size_t len )
1097 {
1098 return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
1099 }
1100
1101 static inline BOOL msi_free( void *mem )
1102 {
1103 return HeapFree( GetProcessHeap(), 0, mem );
1104 }
1105
1106 static inline char *strdupWtoA( LPCWSTR str )
1107 {
1108 LPSTR ret = NULL;
1109 DWORD len;
1110
1111 if (!str) return ret;
1112 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
1113 ret = msi_alloc( len );
1114 if (ret)
1115 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
1116 return ret;
1117 }
1118
1119 static inline LPWSTR strdupAtoW( LPCSTR str )
1120 {
1121 LPWSTR ret = NULL;
1122 DWORD len;
1123
1124 if (!str) return ret;
1125 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
1126 ret = msi_alloc( len * sizeof(WCHAR) );
1127 if (ret)
1128 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
1129 return ret;
1130 }
1131
1132 static inline LPWSTR strdupW( LPCWSTR src )
1133 {
1134 LPWSTR dest;
1135 if (!src) return NULL;
1136 dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
1137 if (dest)
1138 lstrcpyW(dest, src);
1139 return dest;
1140 }
1141
1142 #endif /* __WINE_MSI_PRIVATE__ */