2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002-2005 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_MSI_PRIVATE__
22 #define __WINE_MSI_PRIVATE__
33 #include "wine/list.h"
35 #define MSI_DATASIZEMASK 0x00ff
36 #define MSITYPE_VALID 0x0100
37 #define MSITYPE_STRING 0x0800
38 #define MSITYPE_NULLABLE 0x1000
39 #define MSITYPE_KEY 0x2000
41 #define MSITYPE_BINARY 0x8900
44 typedef struct tagMSITABLE MSITABLE
;
47 typedef struct string_table string_table
;
49 struct tagMSIOBJECTHDR
;
50 typedef struct tagMSIOBJECTHDR MSIOBJECTHDR
;
52 typedef VOID (*msihandledestructor
)( MSIOBJECTHDR
* );
54 struct tagMSIOBJECTHDR
59 msihandledestructor destructor
;
60 struct tagMSIOBJECTHDR
*next
;
61 struct tagMSIOBJECTHDR
*prev
;
64 typedef struct tagMSIDATABASE
68 string_table
*strings
;
70 MSITABLE
*first_table
, *last_table
;
73 typedef struct tagMSIVIEW MSIVIEW
;
75 typedef struct tagMSIQUERY
84 /* maybe we can use a Variant instead of doing it ourselves? */
85 typedef struct tagMSIFIELD
96 typedef struct tagMSIRECORD
99 UINT count
; /* as passed to MsiCreateRecord */
100 MSIFIELD fields
[1]; /* nb. array size is count+1 */
103 typedef struct tagMSIVIEWOPS
106 * fetch_int - reads one integer from {row,col} in the table
108 * This function should be called after the execute method.
109 * Data returned by the function should not change until
110 * close or delete is called.
111 * To get a string value, query the database's string table with
112 * the integer value returned from this function.
114 UINT (*fetch_int
)( struct tagMSIVIEW
*, UINT row
, UINT col
, UINT
*val
);
117 * fetch_int - reads one integer from {row,col} in the table
119 * This function is similar to fetch_int, except fetches a
120 * stream instead of an integer.
122 UINT (*fetch_stream
)( struct tagMSIVIEW
*, UINT row
, UINT col
, IStream
**stm
);
125 * get_int - sets one integer at {row,col} in the table
127 * Similar semantics to fetch_int
129 UINT (*set_int
)( struct tagMSIVIEW
*, UINT row
, UINT col
, UINT val
);
132 * Inserts a new row into the database from the records contents
134 UINT (*insert_row
)( struct tagMSIVIEW
*, MSIRECORD
* );
137 * execute - loads the underlying data into memory so it can be read
139 UINT (*execute
)( struct tagMSIVIEW
*, MSIRECORD
* );
142 * close - clears the data read by execute from memory
144 UINT (*close
)( struct tagMSIVIEW
* );
147 * get_dimensions - returns the number of rows or columns in a table.
149 * The number of rows can only be queried after the execute method
150 * is called. The number of columns can be queried at any time.
152 UINT (*get_dimensions
)( struct tagMSIVIEW
*, UINT
*rows
, UINT
*cols
);
155 * get_column_info - returns the name and type of a specific column
157 * The name is HeapAlloc'ed by this function and should be freed by
159 * The column information can be queried at any time.
161 UINT (*get_column_info
)( struct tagMSIVIEW
*, UINT n
, LPWSTR
*name
, UINT
*type
);
164 * modify - not yet implemented properly
166 UINT (*modify
)( struct tagMSIVIEW
*, MSIMODIFY
, MSIRECORD
* );
169 * delete - destroys the structure completely
171 UINT (*delete)( struct tagMSIVIEW
* );
181 struct msi_dialog_tag
;
182 typedef struct msi_dialog_tag msi_dialog
;
184 typedef struct tagMSIPACKAGE
188 struct list components
;
189 struct list features
;
191 struct list tempfiles
;
197 struct list extensions
;
202 struct tagMSISCRIPT
*script
;
204 struct list RunningActions
;
210 UINT CurrentInstallState
;
214 struct list subscriptions
;
217 typedef struct tagMSIPREVIEW
224 #define MSIHANDLETYPE_ANY 0
225 #define MSIHANDLETYPE_DATABASE 1
226 #define MSIHANDLETYPE_SUMMARYINFO 2
227 #define MSIHANDLETYPE_VIEW 3
228 #define MSIHANDLETYPE_RECORD 4
229 #define MSIHANDLETYPE_PACKAGE 5
230 #define MSIHANDLETYPE_PREVIEW 6
232 #define MSI_MAJORVERSION 2
233 #define MSI_MINORVERSION 0
234 #define MSI_BUILDNUMBER 2600
238 #define MSIHANDLE_MAGIC 0x4d434923
239 #define MSIMAXHANDLES 0xf0
241 #define MSISUMINFO_OFFSET 0x30LL
243 DEFINE_GUID(CLSID_IMsiServer
, 0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
244 DEFINE_GUID(CLSID_IMsiServerX1
, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
245 DEFINE_GUID(CLSID_IMsiServerX2
, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
246 DEFINE_GUID(CLSID_IMsiServerX3
, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
248 DEFINE_GUID(CLSID_IMsiServerMessage
, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
266 /* handle functions */
267 extern void *msihandle2msiinfo(MSIHANDLE handle
, UINT type
);
268 extern MSIHANDLE
alloc_msihandle( MSIOBJECTHDR
* );
269 extern void *alloc_msiobject(UINT type
, UINT size
, msihandledestructor destroy
);
270 extern void msiobj_addref(MSIOBJECTHDR
*);
271 extern int msiobj_release(MSIOBJECTHDR
*);
272 extern void msiobj_lock(MSIOBJECTHDR
*);
273 extern void msiobj_unlock(MSIOBJECTHDR
*);
274 extern MSIHANDLE
msiobj_findhandle( MSIOBJECTHDR
*hdr
);
276 /* add this table to the list of cached tables in the database */
277 extern void add_table(MSIDATABASE
*db
, MSITABLE
*table
);
278 extern void remove_table( MSIDATABASE
*db
, MSITABLE
*table
);
279 extern void free_table( MSIDATABASE
*db
, MSITABLE
*table
);
280 extern void free_cached_tables( MSIDATABASE
*db
);
281 extern UINT
find_cached_table(MSIDATABASE
*db
, LPCWSTR name
, MSITABLE
**table
);
282 extern UINT
get_table(MSIDATABASE
*db
, LPCWSTR name
, MSITABLE
**table
);
283 extern UINT
load_string_table( MSIDATABASE
*db
);
284 extern UINT
MSI_CommitTables( MSIDATABASE
*db
);
285 extern HRESULT
init_string_table( IStorage
*stg
);
288 /* string table functions */
289 extern BOOL
msi_addstring( string_table
*st
, UINT string_no
, const CHAR
*data
, int len
, UINT refcount
);
290 extern BOOL
msi_addstringW( string_table
*st
, UINT string_no
, const WCHAR
*data
, int len
, UINT refcount
);
291 extern UINT
msi_id2stringW( string_table
*st
, UINT string_no
, LPWSTR buffer
, UINT
*sz
);
292 extern UINT
msi_id2stringA( string_table
*st
, UINT string_no
, LPSTR buffer
, UINT
*sz
);
294 extern LPWSTR
MSI_makestring( MSIDATABASE
*db
, UINT stringid
);
295 extern UINT
msi_string2idW( string_table
*st
, LPCWSTR buffer
, UINT
*id
);
296 extern UINT
msi_string2idA( string_table
*st
, LPCSTR str
, UINT
*id
);
297 extern string_table
*msi_init_stringtable( int entries
, UINT codepage
);
298 extern VOID
msi_destroy_stringtable( string_table
*st
);
299 extern UINT
msi_string_count( string_table
*st
);
300 extern UINT
msi_id_refcount( string_table
*st
, UINT i
);
301 extern UINT
msi_string_totalsize( string_table
*st
, UINT
*last
);
302 extern UINT
msi_strcmp( string_table
*st
, UINT lval
, UINT rval
, UINT
*res
);
303 extern const WCHAR
*msi_string_lookup_id( string_table
*st
, UINT id
);
304 extern UINT
msi_string_get_codepage( string_table
*st
);
307 extern UINT
VIEW_find_column( MSIVIEW
*view
, LPCWSTR name
, UINT
*n
);
309 extern BOOL
TABLE_Exists( MSIDATABASE
*db
, LPWSTR name
);
311 extern UINT
read_raw_stream_data( MSIDATABASE
*, LPCWSTR stname
,
312 USHORT
**pdata
, UINT
*psz
);
314 /* action internals */
315 extern UINT
ACTION_DoTopLevelINSTALL( MSIPACKAGE
*, LPCWSTR
, LPCWSTR
, LPCWSTR
);
316 extern void ACTION_free_package_structures( MSIPACKAGE
* );
317 extern UINT
ACTION_DialogBox( MSIPACKAGE
*, LPCWSTR
);
319 /* record internals */
320 extern UINT
MSI_RecordSetIStream( MSIRECORD
*, unsigned int, IStream
*);
321 extern UINT
MSI_RecordGetIStream( MSIRECORD
*, unsigned int, IStream
**);
322 extern const WCHAR
*MSI_RecordGetString( MSIRECORD
*, unsigned int );
323 extern MSIRECORD
*MSI_CreateRecord( unsigned int );
324 extern UINT
MSI_RecordSetInteger( MSIRECORD
*, unsigned int, int );
325 extern UINT
MSI_RecordSetStringW( MSIRECORD
*, unsigned int, LPCWSTR
);
326 extern UINT
MSI_RecordSetStringA( MSIRECORD
*, unsigned int, LPCSTR
);
327 extern BOOL
MSI_RecordIsNull( MSIRECORD
*, unsigned int );
328 extern UINT
MSI_RecordGetStringW( MSIRECORD
* , unsigned int, LPWSTR
, DWORD
*);
329 extern UINT
MSI_RecordGetStringA( MSIRECORD
*, unsigned int, LPSTR
, DWORD
*);
330 extern int MSI_RecordGetInteger( MSIRECORD
*, unsigned int );
331 extern UINT
MSI_RecordReadStream( MSIRECORD
*, unsigned int, char *, DWORD
*);
332 extern unsigned int MSI_RecordGetFieldCount( MSIRECORD
*rec
);
333 extern UINT
MSI_RecordSetStreamW( MSIRECORD
*, unsigned int, LPCWSTR
);
334 extern UINT
MSI_RecordSetStreamA( MSIRECORD
*, unsigned int, LPCSTR
);
335 extern UINT
MSI_RecordDataSize( MSIRECORD
*, unsigned int );
336 extern UINT
MSI_RecordStreamToFile( MSIRECORD
*, unsigned int, LPCWSTR
);
338 /* stream internals */
339 extern UINT
get_raw_stream( MSIHANDLE hdb
, LPCWSTR stname
, IStream
**stm
);
340 extern UINT
db_get_raw_stream( MSIDATABASE
*db
, LPCWSTR stname
, IStream
**stm
);
341 extern void enum_stream_names( IStorage
*stg
);
343 /* database internals */
344 extern UINT
MSI_OpenDatabaseW( LPCWSTR
, LPCWSTR
, MSIDATABASE
** );
345 extern UINT
MSI_DatabaseOpenViewW(MSIDATABASE
*, LPCWSTR
, MSIQUERY
** );
346 extern UINT
MSI_OpenQuery( MSIDATABASE
*, MSIQUERY
**, LPCWSTR
, ... );
347 typedef UINT (*record_func
)( MSIRECORD
*, LPVOID
);
348 extern UINT
MSI_IterateRecords( MSIQUERY
*, DWORD
*, record_func
, LPVOID
);
349 extern MSIRECORD
*MSI_QueryGetRecord( MSIDATABASE
*db
, LPCWSTR query
, ... );
350 extern UINT
MSI_DatabaseImport( MSIDATABASE
*, LPCWSTR
, LPCWSTR
);
351 extern UINT
MSI_DatabaseExport( MSIDATABASE
*, LPCWSTR
, LPCWSTR
, LPCWSTR
);
352 extern UINT
MSI_DatabaseGetPrimaryKeys( MSIDATABASE
*, LPCWSTR
, MSIRECORD
** );
355 extern UINT
MSI_ViewExecute( MSIQUERY
*, MSIRECORD
* );
356 extern UINT
MSI_ViewFetch( MSIQUERY
*, MSIRECORD
** );
357 extern UINT
MSI_ViewClose( MSIQUERY
* );
359 /* package internals */
360 extern MSIPACKAGE
*MSI_CreatePackage( MSIDATABASE
* );
361 extern UINT
MSI_OpenPackageW( LPCWSTR szPackage
, MSIPACKAGE
** );
362 extern UINT
MSI_SetTargetPathW( MSIPACKAGE
*, LPCWSTR
, LPCWSTR
);
363 extern UINT
MSI_SetPropertyW( MSIPACKAGE
*, LPCWSTR
, LPCWSTR
);
364 extern INT
MSI_ProcessMessage( MSIPACKAGE
*, INSTALLMESSAGE
, MSIRECORD
* );
365 extern UINT
MSI_GetPropertyW( MSIPACKAGE
*, LPCWSTR
, LPWSTR
, DWORD
* );
366 extern UINT
MSI_GetPropertyA(MSIPACKAGE
*, LPCSTR
, LPSTR
, DWORD
* );
367 extern MSICONDITION
MSI_EvaluateConditionW( MSIPACKAGE
*, LPCWSTR
);
368 extern UINT
MSI_GetComponentStateW( MSIPACKAGE
*, LPWSTR
, INSTALLSTATE
*, INSTALLSTATE
* );
369 extern UINT
MSI_GetFeatureStateW( MSIPACKAGE
*, LPWSTR
, INSTALLSTATE
*, INSTALLSTATE
* );
370 extern UINT WINAPI
MSI_SetFeatureStateW(MSIPACKAGE
*, LPCWSTR
, INSTALLSTATE
);
372 /* for deformating */
373 extern UINT
MSI_FormatRecordW( MSIPACKAGE
*, MSIRECORD
*, LPWSTR
, DWORD
* );
374 extern UINT
MSI_FormatRecordA( MSIPACKAGE
*, MSIRECORD
*, LPSTR
, DWORD
* );
376 /* registry data encoding/decoding functions */
377 extern BOOL
unsquash_guid(LPCWSTR in
, LPWSTR out
);
378 extern BOOL
squash_guid(LPCWSTR in
, LPWSTR out
);
379 extern BOOL
encode_base85_guid(GUID
*,LPWSTR
);
380 extern BOOL
decode_base85_guid(LPCWSTR
,GUID
*);
381 extern UINT
MSIREG_OpenUninstallKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
);
382 extern UINT
MSIREG_OpenUserProductsKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
);
383 extern UINT
MSIREG_OpenFeatures(HKEY
* key
);
384 extern UINT
MSIREG_OpenFeaturesKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
);
385 extern UINT
MSIREG_OpenComponents(HKEY
* key
);
386 extern UINT
MSIREG_OpenUserComponentsKey(LPCWSTR szComponent
, HKEY
* key
, BOOL create
);
387 extern UINT
MSIREG_OpenComponentsKey(LPCWSTR szComponent
, HKEY
* key
, BOOL create
);
388 extern UINT
MSIREG_OpenProductsKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
);
389 extern UINT
MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
);
390 extern UINT
MSIREG_OpenUserComponentsKey(LPCWSTR szComponent
, HKEY
* key
, BOOL create
);
391 extern UINT
MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
);
392 extern UINT
MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
);
394 /* msi dialog interface */
395 typedef UINT (*msi_dialog_event_handler
)( MSIPACKAGE
*, LPCWSTR
, LPCWSTR
, msi_dialog
* );
396 extern msi_dialog
*msi_dialog_create( MSIPACKAGE
*, LPCWSTR
, msi_dialog_event_handler
);
397 extern UINT
msi_dialog_run_message_loop( msi_dialog
* );
398 extern void msi_dialog_end_dialog( msi_dialog
* );
399 extern void msi_dialog_check_messages( HANDLE
);
400 extern void msi_dialog_do_preview( msi_dialog
* );
401 extern void msi_dialog_destroy( msi_dialog
* );
402 extern BOOL
msi_dialog_register_class( void );
403 extern void msi_dialog_unregister_class( void );
404 extern void msi_dialog_handle_event( msi_dialog
*, LPCWSTR
, LPCWSTR
, MSIRECORD
* );
407 extern MSIPREVIEW
*MSI_EnableUIPreview( MSIDATABASE
* );
408 extern UINT
MSI_PreviewDialogW( MSIPREVIEW
*, LPCWSTR
);
410 /* undocumented functions */
411 UINT WINAPI
MsiCreateAndVerifyInstallerDirectory( DWORD
);
412 UINT WINAPI
MsiDecomposeDescriptorW( LPCWSTR
, LPWSTR
, LPWSTR
, LPWSTR
, DWORD
* );
413 UINT WINAPI
MsiDecomposeDescriptorA( LPCSTR
, LPSTR
, LPSTR
, LPSTR
, DWORD
* );
414 LANGID WINAPI
MsiLoadStringW( MSIHANDLE
, UINT
, LPWSTR
, int, LANGID
);
415 LANGID WINAPI
MsiLoadStringA( MSIHANDLE
, UINT
, LPSTR
, int, LANGID
);
418 extern INSTALLUILEVEL gUILevel
;
420 extern INSTALLUI_HANDLERA gUIHandlerA
;
421 extern INSTALLUI_HANDLERW gUIHandlerW
;
422 extern DWORD gUIFilter
;
423 extern LPVOID gUIContext
;
424 extern WCHAR gszLogFile
[MAX_PATH
];
426 inline static char *strdupWtoA( LPCWSTR str
)
431 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
433 if ((ret
= HeapAlloc( GetProcessHeap(), 0, len
)))
434 WideCharToMultiByte( CP_ACP
, 0, str
, -1, ret
, len
, NULL
, NULL
);
439 inline static LPWSTR
strdupAtoW( LPCSTR str
)
444 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
445 if ((ret
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) )))
446 MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
451 inline static LPWSTR
strdupW( LPCWSTR src
)
454 if (!src
) return NULL
;
455 dest
= HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src
)+1)*sizeof(WCHAR
));
460 #endif /* __WINE_MSI_PRIVATE__ */