https://git.reactos.org/?p=reactos.git;a=commitdiff;h=89fd2b86e4e1013269961…
commit 89fd2b86e4e1013269961a30c3f1135342df08c9
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Wed Oct 13 07:56:12 2021 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Thu Oct 14 23:39:31 2021 +0200
[NTOS:PNP] HACK: release resources when device is removed
CORE-17789
---
ntoskrnl/io/pnpmgr/devaction.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/ntoskrnl/io/pnpmgr/devaction.c b/ntoskrnl/io/pnpmgr/devaction.c
index 18a435f3a38..e9caa760bb5 100644
--- a/ntoskrnl/io/pnpmgr/devaction.c
+++ b/ntoskrnl/io/pnpmgr/devaction.c
@@ -1635,6 +1635,10 @@ PiIrpSendRemoveCheckVpb(
return IopSynchronousCall(targetDevice, &stack, &info);
}
+NTSTATUS
+IopUpdateResourceMapForPnPDevice(
+ IN PDEVICE_NODE DeviceNode);
+
static
VOID
NTAPI
@@ -1647,6 +1651,12 @@ IopSendRemoveDevice(IN PDEVICE_OBJECT DeviceObject)
/* Drivers should never fail a IRP_MN_REMOVE_DEVICE request */
PiIrpSendRemoveCheckVpb(DeviceObject, IRP_MN_REMOVE_DEVICE);
+ /* Start of HACK: update resources stored in registry, so IopDetectResourceConflict
works */
+ DeviceNode->ResourceList->Count = 0;
+ DeviceNode->ResourceListTranslated->Count = 0;
+ IopUpdateResourceMapForPnPDevice(DeviceNode);
+ /* End of HACK */
+
PiSetDevNodeState(DeviceNode, DeviceNodeRemoved);
PiNotifyTargetDeviceChange(&GUID_TARGET_DEVICE_REMOVE_COMPLETE, DeviceObject,
NULL);
LONG_PTR refCount = ObDereferenceObject(DeviceObject);