The ObReferenceObject routine increments the reference count to the given object.
VOID
ObReferenceObject(
IN PVOID Object
);
None
Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.
ObReferenceObject simply increments the pointer reference count for an object, without making any access checks on the given object, as ObReferenceObjectByHandle and ObReferenceObjectByPointer do.
ObReferenceObject prevents deletion of the object at least until the driver subsequently calls its reciprocal, ObDereferenceObject, or closes the given object. The caller must decrement the reference count with ObDereferenceObject as soon as it is done with the object.
When the reference count for an object reaches zero, a kernel-mode component can remove the object from the system. However, a driver can remove only those objects that it created, and a driver should never attempt to remove any object that it did not create.
Callers of ObReferenceObject must be running at IRQL <= DISPATCH_LEVEL.
ObReferenceObjectByHandle, ObReferenceObjectByPointer, ObDereferenceObject, ZwClose