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

Signed-off-by: Sven Baars <sbaars@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sven Baars 2022-03-31 12:54:46 +02:00 committed by Alexandre Julliard
parent 8498a9d1ef
commit 8a17ad4b3f
1 changed files with 13 additions and 4 deletions

View File

@ -802,16 +802,25 @@ static HRESULT open_module_icon(LPCWSTR szFileName, int nIndex, IStream **ppStre
GRPICONDIR *pIconDir; GRPICONDIR *pIconDir;
ENUMRESSTRUCT sEnumRes; ENUMRESSTRUCT sEnumRes;
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
WCHAR fullPathW[MAX_PATH];
DWORD len;
hModule = LoadLibraryExW(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE); 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(fullPathW, 0, LOAD_LIBRARY_AS_DATAFILE);
if (!hModule) if (!hModule)
{ {
if (GetLastError() == ERROR_BAD_EXE_FORMAT) if (GetLastError() == ERROR_BAD_EXE_FORMAT)
return open_module16_icon(szFileName, nIndex, ppStream); return open_module16_icon(fullPathW, nIndex, ppStream);
else else
{ {
WINE_WARN("LoadLibraryExW (%s) failed, error %ld\n", WINE_WARN("LoadLibraryExW (%s) failed, error %ld\n",
wine_dbgstr_w(szFileName), GetLastError()); wine_dbgstr_w(fullPathW), GetLastError());
return HRESULT_FROM_WIN32(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); hResInfo = FindResourceW(hModule, MAKEINTRESOURCEW(-nIndex), (LPCWSTR)RT_GROUP_ICON);
WINE_TRACE("FindResourceW (%s) called, return %p, error %ld\n", WINE_TRACE("FindResourceW (%s) called, return %p, error %ld\n",
wine_dbgstr_w(szFileName), hResInfo, GetLastError()); wine_dbgstr_w(fullPathW), hResInfo, GetLastError());
} }
else else
{ {