From d015d3b98a0aa85ed5826869987778b9637a5af4 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Tue, 10 Feb 2004 02:22:17 +0000 Subject: [PATCH] Add some missing prototypes, fix AssocIsDangerous. Implement StrRetToBSTR, delay-import oleaut32. --- dlls/shlwapi/Makefile.in | 1 + dlls/shlwapi/assoc.c | 15 +++++++-- dlls/shlwapi/shlwapi.spec | 9 ++--- dlls/shlwapi/string.c | 69 +++++++++++++++++++++++++++++++++++++-- include/shlwapi.h | 17 +++++----- 5 files changed, 94 insertions(+), 17 deletions(-) diff --git a/dlls/shlwapi/Makefile.in b/dlls/shlwapi/Makefile.in index 828ee7b3951..f5eee2e2a52 100644 --- a/dlls/shlwapi/Makefile.in +++ b/dlls/shlwapi/Makefile.in @@ -5,6 +5,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = shlwapi.dll IMPORTS = ole32 user32 gdi32 advapi32 kernel32 +DELAYIMPORTS = oleaut32 EXTRALIBS = -luuid $(LIBUNICODE) C_SRCS = \ diff --git a/dlls/shlwapi/assoc.c b/dlls/shlwapi/assoc.c index 849748d896e..753828944ca 100644 --- a/dlls/shlwapi/assoc.c +++ b/dlls/shlwapi/assoc.c @@ -414,11 +414,20 @@ HRESULT WINAPI AssocQueryStringByKeyA(ASSOCF cfFlags, ASSOCSTR str, HKEY hkAssoc /************************************************************************** * AssocIsDangerous (SHLWAPI.@) + * + * Determine if a file association is dangerous (potentially malware). + * + * PARAMS + * lpszAssoc [I] Name of file or file extention to check. + * + * RETURNS + * TRUE, if lpszAssoc may potentially be malware (executable), + * FALSE, Otherwise. */ -HRESULT WINAPI AssocIsDangerous( ASSOCSTR str ) +BOOL WINAPI AssocIsDangerous(LPCWSTR lpszAssoc) { - FIXME("%08x\n", str); - return S_FALSE; + FIXME("%s\n", debugstr_w(lpszAssoc)); + return FALSE; } /************************************************************************** diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec index 002a3af9f46..adf2adc96f5 100644 --- a/dlls/shlwapi/shlwapi.spec +++ b/dlls/shlwapi/shlwapi.spec @@ -796,10 +796,11 @@ # exported in later versions @ stdcall AssocIsDangerous(long) -@ stdcall StrRetToBufA (ptr ptr ptr long) -@ stdcall StrRetToBufW (ptr ptr ptr long) -@ stdcall StrRetToStrA (ptr ptr ptr) -@ stdcall StrRetToStrW (ptr ptr ptr) +@ stdcall StrRetToBufA(ptr ptr ptr long) +@ stdcall StrRetToBufW(ptr ptr ptr long) +@ stdcall StrRetToBSTR(ptr ptr ptr) +@ stdcall StrRetToStrA(ptr ptr ptr) +@ stdcall StrRetToStrW(ptr ptr ptr) @ stdcall SHRegGetPathA(long str str ptr long) @ stdcall SHRegGetPathW(long wstr wstr ptr long) @ stdcall PathIsDirectoryEmptyA(str) diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c index 2f4c836fd1f..7b1a42ee8aa 100644 --- a/dlls/shlwapi/string.c +++ b/dlls/shlwapi/string.c @@ -1333,7 +1333,7 @@ LPWSTR WINAPI StrCatBuffW(LPWSTR lpszStr, LPCWSTR lpszCat, INT cchMax) * * PARAMS * lpStrRet [O] STRRET to convert - * pIdl [I] ITEMIDLIST for lpStrRet->uType = STRRET_OFFSETA + * pIdl [I] ITEMIDLIST for lpStrRet->uType == STRRET_OFFSET * lpszDest [O] Destination for normal string * dwLen [I] Length of lpszDest * @@ -1444,7 +1444,7 @@ HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, * * PARAMS * lpStrRet [O] STRRET to convert - * pidl [I] ITEMIDLIST for lpStrRet->uType = STRRET_OFFSETA + * pidl [I] ITEMIDLIST for lpStrRet->uType == STRRET_OFFSET * ppszName [O] Destination for converted string * * RETURNS @@ -1508,6 +1508,71 @@ HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *p return hRet; } +/* Create an ASCII string copy using SysAllocString() */ +static HRESULT _SHStrDupAToBSTR(LPCSTR src, BSTR *pBstrOut) +{ + *pBstrOut = NULL; + + if (src) + { + INT len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0); + WCHAR* szTemp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + + if (szTemp) + { + MultiByteToWideChar(CP_ACP, 0, src, -1, szTemp, len); + *pBstrOut = SysAllocString(szTemp); + HeapFree(GetProcessHeap(), 0, szTemp); + + if (*pBstrOut) + return S_OK; + } + } + return E_OUTOFMEMORY; +} + +/************************************************************************* + * StrRetToBSTR [SHLWAPI.@] + * + * Converts a STRRET to a BSTR. + * + * PARAMS + * lpStrRet [O] STRRET to convert + * pidl [I] ITEMIDLIST for lpStrRet->uType = STRRET_OFFSET + * pBstrOut [O] Destination for converted BSTR + * + * RETURNS + * Success: S_OK. pBstrOut contains the new string. + * Failure: E_FAIL, if any parameters are invalid. + */ +HRESULT WINAPI StrRetToBSTR(STRRET *lpStrRet, LPCITEMIDLIST pidl, BSTR* pBstrOut) +{ + HRESULT hRet = E_FAIL; + + switch (lpStrRet->uType) + { + case STRRET_WSTR: + *pBstrOut = SysAllocString(lpStrRet->u.pOleStr); + if (*pBstrOut) + hRet = S_OK; + CoTaskMemFree(lpStrRet->u.pOleStr); + break; + + case STRRET_CSTR: + hRet = _SHStrDupAToBSTR(lpStrRet->u.cStr, pBstrOut); + break; + + case STRRET_OFFSET: + hRet = _SHStrDupAToBSTR(((LPCSTR)&pidl->mkid) + lpStrRet->u.uOffset, pBstrOut); + break; + + default: + *pBstrOut = NULL; + } + + return hRet; +} + /************************************************************************* * StrFormatKBSizeA [SHLWAPI.@] * diff --git a/include/shlwapi.h b/include/shlwapi.h index 209db2f4249..9c9102f0446 100644 --- a/include/shlwapi.h +++ b/include/shlwapi.h @@ -22,6 +22,7 @@ #define __WINE_SHLWAPI_H #include +#include #ifdef __cplusplus extern "C" { @@ -279,6 +280,8 @@ HRESULT WINAPI AssocQueryKeyA(ASSOCF,ASSOCKEY,LPCSTR,LPCSTR,PHKEY); HRESULT WINAPI AssocQueryKeyW(ASSOCF,ASSOCKEY,LPCWSTR,LPCWSTR,PHKEY); #define AssocQueryKey WINELIB_NAME_AW(AssocQueryKey) +BOOL WINAPI AssocIsDangerous(LPCWSTR); + #endif /* NO_SHLWAPI_REG */ @@ -819,18 +822,16 @@ BOOL IntlStrEqWorkerW(BOOL,LPCWSTR,LPCWSTR,int); #define IntlStrEqNIW(s1,s2,n) IntlStrEqWorkerW(FALSE,s1,s2,n) #define IntlStrEqNI WINELIB_NAME_AW(IntlStrEqNI) -/* Undocumented */ -struct _STRRET; -struct _ITEMIDLIST; - -HRESULT WINAPI StrRetToStrA(struct _STRRET*,const struct _ITEMIDLIST*,LPSTR*); -HRESULT WINAPI StrRetToStrW(struct _STRRET*,const struct _ITEMIDLIST*,LPWSTR*); +HRESULT WINAPI StrRetToStrA(STRRET*,LPCITEMIDLIST,LPSTR*); +HRESULT WINAPI StrRetToStrW(STRRET*,LPCITEMIDLIST,LPWSTR*); #define StrRetToStr WINELIB_NAME_AW(StrRetToStr) -HRESULT WINAPI StrRetToBufA(struct _STRRET*,const struct _ITEMIDLIST*,LPSTR,UINT); -HRESULT WINAPI StrRetToBufW(struct _STRRET*,const struct _ITEMIDLIST*,LPWSTR,UINT); +HRESULT WINAPI StrRetToBufA(STRRET*,LPCITEMIDLIST,LPSTR,UINT); +HRESULT WINAPI StrRetToBufW(STRRET*,LPCITEMIDLIST,LPWSTR,UINT); #define StrRetToBuf WINELIB_NAME_AW(StrRetToBuf) +HRESULT WINAPI StrRetToBSTR(STRRET*,LPCITEMIDLIST,BSTR*); + #endif /* NO_SHLWAPI_STRFCNS */