[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:
  32584bb521.
- 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@codeweavers.com>
This commit is contained in:
Oleg Dubinskiy 2024-02-02 16:10:36 +01:00 committed by GitHub
parent 913235952c
commit 290221ef5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
{