https://git.reactos.org/?p=reactos.git;a=commitdiff;h=40737bdddb384bd2842c0c...
commit 40737bdddb384bd2842c0cc3f6cacf3f4295731f Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Sun Oct 7 20:30:00 2018 +0200 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Sun Oct 7 20:32:42 2018 +0200
[USER32] Fix the ICO_ExtractIconExW() helper with respect to what is found with the user32_apitest:PrivateExtractIcons test. CORE-15150 --- win32ss/user/user32/misc/exticon.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/win32ss/user/user32/misc/exticon.c b/win32ss/user/user32/misc/exticon.c index 8b65d83430..d3e18b0891 100644 --- a/win32ss/user/user32/misc/exticon.c +++ b/win32ss/user/user32/misc/exticon.c @@ -24,6 +24,10 @@
#include <user32.h>
+#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + /* Start of Hack section */
WINE_DEFAULT_DEBUG_CHANNEL(icon); @@ -275,13 +279,24 @@ static UINT ICO_ExtractIconExW( LPBYTE peimage; HANDLE fmapping; DWORD fsizeh,fsizel; +#ifdef __REACTOS__ + WCHAR szExpandedExePath[MAX_PATH]; +#endif WCHAR szExePath[MAX_PATH]; DWORD dwSearchReturn;
TRACE("%s, %d, %d %p 0x%08x\n", debugstr_w(lpszExeFileName), nIconIndex, nIcons, pIconId, flags);
- dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, sizeof(szExePath) / sizeof(szExePath[0]), szExePath, NULL); - if ((dwSearchReturn == 0) || (dwSearchReturn > sizeof(szExePath) / sizeof(szExePath[0]))) +#ifdef __REACTOS__ + if (RetPtr) + *RetPtr = NULL; + + if (ExpandEnvironmentStringsW(lpszExeFileName, szExpandedExePath, ARRAY_SIZE(szExpandedExePath))) + lpszExeFileName = szExpandedExePath; +#endif + + dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, ARRAY_SIZE(szExePath), szExePath, NULL); + if ((dwSearchReturn == 0) || (dwSearchReturn > ARRAY_SIZE(szExePath))) { WARN("File %s not found or path too long\n", debugstr_w(lpszExeFileName)); return -1;