Author: dquintana Date: Sun Apr 12 01:34:53 2015 New Revision: 67166
URL: http://svn.reactos.org/svn/reactos?rev=67166&view=rev Log: [NTOBJSHEX] * Make the info struct pointers const, to ensure we are not modifying the contents from the const idlists. * Disable checking that the provided PIDL is part of the folder. Fixes enumeration in ros, but feels a lot like hiding a bug. CORE-9432 #resolve
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjns.cpp trunk/reactos/dll/shellext/ntobjshex/precomp.h trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjns.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/ntob... ============================================================================== --- trunk/reactos/dll/shellext/ntobjshex/ntobjns.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/ntobjshex/ntobjns.cpp [iso-8859-1] Sun Apr 12 01:34:53 2015 @@ -199,7 +199,7 @@ return S_OK; }
- HRESULT FindPidlInList(PCUITEMID_CHILD pcidl, NtPidlEntry ** pinfo) + HRESULT FindPidlInList(PCUITEMID_CHILD pcidl, const NtPidlEntry ** pinfo) { HRESULT hr;
@@ -326,7 +326,7 @@ return S_OK; }
- static LPITEMIDLIST CreatePidlFromItem(NtPidlEntry * entry) + static LPITEMIDLIST CreatePidlFromItem(const NtPidlEntry * entry) { LPITEMIDLIST idl = (LPITEMIDLIST) CoTaskMemAlloc(entry->cb + 2); if (!idl) @@ -336,7 +336,7 @@ return idl; }
- static HRESULT CompareIDs(LPARAM lParam, NtPidlEntry * first, NtPidlEntry * second) + static HRESULT CompareIDs(LPARAM lParam, const NtPidlEntry * first, const NtPidlEntry * second) { if ((lParam & 0xFFFF0000) == SHCIDS_ALLFIELDS) { @@ -431,7 +431,7 @@ return E_INVALIDARG; }
- static HRESULT CompareIDs(LPARAM lParam, NtPidlEntry * first, LPCITEMIDLIST pcidl) + static HRESULT CompareIDs(LPARAM lParam, const NtPidlEntry * first, LPCITEMIDLIST pcidl) { LPCITEMIDLIST p = pcidl; NtPidlEntry * second = (NtPidlEntry*) &(p->mkid); @@ -451,7 +451,7 @@ return CompareIDs(lParam, first, pcidl2); }
- static ULONG ConvertAttributes(NtPidlEntry * entry, PULONG inMask) + static ULONG ConvertAttributes(const NtPidlEntry * entry, PULONG inMask) { ULONG mask = inMask ? *inMask : 0xFFFFFFFF; ULONG flags = SFGAO_HASPROPSHEET | SFGAO_CANLINK; @@ -470,7 +470,7 @@
BOOL IsFolder(LPCITEMIDLIST pcidl) { - NtPidlEntry * entry; + const NtPidlEntry * entry; HRESULT hr = FindPidlInList(pcidl, &entry); if (FAILED_UNEXPECTEDLY(hr)) return FALSE; @@ -668,7 +668,7 @@ REFIID riid, void **ppvOut) { - NtPidlEntry * info; + const NtPidlEntry * info; HRESULT hr;
if (IsEqualIID(riid, IID_IShellFolder)) @@ -816,8 +816,7 @@ PCUITEMID_CHILD_ARRAY apidl, SFGAOF *rgfInOut) { - NtPidlEntry * info; - HRESULT hr; + const NtPidlEntry * info;
TRACE("GetAttributesOf\n");
@@ -831,9 +830,15 @@ { PCUITEMID_CHILD pidl = apidl[i];
- hr = m_PidlManager->FindPidlInList(pidl, &info); +#ifndef DISABLE_STRICT_PIDL_CHECK + HRESULT hr = m_PidlManager->FindPidlInList(pidl, &info); if (FAILED_UNEXPECTEDLY(hr)) return hr; +#else + info = (const NtPidlEntry *) pidl; + if (info->magic != NT_OBJECT_PIDL_MAGIC) + return E_INVALIDARG; +#endif
// Update attributes. *rgfInOut = m_PidlManager->ConvertAttributes(info, rgfInOut); @@ -912,14 +917,20 @@ SHGDNF uFlags, STRRET *lpName) { - NtPidlEntry * info; + const NtPidlEntry * info; HRESULT hr;
TRACE("GetDisplayNameOf %p\n", pidl);
+#ifndef DISABLE_STRICT_PIDL_CHECK hr = m_PidlManager->FindPidlInList(pidl, &info); if (FAILED_UNEXPECTEDLY(hr)) return hr; +#else + info = (const NtPidlEntry *) pidl; + if (info->magic != NT_OBJECT_PIDL_MAGIC) + return E_INVALIDARG; +#endif
if ((GET_SHGDN_RELATION(uFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR(uFlags) & SHGDN_FORPARSING)) @@ -1085,16 +1096,21 @@ const SHCOLUMNID *pscid, VARIANT *pv) { - NtPidlEntry * info; - HRESULT hr; + const NtPidlEntry * info;
TRACE("GetDetailsEx\n");
if (pidl) { - hr = m_PidlManager->FindPidlInList(pidl, &info); +#ifndef DISABLE_STRICT_PIDL_CHECK + HRESULT hr = m_PidlManager->FindPidlInList(pidl, &info); if (FAILED_UNEXPECTEDLY(hr)) return hr; +#else + info = (const NtPidlEntry *) pidl; + if (info->magic != NT_OBJECT_PIDL_MAGIC) + return E_INVALIDARG; +#endif
static const GUID storage = PSGUID_STORAGE; if (IsEqualGUID(pscid->fmtid, storage)) @@ -1163,16 +1179,21 @@ UINT iColumn, SHELLDETAILS *psd) { - NtPidlEntry * info; - HRESULT hr; + const NtPidlEntry * info;
TRACE("GetDetailsOf\n");
if (pidl) { - hr = m_PidlManager->FindPidlInList(pidl, &info); +#ifndef DISABLE_STRICT_PIDL_CHECK + HRESULT hr = m_PidlManager->FindPidlInList(pidl, &info); if (FAILED_UNEXPECTEDLY(hr)) return hr; +#else + info = (const NtPidlEntry *) pidl; + if (info->magic != NT_OBJECT_PIDL_MAGIC) + return E_INVALIDARG; +#endif
switch (iColumn) {
Modified: trunk/reactos/dll/shellext/ntobjshex/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/prec... ============================================================================== --- trunk/reactos/dll/shellext/ntobjshex/precomp.h [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/ntobjshex/precomp.h [iso-8859-1] Sun Apr 12 01:34:53 2015 @@ -48,3 +48,6 @@
#include "ntobjns.h" #include "regfolder.h" + +// Workaround for missing entries +#define DISABLE_STRICT_PIDL_CHECKS
Modified: trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/regf... ============================================================================== --- trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp [iso-8859-1] Sun Apr 12 01:34:53 2015 @@ -194,7 +194,7 @@ return S_OK; }
- HRESULT FindPidlInList(PCUITEMID_CHILD pcidl, RegPidlEntry ** pinfo) + HRESULT FindPidlInList(PCUITEMID_CHILD pcidl, const RegPidlEntry ** pinfo) { HRESULT hr;
@@ -323,7 +323,7 @@ }
- static LPITEMIDLIST CreatePidlFromItem(RegPidlEntry * entry) + static LPITEMIDLIST CreatePidlFromItem(const RegPidlEntry * entry) { LPITEMIDLIST idl = (LPITEMIDLIST) CoTaskMemAlloc(entry->cb + 2); if (!idl) @@ -333,7 +333,7 @@ return idl; }
- static HRESULT CompareIDs(LPARAM lParam, RegPidlEntry * first, RegPidlEntry * second) + static HRESULT CompareIDs(LPARAM lParam, const RegPidlEntry * first, const RegPidlEntry * second) { if ((lParam & 0xFFFF0000) == SHCIDS_ALLFIELDS) { @@ -418,7 +418,7 @@ return E_INVALIDARG; }
- static HRESULT CompareIDs(LPARAM lParam, RegPidlEntry * first, LPCITEMIDLIST pcidl) + static HRESULT CompareIDs(LPARAM lParam, const RegPidlEntry * first, LPCITEMIDLIST pcidl) { LPCITEMIDLIST p = pcidl; RegPidlEntry * second = (RegPidlEntry*) &(p->mkid); @@ -438,7 +438,7 @@ return CompareIDs(lParam, first, pcidl2); }
- static ULONG ConvertAttributes(RegPidlEntry * entry, PULONG inMask) + static ULONG ConvertAttributes(const RegPidlEntry * entry, PULONG inMask) { ULONG mask = inMask ? *inMask : 0xFFFFFFFF; ULONG flags = 0; @@ -452,7 +452,7 @@
BOOL IsFolder(LPCITEMIDLIST pcidl) { - RegPidlEntry * entry; + const RegPidlEntry * entry; HRESULT hr = FindPidlInList(pcidl, &entry); if (FAILED_UNEXPECTEDLY(hr)) return FALSE; @@ -512,7 +512,7 @@ } }
- HRESULT FormatContentsForDisplay(RegPidlEntry * info, PCWSTR * strContents) + HRESULT FormatContentsForDisplay(const RegPidlEntry * info, PCWSTR * strContents) { PVOID td = (((PBYTE) info) + FIELD_OFFSET(RegPidlEntry, entryName) + info->entryNameLength + sizeof(WCHAR));
@@ -752,7 +752,7 @@ REFIID riid, void **ppvOut) { - RegPidlEntry * info; + const RegPidlEntry * info; HRESULT hr;
if (IsEqualIID(riid, IID_IShellFolder)) @@ -866,8 +866,7 @@ PCUITEMID_CHILD_ARRAY apidl, SFGAOF *rgfInOut) { - RegPidlEntry * info; - HRESULT hr; + const RegPidlEntry * info;
TRACE("GetAttributesOf\n");
@@ -881,9 +880,15 @@ { PCUITEMID_CHILD pidl = apidl[i];
- hr = m_PidlManager->FindPidlInList(pidl, &info); +#ifndef DISABLE_STRICT_PIDL_CHECK + HRESULT hr = m_PidlManager->FindPidlInList(pidl, &info); if (FAILED_UNEXPECTEDLY(hr)) return hr; +#else + info = (const RegPidlEntry *) pidl; + if (info->magic != REGISTRY_PIDL_MAGIC) + return E_INVALIDARG; +#endif
// Update attributes. *rgfInOut = m_PidlManager->ConvertAttributes(info, rgfInOut); @@ -962,14 +967,20 @@ SHGDNF uFlags, STRRET *lpName) { - RegPidlEntry * info; + const RegPidlEntry * info; HRESULT hr;
TRACE("GetDisplayNameOf %p\n", pidl);
+#ifndef DISABLE_STRICT_PIDL_CHECK hr = m_PidlManager->FindPidlInList(pidl, &info); if (FAILED_UNEXPECTEDLY(hr)) return hr; +#else + info = (const RegPidlEntry *) pidl; + if (info->magic != REGISTRY_PIDL_MAGIC) + return E_INVALIDARG; +#endif
if ((GET_SHGDN_RELATION(uFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR(uFlags) & SHGDN_FORPARSING)) @@ -1134,16 +1145,22 @@ const SHCOLUMNID *pscid, VARIANT *pv) { - RegPidlEntry * info; + const RegPidlEntry * info; HRESULT hr;
TRACE("GetDetailsEx\n");
if (pidl) { +#ifndef DISABLE_STRICT_PIDL_CHECK hr = m_PidlManager->FindPidlInList(pidl, &info); if (FAILED_UNEXPECTEDLY(hr)) return hr; +#else + info = (const RegPidlEntry *) pidl; + if (info->magic != REGISTRY_PIDL_MAGIC) + return E_INVALIDARG; +#endif
static const GUID storage = PSGUID_STORAGE; if (IsEqualGUID(pscid->fmtid, storage)) @@ -1208,16 +1225,22 @@ UINT iColumn, SHELLDETAILS *psd) { - RegPidlEntry * info; + const RegPidlEntry * info; HRESULT hr;
TRACE("GetDetailsOf\n");
if (pidl) { +#ifndef DISABLE_STRICT_PIDL_CHECK hr = m_PidlManager->FindPidlInList(pidl, &info); if (FAILED_UNEXPECTEDLY(hr)) return hr; +#else + info = (const RegPidlEntry *) pidl; + if (info->magic != REGISTRY_PIDL_MAGIC) + return E_INVALIDARG; +#endif
switch (iColumn) {