[Pcsclite-muscle] Windows PC/SC and SCARD_E_SERVICE_STOPPED

Stephan Brunner s.brunner at stephan-brunner.net
Sun Dec 26 11:08:43 PST 2021


Hi,

A quick and dirty solution is to establish a new context when getting
SCARD_E_SERVICE_STOPPED. I had this situation myself when dealing with
this stuff. This method forces the service to start again and stay
alive, until the next time the last reader disconnects...

Looking in ProcMon and watching the service, I can't see any registry
key accessed which could change this behavior. A quick look thus deems
a hardcoded shutdown.  

Apparently MS does not check whether a context (and thus a COM client)
is connected. Maybe it's a cheap oversight.

Or it's done on purpose: Maybe they are tired of software keeping
connected to a service where no real work can be done without any
reader connected? Maybe they try to force saving resources for some
reason.

--
Stephan

PGP: 5FB325E81E548282D458A65114A30C9CE3AE4CE2

Am Sunday, dem 26.12.2021 um 18:58 +0000 schrieb Diego de Felice:
> 
> Just some info from my experience, being a developer of a smart card
> middleware: I started facing a weird problem from Windows 8 installed
> as virtual machine, the Smart Card service suddendly stopped after
> some times. After some search, I discovered that a new "feature" has
> been added to Windows, where services, despite being set as Automatic
> Start, they could be stopped automatically if no work is needed,
> imagine the surprise to know that "Smart Card Service" is stopped
> when no REAL smart card reader are connected to the machine... This
> is a big problem on VMs because there are no physical screader
> connected and this same behaviour cause my middleware big problems on
> really slow PCs: when Windows starts, sometimes the screader is
> recognized after the SCService starts, so... the service stops, and
> my middleware doesn't work!!! Still figuring out how to solve this
> problem, because it's very difficult to debug in dev environment.
> 
> Hope it helps.
> 
> Here the reference:
> 
> https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/hh849637(v=ws.11)#smart-card-service-start-and-stop-behavior
> 
> 
> 
> _______________________________________________
> pcsclite-muscle mailing list
> pcsclite-muscle at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/pcsclite-muscle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5612 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/pcsclite-muscle/attachments/20211226/969566b5/attachment.p7s>


More information about the pcsclite-muscle mailing list