[Pcsclite-muscle] Dual Interface Reader
Dennis Rieks
dennis.rieks at agido.com
Tue Jan 30 04:26:11 PST 2018
Hello,
it is possible to disable the contactless switch off using SCardControl
with escape command 0x9C 0x01. The setting is active as long as the
reader is turned on.
Greetings
Dennis
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winscard.h>
#include <reader.h>
#define IOCTL_CCID_ESCAPE SCARD_CTL_CODE(0xDAC)
unsigned const char CNTLESS_SWITCH_RF_ON_OFF[] = {0x9C, 0x01};
#define PCSC_ERROR_EXIT(rv, text) \
if (rv != SCARD_S_SUCCESS) { \
printf(text ": %s (0x%lX)\n", pcsc_stringify_error(rv), rv); \
return 1; \
}
int main(int argc, char *argv[]) {
LONG rv;
SCARDCONTEXT hContext;
DWORD dwReaders;
LPSTR mszReaders = NULL;
char *ptr;
SCARDHANDLE hCard;
DWORD dwActiveProtocol;
rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
PCSC_ERROR_EXIT(rv, "SCardEstablishContext");
rv = SCardListReaders(hContext, NULL, NULL, &dwReaders);
PCSC_ERROR_EXIT(rv, "SCardListReaders")
mszReaders = malloc(sizeof(char) * dwReaders);
if (mszReaders == NULL) {
printf("malloc: not enough memory\n");
return 1;
}
rv = SCardListReaders(hContext, NULL, mszReaders, &dwReaders);
PCSC_ERROR_EXIT(rv, "SCardListReaders")
ptr = mszReaders;
while (*ptr != '\0') {
rv = SCardConnect(hContext, ptr, SCARD_SHARE_DIRECT,
SCARD_PROTOCOL_UNDEFINED, &hCard,
&dwActiveProtocol);
PCSC_ERROR_EXIT(rv, "SCardConnect")
rv = SCardControl(hCard, IOCTL_CCID_ESCAPE,
CNTLESS_SWITCH_RF_ON_OFF, sizeof(CNTLESS_SWITCH_RF_ON_OFF),
NULL, 0, NULL);
if (rv == SCARD_S_SUCCESS) {
printf("successfully set CNTLESS_SWITCH_RF_ON_OFF for
reader '%s'\n", ptr);
return 0;
}
ptr += strlen(ptr) + 1;
}
printf("No reader found\n");
return 1;
}
--
Dennis Rieks
agido GmbH
Hafenpromenade 3a
44263 Dortmund
Fon: +49-231-399802-70
Fax: +49-231-399802-69
Skype: dennisrieks
http://www.agido.com/
http://www.facebook.com/agido
Amtsgericht Dortmund: HRB 20179
USt-IdNr.: DE287205768
Geschäftsführer: Thomas Louis
More information about the pcsclite-muscle
mailing list