Author: cgutman
Date: Wed Jun 9 20:04:39 2010
New Revision: 47722
URL:
http://svn.reactos.org/svn/reactos?rev=47722&view=rev
Log:
[NTOSKRNL]
- Implement IRP_MN_REMOVE_DEVICE handling for PnP root PDOs
Modified:
trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnproot…
==============================================================================
--- trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c [iso-8859-1] Wed Jun 9 20:04:39 2010
@@ -1027,10 +1027,12 @@
IN PIRP Irp)
{
PPNPROOT_PDO_DEVICE_EXTENSION DeviceExtension;
+ PPNPROOT_FDO_DEVICE_EXTENSION FdoDeviceExtension;
PIO_STACK_LOCATION IrpSp;
NTSTATUS Status;
DeviceExtension = (PPNPROOT_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ FdoDeviceExtension =
(PPNPROOT_FDO_DEVICE_EXTENSION)PnpRootDeviceObject->DeviceExtension;
Status = Irp->IoStatus.Status;
IrpSp = IoGetCurrentIrpStackLocation(Irp);
@@ -1070,7 +1072,32 @@
break;
case IRP_MN_REMOVE_DEVICE:
- DPRINT1("IRP_MN_REMOVE_DEVICE is UNIMPLEMENTED!\n");
+ /* Remove the device from the device list and decrement the device count*/
+ KeAcquireGuardedMutex(&FdoDeviceExtension->DeviceListLock);
+ RemoveEntryList(&DeviceExtension->DeviceInfo->ListEntry);
+ FdoDeviceExtension->DeviceListCount--;
+ KeReleaseGuardedMutex(&FdoDeviceExtension->DeviceListLock);
+
+ /* Free some strings we created */
+ RtlFreeUnicodeString(&DeviceExtension->DeviceInfo->DeviceDescription);
+ RtlFreeUnicodeString(&DeviceExtension->DeviceInfo->DeviceID);
+ RtlFreeUnicodeString(&DeviceExtension->DeviceInfo->InstanceID);
+
+ /* Free the resource requirements list */
+ if (DeviceExtension->DeviceInfo->ResourceRequirementsList != NULL)
+ ExFreePool(DeviceExtension->DeviceInfo->ResourceRequirementsList);
+
+ /* Free the boot resources list */
+ if (DeviceExtension->DeviceInfo->ResourceList != NULL)
+ ExFreePool(DeviceExtension->DeviceInfo->ResourceList);
+
+ /* Free the device info */
+ ExFreePool(DeviceExtension->DeviceInfo);
+
+ /* Finally, delete the device object */
+ IoDeleteDevice(DeviceObject);
+
+ /* Return success */
Status = STATUS_SUCCESS;
break;