From: Rémi Bernon rbernon@codeweavers.com
--- dlls/sechost/service.c | 13 ++++---- dlls/user32/input.c | 66 +++++++++++++++------------------------ include/wine/plugplay.idl | 13 ++++++++ 3 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/dlls/sechost/service.c b/dlls/sechost/service.c index 788bb61bf48..98dd10cf5ec 100644 --- a/dlls/sechost/service.c +++ b/dlls/sechost/service.c @@ -1978,8 +1978,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH StartServiceCtrlDispatcherW( const SERVICE_TABLE_E
struct device_notification_details { - DWORD (CALLBACK *cb)(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header); HANDLE handle; + device_notify_callback callback; union { DEV_BROADCAST_HDR header; @@ -2100,7 +2100,7 @@ static DWORD WINAPI device_notify_proc( void *arg ) for (i = 0; i < details_copy_nelems; i++) { if (!notification_filter_matches( &details_copy[i].filter.header, (DEV_BROADCAST_HDR *)buf )) continue; - details_copy[i].cb( details_copy[i].handle, code, (DEV_BROADCAST_HDR *)buf ); + details_copy[i].callback( details_copy[i].handle, code, (DEV_BROADCAST_HDR *)buf ); } MIDL_user_free(buf); } @@ -2122,12 +2122,11 @@ static DWORD WINAPI device_notify_proc( void *arg ) /****************************************************************************** * I_ScRegisterDeviceNotification (sechost.@) */ -HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_details *details, - void *filter, DWORD flags ) +HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( HANDLE handle, DEV_BROADCAST_HDR *filter, device_notify_callback callback ) { struct device_notify_registration *registration;
- TRACE("callback %p, handle %p, filter %p, flags %#lx\n", details->cb, details->handle, filter, flags); + TRACE( "handle %p, filter %p, callback %p\n", handle, filter, callback );
if (!(registration = malloc( sizeof(struct device_notify_registration) ))) { @@ -2135,7 +2134,9 @@ HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_det return NULL; }
- registration->details = *details; + registration->details.handle = handle; + registration->details.callback = callback; + memcpy( ®istration->details.filter, filter, filter->dbch_size );
EnterCriticalSection( &service_cs ); list_add_tail( &device_notify_list, ®istration->entry ); diff --git a/dlls/user32/input.c b/dlls/user32/input.c index b4ee52f3474..4793688749e 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -28,6 +28,7 @@ #include "dbt.h" #include "wine/server.h" #include "wine/debug.h" +#include "wine/plugplay.h"
WINE_DEFAULT_DEBUG_CHANNEL(win); WINE_DECLARE_DEBUG_CHANNEL(keyboard); @@ -550,21 +551,6 @@ static DWORD CALLBACK devnotify_service_callback(HANDLE handle, DWORD flags, DEV return 0; }
-struct device_notification_details -{ - DWORD (CALLBACK *cb)(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header); - HANDLE handle; - union - { - DEV_BROADCAST_HDR header; - DEV_BROADCAST_DEVICEINTERFACE_W iface; - } filter; -}; - -extern HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_details *details, - void *filter, DWORD flags ); -extern BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle ); - /*********************************************************************** * RegisterDeviceNotificationA (USER32.@) * @@ -580,8 +566,8 @@ HDEVNOTIFY WINAPI RegisterDeviceNotificationA( HANDLE handle, void *filter, DWOR */ HDEVNOTIFY WINAPI RegisterDeviceNotificationW( HANDLE handle, void *filter, DWORD flags ) { - struct device_notification_details details; DEV_BROADCAST_HDR *header = filter; + device_notify_callback callback;
TRACE("handle %p, filter %p, flags %#lx\n", handle, filter, flags);
@@ -597,38 +583,38 @@ HDEVNOTIFY WINAPI RegisterDeviceNotificationW( HANDLE handle, void *filter, DWOR return NULL; }
- if (!header) details.filter.header.dbch_devicetype = 0; - else if (header->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + if (flags & DEVICE_NOTIFY_SERVICE_HANDLE) + callback = devnotify_service_callback; + else if (IsWindowUnicode( handle )) + callback = devnotify_window_callbackW; + else + callback = devnotify_window_callbackA; + + if (!header) { - DEV_BROADCAST_DEVICEINTERFACE_W *iface = (DEV_BROADCAST_DEVICEINTERFACE_W *)header; - details.filter.iface = *iface; + DEV_BROADCAST_HDR dummy = {0}; + return I_ScRegisterDeviceNotification( handle, &dummy, callback ); + } + if (header->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + { + DEV_BROADCAST_DEVICEINTERFACE_W iface = *(DEV_BROADCAST_DEVICEINTERFACE_W *)header;
if (flags & DEVICE_NOTIFY_ALL_INTERFACE_CLASSES) - details.filter.iface.dbcc_size = offsetof( DEV_BROADCAST_DEVICEINTERFACE_W, dbcc_classguid ); + iface.dbcc_size = offsetof( DEV_BROADCAST_DEVICEINTERFACE_W, dbcc_classguid ); else - details.filter.iface.dbcc_size = offsetof( DEV_BROADCAST_DEVICEINTERFACE_W, dbcc_name ); - } - else if (header->dbch_devicetype == DBT_DEVTYP_HANDLE) - { - FIXME( "DBT_DEVTYP_HANDLE filter type not implemented\n" ); - details.filter.header.dbch_devicetype = 0; + iface.dbcc_size = offsetof( DEV_BROADCAST_DEVICEINTERFACE_W, dbcc_name ); + + return I_ScRegisterDeviceNotification( handle, (DEV_BROADCAST_HDR *)&iface, callback ); } - else + if (header->dbch_devicetype == DBT_DEVTYP_HANDLE) { - SetLastError( ERROR_INVALID_DATA ); - return NULL; + FIXME( "DBT_DEVTYP_HANDLE not implemented\n" ); + return I_ScRegisterDeviceNotification( handle, header, callback ); }
- details.handle = handle; - - if (flags & DEVICE_NOTIFY_SERVICE_HANDLE) - details.cb = devnotify_service_callback; - else if (IsWindowUnicode( handle )) - details.cb = devnotify_window_callbackW; - else - details.cb = devnotify_window_callbackA; - - return I_ScRegisterDeviceNotification( &details, filter, 0 ); + FIXME( "type %#lx not implemented\n", header->dbch_devicetype ); + SetLastError( ERROR_INVALID_DATA ); + return NULL; }
/*********************************************************************** diff --git a/include/wine/plugplay.idl b/include/wine/plugplay.idl index a3e7b04bf30..32b0799b83c 100644 --- a/include/wine/plugplay.idl +++ b/include/wine/plugplay.idl @@ -16,8 +16,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#pragma makedep header + import "wtypes.idl";
+cpp_quote("#if 0") +typedef void *HDEVNOTIFY; +typedef struct _DEV_BROADCAST_HDR DEV_BROADCAST_HDR; +cpp_quote("#else") +cpp_quote("#include "dbt.h"") +cpp_quote("#endif") + +typedef DWORD (__stdcall *device_notify_callback)(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header); +HDEVNOTIFY __stdcall I_ScRegisterDeviceNotification(HANDLE handle, DEV_BROADCAST_HDR *filter, device_notify_callback callback); +BOOL __stdcall I_ScUnregisterDeviceNotification(HDEVNOTIFY handle); + [ uuid(57c680ac-7bce-4f39-97fd-ffea566754d5), endpoint("ncacn_np:[\pipe\wine_plugplay]"),