6 Appendix A: Full IDL

For ease of implementation, the full Interface Definition Language (IDL) is provided below where ms-dtyp.idl is the IDL as specified in [MS-DTYP] section 5 and ms-dcom.idl is the IDL as specified in [MS-DCOM] section 6.

 import "ms-dtyp.idl";
 import "ms-dcom.idl";
  
 [
     uuid(A35AF600-9CF4-11CD-A076-08002B2BD711),
     version(1.0),
     pointer_default(unique)
 ]
 interface type_scard_pack
 {
  
 //
 // Packing for calls that use the same params
 //
 typedef struct _REDIR_SCARDCONTEXT
 {
     [range(0, 16)]                  unsigned long       cbContext;      
     [unique] [size_is(cbContext)]   byte               *pbContext;
 } REDIR_SCARDCONTEXT;
  
 typedef struct _REDIR_SCARDHANDLE
 {
                          REDIR_SCARDCONTEXT              Context;
     [range(0, 16)]       unsigned long                   cbHandle;
     [size_is(cbHandle)]  byte                           *pbHandle;
 } REDIR_SCARDHANDLE;
  
 typedef struct _long_Return
 {
     long                 ReturnCode;
 } long_Return;
  
 typedef struct _longAndMultiString_Return
 {
                                          long            ReturnCode;
     [range(0, 65536)]                    unsigned long   cBytes;     
     [unique] [size_is(cBytes)]           byte           *msz;
 } ListReaderGroups_Return, ListReaders_Return;
  
 typedef struct _Context_Call
 {
     REDIR_SCARDCONTEXT                          Context;
 } Context_Call;
  
 typedef struct _ContextAndStringA_Call
 {
              REDIR_SCARDCONTEXT                          Context;
     [string] const char *                                sz;
 } ContextAndStringA_Call;
  
 typedef struct _ContextAndStringW_Call
 {
              REDIR_SCARDCONTEXT                          Context;
     [string] const wchar_t *                             sz;
 } ContextAndStringW_Call;
  
  
 typedef struct _ContextAndTwoStringA_Call
 {
              REDIR_SCARDCONTEXT                          Context;
     [string] const char *                                sz1;
     [string] const char *                                sz2;
 } ContextAndTwoStringA_Call;
  
 typedef struct _ContextAndTwoStringW_Call
 {
              REDIR_SCARDCONTEXT                          Context;
     [string] const wchar_t *                             sz1;
     [string] const wchar_t *                             sz2;
 } ContextAndTwoStringW_Call;
  
 //
 // Call specific packing
 //
 typedef struct _EstablishContext_Call
 {
     unsigned long                               dwScope;
 } EstablishContext_Call;
  
 typedef struct _EstablishContext_Return
 {
     long                                        ReturnCode;
     REDIR_SCARDCONTEXT                          Context;
 } EstablishContext_Return;
  
  
 typedef struct _ListReaderGroups_Call
 {
     REDIR_SCARDCONTEXT                          Context;
     long                                        fmszGroupsIsNULL;
     unsigned long                               cchGroups;
 } ListReaderGroups_Call;
  
  
 typedef struct _ListReaders_Call
 {
                                REDIR_SCARDCONTEXT   Context;
     [range(0, 65536)]          unsigned long        cBytes;
     [unique] [size_is(cBytes)] const byte          *mszGroups;
                             long                 fmszReadersIsNULL;
                                unsigned long        cchReaders;
 } ListReaders_Call;
  
 typedef struct _ReaderState_Common_Call
 {
                       unsigned long             dwCurrentState;
                       unsigned long             dwEventState;
     [range(0, 36)]    unsigned long             cbAtr;
                       byte                      rgbAtr[36];
 } ReaderState_Common_Call;
  
 typedef struct _ReaderStateA
 {
     [string] const char *                                szReader;
              ReaderState_Common_Call                     Common;
 } ReaderStateA;
  
 typedef struct _ReaderStateW
 {
     [string] const wchar_t *                             szReader;
              ReaderState_Common_Call                     Common;
 } ReaderStateW;
  
 typedef struct _ReaderState_Return
 {
                    unsigned long                dwCurrentState;
                    unsigned long                dwEventState;
     [range(0, 36)] unsigned long                cbAtr;
                    byte                         rgbAtr[36];
 } ReaderState_Return;
  
 typedef struct _GetStatusChangeA_Call
 {
                         REDIR_SCARDCONTEXT      Context;
                         unsigned long           dwTimeOut;
     [range(0, 11)]      unsigned long           cReaders;
     [size_is(cReaders)] ReaderStateA           *rgReaderStates;
} GetStatusChangeA_Call;
  
  
 typedef struct _LocateCardsA_Call {
     REDIR_SCARDCONTEXT                 Context;
     [range(0, 65536)] unsigned long    cBytes;
     [size_is(cBytes)] const byte *     mszCards;
     [range(0, 10)] unsigned long       cReaders;
     [size_is(cReaders)] ReaderStateA * rgReaderStates;
 } LocateCardsA_Call;
  
  
 typedef struct _LocateCardsW_Call
 {
                         REDIR_SCARDCONTEXT       Context;
     [range(0, 65536)]   unsigned long            cBytes;
     [size_is(cBytes)]   const byte              *mszCards;
     [range(0, 10)]      unsigned long            cReaders;
     [size_is(cReaders)] ReaderStateW            *rgReaderStates;
 } LocateCardsW_Call;
  
 typedef struct _LocateCards_ATRMask
 {
     [range(0, 36)]      unsigned long            cbAtr;
                         byte                     rgbAtr[36];
                         byte                     rgbMask[36];
 } LocateCards_ATRMask;
  
 typedef struct _LocateCardsByATRA_Call
 {
                         REDIR_SCARDCONTEXT      Context;
     [range(0, 1000)]    unsigned long           cAtrs;
     [size_is(cAtrs)]    LocateCards_ATRMask    *rgAtrMasks;
     [range(0, 10)]      unsigned long           cReaders;
     [size_is(cReaders)] ReaderStateA           *rgReaderStates;
 } LocateCardsByATRA_Call;
  
 typedef struct _LocateCardsByATRW_Call
 {
                         REDIR_SCARDCONTEXT      Context;
     [range(0, 1000)]    unsigned long           cAtrs;
     [size_is(cAtrs)]    LocateCards_ATRMask    *rgAtrMasks;
     [range(0, 10)]      unsigned long           cReaders;
     [size_is(cReaders)] ReaderStateW           *rgReaderStates;
 } LocateCardsByATRW_Call;
  
 typedef struct _GetStatusChange_Return
 {
                         long                     ReturnCode;
     [range(0, 10)]      unsigned long            cReaders;
     [size_is(cReaders)] ReaderState_Return      *rgReaderStates;
 } LocateCards_Return, GetStatusChange_Return;
  
 typedef struct _GetStatusChangeW_Call
 {
                         REDIR_SCARDCONTEXT      Context;
                         unsigned long           dwTimeOut;
     [range(0, 11)]      unsigned long           cReaders;
     [size_is(cReaders)] ReaderStateW           *rgReaderStates;
 } GetStatusChangeW_Call;
  
 typedef struct _Connect_Common
 {
     REDIR_SCARDCONTEXT                       Context;
     unsigned long                            dwShareMode;
     unsigned long                            dwPreferredProtocols;
 } Connect_Common;
  
 typedef struct _ConnectA_Call
 {
     [string] const char *                                szReader;
              Connect_Common                              Common;
 } ConnectA_Call;
  
 typedef struct _ConnectW_Call
 {
     [string] const wchar_t *                             szReader;
              Connect_Common                              Common;
 } ConnectW_Call;
  
 typedef struct _Connect_Return
 {
     long                                        ReturnCode;
     REDIR_SCARDHANDLE                           hCard;
     unsigned long                               dwActiveProtocol;
 } Connect_Return;
  
 typedef struct _Reconnect_Call
 {
     REDIR_SCARDHANDLE                         hCard;
     unsigned long                             dwShareMode;
     unsigned long                             dwPreferredProtocols;
     unsigned long                             dwInitialization;
 } Reconnect_Call;
  
 typedef struct Reconnect_Return
 {
     long                                        ReturnCode;
     unsigned long                               dwActiveProtocol;
 } Reconnect_Return;
  
  
 typedef struct _HCardAndDisposition_Call
 {
     REDIR_SCARDHANDLE                           hCard;
     unsigned long                               dwDisposition;
 } HCardAndDisposition_Call;
  
  
 typedef struct _State_Call
 {
     REDIR_SCARDHANDLE                           hCard;
     long                                        fpbAtrIsNULL;
     unsigned long                               cbAtrLen;
     // EDITOR'S NOTE: Can be 0xFFFFFFFF
 } State_Call;
  
 typedef struct _State_Return
 {
                                     long                ReturnCode;
                                     unsigned long       dwState;
                                     unsigned long       dwProtocol;
     [range(0, 36)]                  unsigned long       cbAtrLen;   
     [unique] [size_is(cbAtrLen)]    byte               *rgAtr;
 } State_Return;
  
  
 typedef struct _Status_Call
 {
     REDIR_SCARDHANDLE                       hCard;
     long                                    fmszReaderNamesIsNULL;
     unsigned long                           cchReaderLen;
     unsigned long                           cbAtrLen;
 } Status_Call;
 typedef struct _Status_Return
 {
                                 long            ReturnCode;
     [range(0, 65536)]           unsigned long   cBytes;
     [unique] [size_is(cBytes)]  byte           *mszReaderNames;
                                 unsigned long   dwState;
                                 unsigned long   dwProtocol;
                                 byte            pbAtr[32];
     [range(0, 32)]        unsigned long   cbAtrLen;
 } Status_Return;
  
  
 typedef struct _SCardIO_Request
 {
                                       unsigned long   dwProtocol;
     [range(0, 1024)]                  unsigned long   cbExtraBytes;   
     [unique] [size_is(cbExtraBytes)]  byte           *pbExtraBytes;
 } SCardIO_Request;
 typedef struct _Transmit_Call
 {
                             REDIR_SCARDHANDLE   hCard;
                             SCardIO_Request     ioSendPci;
     [range(0, 66560)]       unsigned long       cbSendLength;
     [size_is(cbSendLength)] const byte         *pbSendBuffer;
     [unique]                SCardIO_Request    *pioRecvPci;
                             long                fpbRecvBufferIsNULL;
                             unsigned long       cbRecvLength;
 } Transmit_Call;
 typedef struct _Transmit_Return
 {
                                      long             ReturnCode;
     [unique]                         SCardIO_Request *pioRecvPci;
     [range(0, 66560)]                unsigned long    cbRecvLength;
     [unique] [size_is(cbRecvLength)] byte            *pbRecvBuffer;
 } Transmit_Return;
  
 typedef struct _GetTransmitCount_Call
 {
     REDIR_SCARDHANDLE   hCard;
 } GetTransmitCount_Call;
  
 typedef struct _GetTransmitCount_Return
 {
     long                ReturnCode;
     unsigned long       cTransmitCount;
 } GetTransmitCount_Return;
  
 typedef struct _Control_Call
 {
                                  REDIR_SCARDHANDLE  hCard;
                                  unsigned long      dwControlCode;
     [range(0, 66560)]            unsigned long      cbInBufferSize;
     [unique] [size_is(cbInBufferSize)]  const byte  *pvInBuffer;
                                  long     fpvOutBufferIsNULL;
                                  unsigned long      cbOutBufferSize;
 } Control_Call;
  
 typedef struct _Control_Return
 {
                                   long           ReturnCode;
     [range(0, 66560)]             unsigned long  cbOutBufferSize;
     [unique] [size_is(cbOutBufferSize)] byte     *pvOutBuffer;
 } Control_Return;
  
 typedef struct _GetAttrib_Call
 {
     REDIR_SCARDHANDLE                  hCard;
     unsigned long                      dwAttrId;
     long                               fpbAttrIsNULL;
     unsigned long                      cbAttrLen;
 } GetAttrib_Call;
  
 typedef struct _GetAttrib_Return
 {
                                     long                ReturnCode;
     [range(0, 65536)]               unsigned long       cbAttrLen;
     [unique] [size_is(cbAttrLen)]   byte               *pbAttr;
 } GetAttrib_Return;
  
 typedef struct _SetAttrib_Call
 {
                             REDIR_SCARDHANDLE     hCard;
                             unsigned long         dwAttrId;
     [range(0, 65536)]       unsigned long         cbAttrLen;
     [size_is(cbAttrLen)]    const byte           *pbAttr;
 } SetAttrib_Call;
  
 typedef struct _ReadCache_Common
 {
     REDIR_SCARDCONTEXT              Context;
     UUID                           *CardIdentifier;
     unsigned long                   FreshnessCounter;
     long                            fPbDataIsNULL;
     unsigned long                   cbDataLen;
 } ReadCache_Common;
  
 typedef struct _ReadCacheA_Call
 {
     [string] char *                          szLookupName;
              ReadCache_Common                Common;
 } ReadCacheA_Call;
  
 typedef struct _ReadCacheW_Call
 {
     [string] wchar_t *                       szLookupName;
              ReadCache_Common                Common;
 } ReadCacheW_Call;
  
 typedef struct _ReadCache_Return
 {
                                     long           ReturnCode;
     [range(0, 65536)]               unsigned long  cbDataLen;
     [unique] [size_is(cbDataLen)]   byte          *pbData;
 } ReadCache_Return;
  
 typedef struct _WriteCache_Common
 {
                            REDIR_SCARDCONTEXT  Context;
                            UUID               *CardIdentifier;
                            unsigned long       FreshnessCounter;
     [range(0, 65536)]      unsigned long       cbDataLen;
     [unique] [size_is(cbDataLen)]   byte      *pbData;
 } WriteCache_Common;
  
 typedef struct _WriteCacheA_Call
 {
     [string] char *                szLookupName;
              WriteCache_Common     Common;
 } WriteCacheA_Call;
  
 typedef struct _WriteCacheW_Call
 {
     [string] wchar_t *             szLookupName;
              WriteCache_Common     Common;
 } WriteCacheW_Call;
 }