From: Cameron Gutman Date: Wed, 9 Jun 2010 20:04:39 +0000 (+0000) Subject: [NTOSKRNL] X-Git-Tag: backups/Ash_Shell@48412~1^2~504 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=8ebc45f80b14e5e525b38e866a9c707cc111e878 [NTOSKRNL] - Implement IRP_MN_REMOVE_DEVICE handling for PnP root PDOs svn path=/trunk/; revision=47722 --- diff --git a/reactos/ntoskrnl/io/pnpmgr/pnproot.c b/reactos/ntoskrnl/io/pnpmgr/pnproot.c index fb05da9e8d5..42d9421cce8 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnproot.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnproot.c @@ -1027,10 +1027,12 @@ PnpRootPdoPnpControl( 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 @@ PnpRootPdoPnpControl( 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;