WdfIoTargetFormatRequestForInternalIoctlOthers method

[Applies to KMDF only]

The WdfIoTargetFormatRequestForInternalIoctlOthers method builds a non-standard internal device control request for an I/O target but does not send the request.

Syntax


NTSTATUS WdfIoTargetFormatRequestForInternalIoctlOthers(
  [in]            WDFIOTARGET IoTarget,
  [in]            WDFREQUEST Request,
  [in]            ULONG IoctlCode,
  [in, optional]  WDFMEMORY OtherArg1,
  [in, optional]  PWDFMEMORY_OFFSET OtherArg1Offset,
  [in, optional]  WDFMEMORY OtherArg2,
  [in, optional]  PWDFMEMORY_OFFSET OtherArg2Offset,
  [in, optional]  WDFMEMORY OtherArg4,
  [in, optional]  PWDFMEMORY_OFFSET OtherArg4Offset
);

Parameters

IoTarget [in]

A handle to a local or remote I/O target object that was obtained from a previous call to WdfDeviceGetIoTarget or WdfIoTargetCreate, or from a method that a specialized I/O target supplies.

Request [in]

A handle to a framework request object. For more information, see the following Remarks section.

IoctlCode [in]

An I/O control code (IOCTL) that the I/O target supports.

OtherArg1 [in, optional]

A handle to a framework memory object. This object represents a buffer that the driver uses for request-specific, driver-defined context information. For more information, see the following Remarks section. This parameter is optional and can be NULL.

OtherArg1Offset [in, optional]

A pointer to a caller-allocated WDFMEMORY_OFFSET structure that supplies optional byte offset and length values. Drivers can use these values to specify the beginning address and length of a segment of the context area that is specified by OtherArg1. This parameter is optional and can be NULL.

OtherArg2 [in, optional]

A handle to a framework memory object. This object represents a buffer that the driver uses for request-specific, driver-defined context information. For more information, see the following Remarks section. This parameter is optional and can be NULL.

OtherArg2Offset [in, optional]

A pointer to a caller-allocated WDFMEMORY_OFFSET structure that supplies optional byte offset and length values. Drivers can use these values to specify the beginning address and length of a segment of the context area that is specified by OtherArg2. This parameter is optional and can be NULL.

OtherArg4 [in, optional]

A handle to a framework memory object. This object represents a buffer that the driver uses for request-specific, driver-defined context information. For more information, see the following Remarks section. This parameter is optional and can be NULL.

OtherArg4Offset [in, optional]

A pointer to a caller-allocated WDFMEMORY_OFFSET structure that supplies optional byte offset and length values. Drivers can use these values to specify the beginning address and length of a segment of the context area that is specified by OtherArg4. This parameter is optional and can be NULL.

Return value

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

Return codeDescription
STATUS_INVALID_PARAMETER

An invalid parameter was detected.

STATUS_INVALID_DEVICE_REQUEST

The transfer length was larger than the buffer length, or the I/O request was already queued to an I/O target.

STATUS_INSUFFICIENT_RESOURCES

The framework could not allocate system resources (typically memory).

STATUS_REQUEST_NOT_ACCEPTED

The I/O request packet (IRP) that the Request parameter represents does not provide enough IO_STACK_LOCATION structures to allow the driver to forward the request.

 

This method also might return other NTSTATUS values.

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

Remarks

Use the WdfIoTargetFormatRequestForInternalIoctlOthers method, followed by the WdfRequestSend method, to send non-standard internal device control requests either synchronously or asynchronously. Alternatively, use the WdfIoTargetSendInternalIoctlOthersSynchronously method to send non-standard internal device control requests synchronously.

You can forward a non-standard internal device control request that your driver received in an I/O queue, or you can create and send a new request. In either case, the framework requires a request object and some buffer space.

To forward a non-standard internal device control request that your driver received in an I/O queue:

  1. Specify the received request's handle for the WdfIoTargetFormatRequestForInternalIoctlOthers method's Request parameter.

  2. Use the received request's context information for the WdfIoTargetFormatRequestForInternalIoctlOthers method's OtherArg1, OtherArg2, an OtherArg4 parameters.

    To obtain these parameter values, the driver must call WdfRequestGetParameters and use the DeviceIoControl member of the WDF_REQUEST_PARAMETERS structure that is returned.

For more information about forwarding an I/O request, see Forwarding I/O Requests.

Drivers often divide received I/O requests into smaller requests that they send to an I/O target, so your driver might create new requests.

To create a new I/O request:

  1. Create a new request object and supply its handle for the WdfIoTargetFormatRequestForInternalIoctlOthers method's Request parameter.

    Call WdfRequestCreate to preallocate one or more request objects. You can reuse these request objects by calling WdfRequestReuse. Your driver's EvtDriverDeviceAdd callback function can preallocate request objects for a device.

  2. Provide context buffers, if the request requires them, and supply buffer handles for the WdfIoTargetFormatRequestForInternalIoctlOthers method's OtherArg1, OtherArg2, and OtherArg4 parameters.

    Your driver must specify this buffer space as WDFMEMORY handles to framework-managed memory. To obtain WDFMEMORY handles, the driver calls WdfMemoryCreate or WdfMemoryCreatePreallocated.

After a driver calls WdfIoTargetFormatRequestForInternalIoctlOthers to format a device control request, the driver must call WdfRequestSend to send the request (either synchronously or asynchronously) to an I/O target.

Multiple calls to WdfIoTargetFormatRequestForInternalIoctlOthers that use the same request do not cause additional resource allocations. Therefore, to reduce the chance that WdfRequestCreate will return STATUS_INSUFFICIENT_RESOURCES, your driver's EvtDriverDeviceAdd callback function can call WdfRequestCreate to preallocate one or more request objects for a device. The driver can subsequently reuse (call WdfRequestReuse), reformat (call WdfIoTargetFormatRequestForInternalIoctlOthers), and resend (call WdfRequestSend) each request object without risking a STATUS_INSUFFICIENT_RESOURCES return value from a later call to WdfRequestCreate. (If the driver does not call the same request-formatting method each time, additional resources might be allocated.) All subsequent calls to WdfIoTargetFormatRequestForInternalIoctlOthers for the reused request object will return STATUS_SUCCESS, if parameter values do not change.

For information about obtaining status information after an I/O request completes, see Obtaining Completion Information.

For more information about WdfIoTargetFormatRequestForInternalIoctlOthers, see Sending I/O Requests to General I/O Targets.

For more information about I/O targets, see Using I/O Targets.

Examples

The following code example creates a framework memory object, obtains the buffer that the memory object contains, and initializes the buffer. Then, the example formats the request, sets a CompletionRoutine callback function, and sends the request to an I/O target.


PIRB pIrb;
WDFMEMORY memory;
NTSTATUS status;

status = WdfMemoryCreate(
                         WDF_NO_OBJECT_ATTRIBUTES,
                         NonPagedPool,
                         0,
                         sizeof(IRB),
                         &memory,
                         NULL
                         );
if (!NT_SUCCESS(status)) {
    goto Done;
}
pIrb = WdfMemoryGetBuffer(
                          memory,
                          NULL
                          );

pIrb->FunctionNumber = REQUEST_ALLOCATE_ADDRESS_RANGE;
pIrb->Flags = 0;
pIrb->u.AllocateAddressRange.Mdl = pAsyncAddressData->pMdl;
pIrb->u.AllocateAddressRange.fulFlags = fulFlags;
pIrb->u.AllocateAddressRange.nLength = nLength;
pIrb->u.AllocateAddressRange.MaxSegmentSize = MaxSegmentSize;
pIrb->u.AllocateAddressRange.fulAccessType = fulAccessType;
pIrb->u.AllocateAddressRange.fulNotificationOptions = fulNotificationOptions;
pIrb->u.AllocateAddressRange.Callback = NULL;
pIrb->u.AllocateAddressRange.Context = NULL;
pIrb->u.AllocateAddressRange.Required1394Offset = *Required1394Offset;
pIrb->u.AllocateAddressRange.FifoSListHead = NULL;
pIrb->u.AllocateAddressRange.FifoSpinLock = NULL;
pIrb->u.AllocateAddressRange.AddressesReturned = 0;
pIrb->u.AllocateAddressRange.p1394AddressRange = pAsyncAddressData->AddressRange;
pIrb->u.AllocateAddressRange.DeviceExtension = deviceExtension;

status = WdfIoTargetFormatRequestForInternalIoctlOthers(
                                                        IoTarget,
                                                        Request,
                                                        IOCTL_1394_CLASS,
                                                        memory,
                                                        NULL,
                                                        NULL,
                                                        NULL,
                                                        NULL,
                                                        NULL
                                                        );

if (!NT_SUCCESS(status)) {
    goto Done;
}

WdfRequestSetCompletionRoutine(
                               Request,
                               MyRequestCompletion,
                               NULL
                               );

if (WdfRequestSend(
                   Request,
                   IoTarget,
                   NULL
                   ) == FALSE) {
    status = WdfRequestGetStatus(Request);
}
else {
    status = STATUS_SUCCESS;
}

Requirements

Minimum KMDF version

1.0

Header

Wdfiotarget.h (include Wdf.h)

Library

Wdf01000.sys (see Framework Library Versioning.)

IRQL

<=DISPATCH_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2, RequestFormattedValid, RequestSendAndForgetNoFormatting, RequestSendAndForgetNoFormatting2

See also

EvtDriverDeviceAdd
IOCTL
WDF_REQUEST_PARAMETERS
WdfDeviceGetIoTarget
WdfIoTargetCreate
WdfIoTargetSendInternalIoctlOthersSynchronously
WdfIoTargetSendIoctlSynchronously
WdfMemoryCreate
WdfMemoryCreatePreallocated
WdfRequestCreate
WdfRequestGetParameters
WdfRequestReuse
WdfRequestSend
WDFMEMORY_OFFSET

 

 

Send comments about this topic to Microsoft

표시:
© 2014 Microsoft