https://git.reactos.org/?p=reactos.git;a=commitdiff;h=290221ef5bf486face9c9…
commit 290221ef5bf486face9c992dca757b871c5e9550
Author: Oleg Dubinskiy <oleg.dubinskij30(a)gmail.com>
AuthorDate: Fri Feb 2 16:10:36 2024 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Feb 2 18:10:36 2024 +0300
[SHELL32] Sync HCR_RegGetIconW() function to Wine 9.1 (#6418)
Import the following fixes:
- Use the number of bytes instead of the number of characters in the length
passed to RegQueryValueExW. Calculate this by multiplying the number of
characters on the size of one wide character in bytes, since only length
of characters is passed to the function. This fixes ERROR_MORE_DATA
returned from RegQueryValueExW, because the passed number of bytes was
less than the actual length of the output buffer, since it was calculated
incorrectly, so the function failed even when it received the correct
number of wide characters.
This partially imports Wine commit:
https://github.com/wine-mirror/wine/commit/32584bb521bd9dd14030a663671bea16….
- Limit the number of characters in registry icon index buffer from 7 to 5,
as it done in ANSI version of this function, since registry index number
can contain up to 4 digits + space for the null-terminator.
This fixes problems when loading custom (user-defined) icons from registry,
like icons defined by the current user or for all users, instead of just
default icons from the root classes.
CORE-14758
Co-authored-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dll/win32/shell32/wine/classes.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dll/win32/shell32/wine/classes.c b/dll/win32/shell32/wine/classes.c
index df2099914da..ede060044c4 100644
--- a/dll/win32/shell32/wine/classes.c
+++ b/dll/win32/shell32/wine/classes.c
@@ -239,11 +239,11 @@ BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
static BOOL HCR_RegGetIconW(HKEY hkey, LPWSTR szDest, LPCWSTR szName, DWORD len, int*
picon_idx)
{
- DWORD dwType;
+ DWORD dwType, size = len * sizeof(WCHAR);
WCHAR sTemp[MAX_PATH];
- WCHAR sNum[7];
+ WCHAR sNum[5];
- if (!RegQueryValueExW(hkey, szName, 0, &dwType, (LPBYTE)szDest, &len))
+ if (!RegQueryValueExW(hkey, szName, 0, &dwType, (LPBYTE)szDest, &size))
{
if (dwType == REG_EXPAND_SZ)
{