From 377ffd25163d3f262facce6cca4df46afb1c887d Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Tue, 19 Apr 2005 21:47:05 +0000 Subject: [PATCH] convert the device object to a temporary device before deleting it svn path=/trunk/; revision=14706 --- reactos/ntoskrnl/io/device.c | 9 +++++++++ reactos/ntoskrnl/ob/ntobj.c | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index 7e42117f22e..6867df95ddb 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -557,6 +557,15 @@ IoDeleteDevice(PDEVICE_OBJECT DeviceObject) /* 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); } diff --git a/reactos/ntoskrnl/ob/ntobj.c b/reactos/ntoskrnl/ob/ntobj.c index 048936ad52c..b6553f15f6b 100644 --- a/reactos/ntoskrnl/ob/ntobj.c +++ b/reactos/ntoskrnl/ob/ntobj.c @@ -224,6 +224,12 @@ ObpSetPermanentObject (IN PVOID ObjectBody, IN BOOLEAN Permanent) ObjectHeader = BODY_TO_HEADER(ObjectBody); ObjectHeader->Permanent = Permanent; + + if (ObjectHeader->HandleCount == 0 && !Permanent && ObjectHeader->Parent != NULL) + { + /* Remove the object from the namespace */ + ObpRemoveEntryDirectory(ObjectHeader); + } } /**********************************************************************