Jacek Caban : winex11: Directly use ntdll for registry access in create_xcursor_system_cursor.
Alexandre Julliard
julliard at winehq.org
Mon Apr 11 15:54:59 CDT 2022
Module: wine
Branch: master
Commit: 824e9bddd583b7ace5b0a31d9f7a9dbec65d369a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=824e9bddd583b7ace5b0a31d9f7a9dbec65d369a
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Apr 8 13:29:26 2022 +0200
winex11: Directly use ntdll for registry access in create_xcursor_system_cursor.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winex11.drv/mouse.c | 15 ++++++++-------
dlls/winex11.drv/x11drv.h | 6 ++++++
dlls/winex11.drv/x11drv_main.c | 5 ++---
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 6c3d7e09002..1f8bd54cf14 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -1060,9 +1060,8 @@ static Cursor create_xcursor_system_cursor( const ICONINFOEXW *info )
HMODULE module;
HKEY key;
const char * const *names = NULL;
- WCHAR *p, name[MAX_PATH * 2], valueW[64];
+ WCHAR *p, name[MAX_PATH * 2];
char valueA[64];
- DWORD ret;
if (!info->szModName[0]) return 0;
@@ -1075,13 +1074,15 @@ static Cursor create_xcursor_system_cursor( const ICONINFOEXW *info )
valueA[0] = 0;
/* @@ Wine registry key: HKCU\Software\Wine\X11 Driver\Cursors */
- if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\X11 Driver\\Cursors", &key ))
+ if ((key = open_hkcu_key( "Software\\Wine\\X11 Driver\\Cursors" )))
{
- DWORD size = sizeof(valueW);
- ret = RegQueryValueExW( key, name, NULL, NULL, (BYTE *)valueW, &size );
- RegCloseKey( key );
- if (!ret)
+ char buffer[4096];
+ KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer;
+ DWORD size = query_reg_value( key, NULL, value, sizeof(buffer) );
+ NtClose( key );
+ if (size && value->Type == REG_SZ)
{
+ const WCHAR *valueW = (const WCHAR *)value->Data;
if (!valueW[0]) return 0; /* force standard cursor */
if (!WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, valueA, sizeof(valueA), NULL, NULL ))
valueA[0] = 0;
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 252505f80e6..1168e0ea7a6 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -841,6 +841,12 @@ static inline BOOL is_window_rect_mapped( const RECT *rect )
max( rect->bottom, rect->top + 1 ) > virtual_rect.top);
}
+/* registry helpers */
+
+extern HKEY open_hkcu_key( const char *name ) DECLSPEC_HIDDEN;
+extern ULONG query_reg_value( HKEY hkey, const WCHAR *name,
+ KEY_VALUE_PARTIAL_INFORMATION *info, ULONG size ) DECLSPEC_HIDDEN;
+
/* string helpers */
static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index df3c672708e..b6fa5cedc61 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -353,7 +353,7 @@ static HKEY reg_open_key( HKEY root, const WCHAR *name, ULONG name_len )
}
-static HKEY open_hkcu_key( const char *name )
+HKEY open_hkcu_key( const char *name )
{
WCHAR bufferW[256];
static HKEY hkcu;
@@ -385,8 +385,7 @@ static HKEY open_hkcu_key( const char *name )
}
-static ULONG query_reg_value( HKEY hkey, const WCHAR *name,
- KEY_VALUE_PARTIAL_INFORMATION *info, ULONG size )
+ULONG query_reg_value( HKEY hkey, const WCHAR *name, KEY_VALUE_PARTIAL_INFORMATION *info, ULONG size )
{
unsigned int name_size = name ? lstrlenW( name ) * sizeof(WCHAR) : 0;
UNICODE_STRING nameW = { name_size, name_size, (WCHAR *)name };
More information about the wine-cvs
mailing list