Skip to content

Latest commit

 

History

History
127 lines (88 loc) · 5.31 KB

nf-wdm-obreferenceobjectbyhandle.md

File metadata and controls

127 lines (88 loc) · 5.31 KB
UID title description old-location tech.root ms.date keywords ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames f1_keywords topic_type api_type api_location api_name
NF:wdm.ObReferenceObjectByHandle
ObReferenceObjectByHandle function (wdm.h)
The ObReferenceObjectByHandle routine provides access validation on the object handle, and, if access can be granted, returns the corresponding pointer to the object's body.
kernel\obreferenceobjectbyhandle.htm
kernel
04/30/2018
ObReferenceObjectByHandle function
ObReferenceObjectByHandle, ObReferenceObjectByHandle routine [Kernel-Mode Driver Architecture], k107_97ce2cea-8f20-4b30-996c-9ea268951aef.xml, kernel.obreferenceobjectbyhandle, wdm/ObReferenceObjectByHandle
wdm.h
Wdm.h, Ntddk.h, Ntifs.h
Universal
Available starting with Windows 2000.
IrqlObPassive, TargetRelationNeedsRef, HwStorPortProhibitedDDIs
NtosKrnl.lib
NtosKrnl.exe
PASSIVE_LEVEL
Windows
ObReferenceObjectByHandle
wdm/ObReferenceObjectByHandle
APIRef
kbSyntax
DllExport
NtosKrnl.exe
ObReferenceObjectByHandle

ObReferenceObjectByHandle function

-description

The ObReferenceObjectByHandle routine provides access validation on the object handle, and, if access can be granted, returns the corresponding pointer to the object's body.

-parameters

-param Handle [in]

Specifies an open handle for an object.

-param DesiredAccess [in]

Specifies the requested types of access to the object. The interpretation of this field is dependent on the object type. Do not use any generic access rights. For more information, see ACCESS_MASK.

-param ObjectType [in, optional]

Pointer to the object type. ObjectType can be *ExEventObjectType, *ExSemaphoreObjectType, *IoFileObjectType, *PsProcessType, *PsThreadType, *SeTokenObjectType, *TmEnlistmentObjectType, *TmResourceManagerObjectType, *TmTransactionManagerObjectType, or *TmTransactionObjectType.

If ObjectType is not NULL, the operating system verifies that the supplied object type matches the object type of the object that Handle specifies.

-param AccessMode [in]

Specifies the access mode to use for the access check. It must be either UserMode or KernelMode. Drivers should always specify UserMode for handles they receive from user address space.

-param Object [out]

Pointer to a variable that receives a pointer to the object's body. The following table contains the pointer types.

ObjectType parameter Object pointer type
*ExEventObjectType PKEVENT
*ExSemaphoreObjectType PKSEMAPHORE
*IoFileObjectType PFILE_OBJECT
*PsProcessType PEPROCESS or PKPROCESS
*PsThreadType PETHREAD or PKTHREAD
*SeTokenObjectType PACCESS_TOKEN
*TmEnlistmentObjectType PKENLISTMENT
*TmResourceManagerObjectType PKRESOURCEMANAGER
*TmTransactionManagerObjectType PKTM
*TmTransactionObjectType PKTRANSACTION

The structures that the pointer types reference are opaque, and drivers cannot access the structure members. Because the structures are opaque, PEPROCESS is equivalent to PKPROCESS, and PETHREAD is equivalent to PKTHREAD.

-param HandleInformation [out, optional]

Drivers set this to NULL.

-returns

ObReferenceObjectByHandle returns STATUS_SUCCESS if the call is successful. Possible return values include the following error codes:

Return code Description
STATUS_OBJECT_TYPE_MISMATCH The ObjectType parameter specifies the wrong object type for the object that is identified by the Handle parameter.
STATUS_ACCESS_DENIED The caller cannot be granted the requested access rights to the object.
STATUS_INVALID_HANDLE The Handle parameter is not a valid object handle.

-remarks

A pointer to the object body is retrieved from the object table entry and returned to the caller by means of the Object parameter.

If AccessMode is UserMode, the requested access is compared to the granted access for the object. If AccessMode is KernelMode, the handle should originate in the kernel address space.

Starting with Windows 7, if AccessMode is KernelMode and handle is received from user address space, Driver Verifier issues bugcheck C4, subcode F6.

If the call succeeds, a pointer to the object body is returned to the caller and the pointer reference count is incremented. Incrementing this count prevents the object from being deleted while the pointer is being referenced. The caller must decrement the reference count with ObDereferenceObject as soon as it is done with the object.

-see-also

ACCESS_MASK

ObDereferenceObject

ObReferenceObject

ObReferenceObjectByPointer