https://git.reactos.org/?p=reactos.git;a=commitdiff;h=62eaad1811b47187a3849…
commit 62eaad1811b47187a38490aca97f29d7fabbf773
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Jul 20 16:53:04 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Jul 20 16:53:04 2023 +0900
[SHELL32] CD-ROM drive shouldn't be renamed (#5461)
- Add _ILGetDriveType helper function.
- Use _ILGetDrive and GetDriveType functions to determine the drive type.
- If it was a CD-ROM drive, then remove SFGAO_CANRENAME flag.
CORE-18272
---
dll/win32/shell32/folders/CDrivesFolder.cpp | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp
b/dll/win32/shell32/folders/CDrivesFolder.cpp
index 24df6235f4a..2293884e9ea 100644
--- a/dll/win32/shell32/folders/CDrivesFolder.cpp
+++ b/dll/win32/shell32/folders/CDrivesFolder.cpp
@@ -55,6 +55,17 @@ static int iDriveTypeIds[7] = { IDS_DRIVE_FIXED, /* DRIVE_UNKNOWN
*/
IDS_DRIVE_FIXED /* DRIVE_RAMDISK*/
};
+BOOL _ILGetDriveType(LPCITEMIDLIST pidl)
+{
+ char szDrive[8];
+ if (!_ILGetDrive(pidl, szDrive, _countof(szDrive)))
+ {
+ ERR("pidl %p is not a drive\n", pidl);
+ return DRIVE_UNKNOWN;
+ }
+ return ::GetDriveTypeA(szDrive);
+}
+
/***********************************************************************
* IShellFolder implementation
*/
@@ -660,7 +671,12 @@ HRESULT WINAPI CDrivesFolder::ParseDisplayName(HWND hwndOwner, LPBC
pbc, LPOLEST
if (pdwAttributes && *pdwAttributes)
{
if (_ILIsDrive(pidlTemp))
+ {
*pdwAttributes &= dwDriveAttributes;
+
+ if (_ILGetDriveType(pidlTemp) == DRIVE_CDROM)
+ *pdwAttributes &= ~SFGAO_CANRENAME; // CD-ROM drive cannot
rename
+ }
else if (_ILIsSpecialFolder(pidlTemp))
m_regFolder->GetAttributesOf(1, &pidlTemp, pdwAttributes);
else
@@ -877,7 +893,12 @@ HRESULT WINAPI CDrivesFolder::GetAttributesOf(UINT cidl,
PCUITEMID_CHILD_ARRAY a
for (UINT i = 0; i < cidl; ++i)
{
if (_ILIsDrive(apidl[i]))
+ {
*rgfInOut &= dwDriveAttributes;
+
+ if (_ILGetDriveType(apidl[i]) == DRIVE_CDROM)
+ *rgfInOut &= ~SFGAO_CANRENAME; // CD-ROM drive cannot rename
+ }
else if (_ILIsControlPanel(apidl[i]))
*rgfInOut &= dwControlPanelAttributes;
else if (_ILIsSpecialFolder(*apidl))