Module: wine Branch: master Commit: 0826fbbb745917c7414df27da26c2cad7a0eac9a URL: https://gitlab.winehq.org/wine/wine/-/commit/0826fbbb745917c7414df27da26c2ca...
Author: Jacek Caban jacek@codeweavers.com Date: Sat Jul 9 14:09:29 2022 +0200
win32u: Use KeUserModeCallback for ImmProcessKey and ImmTranslateMessage calls.
---
dlls/user32/user_main.c | 15 +++++++++++++-- dlls/win32u/imm.c | 20 ++++++++++++++++++++ dlls/win32u/message.c | 9 ++++----- dlls/win32u/ntuser_private.h | 2 -- include/ntuser.h | 20 ++++++++++++++++++++ 5 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index ae6a0d4c8e4..f9bc4985368 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -133,8 +133,6 @@ static NTSTATUS try_finally( NTSTATUS (CDECL *func)( void *), void *arg,
static const struct user_callbacks user_funcs = { - ImmProcessKey, - ImmTranslateMessage, NtWaitForMultipleObjects, post_dde_message, unpack_dde_message, @@ -163,6 +161,17 @@ static NTSTATUS WINAPI User32DrawText( const struct draw_text_params *params, UL return DrawTextW( params->hdc, params->str, size / sizeof(WCHAR), params->rect, params->flags ); }
+static NTSTATUS WINAPI User32ImmProcessKey( const struct imm_process_key_params *params, ULONG size ) +{ + return ImmProcessKey( params->hwnd, params->hkl, params->vkey, params->key_data, 0 ); +} + +static NTSTATUS WINAPI User32ImmTranslateMessage( const struct imm_translate_message_params *params, + ULONG size ) +{ + return ImmTranslateMessage( params->hwnd, params->msg, params->wparam, params->key_data ); +} + static NTSTATUS WINAPI User32LoadImage( const struct load_image_params *params, ULONG size ) { HANDLE ret = LoadImageW( params->hinst, params->name, params->type, @@ -206,6 +215,8 @@ static const void *kernel_callback_table[NtUserCallCount] = User32DrawScrollBar, User32DrawText, User32FreeCachedClipboardData, + User32ImmProcessKey, + User32ImmTranslateMessage, User32LoadDriver, User32LoadImage, User32LoadSysMenu, diff --git a/dlls/win32u/imm.c b/dlls/win32u/imm.c index 94621bb2a5c..5adfe3704aa 100644 --- a/dlls/win32u/imm.c +++ b/dlls/win32u/imm.c @@ -27,6 +27,7 @@ #include <pthread.h> #include "win32u_private.h" #include "ntuser_private.h" +#include "ddk/imm.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(imm); @@ -391,3 +392,22 @@ void cleanup_imm_thread(void)
NtUserDestroyInputContext( thread_info->client_info.default_imc ); } + +BOOL WINAPI ImmProcessKey( HWND hwnd, HKL hkl, UINT vkey, LPARAM key_data, DWORD unknown ) +{ + struct imm_process_key_params params = + { .hwnd = hwnd, .hkl = hkl, .vkey = vkey, .key_data = key_data }; + void *ret_ptr; + ULONG ret_len; + return KeUserModeCallback( NtUserImmProcessKey, ¶ms, sizeof(params), &ret_ptr, &ret_len ); +} + +BOOL WINAPI ImmTranslateMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM key_data ) +{ + struct imm_translate_message_params params = + { .hwnd = hwnd, .msg = msg, .wparam = wparam, .key_data = key_data }; + void *ret_ptr; + ULONG ret_len; + return KeUserModeCallback( NtUserImmTranslateMessage, ¶ms, sizeof(params), + &ret_ptr, &ret_len ); +} diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 65f44783fe6..b8ea7cdce9f 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -32,6 +32,7 @@ #include "hidusage.h" #include "dbt.h" #include "dde.h" +#include "ddk/imm.h" #include "wine/server.h" #include "wine/debug.h"
@@ -1362,9 +1363,8 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter, if (remove) accept_hardware_message( hw_id ); msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt );
- if (remove && msg->message == WM_KEYDOWN && user_callbacks) - if (user_callbacks->pImmProcessKey( msg->hwnd, NtUserGetKeyboardLayout(0), - msg->wParam, msg->lParam, 0 )) + if (remove && msg->message == WM_KEYDOWN) + if (ImmProcessKey( msg->hwnd, NtUserGetKeyboardLayout(0), msg->wParam, msg->lParam, 0 )) msg->wParam = VK_PROCESSKEY;
return TRUE; @@ -2969,8 +2969,7 @@ BOOL WINAPI NtUserTranslateMessage( const MSG *msg, UINT flags ) return TRUE;
case VK_PROCESSKEY: - return user_callbacks && user_callbacks->pImmTranslateMessage( msg->hwnd, msg->message, - msg->wParam, msg->lParam ); + return ImmTranslateMessage( msg->hwnd, msg->message, msg->wParam, msg->lParam ); }
NtUserGetKeyboardState( state ); diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 780af425673..55f2a449be4 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -32,8 +32,6 @@ struct hardware_msg_data;
struct user_callbacks { - BOOL (WINAPI *pImmProcessKey)(HWND, HKL, UINT, LPARAM, DWORD); - BOOL (WINAPI *pImmTranslateMessage)(HWND, UINT, WPARAM, LPARAM); NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*); BOOL (CDECL *post_dde_message)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, DWORD type ); diff --git a/include/ntuser.h b/include/ntuser.h index 281d88dfb1a..d22799ebe01 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -37,6 +37,8 @@ enum NtUserDrawScrollBar, NtUserDrawText, NtUserFreeCachedClipboardData, + NtUserImmProcessKey, + NtUserImmTranslateMessage, NtUserLoadDriver, NtUserLoadImage, NtUserLoadSysMenu, @@ -181,6 +183,24 @@ struct free_cached_data_params HANDLE handle; };
+/* NtUserImmProcessKey params */ +struct imm_process_key_params +{ + HWND hwnd; + HKL hkl; + UINT vkey; + LPARAM key_data; +}; + +/* NtUserImmTranslateMessage params */ +struct imm_translate_message_params +{ + HWND hwnd; + UINT msg; + WPARAM wparam; + LPARAM key_data; +}; + /* NtUserLoadImage params */ struct load_image_params {