Sven Baars : winemenubuilder: Search for an executable file when no file extension is provided.

Alexandre Julliard julliard at winehq.org
Thu Mar 31 15:21:01 CDT 2022


Module: wine
Branch: master
Commit: 8a17ad4b3f38adc7da7c1ef52bf46cbcf7efe631
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8a17ad4b3f38adc7da7c1ef52bf46cbcf7efe631

Author: Sven Baars <sbaars at codeweavers.com>
Date:   Thu Mar 31 12:54:46 2022 +0200

winemenubuilder: Search for an executable file when no file extension is provided.

Signed-off-by: Sven Baars <sbaars at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/winemenubuilder/winemenubuilder.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index ab8798a88b5..a2aa5eef0e4 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -802,16 +802,25 @@ static HRESULT open_module_icon(LPCWSTR szFileName, int nIndex, IStream **ppStre
     GRPICONDIR *pIconDir;
     ENUMRESSTRUCT sEnumRes;
     HRESULT hr = E_FAIL;
+    WCHAR fullPathW[MAX_PATH];
+    DWORD len;
+
+    len = SearchPathW(NULL, szFileName, L".exe", MAX_PATH, fullPathW, NULL);
+    if (len == 0 || len > MAX_PATH)
+    {
+        WINE_WARN("SearchPath failed\n");
+        return HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
+    }
 
-    hModule = LoadLibraryExW(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE);
+    hModule = LoadLibraryExW(fullPathW, 0, LOAD_LIBRARY_AS_DATAFILE);
     if (!hModule)
     {
         if (GetLastError() == ERROR_BAD_EXE_FORMAT)
-            return open_module16_icon(szFileName, nIndex, ppStream);
+            return open_module16_icon(fullPathW, nIndex, ppStream);
         else
         {
             WINE_WARN("LoadLibraryExW (%s) failed, error %ld\n",
-                     wine_dbgstr_w(szFileName), GetLastError());
+                     wine_dbgstr_w(fullPathW), GetLastError());
             return HRESULT_FROM_WIN32(GetLastError());
         }
     }
@@ -820,7 +829,7 @@ static HRESULT open_module_icon(LPCWSTR szFileName, int nIndex, IStream **ppStre
     {
         hResInfo = FindResourceW(hModule, MAKEINTRESOURCEW(-nIndex), (LPCWSTR)RT_GROUP_ICON);
         WINE_TRACE("FindResourceW (%s) called, return %p, error %ld\n",
-                   wine_dbgstr_w(szFileName), hResInfo, GetLastError());
+                   wine_dbgstr_w(fullPathW), hResInfo, GetLastError());
     }
     else
     {




More information about the wine-cvs mailing list