Export (0) Print
Expand All

ObDereferenceObject routine

The ObDereferenceObject routine decrements the given object's reference count and performs retention checks.

Syntax


VOID ObDereferenceObject(
  _In_  PVOID Object
);

Parameters

Object [in]

Pointer to the object's body.

Return value

ObDereferenceObject returns a value that is reserved for system use. Drivers must treat this value as VOID.

Remarks

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:

  1. Call ObDereferenceObject.

  2. Call the appropriate ZwOpenXxx or ZwCreateXxx routine to get a handle for the object, if necessary.

  3. Call ZwMakeTemporaryObject with the handle obtained in step 2.

  4. Call ZwClose with the handle obtained in step 2.

Important   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.

Requirements

Version

Available in Windows 2000 and later versions of Windows.

Header

Wdm.h (include Wdm.h, Ntddk.h, Ntifs.h, or Fltkernel.h)

Library

Ntoskrnl.lib

IRQL

<= DISPATCH_LEVEL

DDI compliance rules

HwStorPortProhibitedDDIs

See also

ObDereferenceObjectDeferDelete
IoGetDeviceObjectPointer
InitializeObjectAttributes
ZwClose
ZwMakeTemporaryObject

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft