From f89672624d37e57ff87f46f6e11f23b5365c6044 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Wed, 30 Aug 2017 12:49:59 +0000 Subject: [PATCH] [SHELL32] -SHChangeNotifyRegister: Don't call CreateFileW with something that is not a filesystem path as this will obviously fail like when we are browsing My Computer. svn path=/trunk/; revision=75713 --- reactos/dll/win32/shell32/wine/changenotify.c | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/shell32/wine/changenotify.c b/reactos/dll/win32/shell32/wine/changenotify.c index d3c75eeb381..0157297e1ba 100644 --- a/reactos/dll/win32/shell32/wine/changenotify.c +++ b/reactos/dll/win32/shell32/wine/changenotify.c @@ -647,19 +647,25 @@ _AddDirectoryProc(ULONG_PTR arg) BOOL _OpenDirectory(LPNOTIFYREGISTER item) { STRRET strFile; - IShellFolder *psfDesktop; + IShellFolder *psf; HRESULT hr; + LPCITEMIDLIST child; + ULONG ulAttrs; // Makes function idempotent if (item->hDirectory && !(item->hDirectory == INVALID_HANDLE_VALUE)) return TRUE; - hr = SHGetDesktopFolder(&psfDesktop); + hr = SHBindToParent(item->pidl, &IID_IShellFolder, (LPVOID*)&psf, &child); if (FAILED_UNEXPECTEDLY(hr)) - return FALSE; + return hr; - hr = IShellFolder_GetDisplayNameOf(psfDesktop, item->pidl, SHGDN_FORPARSING, &strFile); - IShellFolder_Release(psfDesktop); + ulAttrs = SFGAO_FILESYSTEM | SFGAO_FOLDER; + hr = IShellFolder_GetAttributesOf(psf, 1, (LPCITEMIDLIST*)&child, &ulAttrs); + if (SUCCEEDED(hr)) + hr = IShellFolder_GetDisplayNameOf(psf, child, SHGDN_FORPARSING, &strFile); + + IShellFolder_Release(psf); if (FAILED_UNEXPECTEDLY(hr)) return FALSE; @@ -667,6 +673,13 @@ BOOL _OpenDirectory(LPNOTIFYREGISTER item) if (FAILED_UNEXPECTEDLY(hr)) return FALSE; + if ((ulAttrs & (SFGAO_FILESYSTEM | SFGAO_FOLDER)) != (SFGAO_FILESYSTEM | SFGAO_FOLDER)) + { + TRACE("_OpenDirectory ignoring %s\n", debugstr_w(item->wstrDirectory)); + item->hDirectory = INVALID_HANDLE_VALUE; + return FALSE; + } + TRACE("_OpenDirectory %s\n", debugstr_w(item->wstrDirectory)); item->hDirectory = CreateFileW(item->wstrDirectory, // pointer to the file name