Bewerken

Delen via


WdfRequestGetFileObject function (wdfrequest.h)

[Applies to KMDF and UMDF]

The WdfRequestGetFileObject method retrieves the framework file object that is associated with a specified I/O request.

Syntax

WDFFILEOBJECT WdfRequestGetFileObject(
  [in] WDFREQUEST Request
);

Parameters

[in] Request

A handle to a framework request object.

Return value

WdfRequestGetFileObject returns a handle to the framework file object, if the framework has created a file object for the specified request. Otherwise, this method returns NULL. (A driver typically tests for a NULL return value only if it sets the WdfFileObjectCanBeOptional bit flag in the WDF_FILEOBJECT_CONFIG structure.)

A bug check occurs if the driver supplies an invalid object handle.

Remarks

The WdfRequestGetFileObject method returns NULL if either:

For more information about WdfRequestGetFileObject and framework file objects, see Framework File Objects.

Examples

The following code example obtains an I/O request's file object and then calls a driver-defined routine that obtains a pointer to the file object's context space.

VOID
MyEvtIoWrite(
    IN WDFQUEUE  Queue,
    IN WDFREQUEST  Request,
    IN size_t  Length
    )
{
    WDFFILEOBJECT  fileObject;
    PFILE_OPEN_CONTEXT  pOpenContext;

    fileObject = WdfRequestGetFileObject(Request);
    pOpenContext = GetFileObjectContext(fileObject)->OpenContext;
}

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfrequest.h (include Wdf.h)
Library Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
IRQL <=DISPATCH_LEVEL
DDI compliance rules DriverCreate(kmdf), FileObjectConfigured(kmdf), InvalidReqAccess(kmdf), InvalidReqAccessLocal(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf)

See also

WDF_FILEOBJECT_CLASS

WdfDeviceInitSetFileObjectConfig