Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Establish resource manager context to use smart card reader

I'm developing a c++ application, using Visual Studio 2017.

I'm using the windows library winscard. I'm starting with a simple project where i'm calling the function SCardEstablishContext as the first step needed to read a smart card.

The snippet of code i'm using is the following:

LONG resContext = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hSC);
if (resContext != SCARD_S_SUCCESS) {
    printf("Failed\n");
    printf("Error %X\n", resContext);
}

What i know is that this function use the windows service called "Smart Card" to get the scope within which database operations are performed (read/write cards).

Unfortunately this simple application works (i.e. return the SCARD_S_SUCCESS code) only in windows 7 environment. In all the windows 10 systems that i tested the return code is always 0x8010001DL that is associated to the define SCARD_E_NO_SERVICE that assert:

The Smart Card Resource Manager is not running.

On windows 7 systems the program works without admin privileges, on windows 10 systems i've tried with admin privileges too but the error is the same.

In every windows 10 system that i tested i manually started the service "Smart Card" before testing my program and checked that it still running while testing.

In both windows 7 and windows 10 systems i don't have a smart card reader connected.

The winscard.lib file i use come with Microsoft Windows SDK version 10.0.17763.0

There's something extra to do to get it works with windows 10?

like image 720
S.Orioli Avatar asked May 31 '19 15:05

S.Orioli


1 Answers

Smart Card Subsystem (and Resource Manger) must work "out of the box".

Try to install some smart card drivers that present virtual slots to the system.
For example this one.

Are you working via RDP?

like image 138
Alexander Avatar answered Oct 31 '22 15:10

Alexander