SmartcardT1Request (WDM) routine
The SmartcardT1Request routine copies the request data from the caller's buffer to the buffer that the smart card library routines manage, from which the data is transmitted to the smart card reader. SmartcardT1Request then checks the T=1 protocol status.
Syntax
NTSTATUS SmartcardT1Request(
PSMARTCARD_EXTENSION SmartcardExtension
);
Parameters
- SmartcardExtension
A pointer to a SMARTCARD_EXTENSION structure that contains the device extension of the smart card device.
Return value
SmartcardT1Request returns one of the following NTSTATUS values:
Return code | Description |
---|---|
STATUS_SUCCESS | The buffer was set up successfully. |
STATUS_INSUFFICIENT_RESOURCES | The smart card library buffer was not allocated correctly. |
Remarks
The caller must allocate a SMARTCARD_EXTENSION structure and pass a pointer to this structure to the SmartcardInitialize (WDM) routine. SmartcardInitialize allocates two internal buffers that the smart card library routines manage, and it initializes the SmartcardRequest and SmartcardReply members of the SMARTCARD_EXTENSION structure to point to these two internal buffers. Because SmartcardT1Request uses one of these buffers, SmartcardInitialize must be called before SmartcardT1Request.
A caller of the SmartcardT1Request routine must copy the request data to the location that is pointed to by the IoRequest.RequestBuffer member of the previously allocated and initialized SMARTCARD_EXTENSION structure. The caller must then pass a pointer to this structure to SmartcardT1Request in the SmartcardExtension parameter.
SmartcardT1Request copies the data in the caller's buffer, which is located at IoRequest.RequestBuffer, to the smart card library buffer, which is located at SmartcardExtension->SmartcardRequest.Buffer. SmartcardT1Request then sets SmartcardExtension->SmartcardRequest.BufferLength to the number of bytes to transmit to the smart card.
The driver must call SmartcardT1Reply (WDM) to read the data that is associated with the reply to this request.
If your driver must send header data to the smart card reader before it sends the T=1 data, set SmartcardExtension->SmartcardRequest.BufferLength to the number of bytes that you must have for the header, and then call this routine. The packet will resemble this example:
Here is an example of a T=1 transmission:
// Run this loop as long as the protocolrequires that you send data.
do {
// Copy the data, embedded in a T=1 frame,-
// to SmartcardExtension->SmartcardRequest.Buffer
status = SmartcardT1Request(SmartcardExtension);
if (status != STATUS_SUCCESS)
return status;
// Send the T=1 frame to the smart card.
status = DriverSendDataToSmartcard(...);
if (status != STATUS_SUCCESS)
return status;
// Set an appropriate time out. (This example calculates the time out in ms.)
Timeout = SmartcardExtension->CardCapabilities.T1.BW
(SmartcardExtension->T1.Wtx ? SmartcardExtension->T1.Wtx : 1);
// Receive the T=1 frame from the smart card.
status = DriverReceiveDataFromSmartcard(...);
if (status != STATUS_SUCCESS)
return status;
// Check the T=1 protocol status and copy any data back to the user buffer.
status = SmartcardT1Reply(SmartcardExtension);
} while (status == STATUS_MORE_PROCESSING_REQUIRED);
return status;
Requirements
Target platform |
Desktop |
Version |
Available in Windows XP and later versions of Windows. |
Header |
Smclib.h (include Smclib.h) |
Library |
Smclib.lib |
IRQL |
<= DISPATCH_LEVEL |
See also