https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7d75bfb449286204c4376…
commit 7d75bfb449286204c43766eea43e872f51065568
Author: Whindmar Saksit <whindsaks(a)proton.me>
AuthorDate: Wed Dec 25 20:32:08 2024 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Dec 25 20:32:08 2024 +0100
[SHELL32] ILLoadFromStream must allow loading unknown pidl formats (#7570)
---
dll/win32/shell32/debughlp.cpp | 21 ++++++++++++++++-----
dll/win32/shell32/wine/pidl.c | 6 +++---
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/dll/win32/shell32/debughlp.cpp b/dll/win32/shell32/debughlp.cpp
index 6778418c7a8..f57d399789b 100644
--- a/dll/win32/shell32/debughlp.cpp
+++ b/dll/win32/shell32/debughlp.cpp
@@ -22,6 +22,17 @@
WINE_DEFAULT_DEBUG_CHANNEL(pidl);
+static inline BYTE _dbg_ILGetType(LPCITEMIDLIST pidl)
+{
+ return pidl && pidl->mkid.cb >= 3 ? pidl->mkid.abID[0] : 0;
+}
+
+static inline BYTE _dbg_ILGetFSType(LPCITEMIDLIST pidl)
+{
+ const BYTE type = _dbg_ILGetType(pidl);
+ return (type & PT_FOLDERTYPEMASK) == PT_FS ? type : 0;
+}
+
static
LPITEMIDLIST _dbg_ILGetNext(LPCITEMIDLIST pidl)
{
@@ -97,6 +108,9 @@ LPWSTR _dbg_ILGetTextPointerW(LPCITEMIDLIST pidl)
if (pdata)
{
+ if (_dbg_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG)
+ return (LPWSTR)&(pdata->u.file.szNames);
+
switch (pdata->type)
{
case PT_GUID:
@@ -126,9 +140,6 @@ LPWSTR _dbg_ILGetTextPointerW(LPCITEMIDLIST pidl)
case PT_SHARE:
/* return (LPSTR)&(pdata->u.network.szNames); */
return NULL;
-
- case PT_VALUEW:
- return (LPWSTR)&(pdata->u.file.szNames);
}
}
return NULL;
@@ -271,7 +282,7 @@ static void pdump_impl (LPCITEMIDLIST pidl)
char szName[MAX_PATH];
_dbg_ILSimpleGetText(pidltemp, szName, MAX_PATH);
- if ( pData && (PT_FOLDER == type || PT_VALUE == type) )
+ if (_dbg_ILGetFSType(pidltemp))
dwAttrib = pData->u.file.uFileAttribs;
MESSAGE ("[%p] size=%04u type=%x attr=0x%08x name=%s (%s,%s)\n",
@@ -288,7 +299,7 @@ static void pdump_impl (LPCITEMIDLIST pidl)
char szName[MAX_PATH];
_dbg_ILSimpleGetText(pidltemp, szName, MAX_PATH);
- if ( pData && (PT_FOLDER == type || PT_VALUE == type) )
+ if (_dbg_ILGetFSType(pidltemp))
dwAttrib = pData->u.file.uFileAttribs;
MESSAGE ("[%p] size=%04u type=%x attr=0x%08x name=%s (%s,%s)\n",
diff --git a/dll/win32/shell32/wine/pidl.c b/dll/win32/shell32/wine/pidl.c
index 2bca7cdd436..94d9a22387a 100644
--- a/dll/win32/shell32/wine/pidl.c
+++ b/dll/win32/shell32/wine/pidl.c
@@ -333,8 +333,10 @@ HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST *
ppPidl)
if (*ppPidl && !pcheck(*ppPidl))
{
WARN("Check failed\n");
+#ifndef __REACTOS__ /* We don't know all pidl formats, must allow loading unknown */
SHFree(*ppPidl);
*ppPidl = NULL;
+#endif
}
IStream_Release (pStream);
@@ -2030,11 +2032,9 @@ DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uSize)
*/
BOOL _ILIsUnicode(LPCITEMIDLIST pidl)
{
- LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
-
TRACE("(%p)\n",pidl);
- return (pidl && lpPData && PT_VALUEW == lpPData->type);
+ return (_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG) != 0;
}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)