treat missing MSI tables as empty
Mike McCormack
mike at codeweavers.com
Wed Oct 29 21:01:53 CST 2003
ChangeLog:
* treat missing MSI tables as empty
-------------- next part --------------
Index: dlls/msi/table.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/table.c,v
retrieving revision 1.3
diff -u -r1.3 table.c
--- dlls/msi/table.c 8 Sep 2003 19:38:46 -0000 1.3
+++ dlls/msi/table.c 28 Oct 2003 13:27:06 -0000
@@ -152,26 +152,22 @@
}
#endif
-UINT read_table_from_storage(IStorage *stg, LPCWSTR name, MSITABLE **ptable)
+static BOOL read_stream_data( IStorage *stg, LPWSTR stname,
+ USHORT **pdata, UINT *psz )
{
- WCHAR buffer[0x20];
HRESULT r;
- IStream *stm = NULL;
- STATSTG stat;
UINT ret = ERROR_FUNCTION_FAILED;
VOID *data;
ULONG sz, count;
- MSITABLE *t;
-
- encode_streamname(TRUE, name, buffer);
-
- TRACE("%s -> %s\n",debugstr_w(name),debugstr_w(buffer));
+ IStream *stm = NULL;
+ STATSTG stat;
- r = IStorage_OpenStream(stg, buffer, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm);
+ r = IStorage_OpenStream(stg, stname, NULL,
+ STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm);
if( FAILED( r ) )
{
- ERR("open stream failed r = %08lx!\n",r);
- return r;
+ WARN("open stream failed r = %08lx - empty table?\n",r);
+ return ret;
}
r = IStream_Stat(stm, &stat, STATFLAG_NONAME );
@@ -192,47 +188,54 @@
if( !data )
{
ERR("couldn't allocate memory r=%08lx!\n",r);
+ ret = ERROR_NOT_ENOUGH_MEMORY;
goto end;
}
r = IStream_Read(stm, data, sz, &count );
- if( FAILED( r ) )
+ if( FAILED( r ) || ( count != sz ) )
{
HeapFree( GetProcessHeap(), 0, data );
ERR("read stream failed r = %08lx!\n",r);
goto end;
}
- t = HeapAlloc( GetProcessHeap(), 0, sizeof (MSITABLE) + lstrlenW(name)*sizeof (WCHAR) );
- if( !t )
- {
- HeapFree( GetProcessHeap(), 0, data );
- ERR("malloc failed!\n");
- goto end;
- }
-
- if( count == sz )
- {
- ret = ERROR_SUCCESS;
- t->size = sz;
- t->data = data;
- lstrcpyW( t->name, name );
- t->ref_count = 1;
- *ptable = t;
- }
- else
- {
- HeapFree( GetProcessHeap(), 0, data );
- ERR("Count != sz\n");
- }
+ *pdata = data;
+ *psz = sz;
+ ret = ERROR_SUCCESS;
end:
- if( stm )
- IStream_Release( stm );
+ IStream_Release( stm );
return ret;
}
+UINT read_table_from_storage(IStorage *stg, LPCWSTR name, MSITABLE **ptable)
+{
+ WCHAR buffer[0x20];
+ MSITABLE *t;
+
+ TRACE("%s -> %s\n",debugstr_w(name),debugstr_w(buffer));
+
+ /* non-existing tables should be interpretted as empty tables */
+ t = HeapAlloc( GetProcessHeap(), 0,
+ sizeof (MSITABLE) + lstrlenW(name)*sizeof (WCHAR) );
+ if( !t )
+ return ERROR_NOT_ENOUGH_MEMORY;
+
+ t->size = 0;
+ t->data = NULL;
+ lstrcpyW( t->name, name );
+ t->ref_count = 1;
+ *ptable = t;
+
+ /* if we can't read the table, just assume that it's empty */
+ encode_streamname(TRUE, name, buffer);
+ read_stream_data( stg, buffer, &t->data, &t->size );
+
+ return ERROR_SUCCESS;
+}
+
/* add this table to the list of cached tables in the database */
void add_table(MSIDATABASE *db, MSITABLE *table)
{
More information about the wine-patches
mailing list