Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
815 views
in Technique[技术] by (71.8m points)

c# - How are PCSC smart card reader 'friendly names' constructed?

I use WinSCard to list all readers, which gives me a list like this:

ASK RDR4x7 0
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 0
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 1
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 2

Which is great, but I have no clue which name belongs to which card reader.

Where do these names come from? How are they constructed?

What I've found up until now: in the registry, there is a HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices key. Under this key, you can find the subkey which matches the card reader's "service" (which I found by querying the WMI registry). For example: the service for the SCM Microsystems Inc. SCR3320 USB Smart Card Reader readers is SCR3XX2K.

This subkey (SCR3XX2K) has another subkey Enum, which has multiple interesting values:

  • Count: DWORD, the number of readers connected
  • 0, 1, 2: STRING, hardware Device ID

I guess these are the numbers appended to the 'friendly names', but I can't figure out how the name string is constructed. I need this to map hardware Device ID's (which I get through WMI) to their friendly name.

So, what's the pattern used to create a 'friendly name' for a smart card reader, and where do the values come from?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

They are a concatination of these 3 attributes:

SCARD_ATTR_VENDOR_NAME
SCARD_ATTR_VENDOR_IFD_TYPE
SCARD_ATTR_DEVICE_UNIT

The TechNet article Smart Card Events documents this in the "Smart Card reader name" section.

SCARD_??? attributes are requested with the SCardGetAttrib function.

The SCARD_ATTR_DEVICE_SYSTEM_NAME attribute returns the friendly name as the ones you get while listing the readers.

The list of SmartCard readers exists in the registry under HKLMSOFTWAREMicrosoftCryptographyCalaisReaders. Readers are added to this list by the INF file of the SCR driver, so during driver installation.

A link between device and reader can be found in the SmartCardReader class {50DD5230-BA8A-11D1-BF5D-0000F805F530} under HKLMSYSTEMCurrentControlSetControlClass{50DD5230-BA8A-11D1-BF5D-0000F805F5??30}.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...