Rémi Bernon : sechost: Support device interface notifications filtering.
Alexandre Julliard
julliard at winehq.org
Fri Jan 28 14:29:32 CST 2022
Module: wine
Branch: master
Commit: 439d126a998ba0885d90e6a5f9e3526a75e48cb0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=439d126a998ba0885d90e6a5f9e3526a75e48cb0
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Fri Jan 28 10:02:31 2022 +0100
sechost: Support device interface notifications filtering.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/tests/hotplug.c | 7 ++-----
dlls/sechost/service.c | 20 ++++++++++++++++++--
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c
index 5cb8358e3a9..9993ce23c99 100644
--- a/dlls/dinput/tests/hotplug.c
+++ b/dlls/dinput/tests/hotplug.c
@@ -197,7 +197,6 @@ static LRESULT CALLBACK devnotify_wndproc( HWND hwnd, UINT msg, WPARAM wparam, L
winetest_push_context( "%u", device_change_count );
- todo_wine_if( IsEqualGUID( &iface->dbcc_classguid, &control_class ) && !device_change_all )
ok( IsEqualGUID( &iface->dbcc_classguid, &expect_guid ), "got dbch_classguid %s\n",
debugstr_guid( &iface->dbcc_classguid ) );
ok( iface->dbcc_size >= offsetof( DEV_BROADCAST_DEVICEINTERFACE_W, dbcc_name[wcslen( iface->dbcc_name ) + 1] ),
@@ -315,8 +314,7 @@ static void test_RegisterDeviceNotification(void)
while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
device_change_count = 0;
- if (!strcmp( winetest_platform, "wine" )) device_change_expect = 4;
- else device_change_expect = 2;
+ device_change_expect = 2;
device_change_hwnd = hwnd;
device_change_all = FALSE;
stop_event = CreateEventW( NULL, FALSE, FALSE, NULL );
@@ -349,8 +347,7 @@ static void test_RegisterDeviceNotification(void)
while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
device_change_count = 0;
- if (!strcmp( winetest_platform, "wine" )) device_change_expect = 4;
- else device_change_expect = 2;
+ device_change_expect = 2;
device_change_hwnd = hwnd;
device_change_all = FALSE;
stop_event = CreateEventW( NULL, FALSE, FALSE, NULL );
diff --git a/dlls/sechost/service.c b/dlls/sechost/service.c
index 00485869e9c..fee3b52b6ac 100644
--- a/dlls/sechost/service.c
+++ b/dlls/sechost/service.c
@@ -1990,6 +1990,23 @@ struct device_notify_registration
struct device_notification_details details;
};
+static BOOL notification_filter_matches( DEV_BROADCAST_HDR *filter, DEV_BROADCAST_HDR *event )
+{
+ if (!filter->dbch_devicetype) return TRUE;
+ if (filter->dbch_devicetype != event->dbch_devicetype) return FALSE;
+
+ if (filter->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
+ {
+ DEV_BROADCAST_DEVICEINTERFACE_W *filter_iface = (DEV_BROADCAST_DEVICEINTERFACE_W *)filter;
+ DEV_BROADCAST_DEVICEINTERFACE_W *event_iface = (DEV_BROADCAST_DEVICEINTERFACE_W *)event;
+ if (filter_iface->dbcc_size == offsetof(DEV_BROADCAST_DEVICEINTERFACE_W, dbcc_classguid)) return TRUE;
+ return IsEqualGUID( &filter_iface->dbcc_classguid, &event_iface->dbcc_classguid );
+ }
+
+ FIXME( "Filter dbch_devicetype %u not implemented\n", filter->dbch_devicetype );
+ return TRUE;
+}
+
static DWORD WINAPI device_notify_proc( void *arg )
{
WCHAR endpoint[] = L"\\pipe\\wine_plugplay";
@@ -2074,6 +2091,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 );
}
MIDL_user_free(buf);
@@ -2104,8 +2122,6 @@ HDEVNOTIFY WINAPI I_ScRegisterDeviceNotification( struct device_notification_det
TRACE("callback %p, handle %p, filter %p, flags %#x\n", details->cb, details->handle, filter, flags);
- if (filter) FIXME("Notification filters are not yet implemented.\n");
-
if (!(registration = heap_alloc(sizeof(struct device_notify_registration))))
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
More information about the wine-cvs
mailing list