From: Zebediah Figura zfigura@codeweavers.com
--- dlls/user32/message.c | 19 ------ dlls/user32/rawinput.c | 120 +---------------------------------- dlls/user32/sysparams.c | 2 +- dlls/user32/user_main.c | 2 +- dlls/user32/user_private.h | 3 +- dlls/user32/win.h | 1 - dlls/win32u/message.c | 2 +- dlls/win32u/ntuser_private.h | 2 +- dlls/win32u/rawinput.c | 23 +++++++ dlls/win32u/win32u_private.h | 4 ++ 10 files changed, 33 insertions(+), 145 deletions(-)
diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 02c40f2ca4f..eff0c4efbcf 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -558,25 +558,6 @@ BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam return TRUE; }
-BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data ) -{ - struct rawinput_thread_data *thread_data = rawinput_thread_data(); - - if (msg->message == WM_INPUT_DEVICE_CHANGE) - rawinput_update_device_list(); - else - { - thread_data->buffer->header.dwSize = RAWINPUT_BUFFER_SIZE; - if (!rawinput_from_hardware_message( thread_data->buffer, msg_data )) return FALSE; - thread_data->hw_id = hw_id; - msg->lParam = (LPARAM)hw_id; - } - - msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt ); - return TRUE; -} - - /*********************************************************************** * SendMessageTimeoutW (USER32.@) */ diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index f8980f03e9e..9286aceb670 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -297,7 +297,7 @@ static void enumerate_devices( DWORD type, const WCHAR *class ) NtClose( class_key ); }
-void rawinput_update_device_list(void) +void CDECL rawinput_update_device_list(void) { DWORD idx;
@@ -362,124 +362,6 @@ struct rawinput_thread_data * WINAPI rawinput_thread_data(void) }
-BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_msg_data *msg_data) -{ - SIZE_T size; - - rawinput->header.dwType = msg_data->rawinput.type; - if (msg_data->rawinput.type == RIM_TYPEMOUSE) - { - static const unsigned int button_flags[] = - { - 0, /* MOUSEEVENTF_MOVE */ - RI_MOUSE_LEFT_BUTTON_DOWN, /* MOUSEEVENTF_LEFTDOWN */ - RI_MOUSE_LEFT_BUTTON_UP, /* MOUSEEVENTF_LEFTUP */ - RI_MOUSE_RIGHT_BUTTON_DOWN, /* MOUSEEVENTF_RIGHTDOWN */ - RI_MOUSE_RIGHT_BUTTON_UP, /* MOUSEEVENTF_RIGHTUP */ - RI_MOUSE_MIDDLE_BUTTON_DOWN, /* MOUSEEVENTF_MIDDLEDOWN */ - RI_MOUSE_MIDDLE_BUTTON_UP, /* MOUSEEVENTF_MIDDLEUP */ - }; - unsigned int i; - - rawinput->header.dwSize = FIELD_OFFSET(RAWINPUT, data) + sizeof(RAWMOUSE); - rawinput->header.hDevice = WINE_MOUSE_HANDLE; - rawinput->header.wParam = 0; - - rawinput->data.mouse.usFlags = MOUSE_MOVE_RELATIVE; - rawinput->data.mouse.usButtonFlags = 0; - rawinput->data.mouse.usButtonData = 0; - for (i = 1; i < ARRAY_SIZE(button_flags); ++i) - { - if (msg_data->flags & (1 << i)) - rawinput->data.mouse.usButtonFlags |= button_flags[i]; - } - if (msg_data->flags & MOUSEEVENTF_WHEEL) - { - rawinput->data.mouse.usButtonFlags |= RI_MOUSE_WHEEL; - rawinput->data.mouse.usButtonData = msg_data->rawinput.mouse.data; - } - if (msg_data->flags & MOUSEEVENTF_HWHEEL) - { - rawinput->data.mouse.usButtonFlags |= RI_MOUSE_HORIZONTAL_WHEEL; - rawinput->data.mouse.usButtonData = msg_data->rawinput.mouse.data; - } - if (msg_data->flags & MOUSEEVENTF_XDOWN) - { - if (msg_data->rawinput.mouse.data == XBUTTON1) - rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_DOWN; - else if (msg_data->rawinput.mouse.data == XBUTTON2) - rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_5_DOWN; - } - if (msg_data->flags & MOUSEEVENTF_XUP) - { - if (msg_data->rawinput.mouse.data == XBUTTON1) - rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_UP; - else if (msg_data->rawinput.mouse.data == XBUTTON2) - rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_5_UP; - } - - rawinput->data.mouse.ulRawButtons = 0; - rawinput->data.mouse.lLastX = msg_data->rawinput.mouse.x; - rawinput->data.mouse.lLastY = msg_data->rawinput.mouse.y; - rawinput->data.mouse.ulExtraInformation = msg_data->info; - } - else if (msg_data->rawinput.type == RIM_TYPEKEYBOARD) - { - rawinput->header.dwSize = FIELD_OFFSET(RAWINPUT, data) + sizeof(RAWKEYBOARD); - rawinput->header.hDevice = WINE_KEYBOARD_HANDLE; - rawinput->header.wParam = 0; - - rawinput->data.keyboard.MakeCode = msg_data->rawinput.kbd.scan; - rawinput->data.keyboard.Flags = msg_data->flags & KEYEVENTF_KEYUP ? RI_KEY_BREAK : RI_KEY_MAKE; - if (msg_data->flags & KEYEVENTF_EXTENDEDKEY) rawinput->data.keyboard.Flags |= RI_KEY_E0; - rawinput->data.keyboard.Reserved = 0; - - switch (msg_data->rawinput.kbd.vkey) - { - case VK_LSHIFT: - case VK_RSHIFT: - rawinput->data.keyboard.VKey = VK_SHIFT; - rawinput->data.keyboard.Flags &= ~RI_KEY_E0; - break; - case VK_LCONTROL: - case VK_RCONTROL: - rawinput->data.keyboard.VKey = VK_CONTROL; - break; - case VK_LMENU: - case VK_RMENU: - rawinput->data.keyboard.VKey = VK_MENU; - break; - default: - rawinput->data.keyboard.VKey = msg_data->rawinput.kbd.vkey; - break; - } - - rawinput->data.keyboard.Message = msg_data->rawinput.kbd.message; - rawinput->data.keyboard.ExtraInformation = msg_data->info; - } - else if (msg_data->rawinput.type == RIM_TYPEHID) - { - size = msg_data->size - sizeof(*msg_data); - if (size > rawinput->header.dwSize - sizeof(*rawinput)) return FALSE; - - rawinput->header.dwSize = FIELD_OFFSET( RAWINPUT, data.hid.bRawData ) + size; - rawinput->header.hDevice = ULongToHandle( msg_data->rawinput.hid.device ); - rawinput->header.wParam = 0; - - rawinput->data.hid.dwCount = msg_data->rawinput.hid.count; - rawinput->data.hid.dwSizeHid = msg_data->rawinput.hid.length; - memcpy( rawinput->data.hid.bRawData, msg_data + 1, size ); - } - else - { - FIXME("Unhandled rawinput type %#x.\n", msg_data->rawinput.type); - return FALSE; - } - - return TRUE; -} - - /*********************************************************************** * GetRawInputDeviceList (USER32.@) */ diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index ec83a1822a5..738186afb89 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -724,7 +724,7 @@ POINT point_win_to_phys_dpi( HWND hwnd, POINT pt ) /********************************************************************** * point_phys_to_win_dpi */ -POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) +static POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) { return map_dpi_point( pt, get_win_monitor_dpi( hwnd ), GetDpiForWindow( hwnd )); } diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index 4901bcf7193..72d5f30e536 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -162,7 +162,7 @@ static const struct user_callbacks user_funcs = MENU_GetSysMenu, notify_ime, post_dde_message, - process_rawinput_message, + rawinput_update_device_list, rawinput_device_get_usages, SCROLL_SetStandardScrollPainted, unpack_dde_message, diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 9a2b7de4509..d15a3b6856e 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -61,10 +61,9 @@ struct dce; struct tagWND;
struct hardware_msg_data; -extern BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_msg_data *msg_data); extern BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage); extern struct rawinput_thread_data * WINAPI rawinput_thread_data(void); -extern void rawinput_update_device_list(void); +extern void CDECL rawinput_update_device_list(void);
extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, DWORD type ) DECLSPEC_HIDDEN; diff --git a/dlls/user32/win.h b/dlls/user32/win.h index 1dfc8eb0ad1..79e26a6c86c 100644 --- a/dlls/user32/win.h +++ b/dlls/user32/win.h @@ -63,7 +63,6 @@ extern UINT get_win_monitor_dpi( HWND hwnd ) DECLSPEC_HIDDEN; extern UINT get_thread_dpi(void) DECLSPEC_HIDDEN; extern POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern POINT point_win_to_phys_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; -extern POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; extern POINT point_win_to_thread_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index f5315ec5dd4..94a1bc71520 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -1602,7 +1602,7 @@ static BOOL process_hardware_message( MSG *msg, UINT hw_id, const struct hardwar context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
if (msg->message == WM_INPUT || msg->message == WM_INPUT_DEVICE_CHANGE) - ret = user_callbacks && user_callbacks->process_rawinput_message( msg, hw_id, msg_data ); + ret = process_rawinput_message( msg, hw_id, msg_data ); else if (is_keyboard_message( msg->message )) ret = process_keyboard_message( msg, hw_id, hwnd_filter, first, last, remove ); else if (is_mouse_message( msg->message )) diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index e8051ac39d3..fd644484e48 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -41,7 +41,7 @@ struct user_callbacks void (CDECL *notify_ime)( HWND hwnd, UINT param ); BOOL (CDECL *post_dde_message)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, DWORD type ); - BOOL (CDECL *process_rawinput_message)( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data ); + void (CDECL *rawinput_update_device_list)(void); BOOL (CDECL *rawinput_device_get_usages)(HANDLE handle, USHORT *usage_page, USHORT *usage); void (WINAPI *set_standard_scroll_painted)( HWND hwnd, INT bar, BOOL visible ); BOOL (CDECL *unpack_dde_message)( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index d6f38382b4b..046e25ecf6a 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -334,3 +334,26 @@ UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data, memcpy( data, thread_data->buffer, size ); return size; } + +BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data ) +{ + struct rawinput_thread_data *thread_data; + + if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data())) + return FALSE; + + if (msg->message == WM_INPUT_DEVICE_CHANGE) + { + if (user_callbacks) user_callbacks->rawinput_update_device_list(); + } + else + { + thread_data->buffer->header.dwSize = RAWINPUT_BUFFER_SIZE; + if (!rawinput_from_hardware_message( thread_data->buffer, msg_data )) return FALSE; + thread_data->hw_id = hw_id; + msg->lParam = (LPARAM)hw_id; + } + + msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt ); + return TRUE; +} diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index b2d16b07d8e..406d71ab06d 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -30,6 +30,7 @@ #include "wine/gdi_driver.h" #include "wine/unixlib.h" #include "wine/debug.h" +#include "wine/server.h"
extern const struct user_callbacks *user_callbacks DECLSPEC_HIDDEN;
@@ -437,6 +438,9 @@ extern LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) extern LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, UINT flags, UINT timeout, PDWORD_PTR res_ptr, BOOL ansi );
+/* rawinput.c */ +extern BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data ) DECLSPEC_HIDDEN; + /* sysparams.c */ extern BOOL enable_thunk_lock DECLSPEC_HIDDEN; extern DWORD process_layout DECLSPEC_HIDDEN;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=117216
Your paranoid android.
=== debian11 (32 bit report) ===
user32: msg.c:6881: Test failed: SetFocus(hwnd) on a button: 6: the msg 0x002b was expected, but got msg 0x001c instead msg.c:6881: Test failed: SetFocus(hwnd) on a button: 7: the msg 0x0111 was expected, but got msg 0x0086 instead msg.c:6881: Test failed: SetFocus(hwnd) on a button: 8: the msg 0x8000 was expected, but got msg 0x0006 instead msg.c:6881: Test failed: SetFocus(hwnd) on a button: 9: the msg sequence is not complete: expected 0000 - actual 0009
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/user32/rawinput.c | 11 ----------- dlls/user32/user_main.c | 2 -- dlls/user32/user_private.h | 1 - dlls/win32u/ntuser_private.h | 1 - dlls/win32u/rawinput.c | 15 ++++++++++++--- dlls/win32u/sysparams.c | 1 + 6 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 9286aceb670..d6290f08d12 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -351,17 +351,6 @@ BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage) }
-struct rawinput_thread_data * WINAPI rawinput_thread_data(void) -{ - struct user_thread_info *thread_info = get_user_thread_info(); - struct rawinput_thread_data *data = thread_info->rawinput; - if (data) return data; - data = thread_info->rawinput = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - RAWINPUT_BUFFER_SIZE + sizeof(struct user_thread_info) ); - return data; -} - - /*********************************************************************** * GetRawInputDeviceList (USER32.@) */ diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index 72d5f30e536..55e72dcf203 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -169,7 +169,6 @@ static const struct user_callbacks user_funcs = register_imm, unregister_imm, try_finally, - rawinput_thread_data, };
static NTSTATUS WINAPI User32CopyImage( const struct copy_image_params *params, ULONG size ) @@ -271,7 +270,6 @@ static void thread_detach(void)
NtUserCallNoParam( NtUserThreadDetach ); HeapFree( GetProcessHeap(), 0, thread_info->wmchar_data ); - HeapFree( GetProcessHeap(), 0, thread_info->rawinput );
exiting_thread_id = 0; } diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index d15a3b6856e..71248e03bb8 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -62,7 +62,6 @@ struct tagWND;
struct hardware_msg_data; extern BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage); -extern struct rawinput_thread_data * WINAPI rawinput_thread_data(void); extern void CDECL rawinput_update_device_list(void);
extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index fd644484e48..eb851f57cdb 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -50,7 +50,6 @@ struct user_callbacks void (WINAPI *unregister_imm)( HWND hwnd ); NTSTATUS (CDECL *try_finally)( NTSTATUS (CDECL *func)( void *), void *arg, void (CALLBACK *finally_func)( BOOL )); - struct rawinput_thread_data *(WINAPI *get_rawinput_thread_data)(void); };
#define WM_SYSTIMER 0x0118 diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index 046e25ecf6a..d6d4e0c13f7 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -58,6 +58,15 @@ typedef struct } RAWINPUT64; #endif
+static struct rawinput_thread_data *get_rawinput_thread_data(void) +{ + struct user_thread_info *thread_info = get_user_thread_info(); + struct rawinput_thread_data *data = thread_info->rawinput; + if (data) return data; + data = thread_info->rawinput = calloc( 1, RAWINPUT_BUFFER_SIZE + sizeof(struct user_thread_info) ); + return data; +} + static bool rawinput_from_hardware_message( RAWINPUT *rawinput, const struct hardware_msg_data *msg_data ) { SIZE_T size; @@ -223,7 +232,7 @@ UINT WINAPI NtUserGetRawInputBuffer( RAWINPUT *data, UINT *data_size, UINT heade return 0; }
- if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data())) return ~0u; + if (!(thread_data = get_rawinput_thread_data())) return ~0u; rawinput = thread_data->buffer;
/* first RAWINPUT block in the buffer is used for WM_INPUT message data */ @@ -286,7 +295,7 @@ UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data, TRACE( "rawinput %p, command %#x, data %p, data_size %p, header_size %u.\n", rawinput, command, data, data_size, header_size );
- if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data())) + if (!(thread_data = get_rawinput_thread_data())) { SetLastError( ERROR_OUTOFMEMORY ); return ~0u; @@ -339,7 +348,7 @@ BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_d { struct rawinput_thread_data *thread_data;
- if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data())) + if (!(thread_data = get_rawinput_thread_data())) return FALSE;
if (msg->message == WM_INPUT_DEVICE_CHANGE) diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 01469c345c2..26426586fb8 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -4689,6 +4689,7 @@ static void thread_detach(void)
free( thread_info->key_state ); thread_info->key_state = 0; + free( thread_info->rawinput );
destroy_thread_windows(); NtClose( thread_info->server_queue );
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/win32u/gdiobj.c | 1 - dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 2 - dlls/win32u/wrappers.c | 6 --- dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 99 ++++++++++++++++++++++++++++++++++++ 7 files changed, 102 insertions(+), 10 deletions(-)
diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index 121ed4bbefd..0b148a628b3 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1185,7 +1185,6 @@ static struct unix_funcs unix_funcs = NtUserGetPriorityClipboardFormat, NtUserGetQueueStatus, NtUserGetRawInputBuffer, - NtUserGetRawInputData, NtUserGetSystemMenu, NtUserGetUpdateRect, NtUserGetUpdateRgn, diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index ffb1529e03f..cf5615f4dde 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -145,6 +145,7 @@ static void * const syscalls[] = NtUserGetProcessDpiAwarenessContext, NtUserGetProcessWindowStation, NtUserGetProp, + NtUserGetRawInputData, NtUserGetSystemDpiForProcess, NtUserGetThreadDesktop, NtUserGetTitleBarInfo, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 4a8d839007e..80bfb0bc253 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -984,7 +984,7 @@ @ stdcall NtUserGetQueueStatus(long) @ stub NtUserGetQueueStatusReadonly @ stdcall NtUserGetRawInputBuffer(ptr ptr long) -@ stdcall NtUserGetRawInputData(ptr long ptr ptr long) +@ stdcall -syscall NtUserGetRawInputData(ptr long ptr ptr long) @ stub NtUserGetRawInputDeviceInfo @ stub NtUserGetRawInputDeviceList @ stub NtUserGetRawPointerDeviceData diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 406d71ab06d..631d20f04b0 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -249,8 +249,6 @@ struct unix_funcs INT (WINAPI *pNtUserGetPriorityClipboardFormat)( UINT *list, INT count ); DWORD (WINAPI *pNtUserGetQueueStatus)( UINT flags ); UINT (WINAPI *pNtUserGetRawInputBuffer)( RAWINPUT *data, UINT *data_size, UINT header_size ); - UINT (WINAPI *pNtUserGetRawInputData)( HRAWINPUT rawinput, UINT command, - void *data, UINT *data_size, UINT header_size ); HMENU (WINAPI *pNtUserGetSystemMenu)( HWND hwnd, BOOL revert ); BOOL (WINAPI *pNtUserGetUpdateRect)( HWND hwnd, RECT *rect, BOOL erase ); INT (WINAPI *pNtUserGetUpdateRgn)( HWND hwnd, HRGN hrgn, BOOL erase ); diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 05c25a006e9..a4504135314 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -1054,12 +1054,6 @@ UINT WINAPI DECLSPEC_HOTPATCH NtUserGetRawInputBuffer( RAWINPUT *data, UINT *dat return unix_funcs->pNtUserGetRawInputBuffer( data, data_size, header_size ); }
-UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data, UINT *data_size, UINT header_size ) -{ - if (!unix_funcs) return ~0u; - return unix_funcs->pNtUserGetRawInputData( rawinput, command, data, data_size, header_size ); -} - BOOL WINAPI NtUserGetUpdatedClipboardFormats( UINT *formats, UINT size, UINT *out_size ) { if (!unix_funcs) return FALSE; diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index e1364c2811e..6c4e12bf59a 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -132,6 +132,7 @@ SYSCALL_ENTRY( NtUserGetProcessDpiAwarenessContext ) \ SYSCALL_ENTRY( NtUserGetProcessWindowStation ) \ SYSCALL_ENTRY( NtUserGetProp ) \ + SYSCALL_ENTRY( NtUserGetRawInputData ) \ SYSCALL_ENTRY( NtUserGetSystemDpiForProcess ) \ SYSCALL_ENTRY( NtUserGetThreadDesktop ) \ SYSCALL_ENTRY( NtUserGetTitleBarInfo ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 08b8fb6f2a0..e48afcf69c4 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -56,6 +56,14 @@ typedef struct POINT pt; } MSG32;
+typedef struct +{ + UINT dwType; + UINT dwSize; + UINT hDevice; + UINT wParam; +} RAWINPUTHEADER32; + static MSG *msg_32to64( MSG *msg, MSG32 *msg32 ) { if (!msg32) return NULL; @@ -858,3 +866,94 @@ NTSTATUS WINAPI wow64_NtUserGetTitleBarInfo( UINT *args )
return NtUserGetTitleBarInfo( hwnd, info ); } + +NTSTATUS WINAPI wow64_NtUserGetRawInputData( UINT *args ) +{ + HRAWINPUT handle = get_handle( &args ); + UINT command = get_ulong( &args ); + void *data = get_ptr( &args ); + UINT *data_size = get_ptr( &args ); + UINT header_size = get_ulong( &args ); + + if (header_size != sizeof(RAWINPUTHEADER32)) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return ~0u; + } + + switch (command) + { + case RID_INPUT: + if (data) + { + UINT data_size64, body_size, ret; + RAWINPUTHEADER32 *data32 = data; + RAWINPUTHEADER *data64 = NULL; + + data_size64 = *data_size + sizeof(RAWINPUTHEADER); + if (!(data64 = Wow64AllocateTemp( data_size64 ))) + { + SetLastError( STATUS_NO_MEMORY ); + return ~0u; + } + + ret = NtUserGetRawInputData( handle, command, data64, &data_size64, sizeof(RAWINPUTHEADER) ); + if (ret == ~0u) return ret; + + body_size = ret - sizeof(RAWINPUTHEADER); + if (*data_size < sizeof(RAWINPUTHEADER32) + body_size) + { + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return ~0u; + } + + data32->dwType = data64->dwType; + data32->dwSize = sizeof(RAWINPUTHEADER32) + body_size; + data32->hDevice = (UINT_PTR)data64->hDevice; + data32->wParam = data64->wParam; + memcpy( data32 + 1, data64 + 1, body_size ); + return sizeof(RAWINPUTHEADER32) + body_size; + } + else + { + UINT data_size64, ret; + + ret = NtUserGetRawInputData( handle, command, NULL, &data_size64, sizeof(RAWINPUTHEADER) ); + if (ret == ~0u) return ret; + *data_size = data_size64 - sizeof(RAWINPUTHEADER) + sizeof(RAWINPUTHEADER32); + return 0; + } + + case RID_HEADER: + { + UINT data_size64 = sizeof(RAWINPUTHEADER); + RAWINPUTHEADER32 *data32 = data; + RAWINPUTHEADER data64; + UINT ret; + + if (!data) + { + *data_size = sizeof(RAWINPUTHEADER); + return 0; + } + + if (*data_size < sizeof(RAWINPUTHEADER)) + { + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return ~0u; + } + + ret = NtUserGetRawInputData( handle, command, &data64, &data_size64, sizeof(RAWINPUTHEADER) ); + if (ret == ~0u) return ret; + data32->dwType = data64.dwType; + data32->dwSize = data64.dwSize - sizeof(RAWINPUTHEADER) + sizeof(RAWINPUTHEADER32); + data32->hDevice = (UINT_PTR)data64.hDevice; + data32->wParam = data64.wParam; + return sizeof(RAWINPUTHEADER); + } + + default: + SetLastError( ERROR_INVALID_PARAMETER ); + return ~0u; + } +}
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/win32u/gdiobj.c | 1 - dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 1 - dlls/win32u/wrappers.c | 6 ------ dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 18 ++++++++++++++++++ 7 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index 0b148a628b3..9d95d3cf94a 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1184,7 +1184,6 @@ static struct unix_funcs unix_funcs = NtUserGetMessage, NtUserGetPriorityClipboardFormat, NtUserGetQueueStatus, - NtUserGetRawInputBuffer, NtUserGetSystemMenu, NtUserGetUpdateRect, NtUserGetUpdateRgn, diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index cf5615f4dde..12af30f6c98 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -145,6 +145,7 @@ static void * const syscalls[] = NtUserGetProcessDpiAwarenessContext, NtUserGetProcessWindowStation, NtUserGetProp, + NtUserGetRawInputBuffer, NtUserGetRawInputData, NtUserGetSystemDpiForProcess, NtUserGetThreadDesktop, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 80bfb0bc253..c71f0d20429 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -983,7 +983,7 @@ @ stdcall -syscall NtUserGetProp(long wstr) @ stdcall NtUserGetQueueStatus(long) @ stub NtUserGetQueueStatusReadonly -@ stdcall NtUserGetRawInputBuffer(ptr ptr long) +@ stdcall -syscall NtUserGetRawInputBuffer(ptr ptr long) @ stdcall -syscall NtUserGetRawInputData(ptr long ptr ptr long) @ stub NtUserGetRawInputDeviceInfo @ stub NtUserGetRawInputDeviceList diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 631d20f04b0..aa7918d4d12 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -248,7 +248,6 @@ struct unix_funcs BOOL (WINAPI *pNtUserGetMessage)( MSG *msg, HWND hwnd, UINT first, UINT last ); INT (WINAPI *pNtUserGetPriorityClipboardFormat)( UINT *list, INT count ); DWORD (WINAPI *pNtUserGetQueueStatus)( UINT flags ); - UINT (WINAPI *pNtUserGetRawInputBuffer)( RAWINPUT *data, UINT *data_size, UINT header_size ); HMENU (WINAPI *pNtUserGetSystemMenu)( HWND hwnd, BOOL revert ); BOOL (WINAPI *pNtUserGetUpdateRect)( HWND hwnd, RECT *rect, BOOL erase ); INT (WINAPI *pNtUserGetUpdateRgn)( HWND hwnd, HRGN hrgn, BOOL erase ); diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index a4504135314..b451e57e3b1 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -1048,12 +1048,6 @@ DWORD WINAPI NtUserGetQueueStatus( UINT flags ) return unix_funcs->pNtUserGetQueueStatus( flags ); }
-UINT WINAPI DECLSPEC_HOTPATCH NtUserGetRawInputBuffer( RAWINPUT *data, UINT *data_size, UINT header_size ) -{ - if (!unix_funcs) return ~0u; - return unix_funcs->pNtUserGetRawInputBuffer( data, data_size, header_size ); -} - BOOL WINAPI NtUserGetUpdatedClipboardFormats( UINT *formats, UINT size, UINT *out_size ) { if (!unix_funcs) return FALSE; diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index 6c4e12bf59a..618a7990554 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -132,6 +132,7 @@ SYSCALL_ENTRY( NtUserGetProcessDpiAwarenessContext ) \ SYSCALL_ENTRY( NtUserGetProcessWindowStation ) \ SYSCALL_ENTRY( NtUserGetProp ) \ + SYSCALL_ENTRY( NtUserGetRawInputBuffer ) \ SYSCALL_ENTRY( NtUserGetRawInputData ) \ SYSCALL_ENTRY( NtUserGetSystemDpiForProcess ) \ SYSCALL_ENTRY( NtUserGetThreadDesktop ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index e48afcf69c4..c5c3a81c475 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -957,3 +957,21 @@ NTSTATUS WINAPI wow64_NtUserGetRawInputData( UINT *args ) return ~0u; } } + +NTSTATUS WINAPI wow64_NtUserGetRawInputBuffer( UINT *args ) +{ + RAWINPUT *data = get_ptr( &args ); + UINT *data_size = get_ptr( &args ); + UINT header_size = get_ulong( &args ); + + if (header_size != sizeof(RAWINPUTHEADER32)) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return ~0u; + } + + /* RAWINPUT has different sizes on 32-bit and 64-bit, but no translation is + * done. The function actually returns different structures depending on + * whether it's operating under WoW64 or not. */ + return NtUserGetRawInputBuffer( data, data_size, sizeof(RAWINPUTHEADER) ); +}
On Sat Jun 18 01:39:16 2022 +0000, **** wrote:
Marvin replied on the mailing list:
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=117216 Your paranoid android. === debian11 (32 bit report) === user32: msg.c:6881: Test failed: SetFocus(hwnd) on a button: 6: the msg 0x002b was expected, but got msg 0x001c instead msg.c:6881: Test failed: SetFocus(hwnd) on a button: 7: the msg 0x0111 was expected, but got msg 0x0086 instead msg.c:6881: Test failed: SetFocus(hwnd) on a button: 8: the msg 0x8000 was expected, but got msg 0x0006 instead msg.c:6881: Test failed: SetFocus(hwnd) on a button: 9: the msg sequence is not complete: expected 0000 - actual 0009
These are preexisting failures: https://bugs.winehq.org/show_bug.cgi?id=53207
I also added them to the TestBot's list of known failures: https://testbot.winehq.org/FailureDetails.pl?Key=140
Rémi Bernon (@rbernon) commented about dlls/wow64win/user.c:
POINT pt;
} MSG32;
+typedef struct +{
- UINT dwType;
- UINT dwSize;
- UINT hDevice;
- UINT wParam;
I don't know if it really matters but other structs here use the original types (`DWORD`, ...) when the member size doesn't change, and UINT32 wherever it does.
Rémi Bernon (@rbernon) commented about dlls/wow64win/user.c:
return 0;
}
if (*data_size < sizeof(RAWINPUTHEADER))
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return ~0u;
}
ret = NtUserGetRawInputData( handle, command, &data64, &data_size64, sizeof(RAWINPUTHEADER) );
if (ret == ~0u) return ret;
data32->dwType = data64.dwType;
data32->dwSize = data64.dwSize - sizeof(RAWINPUTHEADER) + sizeof(RAWINPUTHEADER32);
data32->hDevice = (UINT_PTR)data64.hDevice;
data32->wParam = data64.wParam;
return sizeof(RAWINPUTHEADER);
I think this should set `*data_size` to, and return `sizeof(RAWINPUTHEADER32)` instead?
On 6/23/22 11:07, Rémi Bernon (@rbernon) wrote:
Rémi Bernon (@rbernon) commented about dlls/wow64win/user.c:
return 0;
}
if (*data_size < sizeof(RAWINPUTHEADER))
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return ~0u;
}
ret = NtUserGetRawInputData( handle, command, &data64, &data_size64, sizeof(RAWINPUTHEADER) );
if (ret == ~0u) return ret;
data32->dwType = data64.dwType;
data32->dwSize = data64.dwSize - sizeof(RAWINPUTHEADER) + sizeof(RAWINPUTHEADER32);
data32->hDevice = (UINT_PTR)data64.hDevice;
data32->wParam = data64.wParam;
return sizeof(RAWINPUTHEADER);
I think this should set `*data_size` to, and return `sizeof(RAWINPUTHEADER32)` instead?
Whoops, thanks for catching that.