Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

DWORD  dwControlCode,
LPCVOID  pbSendBuffer,
DWORD  cbSendLength,
LPVOID  pbRecvBuffer,
DWORD  cbRecvLength,
LPDWORD  lpBytesReturned 

This function sends a command directly to the IFD Handler to be processed by the reader.

This is useful for creating client side reader drivers for functions like PIN pads, biometrics, or other extensions to the normal smart card reader that are not normally handled by PC/SC.

the API of this function changed. In pcsc-lite 1.2.0 and before the API was not Windows(R) PC/SC compatible. This has been corrected.
[in] hCard Connection made from SCardConnect.
[in] dwControlCode Control code for the operation.
Click here for a list of supported commands by some drivers.
[in] pbSendBuffer Command to send to the reader.
[in] cbSendLength Length of the command.
[out] pbRecvBuffer Response from the reader.
[in] cbRecvLength Length of the response buffer.
[out] lpBytesReturned Length of the response.
Error code.
Return values:
SCARD_E_NOT_TRANSACTED Data exchange not successful.
SCARD_E_INVALID_HANDLE Invalid hCard handle.
SCARD_E_INVALID_VALUE Invalid value was presented.
SCARD_E_READER_UNAVAILABLE The reader has been removed.
SCARD_W_RESET_CARD The card has been reset by another application.
SCARD_W_REMOVED_CARD The card has been removed from the reader.
 LONG rv;
 DWORD dwActiveProtocol, dwSendLength, dwRecvLength;
 BYTE pbRecvBuffer[10];
 BYTE pbSendBuffer[] = { 0x06, 0x00, 0x0A, 0x01, 0x01, 0x10 0x00 };
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
 rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_RAW &hCard, &dwActiveProtocol);
 dwSendLength = sizeof(pbSendBuffer);
 dwRecvLength = sizeof(pbRecvBuffer);
 rv = SCardControl(hCard, 0x42000001, pbSendBuffer, dwSendLength, pbRecvBuffer, sizeof(pbRecvBuffer), &dwRecvLength);

Definition at line 1192 of file winscard.c.

References control_struct::cbRecvLength, control_struct::cbSendLength, rxSharedSegment::data, control_struct::dwBytesReturned, control_struct::dwControlCode, control_struct::hCard, MAX_BUFFER_SIZE, control_struct::pbRecvBuffer, control_struct::pbSendBuffer, PCSCLITE_CLIENT_ATTEMPTS, PCSCLITE_MAX_READERS_CONTEXTS, _psContextMap::psChannelMap, psContextMap, _psChannelMap::readerName, control_struct::rv, SCardCheckDaemonAvailability(), SHMClientRead(), SYS_MutexLock(), SYS_MutexUnLock(), and WrapSHMWrite().

Referenced by MSGFunctionDemarshall().

      LONG rv;
      PREADER_CONTEXT rContext = NULL;

      /* 0 bytes returned by default */
      *lpBytesReturned = 0;

      if (0 == hCard)
            return SCARD_E_INVALID_HANDLE;

       * Make sure no one has a lock on this reader
      if ((rv = RFCheckSharing(hCard)) != SCARD_S_SUCCESS)
            return rv;

      rv = RFReaderInfoById(hCard, &rContext);
      if (rv != SCARD_S_SUCCESS)
            return rv;

      if (IFD_HVERSION_2_0 == rContext->dwVersion)
            if (NULL == pbSendBuffer || 0 == cbSendLength)
                  return SCARD_E_INVALID_PARAMETER;

       * Make sure the reader is working properly
      rv = RFCheckReaderStatus(rContext);
      if (rv != SCARD_S_SUCCESS)
            return rv;

      rv = RFFindReaderHandle(hCard);
      if (rv != SCARD_S_SUCCESS)
            return rv;

       * Make sure some event has not occurred
      if ((rv = RFCheckReaderEventState(rContext, hCard)) != SCARD_S_SUCCESS)
            return rv;

      if (cbSendLength > MAX_BUFFER_SIZE)

      if (IFD_HVERSION_2_0 == rContext->dwVersion)
            /* we must wrap a API 3.0 client in an API 2.0 driver */
            *lpBytesReturned = cbRecvLength;
            return IFDControl_v2(rContext, (PUCHAR)pbSendBuffer,
                  cbSendLength, pbRecvBuffer, lpBytesReturned);
            if (IFD_HVERSION_3_0 == rContext->dwVersion)
                  return IFDControl(rContext, dwControlCode, pbSendBuffer,
                        cbSendLength, pbRecvBuffer, cbRecvLength, lpBytesReturned);
                  return SCARD_E_UNSUPPORTED_FEATURE;

Generated by  Doxygen 1.6.0   Back to index