Zebediah Figura : ntoskrnl.exe: BusRelations is also used when devices are removed.

Alexandre Julliard julliard at winehq.org
Thu Nov 7 16:16:03 CST 2019


Module: wine
Branch: master
Commit: 81cda52d15317d065074fb060732b0f30bf99e4f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=81cda52d15317d065074fb060732b0f30bf99e4f

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Nov  6 23:55:03 2019 -0600

ntoskrnl.exe: BusRelations is also used when devices are removed.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntoskrnl.exe/pnp.c      | 18 +++++++++++++++---
 dlls/winebus.sys/bus_iohid.c |  2 +-
 dlls/winebus.sys/bus_sdl.c   |  2 +-
 dlls/winebus.sys/bus_udev.c  |  2 +-
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c
index 62a32a4afc..863eee390f 100644
--- a/dlls/ntoskrnl.exe/pnp.c
+++ b/dlls/ntoskrnl.exe/pnp.c
@@ -435,6 +435,21 @@ static void handle_bus_relations( DEVICE_OBJECT *parent )
         }
     }
 
+    if (wine_parent->children)
+    {
+        for (i = 0; i < wine_parent->children->Count; ++i)
+        {
+            DEVICE_OBJECT *child = wine_parent->children->Objects[i];
+
+            if (!device_in_list( relations, child ))
+            {
+                TRACE("Removing device %p.\n", child);
+                remove_device( child );
+            }
+            ObDereferenceObject( child );
+        }
+    }
+
     ExFreePool( wine_parent->children );
     wine_parent->children = relations;
 
@@ -453,9 +468,6 @@ void WINAPI IoInvalidateDeviceRelations( DEVICE_OBJECT *device_object, DEVICE_RE
         case BusRelations:
             handle_bus_relations( device_object );
             break;
-        case RemovalRelations:
-            remove_device( device_object );
-            break;
         default:
             FIXME("Unhandled relation %#x.\n", type);
             break;
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c
index ad542b5dfb..c6aa003ffc 100644
--- a/dlls/winebus.sys/bus_iohid.c
+++ b/dlls/winebus.sys/bus_iohid.c
@@ -371,7 +371,7 @@ static void handle_RemovalCallback(void *context, IOReturn result, void *sender,
     device = bus_find_hid_device(&iohid_vtbl, IOHIDDevice);
     if (device)
     {
-        IoInvalidateDeviceRelations(device, RemovalRelations);
+        IoInvalidateDeviceRelations(bus_pdo, BusRelations);
         bus_remove_hid_device(device);
     }
 }
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c
index 5f07ee2435..322e09be79 100644
--- a/dlls/winebus.sys/bus_sdl.c
+++ b/dlls/winebus.sys/bus_sdl.c
@@ -902,7 +902,7 @@ static void try_remove_device(SDL_JoystickID id)
     sdl_controller = private->sdl_controller;
     sdl_haptic = private->sdl_haptic;
 
-    IoInvalidateDeviceRelations(device, RemovalRelations);
+    IoInvalidateDeviceRelations(bus_pdo, BusRelations);
 
     bus_remove_hid_device(device);
 
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c
index b2cf62dedb..5e0b5c5151 100644
--- a/dlls/winebus.sys/bus_udev.c
+++ b/dlls/winebus.sys/bus_udev.c
@@ -1297,7 +1297,7 @@ static void try_remove_device(struct udev_device *dev)
 #endif
     if (!device) return;
 
-    IoInvalidateDeviceRelations(device, RemovalRelations);
+    IoInvalidateDeviceRelations(bus_pdo, BusRelations);
 
     private = impl_from_DEVICE_OBJECT(device);
 




More information about the wine-cvs mailing list