MSI: Set the storage file's GUID so native MSI recognizes it

Mike McCormack mike at codeweavers.com
Tue Jun 29 07:27:25 CDT 2004


ChangeLog:
* Set the storage file's GUID so native MSI recognizes it.
   Fix crash when inserting multiple columns that are invalid.
-------------- next part --------------
diff -ur dlls/msi.old/msi.c dlls/msi/msi.c
--- dlls/msi.old/msi.c	2004-06-29 07:25:07.000000000 -0500
+++ dlls/msi/msi.c	2004-06-29 07:25:42.000000000 -0500
@@ -36,6 +36,8 @@
 #include "wine/unicode.h"
 #include "objbase.h"
 
+#include "initguid.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(msi);
 
 /*
@@ -46,6 +48,8 @@
  */
 #define LPCTSTR LPCWSTR
 
+DEFINE_GUID( CLSID_MsiDatabase, 0x000c1084, 0x0000, 0x0000, 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
+
 static const WCHAR szInstaller[] = {
 'S','o','f','t','w','a','r','e','\\',
 'M','i','c','r','o','s','o','f','t','\\',
@@ -188,6 +192,7 @@
     MSIDATABASE *db;
     UINT ret;
     LPWSTR szMode;
+    STATSTG stat;
 
     TRACE("%s %s %p\n",debugstr_w(szDBPath),debugstr_w(szPersist), phDB);
 
@@ -212,7 +217,10 @@
         r = StgCreateDocfile( szDBPath, 
               STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
         if( r == ERROR_SUCCESS )
+        {
+            IStorage_SetClass( stg, &CLSID_MsiDatabase );
             r = init_string_table( stg );
+        }
     }
     else if( szPersist == MSIDBOPEN_TRANSACT )
     {
@@ -231,6 +239,23 @@
         return ERROR_FUNCTION_FAILED;
     }
 
+    r = IStorage_Stat( stg, &stat, STATFLAG_NONAME );
+    if( FAILED( r ) )
+    {
+        FIXME("Failed to stat storage\n");
+        ret = ERROR_FUNCTION_FAILED;
+        goto end;
+    }
+
+    if( memcmp( &stat.clsid, &CLSID_MsiDatabase, sizeof (GUID) ) )
+    {
+        ERR("storage GUID is not a MSI database GUID %s\n",
+             debugstr_guid(&stat.clsid) );
+        ret = ERROR_FUNCTION_FAILED;
+        goto end;
+    }
+
+
     handle = alloc_msihandle( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE),
                               MSI_CloseDatabase, (void**) &db );
     if( !handle )
diff -ur dlls/msi.old/record.c dlls/msi/record.c
--- dlls/msi.old/record.c	2004-06-29 07:25:07.000000000 -0500
+++ dlls/msi/record.c	2004-06-29 07:25:42.000000000 -0500
@@ -284,6 +284,9 @@
     if( iField > rec->count )
         return NULL;
 
+    if( rec->fields[iField].type != MSIFIELD_WSTR )
+        return NULL;
+
     return rec->fields[iField].u.szwVal;
 }
 
diff -ur dlls/msi.old/string.c dlls/msi/string.c
--- dlls/msi.old/string.c	2004-06-29 07:25:07.000000000 -0500
+++ dlls/msi/string.c	2004-06-29 07:25:42.000000000 -0500
@@ -143,6 +143,8 @@
 {
     int sz;
 
+    if( !data )
+        return 0;
     if( !data[0] )
         return 0;
     if( n > 0 )
@@ -189,6 +191,8 @@
 {
     /* TRACE("[%2d] = %s\n", string_no, debugstr_an(data,len) ); */
 
+    if( !data )
+        return 0;
     if( !data[0] )
         return 0;
     if( n > 0 )


More information about the wine-patches mailing list