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