msi: Use CreateFileW() for handling path from cabinet_open() instead.

This commit is contained in:
Jactry Zeng 2023-09-19 10:12:44 -05:00 committed by Alexandre Julliard
parent 9ef927472c
commit 085e95cd5e
2 changed files with 34 additions and 4 deletions

View file

@ -109,6 +109,8 @@ static INT_PTR CDECL cabinet_open(char *pszFile, int oflag, int pmode)
DWORD dwAccess = 0;
DWORD dwShareMode = 0;
DWORD dwCreateDisposition = OPEN_EXISTING;
HANDLE handle;
WCHAR *path;
switch (oflag & _O_ACCMODE)
{
@ -131,8 +133,10 @@ static INT_PTR CDECL cabinet_open(char *pszFile, int oflag, int pmode)
else if (oflag & _O_CREAT)
dwCreateDisposition = CREATE_ALWAYS;
return (INT_PTR)CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
dwCreateDisposition, 0, NULL);
path = strdupUtoW(pszFile);
handle = CreateFileW(path, dwAccess, dwShareMode, NULL, dwCreateDisposition, 0, NULL);
free(path);
return (INT_PTR)handle;
}
static UINT CDECL cabinet_read(INT_PTR hf, void *pv, UINT cb)
@ -577,11 +581,11 @@ static BOOL extract_cabinet( MSIPACKAGE* package, MSIMEDIAINFO *mi, LPVOID data
return FALSE;
}
cabinet = strdupWtoA( mi->cabinet );
cabinet = strdupWtoU( mi->cabinet );
if (!cabinet)
goto done;
cab_path = strdupWtoA( mi->sourcedir );
cab_path = strdupWtoU( mi->sourcedir );
if (!cab_path)
goto done;

View file

@ -1168,4 +1168,30 @@ static inline LPWSTR strdupAtoW( LPCSTR str )
return ret;
}
static inline char *strdupWtoU( LPCWSTR str )
{
LPSTR ret = NULL;
DWORD len;
if (!str) return ret;
len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
ret = malloc( len );
if (ret)
WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
return ret;
}
static inline LPWSTR strdupUtoW( LPCSTR str )
{
LPWSTR ret = NULL;
DWORD len;
if (!str) return ret;
len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
ret = malloc( len * sizeof(WCHAR) );
if (ret)
MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
return ret;
}
#endif /* __WINE_MSI_PRIVATE__ */