From a790beb22ba2be2814f77fb6fe2dbeaf75187496 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 14 Jun 2026 14:37:58 +0300 Subject: [PATCH] [SHELL32] Fix SHBindToObject This should have 5 parameters and stdcall convention. Get rid of SHBindToObjectEx. --- dll/win32/shell32/brfolder.cpp | 2 +- dll/win32/shell32/changenotify.cpp | 2 +- dll/win32/shell32/folders/CDesktopFolder.cpp | 4 ++-- dll/win32/shell32/folders/CRecycleBin.cpp | 2 +- dll/win32/shell32/folders/CRegFolder.cpp | 2 +- dll/win32/shell32/precomp.h | 11 ++--------- dll/win32/shell32/shldataobject.cpp | 2 +- dll/win32/shell32/utils.cpp | 18 ++++-------------- dll/win32/shell32/wine/shellpath.c | 4 ++-- sdk/include/reactos/undocshell.h | 2 +- 10 files changed, 16 insertions(+), 33 deletions(-) diff --git a/dll/win32/shell32/brfolder.cpp b/dll/win32/shell32/brfolder.cpp index da44e41a9c4..c49c7fed3e1 100644 --- a/dll/win32/shell32/brfolder.cpp +++ b/dll/win32/shell32/brfolder.cpp @@ -190,7 +190,7 @@ BrFolder_InitTreeView(BrFolder *info) PCIDLIST_RELATIVE pidlChild = ILFindLastID(pidlRoot); CComPtr lpsfParent; - hr = SHBindToObject(NULL, pidlParent, /*NULL, */ IID_PPV_ARG(IShellFolder, &lpsfParent)); + hr = SHBindToObject(NULL, pidlParent, NULL, IID_PPV_ARG(IShellFolder, &lpsfParent)); if (FAILED_UNEXPECTEDLY(hr)) return; diff --git a/dll/win32/shell32/changenotify.cpp b/dll/win32/shell32/changenotify.cpp index 19bef814fed..bf6dbd44b10 100644 --- a/dll/win32/shell32/changenotify.cpp +++ b/dll/win32/shell32/changenotify.cpp @@ -71,7 +71,7 @@ Shell_ParsePrinterName( return hr; CComPtr pFolder; - hr = SHBindToObject(NULL, pidlPrinters, IID_PPV_ARG(IShellFolder, &pFolder)); + hr = SHBindToObject(NULL, pidlPrinters, NULL, IID_PPV_ARG(IShellFolder, &pFolder)); if (FAILED_UNEXPECTEDLY(hr)) return hr; diff --git a/dll/win32/shell32/folders/CDesktopFolder.cpp b/dll/win32/shell32/folders/CDesktopFolder.cpp index 9ebc246a5ae..c0d0fd52853 100644 --- a/dll/win32/shell32/folders/CDesktopFolder.cpp +++ b/dll/win32/shell32/folders/CDesktopFolder.cpp @@ -119,7 +119,7 @@ CDesktopFolder::ShellUrlParseDisplayName( if (pch && *pch) { CComPtr psfFolder; - hr = SHBindToObject(NULL, pidlLocation, IID_PPV_ARG(IShellFolder, &psfFolder)); + hr = SHBindToObject(NULL, pidlLocation, NULL, IID_PPV_ARG(IShellFolder, &psfFolder)); if (SUCCEEDED(hr)) { CComHeapPtr pidlNew; @@ -353,7 +353,7 @@ HRESULT CDesktopFolder::_ParseDisplayNameByParent( return E_OUTOFMEMORY; CComPtr pParentFolder; - SHBindToObject(NULL, pidlParent, IID_PPV_ARG(IShellFolder, &pParentFolder)); + SHBindToObject(NULL, pidlParent, NULL, IID_PPV_ARG(IShellFolder, &pParentFolder)); CComHeapPtr pidlChild; HRESULT hr = pParentFolder->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, diff --git a/dll/win32/shell32/folders/CRecycleBin.cpp b/dll/win32/shell32/folders/CRecycleBin.cpp index e215b2e1f9f..95a0b60cfc2 100644 --- a/dll/win32/shell32/folders/CRecycleBin.cpp +++ b/dll/win32/shell32/folders/CRecycleBin.cpp @@ -534,7 +534,7 @@ static HRESULT CALLBACK FileOpCallback(FILEOPCALLBACKEVENT Event, LPCWSTR Src, L { CComHeapPtr pidlBB(SHCloneSpecialIDList(NULL, CSIDL_BITBUCKET, FALSE)); CComPtr pSF; - if (pidlBB && SUCCEEDED(SHBindToObject(NULL, pidlBB, IID_PPV_ARG(IShellFolder, &pSF)))) + if (pidlBB && SUCCEEDED(SHBindToObject(NULL, pidlBB, NULL, IID_PPV_ARG(IShellFolder, &pSF)))) { if (IsRecycleBinEmpty(pSF)) SHUpdateRecycleBinIcon(); diff --git a/dll/win32/shell32/folders/CRegFolder.cpp b/dll/win32/shell32/folders/CRegFolder.cpp index 0d08b042f95..a698a765bfb 100644 --- a/dll/win32/shell32/folders/CRegFolder.cpp +++ b/dll/win32/shell32/folders/CRegFolder.cpp @@ -982,7 +982,7 @@ static HRESULT CRegItemContextMenu_CreateInstance(PCIDLIST_ABSOLUTE pidlFolder, // It currently does not so we have to ask the outer folder ourself so // that we get the correct attributes for My Computer etc. CComPtr pOuterSF; - SHBindToObject(NULL, pidlFolder, IID_PPV_ARG(IShellFolder, &pOuterSF)); + SHBindToObject(NULL, pidlFolder, NULL, IID_PPV_ARG(IShellFolder, &pOuterSF)); SFGAOF att = (psf && cidl) ? SHGetAttributes(pOuterSF ? pOuterSF.p : psf, apidl[0], SFGAO_FOLDER) : 0; if ((att & SFGAO_FOLDER) && (!pGuid || !HasCLSIDShellFolderValue(*pGuid, L"HideFolderVerbs"))) diff --git a/dll/win32/shell32/precomp.h b/dll/win32/shell32/precomp.h index e9620f76415..d373aaf9c2e 100644 --- a/dll/win32/shell32/precomp.h +++ b/dll/win32/shell32/precomp.h @@ -258,17 +258,10 @@ BOOL Shell_FailForceReturn(_In_ HRESULT hr); EXTERN_C INT Shell_ParseSpecialFolder(_In_ LPCWSTR pszStart, _Out_ LPWSTR *ppch, _Out_ INT *pcch); -EXTERN_C -HRESULT SHBindToObject( +SHSTDAPI +SHBindToObject( _In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, - _In_ REFIID riid, - _Out_ void **ppvObj); - -HRESULT -SHBindToObjectEx( - _In_opt_ IShellFolder *pShellFolder, - _In_ LPCITEMIDLIST pidl, _In_opt_ IBindCtx *pBindCtx, _In_ REFIID riid, _Out_ void **ppvObj); diff --git a/dll/win32/shell32/shldataobject.cpp b/dll/win32/shell32/shldataobject.cpp index 0ee78e9f0bf..2a78c23766e 100644 --- a/dll/win32/shell32/shldataobject.cpp +++ b/dll/win32/shell32/shldataobject.cpp @@ -28,7 +28,7 @@ static_assert(sizeof(DataObjectAttributes) == 0xc, "Unexpected struct size!"); static HRESULT _BindToObject(PCUIDLIST_ABSOLUTE pidl, CComPtr& spFolder) { - return SHBindToObject(NULL, pidl, IID_PPV_ARG(IShellFolder, &spFolder)); + return SHBindToObject(NULL, pidl, NULL, IID_PPV_ARG(IShellFolder, &spFolder)); } EXTERN_C diff --git a/dll/win32/shell32/utils.cpp b/dll/win32/shell32/utils.cpp index 5b044082662..cad6fa4e181 100644 --- a/dll/win32/shell32/utils.cpp +++ b/dll/win32/shell32/utils.cpp @@ -405,10 +405,10 @@ BOOL Shell_FailForceReturn(_In_ HRESULT hr) } } -HRESULT -SHBindToObjectEx( +SHSTDAPI +SHBindToObject( _In_opt_ IShellFolder *pShellFolder, - _In_ LPCITEMIDLIST pidl, + _In_ PCUIDLIST_RELATIVE pidl, _In_opt_ IBindCtx *pBindCtx, _In_ REFIID riid, _Out_ void **ppvObj) @@ -438,16 +438,6 @@ SHBindToObjectEx( return hr; } -EXTERN_C -HRESULT SHBindToObject( - _In_opt_ IShellFolder *psf, - _In_ LPCITEMIDLIST pidl, - _In_ REFIID riid, - _Out_ void **ppvObj) -{ - return SHBindToObjectEx(psf, pidl, NULL, riid, ppvObj); -} - EXTERN_C HRESULT SHELL_GetUIObjectOfAbsoluteItem( _In_opt_ HWND hWnd, @@ -554,7 +544,7 @@ SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAt HRESULT SHELL_GetIDListTarget(_In_ LPCITEMIDLIST pidl, _Out_ PIDLIST_ABSOLUTE *ppidl) { IShellLink *pSL; - HRESULT hr = SHBindToObject(NULL, pidl, IID_PPV_ARG(IShellLink, &pSL)); + HRESULT hr = SHBindToObject(NULL, pidl, NULL, IID_PPV_ARG(IShellLink, &pSL)); if (SUCCEEDED(hr)) { hr = pSL->GetIDList(ppidl); // Note: Returns S_FALSE if no target pidl diff --git a/dll/win32/shell32/wine/shellpath.c b/dll/win32/shell32/wine/shellpath.c index eb66010f2c9..5ce07129d72 100644 --- a/dll/win32/shell32/wine/shellpath.c +++ b/dll/win32/shell32/wine/shellpath.c @@ -3232,11 +3232,11 @@ HRESULT SHGetFolderLocationHelper(HWND hwnd, int nFolder, REFCLSID clsid, LPITEM HRESULT hr; IShellFolder *psf; LPITEMIDLIST parent, child; - EXTERN_C HRESULT SHBindToObject(IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, void **ppvObj); + SHSTDAPI SHBindToObject(IShellFolder *psf, LPCITEMIDLIST pidl, IBindCtx *pBindCtx, REFIID riid, void **ppvObj); *ppidl = NULL; if (FAILED(hr = SHGetFolderLocation(hwnd, nFolder, NULL, 0, &parent))) return hr; - if (SUCCEEDED(hr = SHBindToObject(NULL, parent, &IID_IShellFolder, (void**)&psf))) + if (SUCCEEDED(hr = SHBindToObject(NULL, parent, NULL, &IID_IShellFolder, (void**)&psf))) { WCHAR clsidstr[2 + 38 + 1]; clsidstr[0] = clsidstr[1] = L':'; diff --git a/sdk/include/reactos/undocshell.h b/sdk/include/reactos/undocshell.h index e00e33372a4..e8bde5e2b52 100644 --- a/sdk/include/reactos/undocshell.h +++ b/sdk/include/reactos/undocshell.h @@ -15,7 +15,7 @@ #ifndef SHSTDAPI #if defined(_SHELL32_) /* DECLSPEC_IMPORT disabled because of CORE-6504: */ || TRUE -#define SHSTDAPI_(type) type WINAPI +#define SHSTDAPI_(type) EXTERN_C type WINAPI #else #define SHSTDAPI_(type) EXTERN_C DECLSPEC_IMPORT type WINAPI #endif