Commit 68680e9c authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Fixes for MsiGetSourcePath parameter handling.

parent d3d5ad6b
......@@ -150,76 +150,99 @@ UINT WINAPI MsiGetTargetPathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR
return rc;
}
/***********************************************************************
* MsiGetSourcePathA (MSI.@)
*/
UINT WINAPI MsiGetSourcePathA( MSIHANDLE hInstall, LPCSTR szFolder,
LPSTR szPathBuf, DWORD* pcchPathBuf)
* MsiGetSourcePath (internal)
*/
static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
awstring *szPathBuf, DWORD* pcchPathBuf )
{
LPWSTR szwFolder;
LPWSTR szwPathBuf;
UINT rc;
LPWSTR path;
UINT r, len;
MSIPACKAGE *package;
TRACE("getting source %s %p %li\n",szFolder,szPathBuf, *pcchPathBuf);
TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf );
if (!szFolder)
return ERROR_FUNCTION_FAILED;
if (hInstall == 0)
return ERROR_FUNCTION_FAILED;
return ERROR_INVALID_PARAMETER;
szwFolder = strdupAtoW(szFolder);
if (!szwFolder)
return ERROR_FUNCTION_FAILED;
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
if (!package)
return ERROR_INVALID_HANDLE;
szwPathBuf = HeapAlloc( GetProcessHeap(), 0 , *pcchPathBuf * sizeof(WCHAR));
if (szPathBuf->str.w && !pcchPathBuf )
{
msiobj_release( &package->hdr );
return ERROR_INVALID_PARAMETER;
}
rc = MsiGetSourcePathW(hInstall, szwFolder, szwPathBuf,pcchPathBuf);
path = resolve_folder(package, szFolder, TRUE, FALSE, NULL);
msiobj_release( &package->hdr );
WideCharToMultiByte( CP_ACP, 0, szwPathBuf, *pcchPathBuf, szPathBuf,
*pcchPathBuf, NULL, NULL );
TRACE("path = %s\n",debugstr_w(path));
if (!path)
return ERROR_DIRECTORY;
HeapFree(GetProcessHeap(),0,szwFolder);
HeapFree(GetProcessHeap(),0,szwPathBuf);
r = ERROR_SUCCESS;
if (pcchPathBuf)
{
if (szPathBuf->unicode)
{
len = lstrlenW( path );
if (szPathBuf->str.w)
lstrcpynW( szPathBuf->str.w, path, *pcchPathBuf );
}
else
{
len = WideCharToMultiByte( CP_ACP, 0, path, -1,
szPathBuf->str.a, *pcchPathBuf, NULL, NULL );
len--;
}
return rc;
if (len >= *pcchPathBuf)
r = ERROR_MORE_DATA;
*pcchPathBuf = len;
}
HeapFree( GetProcessHeap(), 0, path );
return r;
}
/***********************************************************************
* MsiGetSourcePathW (MSI.@)
*/
UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder, LPWSTR
szPathBuf, DWORD* pcchPathBuf)
* MsiGetSourcePathA (MSI.@)
*/
UINT WINAPI MsiGetSourcePathA( MSIHANDLE hInstall, LPCSTR szFolder,
LPSTR szPathBuf, DWORD* pcchPathBuf )
{
LPWSTR path;
UINT rc = ERROR_FUNCTION_FAILED;
MSIPACKAGE *package;
LPWSTR folder;
awstring str;
UINT r;
TRACE("(%s %p %li)\n",debugstr_w(szFolder),szPathBuf,*pcchPathBuf);
TRACE("%s %p %p\n", szFolder, debugstr_a(szPathBuf), pcchPathBuf);
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
if( !package )
return ERROR_INVALID_HANDLE;
path = resolve_folder(package, szFolder, TRUE, FALSE, NULL);
msiobj_release( &package->hdr );
str.unicode = FALSE;
str.str.a = szPathBuf;
if (path && strlenW(path) > *pcchPathBuf)
{
*pcchPathBuf = strlenW(path)+1;
rc = ERROR_MORE_DATA;
}
else if (path)
{
*pcchPathBuf = strlenW(path)+1;
strcpyW(szPathBuf,path);
TRACE("Returning Path %s\n",debugstr_w(path));
rc = ERROR_SUCCESS;
}
HeapFree(GetProcessHeap(),0,path);
return rc;
folder = strdupAtoW( szFolder );
r = MSI_GetSourcePath( hInstall, folder, &str, pcchPathBuf );
HeapFree( GetProcessHeap(), 0, folder );
return r;
}
/***********************************************************************
* MsiGetSourcePathW (MSI.@)
*/
UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder,
LPWSTR szPathBuf, DWORD* pcchPathBuf )
{
awstring str;
TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf );
str.unicode = TRUE;
str.str.w = szPathBuf;
return MSI_GetSourcePath( hInstall, szFolder, &str, pcchPathBuf );
}
/***********************************************************************
* MsiSetTargetPathA (MSI.@)
......
......@@ -247,6 +247,21 @@ DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x0
DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
typedef struct {
BOOL unicode;
union {
LPSTR a;
LPWSTR w;
} str;
} awstring;
typedef struct {
BOOL unicode;
union {
LPCSTR a;
LPCWSTR w;
} str;
} awcstring;
/* handle functions */
extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
......
......@@ -81,22 +81,6 @@ typedef struct {
#define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER))
typedef struct {
BOOL unicode;
union {
LPSTR a;
LPWSTR w;
} str;
} awstring;
typedef struct {
BOOL unicode;
union {
LPCSTR a;
LPCWSTR w;
} str;
} awcstring;
typedef struct tagMSISUMMARYINFO
{
MSIOBJECTHDR hdr;
......
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