Share via


SmartcardT0Request (WDM) routine

The SmartcardT0Request routine copies the request data from the caller's buffer to the buffer that is managed by the smart card library routines, from which the data is transmitted to the card reader.

Syntax

NTSTATUS SmartcardT0Request(
   PSMARTCARD_EXTENSION SmartcardExtension
);

Parameters

  • SmartcardExtension
    A pointer to a SMARTCARD_EXTENSION structure that contains the device extension of the smart card device.

Return value

SmartcardT0Request returns one of the following NTSTATUS values:

Return code Description
STATUS_SUCCESS

The buffer was set up successfully.

STATUS_BUFFER_OVERFLOW

The internal buffer is too small to hold the data that should be sent to the smart card. To fix this error, allocate a larger send buffer. For more information, seeSmartcardInitialize (WDM).

STATUS_BUFFER_TOO_SMALL

The user buffer is too small to hold the data.

 

Remarks

The caller must allocate a SMARTCARD_EXTENSION structure and pass a pointer to this structure to the SmartcardInitialize (WDM) routine. SmartcardInitialize (WDM) 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 internal buffers. Because SmartcardT0Request uses one of these buffers, SmartcardInitialize (WDM) must be called before SmartcardT0Request.

A caller of the SmartcardT0Request 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 can then pass a pointer to this structure in the SmartcardExtension parameter to SmartcardT0Request.

SmartcardT0Request copies the data from the caller's buffer, which is at IoRequest.RequestBuffer, to the smart card library buffer, which is at SmartcardExtension->SmartcardRequest.Buffer. SmartcardT0Request then sets SmartcardExtension->SmartcardRequest.BufferLength to the number of bytes to transmit to the smart card.

If your driver must send header data to the reader before it sends the T=0 data, set SmartcardExtension->SmartcardRequest.BufferLengthto the number of bytes that you must have for the header, and then call this routine. The packet will resemble this example:

Diagram illustrating a packet with header data preceding T=0 data

Here is an example of a T=0 transmission:

// Copy data from the user buffer to 
// SmartcardExtension->SmartcardRequest.Buffer.
status = SmartcardT0Request(
        SmartcardExtension
        );
if (status != STATUS_SUCCESS)
    return status;

// Transmit SmartcardExtension->SmartcardRequest.Buffer to the smart card.
status = DriverSendDataToSmartcard(...);
if (status != STATUS_SUCCESS)
return status;

// Receive data from the smart card into SmartcardExtension->SmartcardReply.Buffer.
status = DriverReceiveDataFromSmartcard(...);
if (status != STATUS_SUCCESS)
    return status;

// Copy data from SmartcardExtension->SmartcardReply.Buffer back to the user buffer
// and return to the caller.
return SmartcardT0Reply(
SmartcardExtension
);

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

SmartcardInitialize (WDM)

SmartcardT0Reply (WDM)

SMARTCARD_EXTENSION

 

 

Send comments about this topic to Microsoft