[PATCH v2 3/6] user32: Implemented RegisterDeviceNotification
Micah N Gorrell
mgorrell at codeweavers.com
Sat May 18 16:43:34 CDT 2019
Signed-off-by: Micah N Gorrell <mgorrell at codeweavers.com>
---
dlls/user32/misc.c | 74 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 66 insertions(+), 8 deletions(-)
diff --git a/dlls/user32/misc.c b/dlls/user32/misc.c
index 1a03d70dde..648f597837 100644
--- a/dlls/user32/misc.c
+++ b/dlls/user32/misc.c
@@ -33,6 +33,7 @@
#include "winternl.h"
#include "controls.h"
#include "user_private.h"
+#include "wine/server.h"
#include "wine/unicode.h"
#include "wine/debug.h"
@@ -363,11 +364,9 @@ DWORD WINAPI RegisterTasklist (DWORD x)
*
* See RegisterDeviceNotificationW.
*/
-HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hnd, LPVOID notifyfilter, DWORD flags)
+HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hRecipient, LPVOID pNotificationFilter, DWORD dwFlags)
{
- FIXME("(hwnd=%p, filter=%p,flags=0x%08x) returns a fake device notification handle!\n",
- hnd,notifyfilter,flags );
- return (HDEVNOTIFY) 0xcafecafe;
+ return RegisterDeviceNotificationW( hRecipient, pNotificationFilter, dwFlags );
}
/***********************************************************************
@@ -395,9 +394,52 @@ HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hnd, LPVOID notifyfilter, D
*/
HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE hRecipient, LPVOID pNotificationFilter, DWORD dwFlags)
{
- FIXME("(hwnd=%p, filter=%p,flags=0x%08x) returns a fake device notification handle!\n",
+ HWND ret = 0;
+
+ TRACE("(hwnd=%p, filter=%p,flags=0x%08x)\n",
hRecipient,pNotificationFilter,dwFlags );
- return (HDEVNOTIFY) 0xcafeaffe;
+
+ if (dwFlags & DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)
+ {
+ dwFlags &= ~DEVICE_NOTIFY_ALL_INTERFACE_CLASSES;
+ pNotificationFilter = NULL;
+ }
+
+ /* Wine broadcasts WM_DEVICECHANGE anyway, so registering without a handle
+ * is a not needed and can be ignored.
+ */
+ if (!hRecipient)
+ return (HDEVNOTIFY) 0xcafeaffe;
+
+ switch (dwFlags) {
+ case DEVICE_NOTIFY_WINDOW_HANDLE:
+ break;
+
+ case DEVICE_NOTIFY_SERVICE_HANDLE:
+ FIXME("Support for service handles is not yet implemented! Returns a fake device notification handle!\n");
+ return (HDEVNOTIFY) 0xcafeaffe;
+
+ default:
+ SetLastError(ERROR_INVALID_FLAGS);
+ return 0;
+ }
+
+ /* This implementation is not overly concerned with sending too many
+ * messages, so support for filters is not yet implemented.
+ */
+ if (pNotificationFilter)
+ FIXME("Notification filters are not yet implemented! All WM_DEVICECHANGE messages will be sent.\n");
+
+ SERVER_START_REQ( register_device_notification )
+ {
+ req->recipient = wine_server_user_handle( hRecipient );
+
+ wine_server_call( req );
+ ret = wine_server_ptr_handle( reply->handle );
+ }
+ SERVER_END_REQ;
+
+ return (HDEVNOTIFY) ret;
}
/***********************************************************************
@@ -406,8 +448,24 @@ HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE hRecipient, LPVOID pNotific
*/
BOOL WINAPI UnregisterDeviceNotification(HDEVNOTIFY hnd)
{
- FIXME("(handle=%p), STUB!\n", hnd);
- return TRUE;
+ unsigned int res = 0;
+
+ TRACE("(hnd=%p)\n", hnd);
+
+ /* A fake device notification handle is returned in some cases */
+ if ((HDEVNOTIFY) 0xcafeaffe == hnd)
+ return TRUE;
+
+ SERVER_START_REQ( unregister_device_notification )
+ {
+ req->notification = wine_server_user_handle( hnd );
+
+ res = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+
+ if (res) SetLastError( RtlNtStatusToDosError( res ) );
+ return !res;
}
/***********************************************************************
--
2.21.0
More information about the wine-devel
mailing list