winex11: Directly use ntdll for registry access in create_xcursor_system_cursor.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-04-08 13:29:26 +02:00 committed by Alexandre Julliard
parent a3ebf88ad5
commit 824e9bddd5
3 changed files with 16 additions and 10 deletions

View File

@ -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;

View File

@ -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 )

View File

@ -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 };