[SHELL32] shlexec: Initial support of App Paths (#4850)

- Fix SHELL_TryAppPathW helper function by using SHRegQueryValueExW function.
- Fix SHRegQueryValueExA/W functions.
CORE-11335
This commit is contained in:
Katayama Hirofumi MZ 2022-11-08 09:23:06 +09:00 committed by GitHub
parent 05d2935eed
commit 140aa11c36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 20 deletions

View file

@ -593,7 +593,6 @@ static LPWSTR SHELL_BuildEnvW( const WCHAR *path )
return new_env;
}
/***********************************************************************
* SHELL_TryAppPathW [Internal]
*
@ -604,9 +603,9 @@ static LPWSTR SHELL_BuildEnvW( const WCHAR *path )
*/
static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, WCHAR **env)
{
HKEY hkApp = 0;
HKEY hkApp = NULL;
WCHAR buffer[1024];
LONG len;
DWORD len, dwType;
LONG res;
BOOL found = FALSE;
@ -625,14 +624,17 @@ static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, WCHAR **env)
}
len = MAX_PATH * sizeof(WCHAR);
res = RegQueryValueW(hkApp, NULL, lpResult, &len);
if (res) goto end;
res = SHRegQueryValueExW(hkApp, NULL, NULL, &dwType, (LPBYTE)lpResult, &len);
if (res != ERROR_SUCCESS || dwType != REG_SZ)
goto end;
found = TRUE;
if (env)
{
DWORD count = sizeof(buffer);
if (!RegQueryValueExW(hkApp, L"Path", NULL, NULL, (LPBYTE)buffer, &count) && buffer[0])
len = sizeof(buffer);
res = SHRegQueryValueExW(hkApp, L"Path", NULL, &dwType, (LPBYTE)buffer, &len);
if (res == ERROR_SUCCESS && dwType == REG_SZ && buffer[0])
*env = SHELL_BuildEnvW(buffer);
}

View file

@ -28,6 +28,7 @@
#include <windef.h>
#include <winbase.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <wine/debug.h>
@ -73,16 +74,16 @@ HRESULT WINAPI SHRegQueryValueA(HKEY hkey, LPSTR lpSubKey, LPSTR lpValue, LPDWOR
* SHRegQueryValueExA [SHELL32.509]
*
*/
HRESULT WINAPI SHRegQueryValueExA(
LONG WINAPI SHRegQueryValueExA(
HKEY hkey,
LPSTR lpValueName,
LPCSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData)
{
TRACE("%p %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
return SHQueryValueExA(hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
}
/*************************************************************************
@ -102,24 +103,18 @@ HRESULT WINAPI SHRegQueryValueW(
/*************************************************************************
* SHRegQueryValueExW [SHELL32.511] NT4.0
*
* FIXME
* if the datatype REG_EXPAND_SZ then expand the string and change
* *pdwType to REG_SZ.
*/
HRESULT WINAPI SHRegQueryValueExW (
LONG WINAPI SHRegQueryValueExW(
HKEY hkey,
LPWSTR pszValue,
LPCWSTR pszValue,
LPDWORD pdwReserved,
LPDWORD pdwType,
LPVOID pvData,
LPDWORD pcbData)
{
DWORD ret;
WARN("%p %s %p %p %p %p semi-stub\n",
TRACE("%p %s %p %p %p %p\n",
hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
ret = RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
return ret;
return SHQueryValueExW(hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
}
/*************************************************************************

View file

@ -721,6 +721,26 @@ IStream* WINAPI SHGetViewStream(LPCITEMIDLIST, DWORD, LPCTSTR, LPCTSTR, LPCTSTR)
EXTERN_C HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey);
LONG WINAPI SHRegQueryValueExA(
HKEY hkey,
LPCSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData);
LONG WINAPI SHRegQueryValueExW(
HKEY hkey,
LPCWSTR pszValue,
LPDWORD pdwReserved,
LPDWORD pdwType,
LPVOID pvData,
LPDWORD pcbData);
#ifdef UNICODE
#define SHRegQueryValueEx SHRegQueryValueExW
#else
#define SHRegQueryValueEx SHRegQueryValueExA
#endif
/*****************************************************************************
* INVALID_FILETITLE_CHARACTERS
*/