They seem to belong there.
As suggested by Alexandre Julliard.
Signed-off-by: Arkadiusz Hiler arek@hiler.eu --- dlls/user32/input.c | 69 +++++++++++++++++++++++++++++++++++++++++++++ dlls/user32/misc.c | 69 --------------------------------------------- 2 files changed, 69 insertions(+), 69 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 2f8648f177..1dd43a36a1 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -45,6 +45,7 @@ #include "winerror.h" #include "win.h" #include "user_private.h" +#include "dbt.h" #include "wine/server.h" #include "wine/debug.h" #include "wine/unicode.h" @@ -1298,3 +1299,71 @@ BOOL WINAPI EnableMouseInPointer(BOOL enable) SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } + +static DWORD CALLBACK devnotify_window_callback(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header) +{ + SendMessageTimeoutW(handle, WM_DEVICECHANGE, flags, (LPARAM)header, SMTO_ABORTIFHUNG, 2000, NULL); + return 0; +} + +static DWORD CALLBACK devnotify_service_callback(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header) +{ + FIXME("Support for service handles is not yet implemented!\n"); + return 0; +} + +struct device_notification_details +{ + DWORD (CALLBACK *cb)(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header); + HANDLE handle; +}; + +extern HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_details *details, + void *filter, DWORD flags ); +extern BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle ); + +/*********************************************************************** + * RegisterDeviceNotificationA (USER32.@) + * + * See RegisterDeviceNotificationW. + */ +HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hRecipient, LPVOID pNotificationFilter, DWORD dwFlags) +{ + TRACE("(hwnd=%p, filter=%p,flags=0x%08x)\n", + hRecipient,pNotificationFilter,dwFlags); + if (pNotificationFilter) + FIXME("The notification filter will requires an A->W when filter support is implemented\n"); + return RegisterDeviceNotificationW(hRecipient, pNotificationFilter, dwFlags); +} + +/*********************************************************************** + * RegisterDeviceNotificationW (USER32.@) + */ +HDEVNOTIFY WINAPI RegisterDeviceNotificationW( HANDLE handle, void *filter, DWORD flags ) +{ + struct device_notification_details details; + + TRACE("handle %p, filter %p, flags %#x\n", handle, filter, flags); + + if (flags & ~(DEVICE_NOTIFY_SERVICE_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)) + FIXME("unhandled flags %#x\n", flags); + + details.handle = handle; + + if (flags & DEVICE_NOTIFY_SERVICE_HANDLE) + details.cb = devnotify_service_callback; + else + details.cb = devnotify_window_callback; + + return I_ScRegisterDeviceNotification( &details, filter, 0 ); +} + +/*********************************************************************** + * UnregisterDeviceNotification (USER32.@) + */ +BOOL WINAPI UnregisterDeviceNotification( HDEVNOTIFY handle ) +{ + TRACE("%p\n", handle); + + return I_ScUnregisterDeviceNotification( handle ); +} diff --git a/dlls/user32/misc.c b/dlls/user32/misc.c index 41909f9071..59b85baa58 100644 --- a/dlls/user32/misc.c +++ b/dlls/user32/misc.c @@ -31,7 +31,6 @@ #include "wingdi.h" #include "controls.h" #include "user_private.h" -#include "dbt.h"
#include "wine/unicode.h" #include "wine/debug.h" @@ -279,74 +278,6 @@ DWORD WINAPI RegisterTasklist (DWORD x) return TRUE; }
-static DWORD CALLBACK devnotify_window_callback(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header) -{ - SendMessageTimeoutW(handle, WM_DEVICECHANGE, flags, (LPARAM)header, SMTO_ABORTIFHUNG, 2000, NULL); - return 0; -} - -static DWORD CALLBACK devnotify_service_callback(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header) -{ - FIXME("Support for service handles is not yet implemented!\n"); - return 0; -} - -struct device_notification_details -{ - DWORD (CALLBACK *cb)(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header); - HANDLE handle; -}; - -extern HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_details *details, - void *filter, DWORD flags ); -extern BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle ); - -/*********************************************************************** - * RegisterDeviceNotificationA (USER32.@) - * - * See RegisterDeviceNotificationW. - */ -HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hRecipient, LPVOID pNotificationFilter, DWORD dwFlags) -{ - TRACE("(hwnd=%p, filter=%p,flags=0x%08x)\n", - hRecipient,pNotificationFilter,dwFlags); - if (pNotificationFilter) - FIXME("The notification filter will requires an A->W when filter support is implemented\n"); - return RegisterDeviceNotificationW(hRecipient, pNotificationFilter, dwFlags); -} - -/*********************************************************************** - * RegisterDeviceNotificationW (USER32.@) - */ -HDEVNOTIFY WINAPI RegisterDeviceNotificationW( HANDLE handle, void *filter, DWORD flags ) -{ - struct device_notification_details details; - - TRACE("handle %p, filter %p, flags %#x\n", handle, filter, flags); - - if (flags & ~(DEVICE_NOTIFY_SERVICE_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)) - FIXME("unhandled flags %#x\n", flags); - - details.handle = handle; - - if (flags & DEVICE_NOTIFY_SERVICE_HANDLE) - details.cb = devnotify_service_callback; - else - details.cb = devnotify_window_callback; - - return I_ScRegisterDeviceNotification( &details, filter, 0 ); -} - -/*********************************************************************** - * UnregisterDeviceNotification (USER32.@) - */ -BOOL WINAPI UnregisterDeviceNotification( HDEVNOTIFY handle ) -{ - TRACE("%p\n", handle); - - return I_ScUnregisterDeviceNotification( handle ); -} - /*********************************************************************** * GetAppCompatFlags (USER32.@) */
UnregisterDeviceNotification when provided with NULL should not try to dereference it and just return FALSE.
This fixes crashes in BandLab Cakewalk and Glorious Model O control software.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49211 Signed-off-by: Arkadiusz Hiler arek@hiler.eu --- dlls/sechost/service.c | 3 +++ dlls/user32/tests/input.c | 8 ++++++++ 2 files changed, 11 insertions(+)
diff --git a/dlls/sechost/service.c b/dlls/sechost/service.c index 924a6c9264..68d2b9e78e 100644 --- a/dlls/sechost/service.c +++ b/dlls/sechost/service.c @@ -2109,6 +2109,9 @@ BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle )
TRACE("%p\n", handle);
+ if (!handle) + return FALSE; + EnterCriticalSection( &service_cs ); list_remove( ®istration->entry ); LeaveCriticalSection(&service_cs); diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 92b18becd2..913fabfbd8 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -3004,6 +3004,12 @@ static void test_GetPointerType(void) ok(type == PT_MOUSE, " type %d\n", type ); }
+static void test_UnregisterDeviceNotification(void) +{ + BOOL ret = UnregisterDeviceNotification(NULL); + ok(ret == FALSE, "Unregistering NULL Device Notification returned: %d\n", ret); +} + START_TEST(input) { POINT pos; @@ -3050,4 +3056,6 @@ START_TEST(input) test_GetPointerType(); else win_skip("GetPointerType is not available\n"); + + test_UnregisterDeviceNotification(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=72291
Your paranoid android.
=== debiant (32 bit Chinese:China report) ===
user32: menu.c:2337: Test failed: test 25
=== debiant (64 bit WoW report) ===
user32: clipboard.c:833: Test failed: 6: gle 5 clipboard.c:838: Test failed: 6.0: got 0000 instead of 0008 clipboard.c:868: Test failed: 6: gle 1418