msi: Fix use of BSTRs.

This commit is contained in:
James Hawkins 2007-07-05 17:48:08 -07:00 committed by Alexandre Julliard
parent ca78a8b65f
commit 29ce520df9
3 changed files with 150 additions and 37 deletions

View File

@ -30,6 +30,8 @@
#include "wine/debug.h"
#include "msi.h"
#include "msidefs.h"
#include "objbase.h"
#include "oleauto.h"
#include "msipriv.h"
#include "msiserver.h"
@ -73,14 +75,23 @@ UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction )
if (!package)
{
HRESULT hr;
BSTR action;
IWineMsiRemotePackage *remote_package;
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
if (!remote_package)
return ERROR_INVALID_HANDLE;
hr = IWineMsiRemotePackage_DoAction( remote_package, (BSTR *)szAction );
action = SysAllocString( szAction );
if (!action)
{
IWineMsiRemotePackage_Release( remote_package );
return ERROR_OUTOFMEMORY;
}
hr = IWineMsiRemotePackage_DoAction( remote_package, action );
SysFreeString( action );
IWineMsiRemotePackage_Release( remote_package );
if (FAILED(hr))
@ -133,14 +144,23 @@ UINT WINAPI MsiSequenceW( MSIHANDLE hInstall, LPCWSTR szTable, INT iSequenceMode
if (!package)
{
HRESULT hr;
BSTR table;
IWineMsiRemotePackage *remote_package;
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
if (!remote_package)
return ERROR_INVALID_HANDLE;
hr = IWineMsiRemotePackage_Sequence( remote_package, (BSTR *)szTable, iSequenceMode );
table = SysAllocString( szTable );
if (!table)
{
IWineMsiRemotePackage_Release( remote_package );
return ERROR_OUTOFMEMORY;
}
hr = IWineMsiRemotePackage_Sequence( remote_package, table, iSequenceMode );
SysFreeString( table );
IWineMsiRemotePackage_Release( remote_package );
if (FAILED(hr))
@ -211,14 +231,22 @@ static UINT WINAPI MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
HRESULT hr;
IWineMsiRemotePackage *remote_package;
LPWSTR value = NULL;
BSTR folder;
DWORD len;
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
if (!remote_package)
return ERROR_INVALID_HANDLE;
folder = SysAllocString( szFolder );
if (!folder)
{
IWineMsiRemotePackage_Release( remote_package );
return ERROR_OUTOFMEMORY;
}
len = 0;
hr = IWineMsiRemotePackage_GetTargetPath( remote_package, (BSTR *)szFolder,
hr = IWineMsiRemotePackage_GetTargetPath( remote_package, folder,
NULL, &len );
if (FAILED(hr))
goto done;
@ -231,7 +259,7 @@ static UINT WINAPI MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
goto done;
}
hr = IWineMsiRemotePackage_GetTargetPath( remote_package, (BSTR *)szFolder,
hr = IWineMsiRemotePackage_GetTargetPath( remote_package, folder,
(BSTR *)value, &len);
if (FAILED(hr))
goto done;
@ -240,6 +268,7 @@ static UINT WINAPI MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
done:
IWineMsiRemotePackage_Release( remote_package );
SysFreeString( folder );
msi_free( value );
if (FAILED(hr))
@ -327,14 +356,22 @@ static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
HRESULT hr;
IWineMsiRemotePackage *remote_package;
LPWSTR value = NULL;
BSTR folder;
DWORD len;
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
if (!remote_package)
return ERROR_INVALID_HANDLE;
folder = SysAllocString( szFolder );
if (!folder)
{
IWineMsiRemotePackage_Release( remote_package );
return ERROR_OUTOFMEMORY;
}
len = 0;
hr = IWineMsiRemotePackage_GetSourcePath( remote_package, (BSTR *)szFolder,
hr = IWineMsiRemotePackage_GetSourcePath( remote_package, folder,
NULL, &len );
if (FAILED(hr))
goto done;
@ -347,7 +384,7 @@ static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
goto done;
}
hr = IWineMsiRemotePackage_GetSourcePath( remote_package, (BSTR *)szFolder,
hr = IWineMsiRemotePackage_GetSourcePath( remote_package, folder,
(BSTR *)value, &len);
if (FAILED(hr))
goto done;
@ -356,6 +393,7 @@ static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
done:
IWineMsiRemotePackage_Release( remote_package );
SysFreeString( folder );
msi_free( value );
if (FAILED(hr))
@ -546,14 +584,27 @@ UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder,
if (!package)
{
HRESULT hr;
BSTR folder, path;
IWineMsiRemotePackage *remote_package;
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
if (!remote_package)
return ERROR_INVALID_HANDLE;
hr = IWineMsiRemotePackage_SetTargetPath( remote_package, (BSTR *)szFolder, (BSTR *)szFolderPath );
folder = SysAllocString( szFolder );
path = SysAllocString( szFolderPath );
if (!folder || !path)
{
SysFreeString(folder);
SysFreeString(path);
IWineMsiRemotePackage_Release( remote_package );
return ERROR_OUTOFMEMORY;
}
hr = IWineMsiRemotePackage_SetTargetPath( remote_package, folder, path );
SysFreeString(folder);
SysFreeString(path);
IWineMsiRemotePackage_Release( remote_package );
if (FAILED(hr))
@ -751,14 +802,23 @@ UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
if (!package)
{
HRESULT hr;
BSTR feature;
IWineMsiRemotePackage *remote_package;
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
if (!remote_package)
return ERROR_INVALID_HANDLE;
hr = IWineMsiRemotePackage_SetFeatureState(remote_package, (BSTR *)szFeature, iState);
feature = SysAllocString(szFeature);
if (!feature)
{
IWineMsiRemotePackage_Release(remote_package);
return ERROR_OUTOFMEMORY;
}
hr = IWineMsiRemotePackage_SetFeatureState(remote_package, feature, iState);
SysFreeString(feature);
IWineMsiRemotePackage_Release(remote_package);
if (FAILED(hr))
@ -831,15 +891,26 @@ UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
if (!package)
{
HRESULT hr;
BSTR feature;
IWineMsiRemotePackage *remote_package;
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
if (!remote_package)
return ERROR_INVALID_HANDLE;
hr = IWineMsiRemotePackage_GetFeatureState(remote_package, (BSTR *)szFeature,
feature = SysAllocString(szFeature);
if (!feature)
{
IWineMsiRemotePackage_Release(remote_package);
return ERROR_OUTOFMEMORY;
}
hr = IWineMsiRemotePackage_GetFeatureState(remote_package, feature,
piInstalled, piAction);
SysFreeString(feature);
IWineMsiRemotePackage_Release(remote_package);
if (FAILED(hr))
{
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
@ -966,14 +1037,23 @@ UINT WINAPI MsiSetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent,
if (!package)
{
HRESULT hr;
BSTR component;
IWineMsiRemotePackage *remote_package;
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
if (!remote_package)
return ERROR_INVALID_HANDLE;
hr = IWineMsiRemotePackage_SetComponentState(remote_package, (BSTR *)szComponent, iState);
component = SysAllocString(szComponent);
if (!component)
{
IWineMsiRemotePackage_Release(remote_package);
return ERROR_OUTOFMEMORY;
}
hr = IWineMsiRemotePackage_SetComponentState(remote_package, component, iState);
SysFreeString(component);
IWineMsiRemotePackage_Release(remote_package);
if (FAILED(hr))
@ -1008,15 +1088,26 @@ UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent,
if (!package)
{
HRESULT hr;
BSTR component;
IWineMsiRemotePackage *remote_package;
remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
if (!remote_package)
return ERROR_INVALID_HANDLE;
hr = IWineMsiRemotePackage_GetComponentState(remote_package, (BSTR *)szComponent,
component = SysAllocString(szComponent);
if (!component)
{
IWineMsiRemotePackage_Release(remote_package);
return ERROR_OUTOFMEMORY;
}
hr = IWineMsiRemotePackage_GetComponentState(remote_package, component,
piInstalled, piAction);
SysFreeString(component);
IWineMsiRemotePackage_Release(remote_package);
if (FAILED(hr))
{
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)

View File

@ -40,19 +40,19 @@ interface IWineMsiRemotePackage : IUnknown
{
HRESULT SetMsiHandle( [in] MSIHANDLE handle );
HRESULT GetActiveDatabase( [out] MSIHANDLE *handle );
HRESULT GetProperty( [in] BSTR *property, [out] BSTR *value, [out] DWORD *size );
HRESULT SetProperty( [in] BSTR *property, [in] BSTR *value );
HRESULT GetProperty( [in] BSTR property, [out] BSTR *value, [out] DWORD *size );
HRESULT SetProperty( [in] BSTR property, [in] BSTR value );
HRESULT ProcessMessage( [in] INSTALLMESSAGE message, [in] MSIHANDLE record );
HRESULT DoAction( [in] BSTR *action );
HRESULT Sequence( [in] BSTR *table, [in] int sequence );
HRESULT GetTargetPath( [in] BSTR *folder, [out] BSTR *value, [out] DWORD *size );
HRESULT SetTargetPath( [in] BSTR *folder, [in] BSTR *value );
HRESULT GetSourcePath( [in] BSTR *folder, [out] BSTR *value, [out] DWORD *size );
HRESULT DoAction( [in] BSTR action );
HRESULT Sequence( [in] BSTR table, [in] int sequence );
HRESULT GetTargetPath( [in] BSTR folder, [out] BSTR *value, [out] DWORD *size );
HRESULT SetTargetPath( [in] BSTR folder, [in] BSTR value );
HRESULT GetSourcePath( [in] BSTR folder, [out] BSTR *value, [out] DWORD *size );
HRESULT GetMode( [in] MSIRUNMODE mode, [out] BOOL *ret );
HRESULT GetFeatureState( [in] BSTR *feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
HRESULT SetFeatureState( [in] BSTR *feature, [in] INSTALLSTATE state );
HRESULT GetComponentState( [in] BSTR *component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
HRESULT SetComponentState( [in] BSTR *component, [in] INSTALLSTATE state );
HRESULT GetFeatureState( [in] BSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
HRESULT SetFeatureState( [in] BSTR feature, [in] INSTALLSTATE state );
HRESULT GetComponentState( [in] BSTR component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
HRESULT SetComponentState( [in] BSTR component, [in] INSTALLSTATE state );
HRESULT GetLanguage( [out] LANGID *language );
HRESULT SetInstallLevel( [in] int level );
}

View File

@ -1279,15 +1279,28 @@ UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue
if( !package )
{
HRESULT hr;
BSTR name, value;
IWineMsiRemotePackage *remote_package;
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
if (!remote_package)
return ERROR_INVALID_HANDLE;
hr = IWineMsiRemotePackage_SetProperty( remote_package, (BSTR *)szName, (BSTR *)szValue );
name = SysAllocString( szName );
value = SysAllocString( szValue );
if (!name || !value)
{
SysFreeString( name );
SysFreeString( value );
IWineMsiRemotePackage_Release( remote_package );
return ERROR_OUTOFMEMORY;
}
IWineMsiRemotePackage_Release(remote_package);
hr = IWineMsiRemotePackage_SetProperty( remote_package, name, value );
SysFreeString( name );
SysFreeString( value );
IWineMsiRemotePackage_Release( remote_package );
if (FAILED(hr))
{
@ -1403,14 +1416,22 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
HRESULT hr;
IWineMsiRemotePackage *remote_package;
LPWSTR value = NULL;
BSTR bname;
DWORD len;
remote_package = (IWineMsiRemotePackage *)msi_get_remote( handle );
if (!remote_package)
return ERROR_INVALID_HANDLE;
bname = SysAllocString( name );
if (!bname)
{
IWineMsiRemotePackage_Release( remote_package );
return ERROR_OUTOFMEMORY;
}
len = 0;
hr = IWineMsiRemotePackage_GetProperty( remote_package, (BSTR *)name, NULL, &len );
hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, NULL, &len );
if (FAILED(hr))
goto done;
@ -1422,7 +1443,7 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
goto done;
}
hr = IWineMsiRemotePackage_GetProperty( remote_package, (BSTR *)name, (BSTR *)value, &len );
hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, (BSTR *)value, &len );
if (FAILED(hr))
goto done;
@ -1431,6 +1452,7 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
done:
IWineMsiRemotePackage_Release(remote_package);
SysFreeString(bname);
msi_free(value);
if (FAILED(hr))
@ -1550,7 +1572,7 @@ HRESULT WINAPI mrp_GetActiveDatabase( IWineMsiRemotePackage *iface, MSIHANDLE *h
return S_OK;
}
HRESULT WINAPI mrp_GetProperty( IWineMsiRemotePackage *iface, BSTR *property, BSTR *value, DWORD *size )
HRESULT WINAPI mrp_GetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR *value, DWORD *size )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r;
@ -1562,7 +1584,7 @@ HRESULT WINAPI mrp_GetProperty( IWineMsiRemotePackage *iface, BSTR *property, BS
return S_OK;
}
HRESULT WINAPI mrp_SetProperty( IWineMsiRemotePackage *iface, BSTR *property, BSTR *value )
HRESULT WINAPI mrp_SetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR value )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r = MsiSetPropertyW(This->package, (LPWSTR)property, (LPWSTR)value);
@ -1576,35 +1598,35 @@ HRESULT WINAPI mrp_ProcessMessage( IWineMsiRemotePackage *iface, INSTALLMESSAGE
return HRESULT_FROM_WIN32(r);
}
HRESULT WINAPI mrp_DoAction( IWineMsiRemotePackage *iface, BSTR *action )
HRESULT WINAPI mrp_DoAction( IWineMsiRemotePackage *iface, BSTR action )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r = MsiDoActionW(This->package, (LPWSTR)action);
return HRESULT_FROM_WIN32(r);
}
HRESULT WINAPI mrp_Sequence( IWineMsiRemotePackage *iface, BSTR *table, int sequence )
HRESULT WINAPI mrp_Sequence( IWineMsiRemotePackage *iface, BSTR table, int sequence )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r = MsiSequenceW(This->package, (LPWSTR)table, sequence);
return HRESULT_FROM_WIN32(r);
}
HRESULT WINAPI mrp_GetTargetPath( IWineMsiRemotePackage *iface, BSTR *folder, BSTR *value, DWORD *size )
HRESULT WINAPI mrp_GetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR *value, DWORD *size )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r = MsiGetTargetPathW(This->package, (LPWSTR)folder, (LPWSTR)value, size);
return HRESULT_FROM_WIN32(r);
}
HRESULT WINAPI mrp_SetTargetPath( IWineMsiRemotePackage *iface, BSTR *folder, BSTR *value)
HRESULT WINAPI mrp_SetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR value)
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r = MsiSetTargetPathW(This->package, (LPWSTR)folder, (LPWSTR)value);
return HRESULT_FROM_WIN32(r);
}
HRESULT WINAPI mrp_GetSourcePath( IWineMsiRemotePackage *iface, BSTR *folder, BSTR *value, DWORD *size )
HRESULT WINAPI mrp_GetSourcePath( IWineMsiRemotePackage *iface, BSTR folder, BSTR *value, DWORD *size )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r = MsiGetSourcePathW(This->package, (LPWSTR)folder, (LPWSTR)value, size);
@ -1618,7 +1640,7 @@ HRESULT WINAPI mrp_GetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL
return S_OK;
}
HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR *feature,
HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR feature,
INSTALLSTATE *installed, INSTALLSTATE *action )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
@ -1626,14 +1648,14 @@ HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR *feature,
return HRESULT_FROM_WIN32(r);
}
HRESULT WINAPI mrp_SetFeatureState( IWineMsiRemotePackage *iface, BSTR *feature, INSTALLSTATE state )
HRESULT WINAPI mrp_SetFeatureState( IWineMsiRemotePackage *iface, BSTR feature, INSTALLSTATE state )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r = MsiSetFeatureStateW(This->package, (LPWSTR)feature, state);
return HRESULT_FROM_WIN32(r);
}
HRESULT WINAPI mrp_GetComponentState( IWineMsiRemotePackage *iface, BSTR *component,
HRESULT WINAPI mrp_GetComponentState( IWineMsiRemotePackage *iface, BSTR component,
INSTALLSTATE *installed, INSTALLSTATE *action )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
@ -1641,7 +1663,7 @@ HRESULT WINAPI mrp_GetComponentState( IWineMsiRemotePackage *iface, BSTR *compon
return HRESULT_FROM_WIN32(r);
}
HRESULT WINAPI mrp_SetComponentState( IWineMsiRemotePackage *iface, BSTR *component, INSTALLSTATE state )
HRESULT WINAPI mrp_SetComponentState( IWineMsiRemotePackage *iface, BSTR component, INSTALLSTATE state )
{
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
UINT r = MsiSetFeatureStateW(This->package, (LPWSTR)component, state);