The ObDereferenceObject routine decrements the given object's reference count and performs retention checks.
void ObDereferenceObject( a );
Pointer to the object's body.
ObDereferenceObject returns a value that is reserved for system use. Drivers must treat this value as VOID.
ObDereferenceObject decreases the reference count of an object by one. If the object was created as temporary (the OBJ_PERMANENT flag was not specified on creation), and the reference count reaches zero, the object can be deleted by the system.
A driver can delete a temporary object it created by decreasing its reference count to zero. A driver must never attempt to delete an object it did not create.
An object is permanent if it was created with the OBJ_PERMANENT object attribute flag specified. (For more information about object attributes, see InitializeObjectAttributes.) A permanent object is created with a reference count of one, so it is not deleted when the driver dereferences it. A driver can only delete a permanent object it created by using the ZwMakeTemporaryObject routine to make it temporary. Use the following steps to delete a permanent object that you created:
Call the appropriate ZwOpenXxx or ZwCreateXxx routine to get a handle for the object, if necessary.
Call ZwMakeTemporaryObject with the handle obtained in step 2.
Call ZwClose with the handle obtained in step 2.
Use ObDereferenceObjectDeferDelete instead of ObDereferenceObject for any object, particularly Kernel Transaction Manager (KTM) objects, when the immediate deletion by the current thread of the object (by using ObDereferenceObject) might result in a deadlock.
|Minimum supported client||Available in Windows 2000 and later versions of Windows.|
|Header||wdm.h (include Wdm.h, Ntddk.h, Ntifs.h, Fltkernel.h)|
|DDI compliance rules||HwStorPortProhibitedDDIs|