Skip to content

Examples for OS MS Windows

Petr Svenda edited this page Aug 4, 2018 · 1 revision

Examples for OS MS Windows

This page shows example configuration of APDUPlay for the different usage scenarios.

Version check: The APDUPlay library is available in both 32- and 64-bit version. You must to use the correct version corresponding to your application (32/64). Find out if your application requires 32- or 64-bit winscard.dll (e.g., using Sigcheck utility)

Example 1: Simple application directly using winscard.dll

Example application: (CAProfiler.exe)

  1. Find out if your application requires 32- or 64-bit winscard.dll (Sigcheck utility)
  2. Copy Microsoft's original winscard.dll library to a target application folder and rename it to original32.dll or original64.dll (based on Step 1).
  3. Place APDUPlay's custom winscard.dll library to a target application folder, so it is loaded first.
  4. Place configuration file named winscard_rules.txt into the same folder.

The target application folder should now look like this (CAProfiler_64b.exe used as an example)

.
..
CAProfiler_64b.exe       <---- target application (64-bit)
original64.dll           <---- original Microsoft's winscard.dll copied from C:\System\System32\
Winscard.dll             <---- APDUPlay's stub winscard.dll (64-bit)
winscard_rules.txt       <---- configuration file loaded by APDUPlay's stub winscard.dll

The simple example content of winscard_rules.txt file should look like:

[WINSCARD]
LOG_EXCHANGED_APDU = 1
LOG_BASE_PATH = ./
  1. Now run target application (CAProfiler_64b.exe in this example). The application should execute normally.
>CAProfiler_64b.exe
Available readers:
1. Generic EMV Smartcard Reader 0
2. Simona /111.222.123.033@07
... 
The following applets were detected:
APPLET_AID_JCOP_CM             : a0 00 00 00 03 00 00 00
APPLET_AID_VISA_PREFIX         : a0 00 00 00 03
  1. Inspect the generated files with an intercepted communication (winscard_log.txt, apduplay_debug.txt ...).
[begin]
SCardTransmit (handle 0x00000000)#
apduCounter:0#
totalBytesINCounter:1#
transmitted:00 a4 04 00 05 a0 00 00 00 03 00
responseTime:12#
SCardTransmit result:0x0#
received:6f 10 84 08 a0 00 00 00 03 00 00 00 a5 04 9f 65 01 ff 90 00

SCardTransmit (handle 0x00000000)#
apduCounter:1#
totalBytesINCounter:12#
transmitted:00 a4 04 00 05 a0 00 00 00 04 00
responseTime:9#
SCardTransmit result:0x0#
received:6a 82
...
  1. (Optional) Inspect other APDUPlay features like APDU commands modification or redirection to remote socket proxy.

The installation and usage process is relatively simple, but may be little tricky if something does not work (e.g., the library is loaded from a different than an expected path, the application terminates without giving any error message, etc.). The first step is always to make sure that APDUPlay's stub library is used together with the correct winscard_rules.txt. See Examples section for detailed step-by-step installation and troubleshooting.

Example 2: Application with persistent agent

Example application: gpg2.exe --card-edit

TODO

Example 2: Java-based application accessing smartcards via JRE

Example application: GlobalPlatformPro gp -l

TODO