Hartmut Birr wrote:
Currently it exist a bug, which does also prevent from deleting a device. IoDeleteDevice doesn't dereference the driver object.
The attached patch should fix these issues.
Best Regards, Thomas
Index: ob/ntobj.c =================================================================== --- ob/ntobj.c (revision 14704) +++ ob/ntobj.c (working copy) @@ -224,6 +224,12 @@
ObjectHeader = BODY_TO_HEADER(ObjectBody); ObjectHeader->Permanent = Permanent; + + if (ObjectHeader->HandleCount == 0 && !Permanent && ObjectHeader->Parent != NULL) + { + /* Remove the object from the namespace */ + ObpRemoveEntryDirectory(ObjectHeader); + } }
/********************************************************************** Index: io/device.c =================================================================== --- io/device.c (revision 14704) +++ io/device.c (working copy) @@ -557,6 +557,15 @@
/* I guess this should be removed later... but it shouldn't cause problems */ DeviceObject->DeviceObjectExtension->ExtensionFlags |= DOE_DELETE_PENDING; + + /* Make the object temporary. This should automatically remove the device + from the namespace */ + ObMakeTemporaryObject(DeviceObject); + + /* Dereference the driver object */ + ObDereferenceObject(DeviceObject->DriverObject); + + /* Remove the keep-alive reference */ ObDereferenceObject(DeviceObject); }