ObReferenceObjectByPointer

NTSTATUS
    ObReferenceObjectByPointer(

        IN PVOID  Object,
        IN ACCESS_MASK  DesiredAccess,
        IN POBJECT_TYPE  ObjectType,
        IN KPROCESSOR_MODE  AccessMode
        );

ObReferenceObjectByPointer increments the pointer reference count for a given object.

Parameters

Object
Points to the object’s body.
DesiredAccess
Specifies a mask representing the requested access to the object.
ObjectType
Points to the object-type structure for the object.
AccessMode
Indicates the access mode to use for the access check. It must be either UserMode or KernelMode. Lower-level drivers should specify KernelMode.

Return Value

ObReferenceObjectByPointer can return one of the following status codes:

STATUS_SUCCESS
STATUS_OBJECT_TYPE_MISMATCH

Comments

Calling this routine prevents the object from being deleted, possibly by another component’s call to ObDereferenceObject or ZwClose.

Callers of this function must be running at IRQL PASSIVE_LEVEL.

See Also

ObDereferenceObject, ZwClose