2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002,2003,2004,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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define NONAMELESSUNION
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(msi);
42 DEFINE_GUID( CLSID_MsiDatabase, 0x000c1084, 0x0000, 0x0000,
43 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
44 DEFINE_GUID( CLSID_MsiPatch, 0x000c1086, 0x0000, 0x0000,
45 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
50 * An .msi file is a structured storage file.
51 * It contains a number of streams.
52 * A stream for each table in the database.
53 * Two streams for the string table in the database.
54 * Any binary data in a table is a reference to a stream.
57 static VOID MSI_CloseDatabase( MSIOBJECTHDR *arg )
59 MSIDATABASE *db = (MSIDATABASE *) arg;
62 free_cached_tables( db );
63 msi_free_transforms( db );
64 msi_destroy_stringtable( db->strings );
65 IStorage_Release( db->storage );
68 DeleteFileW( db->deletefile );
69 msi_free( db->deletefile );
73 UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
77 MSIDATABASE *db = NULL;
78 UINT ret = ERROR_FUNCTION_FAILED;
79 LPCWSTR szMode, save_path;
84 static const WCHAR backslash[] = {'\\',0};
86 TRACE("%s %s\n",debugstr_w(szDBPath),debugstr_w(szPersist) );
89 return ERROR_INVALID_PARAMETER;
93 if( HIWORD( szPersist ) )
95 if (!CopyFileW( szDBPath, szPersist, FALSE ))
96 return ERROR_OPEN_FAILED;
99 szPersist = MSIDBOPEN_TRANSACT;
103 if( szPersist == MSIDBOPEN_READONLY )
105 r = StgOpenStorage( szDBPath, NULL,
106 STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
108 else if( szPersist == MSIDBOPEN_CREATE || szPersist == MSIDBOPEN_CREATEDIRECT )
110 /* FIXME: MSIDBOPEN_CREATE should case STGM_TRANSACTED flag to be
112 r = StgCreateDocfile( szDBPath,
113 STGM_CREATE|STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
114 if( r == ERROR_SUCCESS )
116 IStorage_SetClass( stg, &CLSID_MsiDatabase );
117 r = msi_init_string_table( stg );
121 else if( szPersist == MSIDBOPEN_TRANSACT )
123 /* FIXME: MSIDBOPEN_TRANSACT should case STGM_TRANSACTED flag to be
125 r = StgOpenStorage( szDBPath, NULL,
126 STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
128 else if( szPersist == MSIDBOPEN_DIRECT )
130 r = StgOpenStorage( szDBPath, NULL,
131 STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
135 ERR("unknown flag %p\n",szPersist);
136 return ERROR_INVALID_PARAMETER;
139 if( FAILED( r ) || !stg )
141 FIXME("open failed r = %08x!\n",r);
142 return ERROR_FUNCTION_FAILED;
145 r = IStorage_Stat( stg, &stat, STATFLAG_NONAME );
148 FIXME("Failed to stat storage\n");
152 if ( !IsEqualGUID( &stat.clsid, &CLSID_MsiDatabase ) &&
153 !IsEqualGUID( &stat.clsid, &CLSID_MsiPatch ) )
155 ERR("storage GUID is not a MSI database GUID %s\n",
156 debugstr_guid(&stat.clsid) );
160 db = alloc_msiobject( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE),
164 FIXME("Failed to allocate a handle\n");
168 if (!strchrW( save_path, '\\' ))
170 GetCurrentDirectoryW( MAX_PATH, path );
171 lstrcatW( path, backslash );
172 lstrcatW( path, save_path );
175 lstrcpyW( path, save_path );
177 db->path = strdupW( path );
179 if( TRACE_ON( msi ) )
180 enum_stream_names( stg );
185 db->deletefile = strdupW( szDBPath );
187 db->deletefile = NULL;
188 list_init( &db->tables );
189 list_init( &db->transforms );
191 db->strings = msi_load_string_table( stg, &db->bytes_per_strref );
195 msi_table_set_strref( db->bytes_per_strref );
198 msiobj_addref( &db->hdr );
199 IStorage_AddRef( stg );
204 msiobj_release( &db->hdr );
206 IStorage_Release( stg );
211 UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
216 TRACE("%s %s %p\n",debugstr_w(szDBPath),debugstr_w(szPersist), phDB);
218 ret = MSI_OpenDatabaseW( szDBPath, szPersist, &db );
219 if( ret == ERROR_SUCCESS )
221 *phDB = alloc_msihandle( &db->hdr );
223 ret = ERROR_NOT_ENOUGH_MEMORY;
224 msiobj_release( &db->hdr );
230 UINT WINAPI MsiOpenDatabaseA(LPCSTR szDBPath, LPCSTR szPersist, MSIHANDLE *phDB)
232 HRESULT r = ERROR_FUNCTION_FAILED;
233 LPWSTR szwDBPath = NULL, szwPersist = NULL;
235 TRACE("%s %s %p\n", debugstr_a(szDBPath), debugstr_a(szPersist), phDB);
239 szwDBPath = strdupAtoW( szDBPath );
244 if( HIWORD(szPersist) )
246 szwPersist = strdupAtoW( szPersist );
251 szwPersist = (LPWSTR)(DWORD_PTR)szPersist;
253 r = MsiOpenDatabaseW( szwDBPath, szwPersist, phDB );
256 if( HIWORD(szPersist) )
257 msi_free( szwPersist );
258 msi_free( szwDBPath );
263 static LPWSTR msi_read_text_archive(LPCWSTR path)
268 DWORD read, size = 0;
270 file = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
271 if (file == INVALID_HANDLE_VALUE)
274 size = GetFileSize( file, NULL );
275 data = msi_alloc( size + 1 );
279 if (!ReadFile( file, data, size, &read, NULL ))
283 wdata = strdupAtoW( data );
291 static void msi_parse_line(LPWSTR *line, LPWSTR **entries, DWORD *num_entries)
293 LPWSTR ptr = *line, save;
298 /* stay on this line */
299 while (*ptr && *ptr != '\n')
301 /* entries are separated by tabs */
308 *entries = msi_alloc(count * sizeof(LPWSTR));
312 /* store pointers into the data */
313 for (i = 0, ptr = *line; i < count; i++)
317 while (*ptr && *ptr != '\t' && *ptr != '\n') ptr++;
319 /* NULL-separate the data */
323 (*entries)[i] = save;
326 /* move to the next line if there's more, else EOF */
330 *num_entries = count;
333 static LPWSTR msi_build_createsql_prelude(LPWSTR table)
338 static const WCHAR create_fmt[] = {'C','R','E','A','T','E',' ','T','A','B','L','E',' ','`','%','s','`',' ','(',' ',0};
340 size = sizeof(create_fmt) + lstrlenW(table) - 2;
341 prelude = msi_alloc(size * sizeof(WCHAR));
345 sprintfW(prelude, create_fmt, table);
349 static LPWSTR msi_build_createsql_columns(LPWSTR *columns_data, LPWSTR *types, DWORD num_columns)
353 DWORD sql_size = 1, i, len;
354 WCHAR expanded[128], *ptr;
355 WCHAR size[10], comma[2], extra[30];
357 static const WCHAR column_fmt[] = {'`','%','s','`',' ','%','s','%','s','%','s','%','s',' ',0};
358 static const WCHAR size_fmt[] = {'(','%','s',')',0};
359 static const WCHAR type_char[] = {'C','H','A','R',0};
360 static const WCHAR type_int[] = {'I','N','T',0};
361 static const WCHAR type_long[] = {'L','O','N','G',0};
362 static const WCHAR type_notnull[] = {' ','N','O','T',' ','N','U','L','L',0};
363 static const WCHAR localizable[] = {' ','L','O','C','A','L','I','Z','A','B','L','E',0};
365 columns = msi_alloc_zero(sql_size * sizeof(WCHAR));
369 for (i = 0; i < num_columns; i++)
372 comma[1] = size[0] = extra[0] = '\0';
374 if (i == num_columns - 1)
386 lstrcpyW(extra, type_notnull);
388 lstrcatW(extra, localizable);
390 sprintfW(size, size_fmt, ptr);
393 lstrcpyW(extra, type_notnull);
396 sprintfW(size, size_fmt, ptr);
399 lstrcpyW(extra, type_notnull);
408 sprintfW(expanded, column_fmt, columns_data[i], type, size, extra, comma);
409 sql_size += lstrlenW(expanded);
411 columns = msi_realloc(columns, sql_size * sizeof(WCHAR));
415 lstrcatW(columns, expanded);
421 static LPWSTR msi_build_createsql_postlude(LPWSTR *primary_keys, DWORD num_keys)
423 LPWSTR postlude, keys, ptr;
424 DWORD size, key_size, i;
426 static const WCHAR key_fmt[] = {'`','%','s','`',',',' ',0};
427 static const WCHAR postlude_fmt[] = {'P','R','I','M','A','R','Y',' ','K','E','Y',' ','%','s',')',0};
429 for (i = 0, size = 1; i < num_keys; i++)
430 size += lstrlenW(key_fmt) + lstrlenW(primary_keys[i]) - 2;
432 keys = msi_alloc(size * sizeof(WCHAR));
436 for (i = 0, ptr = keys; i < num_keys; i++)
438 key_size = lstrlenW(key_fmt) + lstrlenW(primary_keys[i]) -2;
439 sprintfW(ptr, key_fmt, primary_keys[i]);
443 /* remove final ', ' */
446 size = lstrlenW(postlude_fmt) + size - 1;
447 postlude = msi_alloc(size * sizeof(WCHAR));
451 sprintfW(postlude, postlude_fmt, keys);
458 static UINT msi_add_table_to_db(MSIDATABASE *db, LPWSTR *columns, LPWSTR *types, LPWSTR *labels, DWORD num_labels, DWORD num_columns)
464 LPWSTR prelude, columns_sql, postlude;
466 prelude = msi_build_createsql_prelude(labels[0]);
467 columns_sql = msi_build_createsql_columns(columns, types, num_columns);
468 postlude = msi_build_createsql_postlude(labels + 1, num_labels - 1); /* skip over table name */
470 if (!prelude || !columns_sql || !postlude)
471 return ERROR_OUTOFMEMORY;
473 size = lstrlenW(prelude) + lstrlenW(columns_sql) + lstrlenW(postlude) + 1;
474 create_sql = msi_alloc(size * sizeof(WCHAR));
476 return ERROR_OUTOFMEMORY;
478 lstrcpyW(create_sql, prelude);
479 lstrcatW(create_sql, columns_sql);
480 lstrcatW(create_sql, postlude);
483 msi_free(columns_sql);
486 r = MSI_DatabaseOpenViewW( db, create_sql, &view );
487 msi_free(create_sql);
489 if (r != ERROR_SUCCESS)
492 r = MSI_ViewExecute(view, NULL);
494 msiobj_release(&view->hdr);
499 static LPWSTR msi_build_insertsql_prelude(LPWSTR table)
504 static const WCHAR insert_fmt[] = {'I','N','S','E','R','T',' ','I','N','T','O',' ','`','%','s','`',' ','(',' ',0};
506 size = sizeof(insert_fmt) + lstrlenW(table) - 2;
507 prelude = msi_alloc(size * sizeof(WCHAR));
511 sprintfW(prelude, insert_fmt, table);
515 static LPWSTR msi_build_insertsql_columns(LPWSTR *columns_data, LPWSTR *types, DWORD num_columns)
518 DWORD sql_size = 1, i;
521 static const WCHAR column_fmt[] = {'`','%','s','`',',',' ',0};
523 columns = msi_alloc_zero(sql_size * sizeof(WCHAR));
527 for (i = 0; i < num_columns; i++)
529 sprintfW(expanded, column_fmt, columns_data[i]);
530 sql_size += lstrlenW(expanded);
532 if (i == num_columns - 1)
535 expanded[lstrlenW(expanded) - 2] = '\0';
538 columns = msi_realloc(columns, sql_size * sizeof(WCHAR));
542 lstrcatW(columns, expanded);
548 static LPWSTR msi_build_insertsql_data(LPWSTR **records, LPWSTR *types, DWORD num_columns, DWORD irec)
551 DWORD sql_size = 1, i;
554 static const WCHAR str_fmt[] = {'\'','%','s','\'',',',' ',0};
555 static const WCHAR int_fmt[] = {'%','s',',',' ',0};
556 static const WCHAR empty[] = {'\'','\'',',',' ',0};
558 columns = msi_alloc_zero(sql_size * sizeof(WCHAR));
562 for (i = 0; i < num_columns; i++)
566 case 'L': case 'l': case 'S': case 's':
567 sprintfW(expanded, str_fmt, records[irec][i]);
571 sprintfW(expanded, int_fmt, records[irec][i]);
573 lstrcpyW(expanded, empty);
579 if (i == num_columns - 1)
580 expanded[lstrlenW(expanded) - 2] = '\0';
582 sql_size += lstrlenW(expanded);
583 columns = msi_realloc(columns, sql_size * sizeof(WCHAR));
587 lstrcatW(columns, expanded);
593 static UINT msi_add_records_to_table(MSIDATABASE *db, LPWSTR *columns, LPWSTR *types,
594 LPWSTR *labels, LPWSTR **records,
595 int num_columns, int num_records)
600 UINT r = ERROR_SUCCESS;
602 static const WCHAR mid[] = {' ',')',' ','V','A','L','U','E','S',' ','(',' ',0};
603 static const WCHAR end[] = {' ',')',0};
605 LPWSTR prelude = msi_build_insertsql_prelude(labels[0]);
606 LPWSTR columns_sql = msi_build_insertsql_columns(columns, types, num_columns);
608 for (i = 0; i < num_records; i++)
610 LPWSTR data = msi_build_insertsql_data(records, types, num_columns, i);
612 size = lstrlenW(prelude) + lstrlenW(columns_sql) + sizeof(mid) + lstrlenW(data) + sizeof(end) - 1;
613 insert_sql = msi_alloc(size * sizeof(WCHAR));
615 return ERROR_OUTOFMEMORY;
617 lstrcpyW(insert_sql, prelude);
618 lstrcatW(insert_sql, columns_sql);
619 lstrcatW(insert_sql, mid);
620 lstrcatW(insert_sql, data);
621 lstrcatW(insert_sql, end);
625 r = MSI_DatabaseOpenViewW( db, insert_sql, &view );
626 msi_free(insert_sql);
628 if (r != ERROR_SUCCESS)
631 r = MSI_ViewExecute(view, NULL);
633 msiobj_release(&view->hdr);
638 msi_free(columns_sql);
643 UINT MSI_DatabaseImport(MSIDATABASE *db, LPCWSTR folder, LPCWSTR file)
648 DWORD num_columns, num_records = 0;
649 LPWSTR *columns, *types, *labels;
650 LPWSTR path, ptr, data;
653 static const WCHAR backslash[] = {'\\',0};
655 TRACE("%p %s %s\n", db, debugstr_w(folder), debugstr_w(file) );
657 if( folder == NULL || file == NULL )
658 return ERROR_INVALID_PARAMETER;
660 len = lstrlenW(folder) + lstrlenW(backslash) + lstrlenW(file) + 1;
661 path = msi_alloc( len * sizeof(WCHAR) );
663 return ERROR_OUTOFMEMORY;
665 lstrcpyW( path, folder );
666 lstrcatW( path, backslash );
667 lstrcatW( path, file );
669 data = msi_read_text_archive( path );
672 msi_parse_line( &ptr, &columns, &num_columns );
673 msi_parse_line( &ptr, &types, NULL );
674 msi_parse_line( &ptr, &labels, &num_labels );
676 records = msi_alloc(sizeof(LPWSTR *));
678 return ERROR_OUTOFMEMORY;
680 /* read in the table records */
683 msi_parse_line( &ptr, &records[num_records], NULL );
686 records = msi_realloc(records, (num_records + 1) * sizeof(LPWSTR *));
688 return ERROR_OUTOFMEMORY;
691 r = msi_add_table_to_db( db, columns, types, labels, num_labels, num_columns );
692 if (r != ERROR_SUCCESS)
695 r = msi_add_records_to_table( db, columns, types, labels, records, num_columns, num_records );
704 for (i = 0; i < num_records; i++)
705 msi_free(records[i]);
712 UINT WINAPI MsiDatabaseImportW(MSIHANDLE handle, LPCWSTR szFolder, LPCWSTR szFilename)
717 TRACE("%lx %s %s\n",handle,debugstr_w(szFolder), debugstr_w(szFilename));
719 db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
721 return ERROR_INVALID_HANDLE;
722 r = MSI_DatabaseImport( db, szFolder, szFilename );
723 msiobj_release( &db->hdr );
727 UINT WINAPI MsiDatabaseImportA( MSIHANDLE handle,
728 LPCSTR szFolder, LPCSTR szFilename )
730 LPWSTR path = NULL, file = NULL;
731 UINT r = ERROR_OUTOFMEMORY;
733 TRACE("%lx %s %s\n", handle, debugstr_a(szFolder), debugstr_a(szFilename));
737 path = strdupAtoW( szFolder );
744 file = strdupAtoW( szFilename );
749 r = MsiDatabaseImportW( handle, path, file );
758 static UINT msi_export_record( HANDLE handle, MSIRECORD *row, UINT start )
760 UINT i, count, len, r = ERROR_SUCCESS;
766 buffer = msi_alloc( len );
768 return ERROR_OUTOFMEMORY;
770 count = MSI_RecordGetFieldCount( row );
771 for ( i=start; i<=count; i++ )
774 r = MSI_RecordGetStringA( row, i, buffer, &sz );
775 if (r == ERROR_MORE_DATA)
777 char *p = msi_realloc( buffer, sz + 1 );
784 r = MSI_RecordGetStringA( row, i, buffer, &sz );
785 if (r != ERROR_SUCCESS)
788 if (!WriteFile( handle, buffer, sz, &sz, NULL ))
790 r = ERROR_FUNCTION_FAILED;
794 sep = (i < count) ? "\t" : "\r\n";
795 if (!WriteFile( handle, sep, strlen(sep), &sz, NULL ))
797 r = ERROR_FUNCTION_FAILED;
805 static UINT msi_export_row( MSIRECORD *row, void *arg )
807 return msi_export_record( arg, row, 1 );
810 UINT MSI_DatabaseExport( MSIDATABASE *db, LPCWSTR table,
811 LPCWSTR folder, LPCWSTR file )
813 static const WCHAR query[] = {
814 's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','%','s',0 };
815 static const WCHAR szbs[] = { '\\', 0 };
816 MSIRECORD *rec = NULL;
817 MSIQUERY *view = NULL;
822 TRACE("%p %s %s %s\n", db, debugstr_w(table),
823 debugstr_w(folder), debugstr_w(file) );
825 if( folder == NULL || file == NULL )
826 return ERROR_INVALID_PARAMETER;
828 len = lstrlenW(folder) + lstrlenW(file) + 2;
829 filename = msi_alloc(len * sizeof (WCHAR));
831 return ERROR_OUTOFMEMORY;
833 lstrcpyW( filename, folder );
834 lstrcatW( filename, szbs );
835 lstrcatW( filename, file );
837 handle = CreateFileW( filename, GENERIC_READ | GENERIC_WRITE, 0,
838 NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
839 msi_free( filename );
840 if (handle == INVALID_HANDLE_VALUE)
841 return ERROR_FUNCTION_FAILED;
843 r = MSI_OpenQuery( db, &view, query, table );
844 if (r == ERROR_SUCCESS)
846 /* write out row 1, the column names */
847 r = MSI_ViewGetColumnInfo(view, MSICOLINFO_NAMES, &rec);
848 if (r == ERROR_SUCCESS)
850 msi_export_record( handle, rec, 1 );
851 msiobj_release( &rec->hdr );
854 /* write out row 2, the column types */
855 r = MSI_ViewGetColumnInfo(view, MSICOLINFO_TYPES, &rec);
856 if (r == ERROR_SUCCESS)
858 msi_export_record( handle, rec, 1 );
859 msiobj_release( &rec->hdr );
862 /* write out row 3, the table name + keys */
863 r = MSI_DatabaseGetPrimaryKeys( db, table, &rec );
864 if (r == ERROR_SUCCESS)
866 MSI_RecordSetStringW( rec, 0, table );
867 msi_export_record( handle, rec, 0 );
868 msiobj_release( &rec->hdr );
871 /* write out row 4 onwards, the data */
872 r = MSI_IterateRecords( view, 0, msi_export_row, handle );
873 msiobj_release( &view->hdr );
876 CloseHandle( handle );
881 /***********************************************************************
882 * MsiExportDatabaseW [MSI.@]
884 * Writes a file containing the table data as tab separated ASCII.
886 * The format is as follows:
888 * row1 : colname1 <tab> colname2 <tab> .... colnameN <cr> <lf>
889 * row2 : coltype1 <tab> coltype2 <tab> .... coltypeN <cr> <lf>
890 * row3 : tablename <tab> key1 <tab> key2 <tab> ... keyM <cr> <lf>
892 * Followed by the data, starting at row 1 with one row per line
894 * row4 : data <tab> data <tab> data <tab> ... data <cr> <lf>
896 UINT WINAPI MsiDatabaseExportW( MSIHANDLE handle, LPCWSTR szTable,
897 LPCWSTR szFolder, LPCWSTR szFilename )
902 TRACE("%lx %s %s %s\n", handle, debugstr_w(szTable),
903 debugstr_w(szFolder), debugstr_w(szFilename));
905 db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
907 return ERROR_INVALID_HANDLE;
908 r = MSI_DatabaseExport( db, szTable, szFolder, szFilename );
909 msiobj_release( &db->hdr );
913 UINT WINAPI MsiDatabaseExportA( MSIHANDLE handle, LPCSTR szTable,
914 LPCSTR szFolder, LPCSTR szFilename )
916 LPWSTR path = NULL, file = NULL, table = NULL;
917 UINT r = ERROR_OUTOFMEMORY;
919 TRACE("%lx %s %s %s\n", handle, debugstr_a(szTable),
920 debugstr_a(szFolder), debugstr_a(szFilename));
924 table = strdupAtoW( szTable );
931 path = strdupAtoW( szFolder );
938 file = strdupAtoW( szFilename );
943 r = MsiDatabaseExportW( handle, table, path, file );
953 MSIDBSTATE WINAPI MsiGetDatabaseState( MSIHANDLE handle )
955 MSIDBSTATE ret = MSIDBSTATE_READ;
958 TRACE("%ld\n", handle);
960 db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
962 return MSIDBSTATE_ERROR;
963 if (db->mode != MSIDBOPEN_READONLY )
964 ret = MSIDBSTATE_WRITE;
965 msiobj_release( &db->hdr );