diff --git a/dlls/shell32/folders.c b/dlls/shell32/folders.c index aed079230a5..dd12bee4396 100644 --- a/dlls/shell32/folders.c +++ b/dlls/shell32/folders.c @@ -195,7 +195,7 @@ static HRESULT WINAPI IExtractIconA_fnGetIconLocation( } } - TRACE (shell,"-- %s %x\n", debugstr_a(szIconFile), *piIndex); + TRACE (shell,"-- %s %x\n", (ret==NOERROR)?debugstr_a(szIconFile):"[error]", *piIndex); return ret; } /************************************************************************** diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c index 72d071ec971..b7118e63f4c 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -694,11 +694,13 @@ BOOL PidlToSicIndex (IShellFolder * sh, LPITEMIDLIST pidl, BOOL bBigIcon, UINT * BOOL ret = FALSE; UINT dwFlags = 0; + TRACE(shell,"sf=%p pidl=%p\n", sh, pidl); + if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconA, 0, (void **)&ei))) { - if (SUCCEEDED (IExtractIconA_GetIconLocation(ei, 0, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags))) - { *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex); - ret = TRUE; + if (NOERROR==IExtractIconA_GetIconLocation(ei, 0, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)) + { *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex); + ret = TRUE; } IExtractIconA_Release(ei); } diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c index 6a50a7ba0ce..8db0b6034ad 100644 --- a/dlls/shell32/pidl.c +++ b/dlls/shell32/pidl.c @@ -54,6 +54,45 @@ void pdump (LPCITEMIDLIST pidl) TRACE(pidl,"empty pidl (Desktop)\n"); } +BOOL pcheck (LPCITEMIDLIST pidl) +{ DWORD type, ret=TRUE; + + LPITEMIDLIST pidltemp = pidl; + + if (pidltemp && pidltemp->mkid.cb) + { do + { type = _ILGetDataPointer(pidltemp)->type; + switch (type) + { case PT_DESKTOP: + case PT_MYCOMP: + case PT_SPECIAL: + case PT_DRIVE: + case PT_FOLDER: + case PT_VALUE: + break; + default: + { + char szTemp[100]; /* 3*32 + 3 + 1 */ + int i; + for ( i = 0; i < pidltemp->mkid.cb; i++) + { + sprintf (&(szTemp[i*3]),"%02x ", ((LPBYTE)pidltemp)[i]); + if (i>=31) + { + sprintf (&(szTemp[i*3+3]),"..."); + break; + } + } + ERR (pidl,"unknown IDLIST type size=%u type=%lx\n%s\n",pidltemp->mkid.cb,type, szTemp); + ret = FALSE; + } + } + pidltemp = ILGetNext(pidltemp); + } while (pidltemp->mkid.cb); + } + return ret; +} + /************************************************************************* * ILGetDisplayName [SHELL32.15] */ @@ -169,6 +208,13 @@ HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST * ppPidl) *ppPidl = NULL; } } + + /* we are not jet fully compatible */ + if (!pcheck(*ppPidl)) + { SHFree(*ppPidl); + *ppPidl = NULL; + } + IStream_Release (pStream); @@ -274,6 +320,11 @@ BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) TRACE(pidl,"pidl1=%p pidl2=%p\n",pidl1, pidl2); + /* explorer reads from registry directly (StreamMRU), + so we can only check here */ + if ((!pcheck (pidl1)) || (!pcheck (pidl2))) + return FALSE; + pdump (pidl1); pdump (pidl2); diff --git a/dlls/shell32/pidl.h b/dlls/shell32/pidl.h index 8b462d42493..2824f0a621c 100644 --- a/dlls/shell32/pidl.h +++ b/dlls/shell32/pidl.h @@ -121,4 +121,5 @@ LPSTR WINAPI _ILGetTextPointer(PIDLTYPE type, LPPIDLDATA pidldata); LPSTR WINAPI _ILGetSTextPointer(PIDLTYPE type, LPPIDLDATA pidldata); void pdump (LPCITEMIDLIST pidl); +BOOL pcheck (LPCITEMIDLIST pidl); #endif diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h index 45f14499eb8..7bd2ac8de4c 100644 --- a/dlls/shell32/shell32_main.h +++ b/dlls/shell32/shell32_main.h @@ -74,7 +74,7 @@ HRESULT WINAPI StrRetToStrN (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST #define INVALID_INDEX -1 BOOL SIC_Initialize(void); void SIC_Destroy(void); -/*INT32 SIC_GetIconIndex (LPCSTR sSourceFile, INT32 dwSourceIndex );*/ +BOOL PidlToSicIndex (IShellFolder * sh, LPITEMIDLIST pidl, BOOL bBigIcon, UINT * pIndex); /* Classes Root */ BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len); diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c index 6b8af51f374..75f7d00c0b6 100644 --- a/dlls/shell32/shelllink.c +++ b/dlls/shell32/shelllink.c @@ -209,11 +209,14 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFile pdump (&pImage->Pidl); } + if (!pcheck (&pImage->Pidl)) + goto end_3; + This->pPidl = ILClone (&pImage->Pidl); _ILGetPidlPath(&pImage->Pidl, sTemp, 512); This->sPath = HEAP_strdupA ( GetProcessHeap(), 0, sTemp); - + hRet = NOERROR; end_3: UnmapViewOfFile(pImage); end_2: CloseHandle(hMapping);