Previous Next

SmartcardT0Request (WDM)

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

NTSTATUS 
  SmartcardT0Request(
    PSMARTCARD_EXTENSION  SmartcardExtension
    );

Parameters

SmartcardExtension
Pointer to a structure of type SMARTCARD_EXTENSION that contains the device extension of the smart card device.

Return Value

SmartcardT0Request returns an NTSTATUS value. Possible values are the following.

Value Meaning
STATUS_SUCCESS Buffer is successfully set up.
STATUS_BUFFER_OVERFLOW The internal buffer is too small to hold the data to send to the smart card. To fix this error, allocate a larger send buffer. See SmartcardInitialize (WDM) for details.
STATUS_BUFFER_TOO_SMALL The user buffer is too small to hold the data.

Headers

Declared in smclib.h. Include smclib.h.

Comments

The caller must allocate a SMARTCARD_EXTENSION structure and pass a pointer to this structure to the the SmartcardInitialize (WDM) routine. SmartcardInitialize allocates two internal buffers that are managed by the smartcard library routines and initializes the SmartcardRequest and SmartcardReply members of the SMARTCARD_EXTENSION structure to point to these two internal buffers. SmartcardT0Request uses one of these buffers, therefore SmartcardInitialize must be called before SmartcardT0Request.

A caller of the SmartcardT0Request routine must copy the request data to the location pointed to by the IoRequest.RequestBuffer member of the previously allocated and initialized SMARTCARD_EXTENSION structure, and then pass a pointer to this structure to SmartcardT0Request in the SmartcardExtension parameter.

This SmartcardT0Request routine copies the data in the caller's buffer at IoRequest.RequestBuffer to the smartcard library buffer at SmartcardExtension->SmartcardRequest.Buffer. SmartcardT0Request then sets SmartcardExtension->SmartcardRequest.BufferLength to the number of bytes to be transmitted to the smart card.

If your driver must send header data to the reader before the T=0 data, you should set SmartcardExtension->SmartcardRequest.BufferLength to the number of bytes you need for your header before you call this function. The packet will look like this:

Here is an example of a T=0 transmission.

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

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

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

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

For information on the SmartcardT0Request function for VxD drivers, see SmartcardT0Request (VxD).

See Also

SmartcardT0Reply (WDM), SmartcardT0Request (VxD), SmartcardInitialize (WDM), SMARTCARD_EXTENSION