Commit de8674ec authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

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

Fix crash when inserting multiple columns that are invalid.
parent 16abc780
......@@ -36,6 +36,8 @@
#include "wine/unicode.h"
#include "objbase.h"
#include "initguid.h"
WINE_DEFAULT_DEBUG_CHANNEL(msi);
/*
......@@ -46,6 +48,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(msi);
*/
#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 @@ UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phD
MSIDATABASE *db;
UINT ret;
LPWSTR szMode;
STATSTG stat;
TRACE("%s %s %p\n",debugstr_w(szDBPath),debugstr_w(szPersist), phDB);
......@@ -212,7 +217,10 @@ UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phD
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 @@ UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phD
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 )
......
......@@ -284,6 +284,9 @@ const WCHAR *MSI_RecordGetString( MSIHANDLE handle, unsigned int iField )
if( iField > rec->count )
return NULL;
if( rec->fields[iField].type != MSIFIELD_WSTR )
return NULL;
return rec->fields[iField].u.szwVal;
}
......
......@@ -143,6 +143,8 @@ int msi_addstring( string_table *st, int n, const CHAR *data, int len, UINT refc
{
int sz;
if( !data )
return 0;
if( !data[0] )
return 0;
if( n > 0 )
......@@ -189,6 +191,8 @@ int msi_addstringW( string_table *st, int n, const WCHAR *data, int len, UINT re
{
/* TRACE("[%2d] = %s\n", string_no, debugstr_an(data,len) ); */
if( !data )
return 0;
if( !data[0] )
return 0;
if( n > 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment