Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 10  
15 Jun 18 11:28
Seb Henn
xxxxxx@hotmail.com
Join Date: 15 Jun 2018
Posts To This List: 6
SCardListReader, SCardConnect

Hi experts, I try to develop a kmdf smart card driver. Actually my driver is seen as a smart card driver from the device manager. Now, from an application, I'd like to correctly enumerate this driver with the SCardListReaders function and to connect to it with ScardConnect. But I don't know the requirements (name format, registry, ...). By using SCardIntroduceReader and NULL as context in SCardListReader, ok it works. But I'm not sure that I have to use the SCardIntroduceReader function. The documentation says that it's used just to rename a reader... Anyway, the SCardConnect fails after. In the sample provided by Microsoft (PCMCIA Smart Card driver), this function is not used. I think the SCardListReader checks this registry key : HKLM\SOFTWARE\Microsoft\Cryptography\Calais\Reader\ Documentation (link below) says that there are two names to define but how and where ? with SmartcardCreateLink function ? https://docs.microsoft.com/en-us/windows-hardware/drivers/smartcard/wdm-device-na mes-for-smart-card-readers Thanks in advance for your time.
  Message 2 of 10  
15 Jun 18 12:48
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 12008
SCardListReader, SCardConnect

xxxxx@hotmail.com wrote: > ... > Now, from an application, I'd like to correctly enumerate this driver with the SCardListReaders function and to connect to it with ScardConnect. > > But I don't know the requirements (name format, registry, ...). > > By using SCardIntroduceReader and NULL as context in SCardListReader, ok it works. But I'm not sure that I have to use the SCardIntroduceReader function. The documentation says that it's used just to rename a reader... Anyway, the SCardConnect fails after. > > In the sample provided by Microsoft (PCMCIA Smart Card driver), this function is not used. > I think the SCardListReader checks this registry key : HKLM\SOFTWARE\Microsoft\Cryptography\Calais\Reader\ > Documentation (link below) says that there are two names to define but how and where ? with SmartcardCreateLink function ? The documentation seems pretty clear.  You must have a device name that ends with a number.  Are you calling WdfDeviceInitAssignName?  Then, you must pass that name to SmartcardCreateLink so it can create the symbolic that SCardListReader can access.  Are you calling SmartcardCreateLink? -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 3 of 10  
16 Jun 18 16:31
Seb Henn
xxxxxx@hotmail.com
Join Date: 15 Jun 2018
Posts To This List: 6
SCardListReader, SCardConnect

Thanks for your reply. I didn't know WdfDeviceInitAssignName. I try this on the AddDevice routine but SCardListReaders return nothing even with NULL as context: UNICODE_STRING deviceName; wchar_t* name = L"\\DosDevices\\SCReader0"; status = RtlUnicodeStringInit(&deviceName, name); if (!NT_SUCCESS(status)) { status = WdfDeviceInitAssignName(DeviceInit, &deviceName); if (!NT_SUCCESS(status)) { PUNICODE_STRING LinkName = NULL; status = SmartcardCreateLink(LinkName, &deviceName); } } Should I use a AddReg in the .inf file to write something in the registry ?
  Message 4 of 10  
16 Jun 18 16:44
Seb Henn
xxxxxx@hotmail.com
Join Date: 15 Jun 2018
Posts To This List: 6
SCardListReader, SCardConnect

sorry, without the "!" UNICODE_STRING deviceName; wchar_t* name = L"\\DosDevices\\SCReader0"; status = RtlUnicodeStringInit(&deviceName, name); if (NT_SUCCESS(status)) { status = WdfDeviceInitAssignName(DeviceInit, &deviceName); if (NT_SUCCESS(status)) { PUNICODE_STRING LinkName = NULL; status = SmartcardCreateLink(LinkName, &deviceName); } } But it doesn't work.
  Message 5 of 10  
16 Jun 18 19:16
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 10220
SCardListReader, SCardConnect

You probably want wchar_t* name = L"\\Devicr\\SCReader0" DosDevices is usually used for the symbolic link name d Bent from my phone ________________________________ From: 30141712100n behalf of Sent: Saturday, June 16, 2018 4:44 PM To: Windows System Software Devs Interest List Subject: RE:[ntdev] SCardListReader, SCardConnect sorry, without the "!" UNICODE_STRING deviceName; wchar_t* name = L"\\DosDevices\\SCReader0"; status = RtlUnicodeStringInit(&deviceName, name); if (NT_SUCCESS(status)) { status = WdfDeviceInitAssignName(DeviceInit, &deviceName); if (NT_SUCCESS(status)) { PUNICODE_STRING LinkName = NULL; status = SmartcardCreateLink(LinkName, &deviceName); } } But it doesn't work. --- NTDEV is sponsored by OSR Visit the list online at: <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fshowlists.cfm%3Flist%3Dntdev&data=02%7C01%7CDoron.Holan%40microsoft.com%7Cd87 aa81ceb0b492c8b3f08d5d3c9e8a7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636647 786498355029&sdata=G3XQ6y4MExp4cho5zB1GBnfyALLF4bxcsm3IvoSmcPc%3D&reserved=0> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osr.com%2Fse minars&data=02%7C01%7CDoron.Holan%40microsoft.com%7Cd87aa81ceb0b492c8b3f08d5d3c9e 8a7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636647786498355029&sdata=G%2By%2 B69OOz8NxNuLjEXoyYIHkGOdM9P%2FeGfPk42CX2Ik%3D&reserved=0> To unsubscribe, visit the List Server section of OSR Online at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fpage.cfm%3Fname%3DListServer&data=02%7C01%7CDoron.Holan%40microsoft.com%7Cd87 aa81ceb0b492c8b3f08d5d3c9e8a7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636647 786498355029&sdata=WujmiEG7zQ%2B%2BZl7y%2FM8xGWBNf97jF13G5hsZLqS1i2I%3D&reserved= 0> --
  Message 6 of 10  
17 Jun 18 02:54
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 12008
SCardListReader, SCardConnect

On Jun 16, 2018, at 1:43 PM, xxxxx@hotmail.com <xxxxx@lists.osr.com> wrote: > > UNICODE_STRING deviceName; > wchar_t* name = L"\\DosDevices\\SCReader0"; Device, not DosDevices. The SmartcardCreateLink documentation talks about that. > status = RtlUnicodeStringInit(&deviceName, name); > > if (NT_SUCCESS(status)) { > > status = WdfDeviceInitAssignName(DeviceInit, &deviceName); > > if (NT_SUCCESS(status)) { > PUNICODE_STRING LinkName = NULL; > status = SmartcardCreateLink(LinkName, &deviceName); <...excess quoted lines suppressed...> That sequence won't work. All of the WdfDeviceInit calls have to be made before you call WdfDeviceCreate, but SmartcardCreateLink has to be called after the device is created. ??? Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 7 of 10  
17 Jun 18 06:18
Seb Henn
xxxxxx@hotmail.com
Join Date: 15 Jun 2018
Posts To This List: 6
SCardListReader, SCardConnect

Thanks for your reply. I try this without success. Driver is installed but I can't enumerate it with SCardListReaders: UNICODE_STRING deviceName; wchar_t* name = L"\\Device\\SCReader0"; status = RtlUnicodeStringInit(&deviceName, name); if (NT_SUCCESS(status)) { status = WdfDeviceInitAssignName(DeviceInit, &deviceName); if (NT_SUCCESS(status)) { status = WdfDeviceCreate(&DeviceInit, &deviceAttributes, &device); if (NT_SUCCESS(status)) { UNICODE_STRING linkName; status = SmartcardCreateLink(&linkName, &deviceName); .... } } } It doens't create an entry in HKLM\SOFTWARE\Microsoft\Cryptography\Calais\Reader\. deviceName shouldn't be the same as VENDOR_NAME + IFD_TYPE + UNIT_NO ? These fields belong to _SMARTCARD_EXTENSION structure.
  Message 8 of 10  
17 Jun 18 11:44
Seb Henn
xxxxxx@hotmail.com
Join Date: 15 Jun 2018
Posts To This List: 6
SCardListReader, SCardConnect

I specify that it's a virtual smart card reader. I'll use a wearable like a smart card over bluetooth low energy. So I don't use any bus, like USB, PCMCIA, ...
  Message 9 of 10  
17 Jun 18 23:38
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 12008
SCardListReader, SCardConnect

On Jun 17, 2018, at 8:43 AM, xxxxx@hotmail.com <xxxxx@lists.osr.com> wrote: > > I specify that it's a virtual smart card reader. I'll use a wearable like a smart card over bluetooth low energy. > > So I don't use any bus, like USB, PCMCIA, ... Sure there is -- your bus is Bluetooth. Right? ??? Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 10 of 10  
18 Jun 18 02:51
Seb Henn
xxxxxx@hotmail.com
Join Date: 15 Jun 2018
Posts To This List: 6
SCardListReader, SCardConnect

Yes Bluetooth Low Energy provided by Bluegiga USB dongle. I have a Windows service to manage the communication between dongle and wearable.
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 19:16.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license