信息
您所需的主题如下所示。但此主题未包含在此库中。

WdfRequestCreate 方法

The WdfRequestCreate method creates an empty framework request object.

语法

NTSTATUS WdfRequestCreate(
  [in, optional]  PWDF_OBJECT_ATTRIBUTES RequestAttributes,
  [in, optional]  WDFIOTARGET IoTarget,
  [out]           WDFREQUEST *Request
);

参数

RequestAttributes [in, optional]

A pointer to a caller-allocated WDF_OBJECT_ATTRIBUTES structure that specifies object attributes for the request object. This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

IoTarget [in, optional]

A handle to a framework I/O target object. This parameter is optional and can be NULL. If non-NULL, WdfRequestCreate verifies that the driver can eventually send the request to the specified I/O target.

Request [out]

A pointer to a location that receives a handle to a framework request object.

返回值

WdfRequestCreate returns STATUS_SUCCESS if the operation succeeds. Otherwise, this method might return one of the following values:

返回代码说明
STATUS_INVALID_PARAMETER

An input parameter is invalid.

STATUS_INSUFFICIENT_RESOURCES

There are insufficient system resources to complete the operation.

STATUS_REQUEST_NOT_ACCEPTED

The request's array of I/O stack locations is not large enough to allow the driver to send the request to the specified I/O target.

 

For a list of additional return values, see Framework Object Creation Errors.

This method might also return other NTSTATUS values.

评论

A framework-based driver can call WdfRequestCreate to create a new request that the driver subsequently passes to other framework functions for initialization. For example, a driver for a USB device might call WdfUsbTargetPipeFormatRequestForRead to format a new read request.

A framework-based driver that communicates with WDM drivers might specify the contents of a request by calling WdfRequestCreateFromIrp.

If a driver calls WdfRequestCreate to create a request object, it must not call WdfRequestComplete for the request object. Instead, the driver must call WdfObjectDelete when it has finished using the request object. For more information, see Completing I/O Requests.

By default, the new request object's parent is the framework driver object that the WdfDriverCreate method created. You can use the ParentObject member of the WDF_OBJECT_ATTRIBUTES structure to specify a different parent. The framework deletes the request object when it deletes the parent object. If your driver does not change the default parent, the driver should delete the request object when it has finished using the object; otherwise, the request object will remain until the I/O manager unloads your driver.

For more information about calling WdfRequestCreate, see Creating Framework Request Objects.

示例

The following code example creates an I/O target object, initializes a WDF_OBJECT_ATTRIBUTES structure, and calls WdfRequestCreate. The new request object's parent is the I/O target object.

WDF_OBJECT_ATTRIBUTES  attributes;
WDFREQUEST newRequest;
WDFIOTARGET ioTarget;
...
status = WdfIoTargetCreate(
                           Device,
                           WDF_NO_OBJECT_ATTRIBUTES,
                           &ioTarget
                           );
  ...
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = ioTarget;

status = WdfRequestCreate(
                          &attributes,
                          ioTarget,
                          &newRequest
                          );

if (!NT_SUCCESS(status)) {
    return status;
}

要求

版本

Available in version 1.0 and later versions of KMDF.

标头

Wdfrequest.h (包括Wdf.h)

Wdf<MajorVersionNumber>000.sys (see Framework Library Versions.)

IRQL

<=DISPATCH_LEVEL

另请参见

WdfDeviceInitSetRequestAttributes
WdfDriverCreate
WdfRequestCreateFromIrp
WdfRequestReuse
WDF_OBJECT_ATTRIBUTES
WDF_OBJECT_ATTRIBUTES_INIT

 

 

社区附加资源

显示:
© 2014 Microsoft