From: Zebediah Figura zfigura@codeweavers.com
--- dlls/user32/rawinput.c | 63 ----------------------------------------- dlls/user32/user32.spec | 2 +- dlls/win32u/rawinput.c | 61 +++++++++++++++++++++++++++++++++++++++ dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 40 ++++++++++++++++++++++++++ include/ntuser.h | 1 + 8 files changed, 106 insertions(+), 65 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index d6290f08d12..1b02be1398d 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -401,69 +401,6 @@ UINT WINAPI GetRawInputDeviceList(RAWINPUTDEVICELIST *devices, UINT *device_coun return rawinput_devices_count; }
-/*********************************************************************** - * RegisterRawInputDevices (USER32.@) - */ -BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(const RAWINPUTDEVICE *devices, UINT device_count, UINT size) -{ - struct rawinput_device *d; - BOOL ret; - UINT i; - - TRACE("devices %p, device_count %u, size %u.\n", devices, device_count, size); - - if (size != sizeof(*devices)) - { - WARN("Invalid structure size %u.\n", size); - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - for (i = 0; i < device_count; ++i) - { - if ((devices[i].dwFlags & RIDEV_INPUTSINK) && - (devices[i].hwndTarget == NULL)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if ((devices[i].dwFlags & RIDEV_REMOVE) && - (devices[i].hwndTarget != NULL)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - } - - if (!(d = HeapAlloc( GetProcessHeap(), 0, device_count * sizeof(*d) ))) return FALSE; - - for (i = 0; i < device_count; ++i) - { - TRACE("device %u: page %#x, usage %#x, flags %#lx, target %p.\n", - i, devices[i].usUsagePage, devices[i].usUsage, - devices[i].dwFlags, devices[i].hwndTarget); - if (devices[i].dwFlags & ~(RIDEV_REMOVE|RIDEV_NOLEGACY|RIDEV_INPUTSINK|RIDEV_DEVNOTIFY)) - FIXME("Unhandled flags %#lx for device %u.\n", devices[i].dwFlags, i); - - d[i].usage_page = devices[i].usUsagePage; - d[i].usage = devices[i].usUsage; - d[i].flags = devices[i].dwFlags; - d[i].target = wine_server_user_handle( devices[i].hwndTarget ); - } - - SERVER_START_REQ( update_rawinput_devices ) - { - wine_server_add_data( req, d, device_count * sizeof(*d) ); - ret = !wine_server_call( req ); - } - SERVER_END_REQ; - - HeapFree( GetProcessHeap(), 0, d ); - - return ret; -} - /*********************************************************************** * GetRawInputDeviceInfoA (USER32.@) */ diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 887394227a3..dbe2a4c1430 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -605,7 +605,7 @@ @ stub RegisterNetworkCapabilities @ stdcall RegisterPointerDeviceNotifications(long long) @ stdcall RegisterPowerSettingNotification(long ptr long) -@ stdcall RegisterRawInputDevices(ptr long long) +@ stdcall RegisterRawInputDevices(ptr long long) NtUserRegisterRawInputDevices @ stdcall RegisterServicesProcess(long) @ stdcall RegisterShellHookWindow (long) @ stdcall RegisterSuspendResumeNotification(long long) diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index d6d4e0c13f7..359faa39083 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -366,3 +366,64 @@ BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_d msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt ); return TRUE; } + +/********************************************************************** + * NtUserRegisterRawInputDevices (win32u.@) + */ +BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT device_count, UINT size ) +{ + struct rawinput_device *server_devices; + BOOL ret; + UINT i; + + TRACE( "devices %p, device_count %u, size %u.\n", devices, device_count, size ); + + if (size != sizeof(*devices)) + { + WARN( "Invalid structure size %u.\n", size ); + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + + for (i = 0; i < device_count; ++i) + { + if ((devices[i].dwFlags & RIDEV_INPUTSINK) && !devices[i].hwndTarget) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + + if ((devices[i].dwFlags & RIDEV_REMOVE) && devices[i].hwndTarget) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + } + + if (!(server_devices = malloc( device_count * sizeof(*server_devices) ))) return FALSE; + + for (i = 0; i < device_count; ++i) + { + TRACE( "device %u: page %#x, usage %#x, flags %#x, target %p.\n", + i, devices[i].usUsagePage, devices[i].usUsage, + devices[i].dwFlags, devices[i].hwndTarget ); + if (devices[i].dwFlags & ~(RIDEV_REMOVE|RIDEV_NOLEGACY|RIDEV_INPUTSINK|RIDEV_DEVNOTIFY)) + FIXME( "Unhandled flags %#x for device %u.\n", devices[i].dwFlags, i ); + + server_devices[i].usage_page = devices[i].usUsagePage; + server_devices[i].usage = devices[i].usUsage; + server_devices[i].flags = devices[i].dwFlags; + server_devices[i].target = wine_server_user_handle( devices[i].hwndTarget ); + } + + SERVER_START_REQ( update_rawinput_devices ) + { + wine_server_add_data( req, server_devices, device_count * sizeof(*server_devices) ); + ret = !wine_server_call( req ); + } + SERVER_END_REQ; + + free( server_devices ); + + return ret; +} diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index 12af30f6c98..3f2c596f727 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -160,6 +160,7 @@ static void * const syscalls[] = NtUserOpenDesktop, NtUserOpenInputDesktop, NtUserOpenWindowStation, + NtUserRegisterRawInputDevices, NtUserRemoveClipboardFormatListener, NtUserRemoveMenu, NtUserRemoveProp, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index c71f0d20429..687ef3af8dc 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1130,7 +1130,7 @@ @ stub NtUserRegisterManipulationThread @ stub NtUserRegisterPointerDeviceNotifications @ stub NtUserRegisterPointerInputTarget -@ stub NtUserRegisterRawInputDevices +@ stdcall -syscall NtUserRegisterRawInputDevices(ptr long long) @ stub NtUserRegisterServicesProcess @ stub NtUserRegisterSessionPort @ stub NtUserRegisterShellPTPListener diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index 618a7990554..531f9f7f9cd 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -147,6 +147,7 @@ SYSCALL_ENTRY( NtUserOpenDesktop ) \ SYSCALL_ENTRY( NtUserOpenInputDesktop ) \ SYSCALL_ENTRY( NtUserOpenWindowStation ) \ + SYSCALL_ENTRY( NtUserRegisterRawInputDevices ) \ SYSCALL_ENTRY( NtUserRemoveClipboardFormatListener ) \ SYSCALL_ENTRY( NtUserRemoveMenu ) \ SYSCALL_ENTRY( NtUserRemoveProp ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 9c6730b24ae..231f6a04a1e 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -64,6 +64,14 @@ typedef struct UINT32 wParam; } RAWINPUTHEADER32;
+typedef struct +{ + USHORT usUsagePage; + USHORT usUsage; + DWORD dwFlags; + UINT32 hwndTarget; +} RAWINPUTDEVICE32; + static MSG *msg_32to64( MSG *msg, MSG32 *msg32 ) { if (!msg32) return NULL; @@ -975,3 +983,35 @@ NTSTATUS WINAPI wow64_NtUserGetRawInputBuffer( UINT *args ) * whether it's operating under WoW64 or not. */ return NtUserGetRawInputBuffer( data, data_size, sizeof(RAWINPUTHEADER) ); } + +NTSTATUS WINAPI wow64_NtUserRegisterRawInputDevices( UINT *args ) +{ + const RAWINPUTDEVICE32 *devices32 = get_ptr( &args ); + UINT count = get_ulong( &args ); + UINT size = get_ulong( &args ); + + RAWINPUTDEVICE *devices64; + unsigned int i; + + if (size != sizeof(RAWINPUTDEVICE32)) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + + if (!(devices64 = Wow64AllocateTemp( count * sizeof(*devices64) ))) + { + SetLastError( ERROR_NOT_ENOUGH_MEMORY ); + return FALSE; + } + + for (i = 0; i < count; ++i) + { + devices64[i].usUsagePage = devices32[i].usUsagePage; + devices64[i].usUsage = devices32[i].usUsage; + devices64[i].dwFlags = devices32[i].dwFlags; + devices64[i].hwndTarget = UlongToPtr( devices32[i].hwndTarget ); + } + + return NtUserRegisterRawInputDevices( devices64, count, sizeof(*devices64) ); +} diff --git a/include/ntuser.h b/include/ntuser.h index 18ddbcaa4a4..cb5696ec827 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -663,6 +663,7 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING * struct client_menu_name *client_menu_name, DWORD fnid, DWORD flags, DWORD *wow ); BOOL WINAPI NtUserRegisterHotKey( HWND hwnd, INT id, UINT modifiers, UINT vk ); +BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT device_count, UINT size ); INT WINAPI NtUserReleaseDC( HWND hwnd, HDC hdc ); BOOL WINAPI NtUserRemoveClipboardFormatListener( HWND hwnd ); BOOL WINAPI NtUserRemoveMenu( HMENU menu, UINT id, UINT flags );