Author: dquintana
Date: Wed Aug 26 23:30:47 2015
New Revision: 68832
URL:
http://svn.reactos.org/svn/reactos?rev=68832&view=rev
Log:
[NTOBJSHEX]
* Now that we use lazy enumeration instead of keeping a full list of all items, I was able
to simplify a few things.
Modified:
trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp
trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.h
trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp
trunk/reactos/dll/shellext/ntobjshex/regfolder.h
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 Aug 26 23:30:47
2015
@@ -131,28 +131,9 @@
};
-class CNtObjectPidlManager
-{
-private:
- PWSTR m_ntPath;
-
+class CNtObjectPidlHelper
+{
public:
- CNtObjectPidlManager() :
- m_ntPath(NULL)
- {
- }
-
- ~CNtObjectPidlManager()
- {
- }
-
- HRESULT Initialize(PWSTR ntPath)
- {
- m_ntPath = ntPath;
-
- return S_OK;
- }
-
static HRESULT CompareIDs(LPARAM lParam, const NtPidlEntry * first, const NtPidlEntry
* second)
{
if ((lParam & 0xFFFF0000) == SHCIDS_ALLFIELDS)
@@ -285,7 +266,7 @@
return flags & mask;
}
- BOOL IsFolder(LPCITEMIDLIST pcidl)
+ static BOOL IsFolder(LPCITEMIDLIST pcidl)
{
NtPidlEntry * entry = (NtPidlEntry*) &(pcidl->mkid);
if ((entry->cb < sizeof(NtPidlEntry)) || (entry->magic !=
NT_OBJECT_PIDL_MAGIC))
@@ -296,7 +277,7 @@
(entry->objectType == KEY_OBJECT);
}
- HRESULT GetInfoFromPidl(LPCITEMIDLIST pcidl, const NtPidlEntry ** pentry)
+ static HRESULT GetInfoFromPidl(LPCITEMIDLIST pcidl, const NtPidlEntry ** pentry)
{
NtPidlEntry * entry = (NtPidlEntry*) &(pcidl->mkid);
@@ -321,7 +302,6 @@
// CNtObjectFolder
CNtObjectFolder::CNtObjectFolder() :
- m_PidlManager(NULL),
m_shellPidl(NULL)
{
}
@@ -330,8 +310,6 @@
{
if (m_shellPidl)
ILFree(m_shellPidl);
- if (m_PidlManager)
- delete m_PidlManager;
}
// IShellFolder
@@ -370,7 +348,7 @@
if (hr != S_OK)
break;
- hr = m_PidlManager->GetInfoFromPidl(*ppidl, &info);
+ hr = CNtObjectPidlHelper::GetInfoFromPidl(*ppidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -389,7 +367,7 @@
*pchEaten = wcslen(info->entryName);
if (pdwAttributes)
- *pdwAttributes = m_PidlManager->ConvertAttributes(info, pdwAttributes);
+ *pdwAttributes = CNtObjectPidlHelper::ConvertAttributes(info,
pdwAttributes);
}
return S_OK;
@@ -413,7 +391,7 @@
if (IsEqualIID(riid, IID_IShellFolder))
{
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CNtObjectPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -514,7 +492,7 @@
{
TRACE("CompareIDs\n");
- HRESULT hr = m_PidlManager->CompareIDs(lParam, pidl1, pidl2);
+ HRESULT hr = CNtObjectPidlHelper::CompareIDs(lParam, pidl1, pidl2);
if (hr != S_OK)
return hr;
@@ -581,12 +559,12 @@
{
PCUITEMID_CHILD pidl = apidl[i];
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CNtObjectPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
// Update attributes.
- *rgfInOut = m_PidlManager->ConvertAttributes(info, rgfInOut);
+ *rgfInOut = CNtObjectPidlHelper::ConvertAttributes(info, rgfInOut);
}
return S_OK;
@@ -612,7 +590,7 @@
HKEY keys[1];
int nkeys = _countof(keys);
- if (cidl == 1 && m_PidlManager->IsFolder(apidl[0]))
+ if (cidl == 1 && CNtObjectPidlHelper::IsFolder(apidl[0]))
{
res = RegOpenKey(HKEY_CLASSES_ROOT, L"Folder", keys + 0);
if (!NT_SUCCESS(res))
@@ -642,7 +620,7 @@
if (IsEqualIID(riid, IID_IQueryAssociations))
{
- if (cidl == 1 && m_PidlManager->IsFolder(apidl[0]))
+ if (cidl == 1 && CNtObjectPidlHelper::IsFolder(apidl[0]))
{
CComPtr<IQueryAssociations> pqa;
HRESULT hr = AssocCreate(CLSID_QueryAssociations,
IID_PPV_ARG(IQueryAssociations, &pqa));
@@ -669,7 +647,7 @@
TRACE("GetDisplayNameOf %p\n", pidl);
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CNtObjectPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -748,16 +726,9 @@
{
m_shellPidl = ILClone(pidl);
- PCWSTR ntPath = L"\\";
-
- if (!m_PidlManager)
- {
- m_PidlManager = new CNtObjectPidlManager();
-
- StringCbCopy(m_NtPath, _countof(m_NtPath), ntPath);
- }
-
- return m_PidlManager->Initialize(m_NtPath);
+ StringCbCopy(m_NtPath, _countof(m_NtPath), L"\\");
+
+ return S_OK;
}
// Internal
@@ -765,11 +736,9 @@
{
m_shellPidl = ILClone(pidl);
- if (!m_PidlManager)
- m_PidlManager = new CNtObjectPidlManager();
-
StringCbCopy(m_NtPath, _countof(m_NtPath), ntPath);
- return m_PidlManager->Initialize(m_NtPath);
+
+ return S_OK;
}
// IPersistFolder2
@@ -840,7 +809,7 @@
if (pidl)
{
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CNtObjectPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -907,7 +876,7 @@
if (pidl)
{
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CNtObjectPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/nto…
==============================================================================
--- trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.h [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/ntobjshex/ntobjfolder.h [iso-8859-1] Wed Aug 26 23:30:47
2015
@@ -9,8 +9,6 @@
extern const GUID CLSID_NtObjectFolder;
-class CNtObjectPidlManager;
-
class CNtObjectFolder :
public CComCoClass<CNtObjectFolder, &CLSID_NtObjectFolder>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
@@ -18,8 +16,6 @@
public IPersistFolder2,
public IShellFolderViewCB
{
- CNtObjectPidlManager * m_PidlManager;
-
WCHAR m_NtPath[MAX_PATH];
LPITEMIDLIST m_shellPidl;
@@ -28,8 +24,6 @@
CNtObjectFolder();
virtual ~CNtObjectFolder();
-
- CNtObjectPidlManager& GetManager() { return *m_PidlManager; }
// IShellFolder
virtual HRESULT STDMETHODCALLTYPE ParseDisplayName(
Modified: trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/reg…
==============================================================================
--- trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp [iso-8859-1] Wed Aug 26 23:30:47
2015
@@ -125,44 +125,9 @@
};
-class CRegistryPidlManager
-{
-private:
- PWSTR m_ntPath;
- HKEY m_hRoot;
-
- int DpaDeleteCallback(RegPidlEntry * info)
- {
- CoTaskMemFree(info);
- return 0;
- }
-
- static int CALLBACK s_DpaDeleteCallback(void *pItem, void *pData)
- {
- CRegistryPidlManager * mf = (CRegistryPidlManager*) pData;
- RegPidlEntry * item = (RegPidlEntry*) pItem;
- return mf->DpaDeleteCallback(item);
- }
-
+class CRegistryPidlHelper
+{
public:
- CRegistryPidlManager() :
- m_ntPath(NULL),
- m_hRoot(NULL)
- {
- }
-
- ~CRegistryPidlManager()
- {
- }
-
- HRESULT Initialize(PWSTR ntPath, HKEY hRoot)
- {
- m_ntPath = ntPath;
- m_hRoot = hRoot;
-
- return S_OK;
- }
-
static HRESULT CompareIDs(LPARAM lParam, const RegPidlEntry * first, const
RegPidlEntry * second)
{
if ((lParam & 0xFFFF0000) == SHCIDS_ALLFIELDS)
@@ -290,7 +255,7 @@
return flags & mask;
}
- BOOL IsFolder(LPCITEMIDLIST pcidl)
+ static BOOL IsFolder(LPCITEMIDLIST pcidl)
{
RegPidlEntry * entry = (RegPidlEntry*) &(pcidl->mkid);
if ((entry->cb < sizeof(RegPidlEntry)) || (entry->magic !=
REGISTRY_PIDL_MAGIC))
@@ -300,7 +265,7 @@
(entry->entryType == REG_ENTRY_ROOT);
}
- HRESULT GetInfoFromPidl(LPCITEMIDLIST pcidl, const RegPidlEntry ** pentry)
+ static HRESULT GetInfoFromPidl(LPCITEMIDLIST pcidl, const RegPidlEntry ** pentry)
{
RegPidlEntry * entry = (RegPidlEntry*) &(pcidl->mkid);
@@ -371,7 +336,7 @@
}
}
- HRESULT FormatContentsForDisplay(const RegPidlEntry * info, PCWSTR * strContents)
+ static HRESULT FormatContentsForDisplay(const RegPidlEntry * info, LPCWSTR ntPath,
PCWSTR * strContents)
{
PVOID td = (((PBYTE) info) + FIELD_OFFSET(RegPidlEntry, entryName) +
info->entryNameLength + sizeof(WCHAR));
@@ -386,7 +351,7 @@
{
PVOID valueData;
DWORD valueLength;
- HRESULT hr = ReadRegistryValue(NULL, m_ntPath, info->entryName,
&valueData, &valueLength);
+ HRESULT hr = ReadRegistryValue(NULL, ntPath, info->entryName,
&valueData, &valueLength);
if (FAILED_UNEXPECTEDLY(hr))
{
PCWSTR strEmpty = L"(Error reading value)";
@@ -429,7 +394,6 @@
// CRegistryFolder
CRegistryFolder::CRegistryFolder() :
- m_PidlManager(NULL),
m_shellPidl(NULL)
{
}
@@ -438,8 +402,6 @@
{
if (m_shellPidl)
ILFree(m_shellPidl);
- if (m_PidlManager)
- delete m_PidlManager;
}
// IShellFolder
@@ -480,7 +442,7 @@
if (hr != S_OK)
break;
- hr = m_PidlManager->GetInfoFromPidl(*ppidl, &info);
+ hr = CRegistryPidlHelper::GetInfoFromPidl(*ppidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -499,7 +461,7 @@
*pchEaten = wcslen(info->entryName);
if (pdwAttributes)
- *pdwAttributes = m_PidlManager->ConvertAttributes(info, pdwAttributes);
+ *pdwAttributes = CRegistryPidlHelper::ConvertAttributes(info,
pdwAttributes);
}
return S_OK;
@@ -530,7 +492,7 @@
if (IsEqualIID(riid, IID_IShellFolder))
{
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CRegistryPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -586,7 +548,7 @@
{
TRACE("CompareIDs\n");
- HRESULT hr = m_PidlManager->CompareIDs(lParam, pidl1, pidl2);
+ HRESULT hr = CRegistryPidlHelper::CompareIDs(lParam, pidl1, pidl2);
if (hr != S_OK)
return hr;
@@ -653,12 +615,12 @@
{
PCUITEMID_CHILD pidl = apidl[i];
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CRegistryPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
// Update attributes.
- *rgfInOut = m_PidlManager->ConvertAttributes(info, rgfInOut);
+ *rgfInOut = CRegistryPidlHelper::ConvertAttributes(info, rgfInOut);
}
return S_OK;
@@ -684,7 +646,7 @@
HKEY keys[1];
int nkeys = _countof(keys);
- if (cidl == 1 && m_PidlManager->IsFolder(apidl[0]))
+ if (cidl == 1 && CRegistryPidlHelper::IsFolder(apidl[0]))
{
res = RegOpenKey(HKEY_CLASSES_ROOT, L"Folder", keys + 0);
if (!NT_SUCCESS(res))
@@ -714,7 +676,7 @@
if (IsEqualIID(riid, IID_IQueryAssociations))
{
- if (cidl == 1 && m_PidlManager->IsFolder(apidl[0]))
+ if (cidl == 1 && CRegistryPidlHelper::IsFolder(apidl[0]))
{
CComPtr<IQueryAssociations> pqa;
HRESULT hr = AssocCreate(CLSID_QueryAssociations,
IID_PPV_ARG(IQueryAssociations, &pqa));
@@ -741,7 +703,7 @@
TRACE("GetDisplayNameOf %p\n", pidl);
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CRegistryPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -821,16 +783,8 @@
m_shellPidl = ILClone(pidl);
m_hRoot = NULL;
- PCWSTR ntPath = L"";
-
- if (!m_PidlManager)
- {
- m_PidlManager = new CRegistryPidlManager();
-
- StringCbCopy(m_NtPath, _countof(m_NtPath), ntPath);
- }
-
- return m_PidlManager->Initialize(m_NtPath, m_hRoot);
+ StringCbCopy(m_NtPath, _countof(m_NtPath), L"");
+ return S_OK;
}
// Internal
@@ -839,11 +793,8 @@
m_shellPidl = ILClone(pidl);
m_hRoot = hRoot;
- if (!m_PidlManager)
- m_PidlManager = new CRegistryPidlManager();
-
StringCbCopy(m_NtPath, _countof(m_NtPath), ntPath);
- return m_PidlManager->Initialize(m_NtPath, m_hRoot);
+ return S_OK;
}
// IPersistFolder2
@@ -914,7 +865,7 @@
if (pidl)
{
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CRegistryPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -953,7 +904,7 @@
{
PCWSTR strValueContents;
- hr = m_PidlManager->FormatContentsForDisplay(info,
&strValueContents);
+ hr = CRegistryPidlHelper::FormatContentsForDisplay(info, m_NtPath,
&strValueContents);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -987,7 +938,7 @@
if (pidl)
{
- HRESULT hr = m_PidlManager->GetInfoFromPidl(pidl, &info);
+ HRESULT hr = CRegistryPidlHelper::GetInfoFromPidl(pidl, &info);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -1029,7 +980,7 @@
PCWSTR strValueContents;
- hr = m_PidlManager->FormatContentsForDisplay(info,
&strValueContents);
+ hr = CRegistryPidlHelper::FormatContentsForDisplay(info, m_NtPath,
&strValueContents);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
Modified: trunk/reactos/dll/shellext/ntobjshex/regfolder.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/reg…
==============================================================================
--- trunk/reactos/dll/shellext/ntobjshex/regfolder.h [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/ntobjshex/regfolder.h [iso-8859-1] Wed Aug 26 23:30:47
2015
@@ -10,8 +10,6 @@
extern const GUID CLSID_RegistryFolder;
-class CRegistryPidlManager;
-
class CRegistryFolder :
public CComCoClass<CRegistryFolder, &CLSID_RegistryFolder>,
public CComObjectRootEx<CComMultiThreadModelNoCS>,
@@ -19,8 +17,6 @@
public IPersistFolder2,
public IShellFolderViewCB
{
- CRegistryPidlManager * m_PidlManager;
-
HKEY m_hRoot;
WCHAR m_NtPath[MAX_PATH];
@@ -30,8 +26,6 @@
CRegistryFolder();
virtual ~CRegistryFolder();
-
- CRegistryPidlManager& GetManager() { return *m_PidlManager; }
// IShellFolder
virtual HRESULT STDMETHODCALLTYPE ParseDisplayName(