[Applies to KMDF only]
The WdfIoTargetSendInternalIoctlSynchronously method builds an internal device control request and sends it synchronously to an I/O target.
NTSTATUS WdfIoTargetSendInternalIoctlSynchronously( WDFIOTARGET IoTarget, WDFREQUEST Request, ULONG IoctlCode, PWDF_MEMORY_DESCRIPTOR InputBuffer, PWDF_MEMORY_DESCRIPTOR OutputBuffer, PWDF_REQUEST_SEND_OPTIONS RequestOptions, PULONG_PTR BytesReturned );
A handle to a framework request object. This parameter is optional and can be NULL. For more information, see the following Remarks section.
An I/O control code (IOCTL) that the I/O target supports.
A pointer to a caller-allocated WDF_MEMORY_DESCRIPTOR structure that describes a buffer that will be written to the I/O target. For more information, see the following Remarks section. This parameter is optional and can be NULL if the request does not send data.
A pointer to a caller-allocated WDF_MEMORY_DESCRIPTOR structure that describes a buffer that will receive data from the I/O target. For more information, see the following Remarks section. This parameter is optional and can be NULL if the request does not receive data.
A pointer to a caller-allocated WDF_REQUEST_SEND_OPTIONS structure that specifies options for the request. This pointer is optional and can be NULL. For more information, see the following Remarks section.
A pointer to a location that receives information (such as the number of bytes that were transferred) that another driver supplies when it completes the request by calling WdfRequestCompleteWithInformation. This pointer is optional and can be NULL.
If the operation succeeds, WdfIoTargetSendInternalIoctlSynchronously returns after the internal device control request completes, and the return value is the request's completion status value. Otherwise, this method might return one of the following values:
||An invalid parameter was detected.|
||The size of the WDF_REQUEST_SEND_OPTIONS structure that the RequestOptions parameter pointed to was incorrect.|
||The request was already queued to an I/O target.|
||The framework could not allocate system resources (typically memory).|
||The driver supplied a time-out value and the request did not complete within the allotted time.|
||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.
Use the WdfIoTargetSendInternalIoctlSynchronously method to send internal device control requests synchronously. To send internal device control requests asynchronously, use the WdfIoTargetFormatRequestForInternalIoctl method, followed by the WdfRequestSend method.
For more information about internal device control requests, see Using I/O Control Codes.
The WdfIoTargetSendInternalIoctlSynchronously method does not return until the request has completed, unless the driver supplies a time-out value in the RequestOptions parameter's WDF_REQUEST_SEND_OPTIONS structure, or unless an error is detected.
You can forward an 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 an internal device control request that your driver received in an I/O queue:
- Specify the received request's handle for the WdfIoTargetSendInternalIoctlSynchronously method's Request parameter.
Use the received request's input buffer for the WdfIoTargetSendInternalIoctlSynchronously method's InputBuffer parameter.
The driver must call WdfRequestRetrieveInputMemory to obtain a handle to the request's input buffer. The driver must then place that handle in the WDF_MEMORY_DESCRIPTOR structure that the driver supplies for the InputBuffer parameter.
Use the received request's output buffer for the WdfIoTargetSendInternalIoctlSynchronously method's OutputBuffer parameter.
The driver must call WdfRequestRetrieveOutputMemory to obtain a handle to the request's output buffer, and it must then place that handle in the WDF_MEMORY_DESCRIPTOR structure that the driver supplies for the OutputBuffer parameter.
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:
Supply a NULL request handle for the WdfIoTargetSendInternalIoctlSynchronously method's Request parameter, or create a new request object and supply its handle:
- If you supply a NULL request handle, the framework uses an internal request object. This technique is simple to use, but the driver cannot cancel the request.
- If you call WdfRequestCreate to create one or more request objects, you can reuse these request objects by calling WdfRequestReuse. This technique enables your driver's EvtDriverDeviceAdd callback function to preallocate request objects for a device. Additionally, another driver thread can call WdfRequestCancelSentRequest to cancel the request, if necessary.
Your driver can specify a non-NULL RequestOptions parameter, whether the driver provides a non-NULL or a NULL Request parameter. You can, for example, use the RequestOptions parameter to specify a time-out value.
Provide buffer space for the WdfIoTargetSendInternalIoctlSynchronously method's InputBuffer and OutputBuffer parameters, if the request requires them.
Your driver can specify this buffer space as locally allocated buffers, as WDFMEMORY handles, or as memory descriptor lists (MDLs). You can use whichever method is most convenient.
If necessary, the framework converts the buffer descriptions so that they are correct for the IOCTL's transfer type. For more information about IOCTL transfer types, see Defining I/O Control Codes.
The following techniques to specify buffer space are available:
Supply local buffers.
Because WdfIoTargetSendInternalIoctlSynchronously handles I/O requests synchronously, the driver can create request buffers that are local to the calling routine, as the following code example shows.
WDF_MEMORY_DESCRIPTOR MemoryDescriptor; MY_BUFFER_TYPE MyBuffer; WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&MemoryDescriptor, (PVOID) &MyBuffer, sizeof(MyBuffer));
Supply WDFMEMORY handles.
WDF_MEMORY_DESCRIPTOR MemoryDescriptor; WDFMEMORY MemoryHandle = NULL; status = WdfMemoryCreate(NULL, NonPagedPool, POOL_TAG, MY_BUFFER_SIZE, &MemoryHandle, NULL); WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(&MemoryDescriptor, MemoryHandle, NULL);
Alternatively, the driver can call WdfRequestRetrieveInputMemory or WdfRequestRetrieveOutputMemory to obtain a handle to a framework memory object that represents a received I/O request's buffer, if you want the driver to pass that buffer's contents to the I/O target. The driver must not complete the received I/O request until the new request that WdfIoTargetSendInternalIoctlSynchronously sends to the I/O target has been deleted, reused, or reformatted. (WdfIoTargetSendInternalIoctlSynchronously increments the memory object's reference count. Deleting, reusing, or reformatting a request object decrements the memory object's reference count.)
- Supply MDLs.
- Supply local buffers.
For more information about WdfIoTargetSendInternalIoctlSynchronously, see Sending I/O Requests to General I/O Targets.
For more information about I/O targets, see Using I/O Targets.
The following code example defines a local buffer, initializes a WDF_MEMORY_DESCRIPTOR structure, and calls WdfIoTargetSendInternalIoctlSynchronously. This example specifies NULL for the request object handle, so the framework will create a new request object for the I/O target.
WDF_MEMORY_DESCRIPTOR outputDescriptor; NTSTATUS status; MY_DRIVER_INFORMATION driverInformation; WDF_MEMORY_DESCRIPTOR_INIT_BUFFER( &outputDescriptor, (PVOID) &driverInformation, sizeof(MY_DRIVER_INFORMATION) ); status = WdfIoTargetSendInternalIoctlSynchronously( hidTarget, NULL, IOCTL_INTERNAL_GET_MY_DRIVER_INFORMATION, NULL, &outputDescriptor, NULL, NULL );
|Minimum KMDF version||1.0|
|Header||wdfiotarget.h (include Wdf.h)|
|Library||Wdf01000.sys (see Framework Library Versioning.)|
|DDI compliance rules||DeferredRequestCompleted, DriverCreate, IoctlReqs, KmdfIrql, KmdfIrql2, ReadReqs, RequestCompleted, RequestCompletedLocal, WriteReqs|