-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SCardGetStatusChange for PNP notification return SCARD_E_TIMEOUT #76
Comments
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. |
I can't reproduce your behavior on Windows. #! /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:https://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:
I receive 0x8010000A (SCARD_E_TIMEOUT) and not 0 (SCARD_S_SUCCESS). In your program I note you use |
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: Why the SCardGetStatusChange has the different result under Linux and Windows platform? |
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
|
It is true that I modify the code as your patch do: 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? |
Send me your source code instead. |
/home/test/pcsc-tools-master I also attach the zip file that include the modified .c file compiled exe. Please have a try on your windows. for sure when execute the pcsc_scan.exe app, I had attached the physical smart card reader& card to the Windows machine. |
I see the problem.
I get the expected But if I connect a reader before running pcsc_scan.exe I get:
I get the surprising This is surprising because in the two cases only the special reader What do you think? |
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? |
For me it is a bug on Windows. Why is it important for you to change the behavior of |
For the latest pcsc_scan.c file, I add code at 528 line to check the SCardGetStatusChange return value for the PNP notification, but unfortunately the return value is SCARD_E_TIMEOUT but not SCARD_S_SUCCESS. (my local pcsc-lite version is 1.8.23 and ubuntu Linux)
_rgReaderStates[0].szReader = "\\?PnP?\Notification";
rgReaderStates[0].dwCurrentState = SCARD_STATE_UNAWARE;
rv = SCardGetStatusChange(hContext, 0, rgReaderStates, 1);
printf("SCardGetStatusChange for PNP notification result = %lu\n", rv)_
I think it should be SCARD_S_SUCCESS but not this SCARD_E_TIMEOUT value. Do you know why and do you have the plan to fix this issue?
The text was updated successfully, but these errors were encountered: