https://git.reactos.org/?p=reactos.git;a=commitdiff;h=140aa11c361cd51e1da9e…
commit 140aa11c361cd51e1da9eb2d3e5b6785b2de910c
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Nov 8 09:23:06 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Nov 8 09:23:06 2022 +0900
[SHELL32] shlexec: Initial support of App Paths (#4850)
- Fix SHELL_TryAppPathW helper function by using SHRegQueryValueExW function.
- Fix SHRegQueryValueExA/W functions.
CORE-11335
---
dll/win32/shell32/shlexec.cpp | 16 +++++++++-------
dll/win32/shell32/wine/shellreg.c | 21 ++++++++-------------
sdk/include/reactos/undocshell.h | 20 ++++++++++++++++++++
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/dll/win32/shell32/shlexec.cpp b/dll/win32/shell32/shlexec.cpp
index 133c3b11c2a..8784bbf4373 100644
--- a/dll/win32/shell32/shlexec.cpp
+++ b/dll/win32/shell32/shlexec.cpp
@@ -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);
}
diff --git a/dll/win32/shell32/wine/shellreg.c b/dll/win32/shell32/wine/shellreg.c
index 92e5b9c18b6..807a94e5cc8 100644
--- a/dll/win32/shell32/wine/shellreg.c
+++ b/dll/win32/shell32/wine/shellreg.c
@@ -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);
}
/*************************************************************************
diff --git a/sdk/include/reactos/undocshell.h b/sdk/include/reactos/undocshell.h
index 0aad1cf1851..7aeb796c8b7 100644
--- a/sdk/include/reactos/undocshell.h
+++ b/sdk/include/reactos/undocshell.h
@@ -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
*/