msi: Avoid allocating a database handle only to retrieve the summary information.
This commit is contained in:
parent
052b3a748e
commit
cd73576ec0
|
@ -958,6 +958,7 @@ extern INT msi_suminfo_get_int32( MSISUMMARYINFO *si, UINT uiProperty ) DECLSPEC
|
|||
extern LPWSTR msi_get_suminfo_product( IStorage *stg ) DECLSPEC_HIDDEN;
|
||||
extern UINT msi_add_suminfo( MSIDATABASE *db, LPWSTR **records, int num_records, int num_columns ) DECLSPEC_HIDDEN;
|
||||
extern enum platform parse_platform( const WCHAR *str ) DECLSPEC_HIDDEN;
|
||||
extern UINT msi_load_suminfo_properties( MSIPACKAGE *package ) DECLSPEC_HIDDEN;
|
||||
|
||||
/* undocumented functions */
|
||||
UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
|
||||
|
|
|
@ -1027,74 +1027,6 @@ static VOID set_installer_properties(MSIPACKAGE *package)
|
|||
msi_set_property( package->db, szBrowseProperty, szInstallDir, -1 );
|
||||
}
|
||||
|
||||
static UINT msi_load_summary_properties( MSIPACKAGE *package )
|
||||
{
|
||||
UINT rc;
|
||||
MSIHANDLE suminfo;
|
||||
MSIHANDLE hdb = alloc_msihandle( &package->db->hdr );
|
||||
INT count;
|
||||
DWORD len;
|
||||
LPWSTR package_code;
|
||||
static const WCHAR szPackageCode[] = {
|
||||
'P','a','c','k','a','g','e','C','o','d','e',0};
|
||||
|
||||
if (!hdb) {
|
||||
ERR("Unable to allocate handle\n");
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
rc = MsiGetSummaryInformationW( hdb, NULL, 0, &suminfo );
|
||||
MsiCloseHandle(hdb);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
ERR("Unable to open Summary Information\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_PAGECOUNT, NULL,
|
||||
&count, NULL, NULL, NULL );
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
WARN("Unable to query page count: %d\n", rc);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* load package code property */
|
||||
len = 0;
|
||||
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
|
||||
NULL, NULL, NULL, &len );
|
||||
if (rc != ERROR_MORE_DATA)
|
||||
{
|
||||
WARN("Unable to query revision number: %d\n", rc);
|
||||
rc = ERROR_FUNCTION_FAILED;
|
||||
goto done;
|
||||
}
|
||||
|
||||
len++;
|
||||
package_code = msi_alloc( len * sizeof(WCHAR) );
|
||||
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
|
||||
NULL, NULL, package_code, &len );
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
WARN("Unable to query rev number: %d\n", rc);
|
||||
msi_free( package_code );
|
||||
goto done;
|
||||
}
|
||||
|
||||
msi_set_property( package->db, szPackageCode, package_code, len );
|
||||
msi_free( package_code );
|
||||
|
||||
/* load package attributes */
|
||||
count = 0;
|
||||
MsiSummaryInfoGetPropertyW( suminfo, PID_WORDCOUNT, NULL,
|
||||
&count, NULL, NULL, NULL );
|
||||
package->WordCount = count;
|
||||
|
||||
done:
|
||||
MsiCloseHandle(suminfo);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static MSIPACKAGE *msi_alloc_package( void )
|
||||
{
|
||||
MSIPACKAGE *package;
|
||||
|
@ -1187,7 +1119,7 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
|
|||
len = sprintfW( uilevel, fmtW, gUILevel & INSTALLUILEVEL_MASK );
|
||||
msi_set_property( package->db, szUILevel, uilevel, len );
|
||||
|
||||
r = msi_load_summary_properties( package );
|
||||
r = msi_load_suminfo_properties( package );
|
||||
if (r != ERROR_SUCCESS)
|
||||
{
|
||||
msiobj_release( &package->hdr );
|
||||
|
|
|
@ -608,26 +608,12 @@ UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, PUINT pCount)
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
|
||||
INT *piValue, FILETIME *pftValue, awstring *str, DWORD *pcchValueBuf)
|
||||
static UINT get_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT *puiDataType, INT *piValue,
|
||||
FILETIME *pftValue, awstring *str, DWORD *pcchValueBuf)
|
||||
{
|
||||
MSISUMMARYINFO *si;
|
||||
PROPVARIANT *prop;
|
||||
UINT ret = ERROR_SUCCESS;
|
||||
|
||||
TRACE("%d %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
|
||||
piValue, pftValue, str, pcchValueBuf);
|
||||
|
||||
if ( uiProperty >= MSI_MAX_PROPS )
|
||||
{
|
||||
if (puiDataType) *puiDataType = VT_EMPTY;
|
||||
return ERROR_UNKNOWN_PROPERTY;
|
||||
}
|
||||
|
||||
si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
|
||||
if( !si )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
prop = &si->property[uiProperty];
|
||||
|
||||
if( puiDataType )
|
||||
|
@ -674,7 +660,6 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
|
|||
FIXME("Unknown property variant type\n");
|
||||
break;
|
||||
}
|
||||
msiobj_release( &si->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -723,42 +708,65 @@ UINT WINAPI MsiSummaryInfoGetPropertyA(
|
|||
MSIHANDLE handle, UINT uiProperty, PUINT puiDataType, LPINT piValue,
|
||||
FILETIME *pftValue, LPSTR szValueBuf, LPDWORD pcchValueBuf)
|
||||
{
|
||||
MSISUMMARYINFO *si;
|
||||
awstring str;
|
||||
UINT r;
|
||||
|
||||
TRACE("%d %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
|
||||
TRACE("%u, %u, %p, %p, %p, %p, %p\n", handle, uiProperty, puiDataType,
|
||||
piValue, pftValue, szValueBuf, pcchValueBuf );
|
||||
|
||||
if (uiProperty >= MSI_MAX_PROPS)
|
||||
{
|
||||
if (puiDataType) *puiDataType = VT_EMPTY;
|
||||
return ERROR_UNKNOWN_PROPERTY;
|
||||
}
|
||||
|
||||
if (!(si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO )))
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
str.unicode = FALSE;
|
||||
str.str.a = szValueBuf;
|
||||
|
||||
return get_prop( handle, uiProperty, puiDataType, piValue,
|
||||
pftValue, &str, pcchValueBuf );
|
||||
r = get_prop( si, uiProperty, puiDataType, piValue, pftValue, &str, pcchValueBuf );
|
||||
msiobj_release( &si->hdr );
|
||||
return r;
|
||||
}
|
||||
|
||||
UINT WINAPI MsiSummaryInfoGetPropertyW(
|
||||
MSIHANDLE handle, UINT uiProperty, PUINT puiDataType, LPINT piValue,
|
||||
FILETIME *pftValue, LPWSTR szValueBuf, LPDWORD pcchValueBuf)
|
||||
{
|
||||
MSISUMMARYINFO *si;
|
||||
awstring str;
|
||||
UINT r;
|
||||
|
||||
TRACE("%d %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
|
||||
TRACE("%u, %u, %p, %p, %p, %p, %p\n", handle, uiProperty, puiDataType,
|
||||
piValue, pftValue, szValueBuf, pcchValueBuf );
|
||||
|
||||
if (uiProperty >= MSI_MAX_PROPS)
|
||||
{
|
||||
if (puiDataType) *puiDataType = VT_EMPTY;
|
||||
return ERROR_UNKNOWN_PROPERTY;
|
||||
}
|
||||
|
||||
if (!(si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO )))
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
str.unicode = TRUE;
|
||||
str.str.w = szValueBuf;
|
||||
|
||||
return get_prop( handle, uiProperty, puiDataType, piValue,
|
||||
pftValue, &str, pcchValueBuf );
|
||||
r = get_prop( si, uiProperty, puiDataType, piValue, pftValue, &str, pcchValueBuf );
|
||||
msiobj_release( &si->hdr );
|
||||
return r;
|
||||
}
|
||||
|
||||
static UINT set_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT type,
|
||||
INT iValue, FILETIME* pftValue, awcstring *str )
|
||||
INT iValue, FILETIME *pftValue, awcstring *str )
|
||||
{
|
||||
PROPVARIANT *prop;
|
||||
UINT len;
|
||||
|
||||
TRACE("%p %u %u %i %p %p\n", si, uiProperty, type, iValue,
|
||||
pftValue, str );
|
||||
TRACE("%p, %u, %u, %d, %p, %p\n", si, uiProperty, type, iValue, pftValue, str );
|
||||
|
||||
prop = &si->property[uiProperty];
|
||||
|
||||
|
@ -806,15 +814,15 @@ static UINT set_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT type,
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
UINT WINAPI MsiSummaryInfoSetPropertyW( MSIHANDLE handle, UINT uiProperty,
|
||||
UINT uiDataType, INT iValue, FILETIME* pftValue, LPCWSTR szValue )
|
||||
UINT WINAPI MsiSummaryInfoSetPropertyW( MSIHANDLE handle, UINT uiProperty, UINT uiDataType,
|
||||
INT iValue, FILETIME *pftValue, LPCWSTR szValue )
|
||||
{
|
||||
awcstring str;
|
||||
MSISUMMARYINFO *si;
|
||||
UINT type, ret;
|
||||
|
||||
TRACE("%d %u %u %i %p %s\n", handle, uiProperty, uiDataType,
|
||||
iValue, pftValue, debugstr_w(szValue) );
|
||||
TRACE("%u, %u, %u, %d, %p, %s\n", handle, uiProperty, uiDataType, iValue, pftValue,
|
||||
debugstr_w(szValue) );
|
||||
|
||||
type = get_type( uiProperty );
|
||||
if( type == VT_EMPTY || type != uiDataType )
|
||||
|
@ -826,27 +834,26 @@ UINT WINAPI MsiSummaryInfoSetPropertyW( MSIHANDLE handle, UINT uiProperty,
|
|||
if( uiDataType == VT_FILETIME && !pftValue )
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
|
||||
if( !si )
|
||||
if (!(si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO )))
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
str.unicode = TRUE;
|
||||
str.str.w = szValue;
|
||||
ret = set_prop( si, uiProperty, type, iValue, pftValue, &str );
|
||||
|
||||
ret = set_prop( si, uiProperty, type, iValue, pftValue, &str );
|
||||
msiobj_release( &si->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
||||
UINT WINAPI MsiSummaryInfoSetPropertyA( MSIHANDLE handle, UINT uiProperty,
|
||||
UINT uiDataType, INT iValue, FILETIME* pftValue, LPCSTR szValue )
|
||||
UINT WINAPI MsiSummaryInfoSetPropertyA( MSIHANDLE handle, UINT uiProperty, UINT uiDataType,
|
||||
INT iValue, FILETIME *pftValue, LPCSTR szValue )
|
||||
{
|
||||
awcstring str;
|
||||
MSISUMMARYINFO *si;
|
||||
UINT type, ret;
|
||||
|
||||
TRACE("%d %u %u %i %p %s\n", handle, uiProperty, uiDataType,
|
||||
iValue, pftValue, debugstr_a(szValue) );
|
||||
TRACE("%u, %u, %u, %d, %p, %s\n", handle, uiProperty, uiDataType, iValue, pftValue,
|
||||
debugstr_a(szValue) );
|
||||
|
||||
type = get_type( uiProperty );
|
||||
if( type == VT_EMPTY || type != uiDataType )
|
||||
|
@ -858,14 +865,13 @@ UINT WINAPI MsiSummaryInfoSetPropertyA( MSIHANDLE handle, UINT uiProperty,
|
|||
if( uiDataType == VT_FILETIME && !pftValue )
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
|
||||
if( !si )
|
||||
if (!(si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO )))
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
str.unicode = FALSE;
|
||||
str.str.a = szValue;
|
||||
ret = set_prop( si, uiProperty, uiDataType, iValue, pftValue, &str );
|
||||
|
||||
ret = set_prop( si, uiProperty, uiDataType, iValue, pftValue, &str );
|
||||
msiobj_release( &si->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
@ -1046,3 +1052,57 @@ UINT WINAPI MsiCreateTransformSummaryInfoW( MSIHANDLE db, MSIHANDLE db_ref, LPCW
|
|||
FIXME("%u, %u, %s, %d, %d\n", db, db_ref, debugstr_w(transform), error, validation);
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
}
|
||||
|
||||
UINT msi_load_suminfo_properties( MSIPACKAGE *package )
|
||||
{
|
||||
static const WCHAR packagecodeW[] = {'P','a','c','k','a','g','e','C','o','d','e',0};
|
||||
MSISUMMARYINFO *si;
|
||||
WCHAR *package_code;
|
||||
UINT r, len;
|
||||
awstring str;
|
||||
INT count;
|
||||
|
||||
r = msi_get_suminfo( package->db->storage, 0, &si );
|
||||
if (r != ERROR_SUCCESS)
|
||||
{
|
||||
r = msi_get_db_suminfo( package->db, 0, &si );
|
||||
if (r != ERROR_SUCCESS)
|
||||
{
|
||||
ERR("Unable to open summary information stream %u\n", r);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
str.unicode = TRUE;
|
||||
str.str.w = NULL;
|
||||
len = 0;
|
||||
r = get_prop( si, PID_REVNUMBER, NULL, NULL, NULL, &str, &len );
|
||||
if (r != ERROR_MORE_DATA)
|
||||
{
|
||||
WARN("Unable to query revision number %u\n", r);
|
||||
msiobj_release( &si->hdr );
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
}
|
||||
|
||||
len++;
|
||||
if (!(package_code = msi_alloc( len * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
|
||||
str.str.w = package_code;
|
||||
|
||||
r = get_prop( si, PID_REVNUMBER, NULL, NULL, NULL, &str, &len );
|
||||
if (r != ERROR_SUCCESS)
|
||||
{
|
||||
msi_free( package_code );
|
||||
msiobj_release( &si->hdr );
|
||||
return r;
|
||||
}
|
||||
|
||||
r = msi_set_property( package->db, packagecodeW, package_code, len );
|
||||
msi_free( package_code );
|
||||
|
||||
count = 0;
|
||||
get_prop( si, PID_WORDCOUNT, NULL, &count, NULL, NULL, NULL );
|
||||
package->WordCount = count;
|
||||
|
||||
msiobj_release( &si->hdr );
|
||||
return r;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue