SMARTCARD_EXTENSION

The SMARTCARD_EXTENSION structure is used by the driver to access all the other smart card data structures, and additional information. This structure is passed to all callback functions.

typedef struct _SMARTCARD_EXTENSION {

    //
    // Version of this structure
    //
    ULONG           Version;

    //
    // Mandatory reader info
    //
    VENDOR_ATTR        VendorAttr;

    //
    // Array of callback reader functions
    //
    NTSTATUS (*ReaderFunction[16])(PSMARTCARD_EXTENSION);

    //
    // Capabilities of the current inserted card
    //
    SCARD_CARD_CAPABILITIES    CardCapabilities;

    //
    // This is used to store the last error of an overlapped operation
    // (Used only for Win9x VxDs)
    //
    ULONG LastError;

    //
    // This structure holds the data of the users IO request
    //
    struct {

        //
        // Number of bytes returned
        //
        PULONG    Information;
        
        //
        // Pointer to data to send to the card
        //
        PUCHAR    RequestBuffer;

        //
        // Number of bytes to send
        // 
        ULONG    RequestBufferLength;

        //
        // Pointer to buffer that receives the answer
        //
        PUCHAR    ReplyBuffer;

        //
        // Size of reply buffer
        //
        ULONG    ReplyBufferLength;

    } IoRequest;

    //
    // Major and minor IO control code for current request
    //
    ULONG    MajorIoControlCode;
    ULONG    MinorIoControlCode;

    //
    // OS dependent data
    //
    POS_DEP_DATA    OsData;

    //
    // Capabilities of the keyboard-reader
    //
    SCARD_READER_CAPABILITIES    ReaderCapabilities;

    //
    // Reader specific data
    //
    PREADER_EXTENSION    ReaderExtension;

    //
    // The reader stores all replies from the card here
    //
    SMARTCARD_REPLY        SmartcardReply;

    //
    // Current command that will be sent to the smart card
    //
    SMARTCARD_REQUEST    SmartcardRequest;

    //
    // Data for T=0
    //
    T0_DATA    T0;

    //
    // Data for T=1
    //
    T1_DATA    T1;

    //
    // Reserved, do not use
    //
    ULONG   Reserved[25];

} SMARTCARD_EXTENSION, *PSMARTCARD_EXTENSION;
 

Members

OsData
This structure contains information dependent on the driver type.
WDM driver version:
typedef struct _OS_DEP_DATA {

    //
    // Pointer to the device object
    //
    PDEVICE_OBJECT DeviceObject;

    //
    // This is the current Irp to be processed
    //
    PIRP CurrentIrp;

    //
    // Irp to be notified of card insertion/removal 
    //
    PIRP NotificationIrp;

    //
    // Used to synchronize access to the driver 
    //
    KMUTANT Mutex;

} OS_DEP_DATA, *POS_DEP_DATA;
 

This structure will be allocated by a call to SmartcardInitialize (WDM). After this call, copy the pointer of your device object to DeviceObject. Otherwise, the Smart Card Driver Library will not work. You cannot use this structure to store driver-dependent information. However, when one of your callback functions is called, CurrentIrp is set to the requesting Irp for every request, except card-tracking requests. For card-tracking requests, NotificationIrp is set to the requesting Irp. See RDF_CARD_TRACKING for more information about card tracking.

VxD driver version:
typedef struct _OS_DEP_DATA {

    //
    // Pointer to the smartcard extension
    //
    PSMARTCARD_EXTENSION SmartcardExtension;

    //
    // Current DiocParams to be processed
    //
    PDIOCPARAMETERS CurrentDiocParams;

    //
    // This overlapped is used for card tracking completion
    //
    OVERLAPPED *NotificationOverlappedData;

    //
    // This is used to synchronize access to the driver
    //
    PVMMMUTEX Mutex;

} OS_DEP_DATA, *POS_DEP_DATA;

This structure will be allocated by a call to SmartcardInitialize (VxD). You cannot use this structure to store driver-dependent information. However, when one of your callback functions is called, CurrentDiocParams is set to the requesting parameters for every request, except card-tracking requests. For card-tracking requests, NotificationOverlappedData is set to the overlapped structure of the caller.