[NTOS:PNP] HACK: release resources when device is removed

CORE-17789
This commit is contained in:
Hervé Poussineau 2021-10-13 07:56:12 +02:00
parent 49358f3416
commit 89fd2b86e4

View file

@ -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);