Skip to content

Commit 4bbfa4f

Browse files
authored
Merge pull request #10 from crocs-muni/devel
Devel
2 parents 10f0d2b + a9ff172 commit 4bbfa4f

16 files changed

+769
-565
lines changed

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,37 @@ The APDUPlay project is providing following functionality:
2121
See more details at https://github.com/petrs/APDUPlay/wiki.
2222

2323
## Installation
24-
1. Find out if your targeted application is 32- or 64-bit [(howto)](https://superuser.com/questions/103071/quick-way-to-tell-if-an-installed-application-is-64-bit-or-32-bit#103073).
25-
1. Copy Winscard.dll from your system folder (c:\Windows\winscard.dll for 32-bit target application or c:\Windows\SysWOW64\winscard.dll for 64-bit application) to the folder with target application and rename it to original32.dll or original64.dll respectively
24+
1. Find out if your targeted application is 32- or 64-bit [(Use Microsoft Sysinternals Sigcheck utility)](https://docs.microsoft.com/en-us/sysinternals/downloads/sigcheck). Run sigcheck.exe targetApp.exe and look for MachineType: 32-bit or 64-bit (works also for dll files)
25+
1. Copy Winscard.dll from your system folder (c:\Windows\System32\winscard.dll for 64-bit target application (if you are running 64-bit OS) or c:\Windows\SysWOW64\winscard.dll for 32-bit application) to the folder with target application and rename it to original32.dll or original64.dll respectively. NOTE: c:\Windows\System32\ will contain either 32-bit or 64-bit version based on your OS.
2626
2. Copy Winscard.dll from APDUPlay project to the folder with target application (the folder should contain winscard.dll binary from APDUPlay project AND originalXX.dll which is original Microsoft's winscard.dll)
2727
3. Run the application and inspect resulting files winscard_log.txt and winscard_rules_log.txt
2828
4. (Optional) Change configuration file winscard_rules.txt to modify default behavior (see below)
2929

30-
## Troubleshooting
30+
## Examples
3131

32-
* If you use (wrongly) 64bit version of library Microsoft's winscard.dll (renamed as original32.dll), it will fail with "The procedure entry point original.g_rgSCardT1Pci could not be located in the dynamic link library WinSCard.dll."
33-
32+
The localization of correct winscard.dll path can be tedious task for some applications. Here are some examples with increasing difficulty:
33+
1. Simple application directly using winscard.dll (CAProfiler)
34+
2. Application with persistent agent (gpg2.exe --card-edit)
35+
3. Java-based application accessing smartcards via JRE: (GlobalPlatformPro gp -l)
3436

3537

38+
## Troubleshooting
39+
40+
* Problem: After running target application, the following error message is displayed: "The procedure entry point original.g_rgSCardT1Pci could not be located in the dynamic link library WinSCard.dll.". You likely mismatched 64-bit and 32-bit versions of APDUPlay's winscard.dll and Microsoft's original library (renamed as original32.dll). Use [Microsoft Sysinternals Sigcheck utility](https://docs.microsoft.com/en-us/sysinternals/downloads/sigcheck) to verify that both libraries as either 64-bit or 32-bit (based on your target application needs).
41+
42+
* Problem: Target application is (probably) not loading modified winscard.dll from APDUPlay project, but uses standard Microsoft's one from system folder (no files with logged communication are created). Use [Process Monitor utility]( https://docs.microsoft.com/en-us/sysinternals/downloads/procmon) from Microsoft to find location of loaded libraries (use Filter option to limit results only to target application: CTRL+L -> Process Name is 'targetApp.exe' -> Add). Search for event 'Load Image path_to_folder\Winscard.dll'. The path_to_folder should point to APDUPlay's version of winscard.dll, not Microsoft one.
43+
44+
* Problem: Logging seems to work, but only for the first of application. When started again, changes done to winscard_rules.txt does not apply. Target application might have persistent component (e.g., GPG have gpg-agent.exe) which loads the dll (and rules from winscard_rules.txt) and runs even when target application is terminated. Try to locate and kill this component, or restart computer (will force component to restart again).
45+
46+
* Problem: Target application always opens winscard.dll from system folders (either system32 or sysWOW64 folder).
47+
Run cmd as admin, then:
48+
```
49+
cd target_folder (either system32 or sysWOW64)
50+
takeown /f winscard.dll
51+
cacls winscard.dll /G your_username:F
52+
rename winscard.dll to winscard_MS.dll (winscard.dll might be currently used by some other process so direct copy woudl not be possible)
53+
copy APDUPlay's winscard.dll instead winscard.dll
54+
```
3655

3756
Please, open an issue in case of any bug found.
3857

Winscard/CommonFnc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ int CCommonFnc::File_SaveMatrixInt(string_type filePath, INT_DATA_BLOB* pBlob, s
224224
}
225225
else {
226226
for (i = startOffset; i < endOffset; i++) {
227-
//value.Format("%d\r\n", pBlob->pData[i]);
228-
value = string_format(_CONV("%d\r\n"), pBlob->pData[i]);
227+
value = string_format(_CONV("%d\n"), pBlob->pData[i]);
229228
values += value;
230229

231230
if ((i % NUM_VALUES_PER_WRITE) == 0) {

Winscard/ReadMe.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ res\Winscard.rc2
3434
Visual C++. You should place all resources not editable by
3535
the resource editor in this file.
3636

37-
Winscard.def
37+
Winscard32.def or Winscard64.def
3838
This file contains information about the DLL that must be
3939
provided to run with Microsoft Windows. It defines parameters
4040
such as the name and description of the DLL. It also exports

0 commit comments

Comments
 (0)