Author: dquintana
Date: Sat Mar 14 04:04:27 2015
New Revision: 66676
URL:
http://svn.reactos.org/svn/reactos?rev=66676&view=rev
Log:
[NTOBJSHEX]
* Fix content type column to represent the correct type, or "Key". This column
would contain the custom class name if it was ever assigned (I have not seen such a
case).
* Implement reading registry values when enumerating details.
Now the registry browsing is semi-useful, albeit read-only.
Modified:
trunk/reactos/dll/shellext/ntobjshex/ntobjutil.cpp
trunk/reactos/dll/shellext/ntobjshex/ntobjutil.h
trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjutil.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/nto…
==============================================================================
--- trunk/reactos/dll/shellext/ntobjshex/ntobjutil.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/ntobjshex/ntobjutil.cpp [iso-8859-1] Sat Mar 14 04:04:27
2015
@@ -372,6 +372,7 @@
entry->cb = FIELD_OFFSET(RegPidlEntry, entryName);
entry->magic = REGISTRY_PIDL_MAGIC;
entry->entryType = otype;
+ entry->contentType = type;
if (cchName > 0)
{
@@ -415,3 +416,50 @@
return S_OK;
}
+
+HRESULT ReadRegistryValue(HKEY root, PCWSTR path, PCWSTR valueName, PVOID * valueData,
PDWORD valueLength)
+{
+ HKEY hkey;
+
+ DWORD res;
+ if (root)
+ {
+ res = RegOpenKeyExW(root, *path == '\\' ? path + 1 : path, 0,
STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, &hkey);
+ }
+ else
+ {
+ res = NtOpenObject(KEY_OBJECT, (PHANDLE) &hkey, STANDARD_RIGHTS_READ |
KEY_QUERY_VALUE, path);
+ }
+ if (!NT_SUCCESS(res))
+ {
+ ERR("RegOpenKeyExW failed for path %S with status=%x\n", path, res);
+ return HRESULT_FROM_NT(res);
+ }
+
+ res = RegQueryValueExW(hkey, valueName, NULL, NULL, NULL, valueLength);
+
+ if (*valueLength > 0)
+ {
+ *valueData = (PBYTE) CoTaskMemAlloc(*valueLength);
+
+ res = RegQueryValueExW(hkey, valueName, NULL, NULL, (PBYTE) *valueData,
valueLength);
+ if (!NT_SUCCESS(res))
+ {
+ CoTaskMemFree(*valueData);
+ *valueData = NULL;
+
+ RegCloseKey(hkey);
+
+ ERR("RegOpenKeyExW failed for path %S with status=%x\n", path,
res);
+ return HRESULT_FROM_NT(res);
+ }
+ }
+ else
+ {
+ *valueData = NULL;
+ }
+
+ RegCloseKey(hkey);
+
+ return S_OK;
+}
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjutil.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/nto…
==============================================================================
--- trunk/reactos/dll/shellext/ntobjshex/ntobjutil.h [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/ntobjshex/ntobjutil.h [iso-8859-1] Sat Mar 14 04:04:27
2015
@@ -101,4 +101,6 @@
#include <poppack.h>
HRESULT EnumerateNtDirectory(HDPA hdpa, PCWSTR path, UINT * hdpaCount);
-HRESULT EnumerateRegistryKey(HDPA hdpa, PCWSTR path, HKEY root, UINT * hdpaCount);
+HRESULT EnumerateRegistryKey(HDPA hdpa, PCWSTR path, HKEY root, UINT * hdpaCount);
+
+HRESULT ReadRegistryValue(HKEY root, PCWSTR path, PCWSTR valueName, PVOID * valueData,
PDWORD valueLength);
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] Sat Mar 14 04:04:27
2015
@@ -362,66 +362,88 @@
return (entry->entryType == REG_ENTRY_KEY);
}
+ HRESULT FormatValueData(DWORD contentType, PVOID td, DWORD contentsLength, PCWSTR *
strContents)
+ {
+ switch (contentType)
+ {
+ case 0:
+ {
+ PCWSTR strTodo = L"";
+ DWORD bufferLength = (wcslen(strTodo) + 1) * sizeof(WCHAR);
+ PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
+ StringCbCopyW(strValue, bufferLength, strTodo);
+ *strContents = strValue;
+ return S_OK;
+ }
+ case REG_SZ:
+ case REG_EXPAND_SZ:
+ {
+ PWSTR strValue = (PWSTR) CoTaskMemAlloc(contentsLength + sizeof(WCHAR));
+ StringCbCopyNW(strValue, contentsLength + sizeof(WCHAR), (LPCWSTR) td,
contentsLength);
+ *strContents = strValue;
+ return S_OK;
+ }
+ case REG_DWORD:
+ {
+ DWORD bufferLength = 64 * sizeof(WCHAR);
+ PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
+ StringCbPrintfW(strValue, bufferLength, L"0x%08x (%d)",
+ *(DWORD*) td, *(DWORD*) td);
+ *strContents = strValue;
+ return S_OK;
+ }
+ case REG_QWORD:
+ {
+ DWORD bufferLength = 64 * sizeof(WCHAR);
+ PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
+ StringCbPrintfW(strValue, bufferLength, L"0x%016llx (%d)",
+ *(LARGE_INTEGER*) td, ((LARGE_INTEGER*) td)->QuadPart);
+ *strContents = strValue;
+ return S_OK;
+ }
+ default:
+ {
+ PCWSTR strTodo = L"<TODO: Convert value for display>";
+ DWORD bufferLength = (wcslen(strTodo) + 1) * sizeof(WCHAR);
+ PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
+ StringCbCopyW(strValue, bufferLength, strTodo);
+ *strContents = strValue;
+ return S_OK;
+ }
+ }
+ }
+
HRESULT FormatContentsForDisplay(RegPidlEntry * info, PCWSTR * strContents)
{
PVOID td = (((PBYTE) info) + FIELD_OFFSET(RegPidlEntry, entryName) +
info->entryNameLength + sizeof(WCHAR));
- if (info->contentsLength > 0)
- {
- if (info->entryType == REG_ENTRY_VALUE_WITH_CONTENT)
+ if (info->entryType == REG_ENTRY_VALUE_WITH_CONTENT)
+ {
+ if (info->contentsLength > 0)
{
- switch (info->contentType)
- {
- case REG_SZ:
- case REG_EXPAND_SZ:
- {
- PWSTR strValue = (PWSTR) CoTaskMemAlloc(info->contentsLength +
sizeof(WCHAR));
- StringCbCopyNW(strValue, info->contentsLength + sizeof(WCHAR),
(LPCWSTR) td, info->contentsLength);
- *strContents = strValue;
- return S_OK;
- }
- case REG_DWORD:
- {
- DWORD bufferLength = 64 * sizeof(WCHAR);
- PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
- StringCbPrintfW(strValue, bufferLength, L"0x%08x (%d)",
- *(DWORD*) td, *(DWORD*) td);
- *strContents = strValue;
- return S_OK;
- }
- case REG_QWORD:
- {
- DWORD bufferLength = 64 * sizeof(WCHAR);
- PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
- StringCbPrintfW(strValue, bufferLength, L"0x%016llx (%d)",
- *(LARGE_INTEGER*) td, ((LARGE_INTEGER*) td)->QuadPart);
- *strContents = strValue;
- return S_OK;
- }
- default:
- {
- PCWSTR strTodo = L"<TODO: Convert value for
display>";
- DWORD bufferLength = (wcslen(strTodo) + 1) * sizeof(WCHAR);
- PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
- StringCbCopyW(strValue, bufferLength, strTodo);
- *strContents = strValue;
- return S_OK;
- }
- }
+ return FormatValueData(info->contentType, td, info->contentsLength,
strContents);
}
- else
+ }
+ else if (info->entryType == REG_ENTRY_VALUE)
+ {
+ PVOID valueData;
+ DWORD valueLength;
+ HRESULT hr = ReadRegistryValue(NULL, m_ntPath, info->entryName,
&valueData, &valueLength);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ if (valueLength > 0)
{
- PCWSTR strTodo = L"<TODO: Query non-embedded value>";
- DWORD bufferLength = (wcslen(strTodo) + 1) * sizeof(WCHAR);
- PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
- StringCbCopyW(strValue, bufferLength, strTodo);
- *strContents = strValue;
- return S_OK;
+ hr = FormatValueData(info->contentType, valueData, valueLength,
strContents);
+
+ CoTaskMemFree(valueData);
+
+ return hr;
}
}
else
{
- PCWSTR strEmpty = L"(Empty)";
+ PCWSTR strEmpty = L"";
DWORD bufferLength = (wcslen(strEmpty) + 1) * sizeof(WCHAR);
PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
StringCbCopyW(strValue, bufferLength, strEmpty);
@@ -429,6 +451,12 @@
return S_OK;
}
+ PCWSTR strEmpty = L"(Empty)";
+ DWORD bufferLength = (wcslen(strEmpty) + 1) * sizeof(WCHAR);
+ PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength);
+ StringCbCopyW(strValue, bufferLength, strEmpty);
+ *strContents = strValue;
+ return S_OK;
}
};
@@ -1003,11 +1031,26 @@
{
if (pscid->pid == PID_STG_NAME)
{
- return MakeVariantString(pv, info->entryName);
+ if (info->entryNameLength > 0)
+ {
+ return MakeVariantString(pv, info->entryName);
+ }
+ return MakeVariantString(pv, L"(Default)");
}
else if (pscid->pid == PID_STG_STORAGETYPE)
{
- return MakeVariantString(pv, RegistryTypeNames[info->entryType]);
+ if (info->entryType == REG_ENTRY_KEY)
+ {
+ if (info->contentsLength > 0)
+ {
+ PWSTR td = (PWSTR)(((PBYTE) info) + FIELD_OFFSET(RegPidlEntry,
entryName) + info->entryNameLength + sizeof(WCHAR));
+
+ return MakeVariantString(pv, td);
+ }
+ return MakeVariantString(pv, L"Key");
+ }
+
+ return MakeVariantString(pv, RegistryTypeNames[info->contentType]);
}
else if (pscid->pid == PID_STG_CONTENTS)
{
@@ -1065,6 +1108,18 @@
case REGISTRY_COLUMN_TYPE:
psd->fmt = LVCFMT_LEFT;
+
+ if (info->entryType == REG_ENTRY_KEY)
+ {
+ if (info->contentsLength > 0)
+ {
+ PWSTR td = (PWSTR) (((PBYTE) info) + FIELD_OFFSET(RegPidlEntry,
entryName) + info->entryNameLength + sizeof(WCHAR));
+
+ return MakeStrRetFromString(td, info->contentsLength,
&(psd->str));
+ }
+
+ return MakeStrRetFromString(L"Key", &(psd->str));
+ }
return MakeStrRetFromString(RegistryTypeNames[info->entryType],
&(psd->str));