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-names-for-smart-card-readers
Thanks in advance for your time.
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.
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 ?
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.
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:
MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at https:
To unsubscribe, visit the List Server section of OSR Online at https:</https:></https:></https:>
On Jun 16, 2018, at 1:43 PM, xxxxx@hotmail.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);
> }
> }
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.
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.
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, …
On Jun 17, 2018, at 8:43 AM, xxxxx@hotmail.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.
Yes Bluetooth Low Energy provided by Bluegiga USB dongle. I have a Windows service to manage the communication between dongle and wearable.