From: David Quintana Date: Thu, 22 Jun 2017 17:49:42 +0000 (+0000) Subject: [NTOBJSHEX] X-Git-Tag: ReactOS-0.4.6~197 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=cdb3d06d8d0e5b27508121ba67170f3c860d3577 [NTOBJSHEX] Fixed registry value display for values that are too long to fit inside the shitemid. Set the maximum for shitemid embedding back to a smaller number. svn path=/trunk/; revision=75166 --- diff --git a/reactos/dll/shellext/ntobjshex/ntobjenum.cpp b/reactos/dll/shellext/ntobjshex/ntobjenum.cpp index 0d205e4e7d5..603b1440d50 100644 --- a/reactos/dll/shellext/ntobjshex/ntobjenum.cpp +++ b/reactos/dll/shellext/ntobjshex/ntobjenum.cpp @@ -432,7 +432,7 @@ public: DWORD entryBufferLength = FIELD_OFFSET(RegPidlEntry, entryName) + sizeof(WCHAR) + cchName * sizeof(WCHAR); - BOOL copyData = dataSize < 256; + BOOL copyData = dataSize <= 32; if (copyData) { entryBufferLength += dataSize + sizeof(WCHAR); diff --git a/reactos/dll/shellext/ntobjshex/regfolder.cpp b/reactos/dll/shellext/ntobjshex/regfolder.cpp index 6a688c10349..c9f9c1406d5 100644 --- a/reactos/dll/shellext/ntobjshex/regfolder.cpp +++ b/reactos/dll/shellext/ntobjshex/regfolder.cpp @@ -305,6 +305,40 @@ public: *strContents = strValue; return S_OK; } + case REG_MULTI_SZ: + { + PCWSTR separator = L" "; // To match regedit + int sepChars = wcslen(separator); + int strings = 0; + int stringChars = 0; + + PCWSTR strData = (PCWSTR)td; + while (*strData) + { + int l = wcslen(strData); + stringChars += l; + strData += l + 1; // Skips null-terminator + strings++; + } + + int cch = stringChars + (strings - 1) * sepChars + 1; + + PWSTR strValue = (PWSTR)CoTaskMemAlloc(cch * sizeof(WCHAR)); + + strValue[0] = 0; + + strData = (PCWSTR)td; + while (*strData) + { + StrCatW(strValue, strData); + strData += wcslen(strData) + 1; + if (*strData) + StrCatW(strValue, separator); + } + + *strContents = strValue; + return S_OK; + } case REG_DWORD: { DWORD bufferLength = 64 * sizeof(WCHAR); @@ -318,24 +352,39 @@ public: { DWORD bufferLength = 64 * sizeof(WCHAR); PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength); - StringCbPrintfW(strValue, bufferLength, L"0x%016llx (%d)", + StringCbPrintfW(strValue, bufferLength, L"0x%016llx (%lld)", *(LARGE_INTEGER*) td, ((LARGE_INTEGER*) td)->QuadPart); *strContents = strValue; return S_OK; } + case REG_BINARY: + { + DWORD bufferLength = (contentsLength * 3 + 1) * sizeof(WCHAR); + PWSTR strValue = (PWSTR)CoTaskMemAlloc(bufferLength); + PWSTR strTemp = strValue; + PBYTE data = (PBYTE)td; + for (int i = 0; i < contentsLength; i++) + { + StringCbPrintfW(strTemp, bufferLength, L"%02x ", data[i]); + strTemp += 3; + bufferLength -= 3; + } + *strContents = strValue; + return S_OK; + } default: { - PCWSTR strTodo = L""; - DWORD bufferLength = (wcslen(strTodo) + 1) * sizeof(WCHAR); + PCWSTR strFormat = L""; + DWORD bufferLength = (wcslen(strFormat) + 15) * sizeof(WCHAR); PWSTR strValue = (PWSTR) CoTaskMemAlloc(bufferLength); - StringCbCopyW(strValue, bufferLength, strTodo); + StringCbPrintfW(strValue, bufferLength, strFormat, contentType); *strContents = strValue; return S_OK; } } } - static HRESULT FormatContentsForDisplay(const RegPidlEntry * info, LPCWSTR ntPath, PCWSTR * strContents) + static HRESULT FormatContentsForDisplay(const RegPidlEntry * info, HKEY rootKey, LPCWSTR ntPath, PCWSTR * strContents) { PVOID td = (((PBYTE) info) + FIELD_OFFSET(RegPidlEntry, entryName) + info->entryNameLength + sizeof(WCHAR)); @@ -350,7 +399,7 @@ public: { PVOID valueData; DWORD valueLength; - HRESULT hr = ReadRegistryValue(NULL, ntPath, info->entryName, &valueData, &valueLength); + HRESULT hr = ReadRegistryValue(rootKey, ntPath, info->entryName, &valueData, &valueLength); if (FAILED_UNEXPECTEDLY(hr)) { PCWSTR strEmpty = L"(Error reading value)"; @@ -908,7 +957,7 @@ HRESULT STDMETHODCALLTYPE CRegistryFolder::GetDetailsEx( { PCWSTR strValueContents; - hr = CRegistryPidlHelper::FormatContentsForDisplay(info, m_NtPath, &strValueContents); + hr = CRegistryPidlHelper::FormatContentsForDisplay(info, m_hRoot, m_NtPath, &strValueContents); if (FAILED_UNEXPECTEDLY(hr)) return hr; @@ -984,7 +1033,7 @@ HRESULT STDMETHODCALLTYPE CRegistryFolder::GetDetailsOf( PCWSTR strValueContents; - hr = CRegistryPidlHelper::FormatContentsForDisplay(info, m_NtPath, &strValueContents); + hr = CRegistryPidlHelper::FormatContentsForDisplay(info, m_hRoot, m_NtPath, &strValueContents); if (FAILED_UNEXPECTEDLY(hr)) return hr;