Comments (10)
I also compiled the same project under the Windows platform and found that the SCardGetStatusChange for PNP notification returns the right value SCARD_S_SUCCESS as expected after run it under Windows platform.
This difference under different platforms may cause issue under VDI user scenario.
from pcsc-tools.
I can't reproduce your behavior on Windows.
I used this Python program:
#! /usr/bin/env python3
# SCardGetStatusChange.py : Unitary test for SCardGetStatusChange()
# Copyright (C) 2023 Ludovic Rousseau
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
from smartcard.scard import *
from smartcard.pcsc.PCSCExceptions import *
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
raise EstablishContextException(hresult)
reader="\\\\?PnP?\\Notification"
readerstates = {}
readerstates[reader] = (reader, SCARD_STATE_UNAWARE)
hresult, newstates = SCardGetStatusChange(hcontext, 0,
list(readerstates.values()))
if hresult != SCARD_S_SUCCESS:
raise BaseSCardException(hresult)
hresult = SCardReleaseContext(hcontext)
print("SCardReleaseContext()", SCardGetErrorMessage(hresult))
if hresult != SCARD_S_SUCCESS:
raise ReleaseContextException(hresult)
And on Windows I get:
(base) C:\Users\Ludovic\Downloads>python SCardGetStatusChange.py
Traceback (most recent call last):
File "C:\Users\Ludovic\Downloads\SCardGetStatusChange.py", line 33, in <module>
raise BaseSCardException(hresult)
smartcard.pcsc.PCSCExceptions.BaseSCardException: scard exception: Le délai d’attente spécifié par l’utilisateur a expiré. (0x8010000A)
I receive 0x8010000A (SCARD_E_TIMEOUT) and not 0 (SCARD_S_SUCCESS).
In your program I note you use _rgReaderStates[0]
and also rgReaderStates[0]
(without the _
).
Maybe the problem is a bug in your code.
from pcsc-tools.
Just as the way you mentioned how to compile the pcsc_scan.exe for Windows (https://ludovicrousseau.blogspot.com/2017/05/pcscscan-on-windows.html), I had compile it and put the exe into the attachment file.
Please see the attached screen, you can see the log screen shot:
git-modify.zip
you can use the compiled pcsc_scan exe to verify the result.
Why the SCardGetStatusChange has the different result under Linux and Windows platform?
from pcsc-tools.
Do not send me binary program. Send me the patch you used instead.
On my side I tried with this patch:
--- pcsc_scan.c 2023-02-11 12:33:09.000000000 +0100
+++ pcsc_scan.c 2023-04-10 11:09:24.000000000 +0200
@@ -525,6 +527,7 @@
rgReaderStates[0].dwCurrentState = SCARD_STATE_UNAWARE;
rv = SCardGetStatusChange(hContext, 0, rgReaderStates, 1);
+ printf("rv: %lx\n", rv);
if (rgReaderStates[0].dwEventState & SCARD_STATE_UNKNOWN)
{
if (Options.verbose)
And I confirm the returned value is SCARD_E_TIMEOUT
on my Winows 10.
I get:
$ ./pcsc_scan.exe
PC/SC device scanner
V 1.6.2 (c) 2001-2022, Ludovic Rousseau <[email protected]>
Press shift key to quit
rv: 8010000a
Using reader plug'n play mechanism
from pcsc-tools.
It is true that I modify the code as your patch do:
adding printf("SCardGetStatusChange for PNP notification result = %lu\n", rv) at line 528.
But when I run the pcsc_scan.exe on my desktop win10 and win11, the result always zero.
would you like to try the binary I provided on your desktop?
from pcsc-tools.
Send me your source code instead.
A binary program is useless for me since I do not know what code is really executed.
from pcsc-tools.
/home/test/pcsc-tools-master
$ diff pcsc_scan.c pcsc_scan.backout
528d527
< printf("SCardGetStatusChange for PNP notification result = %lx\n", rv);
I also attach the zip file that include the modified .c file compiled exe. Please have a try on your windows.
git.zip
for sure when execute the pcsc_scan.exe app, I had attached the physical smart card reader& card to the Windows machine.
from pcsc-tools.
I see the problem.
With your program and no smart card reader connected I get:
C:\Users\Ludovic\Documents\git\git>pcsc_scan.exe
PC/SC device scanner
V 1.6.2 (c) 2001-2022, Ludovic Rousseau <[email protected]>
Press shift key to quit
SCardGetStatusChange for PNP notification result = 8010000a
Using reader plug'n play mechanism
Scanning present readers...
I get the expected SCARD_E_TIMEOUT
.
But if I connect a reader before running pcsc_scan.exe I get:
C:\Users\Ludovic\Documents\git\git>pcsc_scan.exe
PC/SC device scanner
V 1.6.2 (c) 2001-2022, Ludovic Rousseau <[email protected]>
Press shift key to quit
SCardGetStatusChange for PNP notification result = 0
Using reader plug'n play mechanism
Scanning present readers...
0: Gemplus USB SmartCard Reader 0
Wed Apr 12 14:59:31 2023
Reader 0: Gemplus USB SmartCard Reader 0
Event number: 1
Card state: Card inserted,
ATR: 3B A7 00 40 18 80 65 A2 08 01 01 52
Reader 1: \\?PnP?\Notification
Event number: 1
Card state:
I get the surprising SCARD_S_SUCCESS
.
This is surprising because in the two cases only the special reader \\?PnP?\Notification
is used in SCardGetStatusChange()
. So the other reader should not have any impact.
I consider this a Windows bug, unless this behaviour is documented somewhere.
What do you think?
from pcsc-tools.
Yes, typical user scenario is that the physical smart card reader are attached before the pcsc_scan.exe executed. I think this is the expected result that return SCARD_S_SUCCESS at this scenario under Windows platform.
Here I want to say the Under Linux platform the pcsc_scan return SCARD_E_TIMEOUT is a bad case. how can we fix this issue?
from pcsc-tools.
For me it is a bug on Windows.
If you think different then please provide technical arguments corresponding to the function documentation.
Why is it important for you to change the behavior of SCardGetStatusChange()
?
from pcsc-tools.
Related Issues (20)
- pcsc_scan under Ubuntu requirements: libgtk3-perl HOT 1
- pcsc_scan ISO/IEC 14443-4B ? HOT 2
- pcsc_scan not detecting the cards unless I unplug and replug the reader HOT 6
- How to submit misrecognized card HOT 3
- Reader AK910 HKey not detected HOT 2
- Need to add new DOD CAC card HOT 2
- can not compile under windows HOT 2
- how to compile the pcsc_scan.exe with UNICODE on Windows platform HOT 5
- Non-relevant application to strings of red color code HOT 4
- Observations HOT 1
- File LICENCE not in tar.bz2 archive HOT 1
- configure fails
- compile from git fails HOT 5
- Please add more maps to the database HOT 1
- SCardEstablishContext: Service was stopped. HOT 2
- try setup in raspberry pi HOT 13
- Update to smartcard_list.txt for ATR 3BB2110010800016 HOT 3
- pcsc scan : waiting for the first reader HOT 1
- ACR122u is visible only after disconnection and reconnection HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pcsc-tools.