Author: dquintana
Date: Wed Jun 21 22:32:34 2017
New Revision: 75160
URL:
http://svn.reactos.org/svn/reactos?rev=75160&view=rev
Log:
[NTOBJSHEX]
* Fixed NT object symbolic link target retrieval.
* Fixed NT path parsing (didn't consider paths sub sub-folders in them).
* Fixed BindToObject to properly resolve the target path for symlinks.
* Made the maximum embedded content length for registry keys a bit bigger.
Modified:
trunk/reactos/dll/shellext/ntobjshex/ntobjenum.cpp
trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjenum.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/nto…
==============================================================================
--- trunk/reactos/dll/shellext/ntobjshex/ntobjenum.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/ntobjshex/ntobjenum.cpp [iso-8859-1] Wed Jun 21 22:32:34
2017
@@ -172,7 +172,10 @@
StringCbCopyExW(buffer, sizeof(buffer), path, &pend, NULL, 0);
if (pend[-1] != '\\')
+ {
*pend++ = '\\';
+ *pend = 0;
+ }
StringCbCatW(buffer, sizeof(buffer), entryName);
@@ -180,11 +183,11 @@
LinkTarget->Length = 0;
- DWORD err = NtOpenObject(SYMBOLICLINK_OBJECT, &handle, 0, buffer);
+ DWORD err = NtOpenObject(SYMBOLICLINK_OBJECT, &handle, SYMBOLIC_LINK_QUERY,
buffer);
if (!NT_SUCCESS(err))
return HRESULT_FROM_NT(err);
- err = NT_SUCCESS(NtQuerySymbolicLinkObject(handle, LinkTarget, NULL));
+ err = NtQuerySymbolicLinkObject(handle, LinkTarget, NULL);
if (!NT_SUCCESS(err))
return HRESULT_FROM_NT(err);
@@ -429,7 +432,7 @@
DWORD entryBufferLength = FIELD_OFFSET(RegPidlEntry, entryName) + sizeof(WCHAR) +
cchName * sizeof(WCHAR);
- BOOL copyData = dataSize < 32;
+ BOOL copyData = dataSize < 256;
if (copyData)
{
entryBufferLength += dataSize + sizeof(WCHAR);
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/nto…
==============================================================================
--- trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp [iso-8859-1] Wed Jun 21 22:32:34
2017
@@ -338,6 +338,9 @@
if (FAILED(hr))
return hr;
+ PWSTR end = StrChrW(lpszDisplayName, '\\');
+ int length = end ? end - lpszDisplayName : wcslen(lpszDisplayName);
+
while (TRUE)
{
hr = it->Next(1, ppidl, NULL);
@@ -346,29 +349,45 @@
return hr;
if (hr != S_OK)
+ return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
+
+ hr = CNtObjectPidlHelper::GetInfoFromPidl(*ppidl, &info);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ if (StrCmpNW(info->entryName, lpszDisplayName, length) == 0)
break;
-
- hr = CNtObjectPidlHelper::GetInfoFromPidl(*ppidl, &info);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
- if (StrCmpW(info->entryName, lpszDisplayName) == 0)
- break;
- }
-
- if (hr != S_OK)
- {
- return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
- }
-
- if (pchEaten || pdwAttributes)
- {
+ }
+
+ // if has remaining path to parse (and the path didn't just terminate in a
backslash)
+ if (end && wcslen(end) > 1)
+ {
+ CComPtr<IShellFolder> psfChild;
+ hr = BindToObject(*ppidl, pbcReserved, IID_PPV_ARG(IShellFolder,
&psfChild));
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ LPITEMIDLIST child;
+ hr = psfChild->ParseDisplayName(hwndOwner, pbcReserved, end + 1, pchEaten,
&child, pdwAttributes);
+ if (FAILED(hr))
+ return hr;
+
+ LPITEMIDLIST old = *ppidl;
+ *ppidl = ILCombine(old, child);
+ ILFree(old);
+
+ // Count the path separator
if (pchEaten)
- *pchEaten = wcslen(info->entryName);
-
+ (*pchEaten) += 1;
+ }
+ else
+ {
if (pdwAttributes)
*pdwAttributes = CNtObjectPidlHelper::ConvertAttributes(info,
pdwAttributes);
}
+
+ if (pchEaten)
+ *pchEaten += wcslen(info->entryName);
return S_OK;
}
@@ -398,7 +417,6 @@
WCHAR path[MAX_PATH];
StringCbCopyW(path, _countof(path), m_NtPath);
-
PathAppendW(path, info->entryName);
LPITEMIDLIST first = ILCloneFirst(pidl);
@@ -440,9 +458,17 @@
if (FAILED_UNEXPECTEDLY(hr))
return hr;
- hr = psfDesktop->ParseDisplayName(NULL, NULL, path, NULL, &first,
NULL);
+ LPITEMIDLIST pidl;
+
+ hr = psfDesktop->ParseDisplayName(NULL, NULL, path, NULL, &pidl,
NULL);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
+
+ CComPtr<IShellFolder> psfChild;
+ hr = psfDesktop->BindToObject(pidl, NULL, riid, ppvOut);
+ ILFree(pidl);
+
+ return hr;
}
else
{
@@ -533,9 +559,9 @@
SFV_CREATE sfv;
sfv.cbSize = sizeof(sfv);
- sfv.pshf = this;
+ sfv.pshf = static_cast<IShellFolder*>(this);
sfv.psvOuter = NULL;
- sfv.psfvcb = this;
+ sfv.psfvcb = static_cast<IShellFolderViewCB*>(this);
return SHCreateShellFolderView(&sfv, (IShellView**) ppvOut);
}