PCSC API spy for GNU systems
Executive summary
- Copy the file ltrace.conf to
~/.ltrace.conf
- Use with:
ltrace -l/usr/lib/libpcsclite.so your_application
Discussion
It may be difficult to debug a PC/SC application. You can ask
pcscd
to generate logs using --debug
but these logs are mainly to trace problems at the reader level, not at the application level.ltrace
ltrace (wikipedia)
ltrace is a debugging utility in Linux to monitor the library calls used by a program and all the signals it receives. It can also show system calls, used by a program.
It is easy to use ltrace to trace a program. I will use the testpcsc program included in pcsc-lite as a PC/SC sample code:
$ ltrace .libs/testpcsc
__libc_start_main(0x8048c5a, 1, 0xbfdfadb4, 0x8049dc0, 0x8049db0
puts("\nMUSCLE PC/SC Lite unitary test "...
MUSCLE PC/SC Lite unitary test Program
) = 41
puts("\033[35mTHIS PROGRAM IS NOT DESIGNE"...THIS PROGRAM IS NOT DESIGNED AS A TESTING TOOL FOR END USERS!
) = 67
printf("Do NOT use it unless you really "...Do NOT use it unless you really know what you do.
) = 55
printf("Testing SCardEstablishContext\t:"...) = 32
SCardEstablishContext(2, 0, 0, 0xbfdfacd8, 0) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xb778780d, 0xb7764ff4, 0) = 0xb778c340
puts("Command successful."Testing SCardEstablishContext : Command successful.
) = 20
printf("Testing SCardIsValidContext\t: ") = 30
SCardIsValidContext(0x103a3a0, 0x103a3a0, 0, 0xbfdfacd8, 0) = 0
pcsc_stringify_error(0, 0, 0xbfdfa568, 0xb77855ce, 0x103a3a0) = 0xb778c340
puts("Command successful."Testing SCardIsValidContext : Command successful.
) = 20
printf("Testing SCardIsValidContext\t: ") = 30
SCardIsValidContext(0x103a3a1, 0x103a3a0, 0, 0xbfdfacd8, 0) = 0x80100003
pcsc_stringify_error(0x80100003, 0, 0xbfdfa568, 0xb77855ce, 0xbfdfa574) = 0xb778c340
printf("\033[34m%s (don't panic)\n\033[0"..., "Invalid handle."Testing SCardIsValidContext : Invalid handle. (don't panic)
) = 39
printf("Testing SCardListReaderGroups\t:"...) = 32
SCardListReaderGroups(0x103a3a0, 0xbfdfac08, 0xbfdfac04, 0xbfdfacd8, 0) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfac08, 0xb7764ff4, 0) = 0xb778c340
puts("Command successful."Testing SCardListReaderGroups : Command successful.
) = 20
printf("\033[32mGroup %02d: %s\n\033[0m", 1, "SCard$DefaultReaders"Group 01: SCard$DefaultReaders
) = 40
printf("Testing SCardFreeMemory\t\t: ") = 27
SCardFreeMemory(0x103a3a0, 0x96ea0f8, 0x96ea0f8, 0xbfdfacd8, 0) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0x96ea0f8, 0xb77855e0, 0xb77855e9) = 0xb778c340
puts("Command successful."Testing SCardFreeMemory : Command successful.
) = 20
printf("Testing SCardListReaders\t: ") = 27
SCardListReaders(0x103a3a0, 0, 0, 0xbfdfac88, 0) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0, 0xb7764ff4, 0) = 0xb778c340
puts("Command successful."Testing SCardListReaders : Command successful.
) = 20
printf("Testing SCardListReaders\t: ") = 27
SCardListReaders(0x103a3a0, 0, 0xbfdfac80, 0xbfdfac88, 0) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0xbfdfac88, 0) = 0xb778c340
puts("Command successful."Testing SCardListReaders : Command successful.
) = 20
printf("\033[32mReader %02d: %s\n\033[0m", 1, "Lenovo Integrated Smart Card Rea"...Reader 01: Lenovo Integrated Smart Card Reader 00 00
) = 62
printf("Waiting for card insertion\t: ") = 29
fflush(0xb77654c0Waiting for card insertion : ) = 0
SCardGetStatusChange(0x103a3a0, -1, 0xbfdfaca0, 1, 0) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfaca0, 0xbfdfac88, 0) = 0xb778c340
puts("Command successful."Command successful.
) = 20
printf("Testing SCardConnect\t\t: ") = 24
SCardConnect(0x103a3a0, 0x96ea118, 2, 3, 0xbfdfacdc) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfacdc, 0xbfdfac88, 0) = 0xb778c340
puts("Command successful."Testing SCardConnect : Command successful.
) = 20
printf("Select file:") = 12
memcpy(0xbfdfaaa8, "", 7) = 0xbfdfaaa8
printf(" %02X", 0) = 3
printf(" %02X", 0xa4) = 3
printf(" %02X", 0) = 3
printf(" %02X", 0) = 3
printf(" %02X", 0x2) = 3
printf(" %02X", 0x3f) = 3
printf(" %02X", 0) = 3
putchar(10, 0, 7, 3, 0xbfdfacdcSelect file: 00 A4 00 00 02 3F 00
) = 10
printf("Testing SCardTransmit\t\t: ") = 25
SCardTransmit(105074, 0xbfdfabb0, 0xbfdfaaa8, 7, 0xbfdfabb8) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfabb0, 0xbfdfac88, 0) = 0xb778c340
puts("Command successful."Testing SCardTransmit : Command successful.
) = 20
printf(" card response:\033[32m") = 20
printf(" %02X", 0x6f) = 3
printf(" %02X", 0x14) = 3
printf(" %02X", 0x84) = 3
printf(" %02X", 0xd) = 3
printf(" %02X", 0x70) = 3
printf(" %02X", 0x3c) = 3
printf(" %02X", 0x71) = 3
printf(" %02X", 0xb7) = 3
printf(" %02X", 0x6c) = 3
printf(" %02X", 0x3a) = 3
printf(" %02X", 0x8) = 3
printf(" %02X", 0x9) = 3
printf(" %02X", 0x2f) = 3
printf(" %02X", 0x2d) = 3
printf(" %02X", 0x73) = 3
printf(" %02X", 0xb7) = 3
printf(" %02X", 0xff) = 3
printf(" %02X", 0xa5) = 3
printf(" %02X", 0x3) = 3
printf(" %02X", 0x88) = 3
printf(" %02X", 0x1) = 3
printf(" %02X", 0) = 3
printf(" %02X", 0x90) = 3
printf(" %02X", 0) = 3
printf("\n\033[0m" card response: 6F 14 84 0D 70 3C 71 B7 6C 3A 08 09 2F 2D 73 B7 FF A5 03 88 01 00 90 00
) = 5
printf("Testing SCardControl\t\t: ") = 24
SCardControl(105074, 0x42000001, 0xbfdfa598, 1, 0xbfdfa598) = 0x80100016
pcsc_stringify_error(0x80100016, 0xb77b73a0, 0xbfdfa598, 0xbfdfa598, 0) = 0xb778c340
printf("\033[34m%s (don't panic)\n\033[0"..., "Transaction failed."Testing SCardControl : Transaction failed. (don't panic)
) = 43
printf("Testing SCardGetAttrib\t\t: ") = 26
SCardGetAttrib(105074, 0x7fff0003, 0xbfdfac10, 0xbfdfac0c, 0xbfdfa598) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfac10, 0xbfdfa598, 0) = 0xb778c340
puts("Command successful."Testing SCardGetAttrib : Command successful.
) = 20
printf("SCARD_ATTR_DEVICE_FRIENDLY_NAME:"...SCARD_ATTR_DEVICE_FRIENDLY_NAME: Lenovo Integrated Smart Card Reader 00 00
) = 84
printf("Testing SCardFreeMemory\t\t: ") = 27
SCardFreeMemory(0x103a3a0, 0x96ea198, 1, 0xbfdfac0c, 0xbfdfa598) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0x8049fbe, 0xb77855e9) = 0xb778c340
puts("Command successful."Testing SCardFreeMemory : Command successful.
) = 20
printf("Testing SCardGetAttrib\t\t: ") = 26
SCardGetAttrib(105074, 590595, 0xbfdfac10, 0xbfdfac0c, 0xbfdfa598) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0xbfdfa598, 0) = 0xb778c340
puts("Command successful."Testing SCardGetAttrib : Command successful.
) = 20
printf("SCARD_ATTR_ATR_STRING length: \033"...SCARD_ATTR_ATR_STRING length: 23
) = 42
printf("SCARD_ATTR_ATR_STRING: \033[32m") = 28
printf("%02X ", 0x3b) = 3
printf("%02X ", 0x9f) = 3
printf("%02X ", 0x95) = 3
printf("%02X ", 0x81) = 3
printf("%02X ", 0x31) = 3
printf("%02X ", 0xfe) = 3
printf("%02X ", 0x9f) = 3
printf("%02X ", 0) = 3
printf("%02X ", 0x65) = 3
printf("%02X ", 0x46) = 3
printf("%02X ", 0x53) = 3
printf("%02X ", 0x5) = 3
printf("%02X ", 0x30) = 3
printf("%02X ", 0x6) = 3
printf("%02X ", 0x71) = 3
printf("%02X ", 0xdf) = 3
printf("%02X ", 0) = 3
printf("%02X ", 0) = 3
printf("%02X ", 0) = 3
printf("%02X ", 0x81) = 3
printf("%02X ", 0x61) = 3
printf("%02X ", 0x16) = 3
printf("%02X ", 0xc0) = 3
printf("\n\033[0m"SCARD_ATTR_ATR_STRING: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 16 C0
) = 5
printf("Testing SCardFreeMemory\t\t: ") = 27
SCardFreeMemory(0x103a3a0, 0x96ea198, 1, 0xbfdfac0c, 0xbfdfa598) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0x8049fbe, 0xb77855e9) = 0xb778c340
puts("Command successful."Testing SCardFreeMemory : Command successful.
) = 20
printf("Testing SCardGetAttrib\t\t: ") = 26
SCardGetAttrib(105074, 65794, 0xbfdfac18, 0xbfdfac14, 0xbfdfa598) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0xbfdfa598, 0) = 0xb778c340
puts("Command successful."Testing SCardGetAttrib : Command successful.
) = 20
printf("Vendor IFD version\t\t: \033[32m"...Vendor IFD version : 0x0103000D
) = 42
printf("Testing SCardGetAttrib\t\t: ") = 26
SCardGetAttrib(105074, 499719, 0xbfdfac18, 0xbfdfac14, 0xbfdfa598) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0xbfdfa598, 0) = 0xb778c340
puts("Command successful."Testing SCardGetAttrib : Command successful.
) = 20
printf("Max message length\t\t: \033[32m"..., 261Max message length : 261
) = 35
printf("Testing SCardGetAttrib\t\t: ") = 26
SCardGetAttrib(105074, 65792, 0xbfdfac18, 0xbfdfac14, 0xbfdfa598) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0xbfdfa598, 0) = 0xb778c340
puts("Command successful."Testing SCardGetAttrib : Command successful.
) = 20
printf("Vendor name\t\t\t: \033[32m%s\n\033"..., "Ludovic Rousseau"Vendor name : Ludovic Rousseau
) = 42
printf("Testing SCardSetAttrib\t\t: ") = 26
SCardSetAttrib(105074, 590595, 0x804a2ab, 1, 0xbfdfa598) = 0x80100016
pcsc_stringify_error(0x80100016, 0x804a2ab, 0xbfdfa57c, 0xb77867a0, 105074) = 0xb778c340
printf("\033[34m%s (don't panic)\n\033[0"..., "Transaction failed."Testing SCardSetAttrib : Transaction failed. (don't panic)
) = 43
printf("Testing SCardStatus\t\t: ") = 23
SCardStatus(105074, 0xbfdfac84, 0xbfdfac9c, 0xbfdfac98, 0xbfdfac94) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfac84, 0xbfdfac90, 0) = 0xb778c340
puts("Command successful."Testing SCardStatus : Command successful.
) = 20
printf("Current Reader Name\t\t: \033[32"..., "Lenovo Integrated Smart Card Rea"...Current Reader Name : Lenovo Integrated Smart Card Reader 00 00
) = 74
printf("Current Reader State\t\t: \033[3"...Current Reader State : 0x10034
) = 41
printf("Current Reader Protocol\t\t: T=\033"...Current Reader Protocol : T=1
) = 40
printf("Current Reader ATR Size\t\t: \033"...Current Reader ATR Size : 23 bytes
) = 45
printf("Current Reader ATR Value\t: \033"...) = 32
printf("%02X ", 0x3b) = 3
printf("%02X ", 0x9f) = 3
printf("%02X ", 0x95) = 3
printf("%02X ", 0x81) = 3
printf("%02X ", 0x31) = 3
printf("%02X ", 0xfe) = 3
printf("%02X ", 0x9f) = 3
printf("%02X ", 0) = 3
printf("%02X ", 0x65) = 3
printf("%02X ", 0x46) = 3
printf("%02X ", 0x53) = 3
printf("%02X ", 0x5) = 3
printf("%02X ", 0x30) = 3
printf("%02X ", 0x6) = 3
printf("%02X ", 0x71) = 3
printf("%02X ", 0xdf) = 3
printf("%02X ", 0) = 3
printf("%02X ", 0) = 3
printf("%02X ", 0) = 3
printf("%02X ", 0x81) = 3
printf("%02X ", 0x61) = 3
printf("%02X ", 0x16) = 3
printf("%02X ", 0xc0) = 3
puts("\033[0m"Current Reader ATR Value : 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 16 C0
) = 5
printf("Testing SCardFreeMemory\t\t: ") = 27
SCardFreeMemory(0x103a3a0, 0x96ea198, 0, 0xbfdfac98, 0xbfdfac94) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0x8049fbe, 0xb77855e9) = 0xb778c340
puts("Command successful."Testing SCardFreeMemory : Command successful.
) = 20
printf("Testing SCardFreeMemory\t\t: ") = 27
SCardFreeMemory(0x103a3a0, 0x96ea0f8, 0, 0xbfdfac98, 0xbfdfac94) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0x8049fbe, 0xb77855e9) = 0xb778c340
puts("Command successful."Testing SCardFreeMemory : Command successful.
) = 20
printf("Press enter: ") = 13
getchar(0x804a396, 0x103a3a0, 0, 0xbfdfac98, 0xbfdfac94Press enter:
) = 10
printf("Testing SCardReconnect\t\t: ") = 26
SCardReconnect(105074, 2, 3, 2, 0xbfdfac8c) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfac8c, 0xbfdfac90, 0) = 0xb778c340
puts("Command successful."Testing SCardReconnect : Command successful.
) = 20
printf("Testing SCardDisconnect\t\t: ") = 27
SCardDisconnect(105074, 2, 0, 2, 0xbfdfac8c) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfa4b4, 0xbfdfac90, 0) = 0xb778c340
puts("Command successful."Testing SCardDisconnect : Command successful.
) = 20
printf("Testing SCardFreeMemory\t\t: ") = 27
SCardFreeMemory(0x103a3a0, 0x96ea118, 0, 2, 0xbfdfac8c) = 0
pcsc_stringify_error(0, 0xb7669260, 0xb77654c0, 0x8049fbe, 0xb77855e9) = 0xb778c340
puts("Command successful."Testing SCardFreeMemory : Command successful.
) = 20
printf("Testing SCardReleaseContext\t: ") = 30
SCardReleaseContext(0x103a3a0, 0x103a3a0, 0, 2, 0xbfdfac8c) = 0
pcsc_stringify_error(0, 0xb77b73a0, 0xbfdfa4b4, 0xbfdfac90, 0) = 0xb778c340
puts("Command successful."Testing SCardReleaseContext : Command successful.
) = 20
putchar(10, 0x103a3a0, 0, 2, 0xbfdfac8c
) = 10
puts("PC/SC Test Completed Successfull"...PC/SC Test Completed Successfully !
) = 36
+++ exited (status 0) +++
Limitations
By default ltrace lists all the calls from all the libraries. You can restrict the tracing to one specific library using:
-l/usr/lib/libpcsclite.so
The PC/SC API calls are not really useful. You have to parse the argument by hand. It is not easy to know what
SCardConnect(0x103a3a0, 0x96ea118, 2, 3, 0xbfdfacdc) = 0
is really doing.ltrace PCSC configuration file
ltrace can use a configuration file to parse the arguments of the functions and display a (more) human readable version.
The configuration file uses a very simple format. For example for
SCardConnect
I used:scarderror SCardConnect(scardcontext, string, share_mode, protocol, +scardhandle*, +protocol*);
A ltrace configuration file is now included in the pcsc-lite project in the new contrib/ directory. Just copy the file to
~/.ltrace.conf
.Example with the configuration file
$ ltrace -l/usr/lib/libpcsclite.so .libs/testpcsc
MUSCLE PC/SC Lite unitary test Program
THIS PROGRAM IS NOT DESIGNED AS A TESTING TOOL FOR END USERS!
Do NOT use it unless you really know what you do.
SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, 0x103d6cb) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardEstablishContext : Command successful.
SCardIsValidContext(0x103d6cb) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardIsValidContext : Command successful.
SCardIsValidContext(0x103d6cc) = SCARD_E_INVALID_HANDLE
pcsc_stringify_error(SCARD_E_INVALID_HANDLE) = "Invalid handle."
Testing SCardIsValidContext : Invalid handle. (don't panic)
SCardListReaderGroups(0x103d6cb, "SCard$DefaultReaders", 22) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardListReaderGroups : Command successful.
Group 01: SCard$DefaultReaders
SCardFreeMemory(0x103d6cb, 0x09eb70f8) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardFreeMemory : Command successful.
SCardListReaders(0x103d6cb, NULL, NULL, 43) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardListReaders : Command successful.
SCardListReaders(0x103d6cb, NULL, "Lenovo Integrated Smart Card Rea"..., 43) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardListReaders : Command successful.
Reader 01: Lenovo Integrated Smart Card Reader 00 00
Waiting for card insertion : SCardGetStatusChange(0x103d6cb, -1, { "Lenovo Integrated Smart Card Rea"..., 0x00000001, 16, 34, 23, [ ';', '\237', '\225', '\201'... ] }, 1) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Command successful.
SCardConnect(0x103d6cb, "Lenovo Integrated Smart Card Rea"..., SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0_SCARD_PROTOCOL_T1, 126261, SCARD_PROTOCOL_T1) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardConnect : Command successful.
Select file: 00 A4 00 00 02 3F 00
SCardTransmit(126261, { SCARD_PROTOCOL_T1, 8 }, [ '\000', '\244', '\000', '\000'... ], 7, { 0xbfe04130, -1216591178 }, 'o', 24) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardTransmit : Command successful.
card response: 6F 14 84 0D 70 3C 71 B7 6C 3A 08 09 2F 2D 73 B7 FF A5 03 88 01 00 90 00
SCardControl(126261, 1107296257, [ '\002' ], 1, [ '\002', '\000', '\000', '\000'... ], 1024, 0) = SCARD_E_NOT_TRANSACTED
pcsc_stringify_error(SCARD_E_NOT_TRANSACTED) = "Transaction failed."
Testing SCardControl : Transaction failed. (don't panic)
SCardGetAttrib(126261, SCARD_ATTR_DEVICE_FRIENDLY_NAME, [ ], 42) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardGetAttrib : Command successful.
SCARD_ATTR_DEVICE_FRIENDLY_NAME: Lenovo Integrated Smart Card Reader 00 00
SCardFreeMemory(0x103d6cb, 0x09eb7198) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardFreeMemory : Command successful.
SCardGetAttrib(126261, SCARD_ATTR_ATR_STRING, [ ], 23) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardGetAttrib : Command successful.
SCARD_ATTR_ATR_STRING length: 23
SCARD_ATTR_ATR_STRING: 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 16 C0
SCardFreeMemory(0x103d6cb, 0x09eb7198) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardFreeMemory : Command successful.
SCardGetAttrib(126261, SCARD_ATTR_VENDOR_IFD_VERSION, [ ], 4) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardGetAttrib : Command successful.
Vendor IFD version : 0x0103000D
SCardGetAttrib(126261, SCARD_ATTR_MAXINPUT, [ ], 4) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardGetAttrib : Command successful.
Max message length : 261
SCardGetAttrib(126261, SCARD_ATTR_VENDOR_NAME, [ ], 17) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardGetAttrib : Command successful.
Vendor name : Ludovic Rousseau
SCardSetAttrib(126261, SCARD_ATTR_ATR_STRING, , 1) = SCARD_E_NOT_TRANSACTED
pcsc_stringify_error(SCARD_E_NOT_TRANSACTED) = "Transaction failed."
Testing SCardSetAttrib : Transaction failed. (don't panic)
SCardStatus(126261, "Lenovo Integrated Smart Card Rea"..., 42, 52, SCARD_PROTOCOL_T1, [ '\370', 'p', '\353', '\t'... ], 23) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardStatus : Command successful.
Current Reader Name : Lenovo Integrated Smart Card Reader 00 00
Current Reader State : 0x0034
Current Reader Protocol : T=1
Current Reader ATR Size : 23 bytes
Current Reader ATR Value : 3B 9F 95 81 31 FE 9F 00 65 46 53 05 30 06 71 DF 00 00 00 81 61 16 C0
SCardFreeMemory(0x103d6cb, 0x09eb7198) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardFreeMemory : Command successful.
SCardFreeMemory(0x103d6cb, 0x09eb70f8) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardFreeMemory : Command successful.
Press enter:
SCardReconnect(126261, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0_SCARD_PROTOCOL_T1, SCARD_UNPOWER_CARD, SCARD_PROTOCOL_T1) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardReconnect : Command successful.
SCardDisconnect(126261, SCARD_UNPOWER_CARD) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardDisconnect : Command successful.
SCardFreeMemory(0x103d6cb, 0x09eb7118) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardFreeMemory : Command successful.
SCardReleaseContext(0x103d6cb) = SCARD_S_SUCCESS
pcsc_stringify_error(SCARD_S_SUCCESS) = "Command successful."
Testing SCardReleaseContext : Command successful.
PC/SC Test Completed Successfully !
+++ exited (status 0) +++
- Call to other libraries (lib C in particular) are no more displayed
- PCSC functions arguments are displayed in a human form
If I reuse the same
SCardConnect
example we now have:SCardConnect(0x103d6cb, "Lenovo Integrated Smart Card Rea"..., SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0_SCARD_PROTOCOL_T1, 126261, SCARD_PROTOCOL_T1) = SCARD_S_SUCCESS
We get:
- Connection context to the PC/SC Resource Manager. It is just a random numeric value:
0x103d6cb
- Reader name to connect to:
"Lenovo Integrated Smart Card Rea"...
- Mode of connection type: exclusive or shared.
SCARD_SHARE_SHARED
- Desired protocol use:
SCARD_PROTOCOL_T0_SCARD_PROTOCOL_T1
- Handle to this connection:
126261
- Established protocol to this connection:
SCARD_PROTOCOL_T1
- Return code:
SCARD_S_SUCCESS
Conclusion
I discovered the use of ltrace very recently. The configuration file may contain bugs. But I hope it will be useful.