VOID
ObDereferenceObject(
IN PVOID Object
);
ObDereferenceObject decrements the given object’s reference count and performs retention checks.
When the reference count for an object reaches zero, a kernel-mode component can remove the object from the system.
A named object with the permanent attribute, such as a directory object created to hold a driver’s symbolic link objects, can be deleted by calling this routine and then calling the appropriate ZwOpenXxx or ZwCreateXxx to get a handle for the object, ZwMakeTemporaryObject with the handle, and, then, ZwClose with the handle.
Callers of ObDereferenceObject must be running at IRQL PASSIVE_LEVEL.