KMDF 2 driver in same .sys file

Hello everybody,

I develop a smartcard reader driver for a multiSlot reader target.
I try to create a bus driver and a slot driver in the same .sys file with two .inf file.

I have used the static enumeration toaster sourcecode for create child PDO.
This work fine,
now I would like to know how to proceed for create FDO for my child.
During child PDO process, I have implemented SlotEvtPrepareHard, SlotEvtDeviceD0Entry and SlotEvtDeviceD0Exit for initialize smartcard reader Slot.

Now When I plug the reader, I install the BusSlotDriver with the first bus.inf file,
The BusEvtDeviceAdd is OK
The BusEvtDevPrepareHard is OK
-> Create ChildPDO ( add Callback SlotPrepareHard and SlotDeviceD0Entry )
Now the dialogBox appear, I browse the PC for the second .inf file slot.inf
-> SlotEvtDevPrepareHard is called and is OK
-> SlotEvtDevD0Entry is called and is OK
Reexecute BusEvtDeviceAdd
Reexecute BusEvtDevPrepareHard Failed ( USB already initialized, so return 0x0C0000010 )
Execute SlotEvtDeviceD0Exit

And the Slot driver is not installed.

I would like to know if someone has already encountered this problem.
Maybe a initialisation problem. I don’t understand why BusEvtPrepareHard and BusEvtDeviceAdd are reexecuted.
Normally I suppose if the SlotPrepareHard and SlotEvtDevD0Entry are successfully executed the Bus Driver should be work, it’s not my case.

In this case how to distinguish function called for Bus driver and Child driver.
It’s possible, need to add an other callback or implement a link from the busPDO to the childFDO ?

Thanks in advance,

Sorry for this silly questions, but I’m new in KMDF driver devlopment.

Best regard,

Kamel

Why would you want two highly different drivers in the same .sys? Not
only are you breaking the model of drivers in general and KMDF
specifically, but you are creating a maintenance nightmare. Split this
into two drivers and have the INF install both of them.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@hotmail.com” wrote in message
news:xxxxx@ntdev:

> Hello everybody,
>
> I develop a smartcard reader driver for a multiSlot reader target.
> I try to create a bus driver and a slot driver in the same .sys file with two .inf file.
>
> I have used the static enumeration toaster sourcecode for create child PDO.
> This work fine,
> now I would like to know how to proceed for create FDO for my child.
> During child PDO process, I have implemented SlotEvtPrepareHard, SlotEvtDeviceD0Entry and SlotEvtDeviceD0Exit for initialize smartcard reader Slot.
>
> Now When I plug the reader, I install the BusSlotDriver with the first bus.inf file,
> The BusEvtDeviceAdd is OK
> The BusEvtDevPrepareHard is OK
> -> Create ChildPDO ( add Callback SlotPrepareHard and SlotDeviceD0Entry )
> Now the dialogBox appear, I browse the PC for the second .inf file slot.inf
> -> SlotEvtDevPrepareHard is called and is OK
> -> SlotEvtDevD0Entry is called and is OK
> Reexecute BusEvtDeviceAdd
> Reexecute BusEvtDevPrepareHard Failed ( USB already initialized, so return 0x0C0000010 )
> Execute SlotEvtDeviceD0Exit
>
> And the Slot driver is not installed.
>
> I would like to know if someone has already encountered this problem.
> Maybe a initialisation problem. I don’t understand why BusEvtPrepareHard and BusEvtDeviceAdd are reexecuted.
> Normally I suppose if the SlotPrepareHard and SlotEvtDevD0Entry are successfully executed the Bus Driver should be work, it’s not my case.
>
> In this case how to distinguish function called for Bus driver and Child driver.
> It’s possible, need to add an other callback or implement a link from the busPDO to the childFDO ?
>
> Thanks in advance,
>
> Sorry for this silly questions, but I’m new in KMDF driver devlopment.
>
> Best regard,
>
> Kamel

Thanks don for your reply.
But it’s not my choice, our client want to have just one .sys file for their reader.
I have already created 2 .sys file in WDM and it’s work fine, but now they want in the same .sys file.

Thanks,

I am not sure this can be made to work with KMDF, I will defer to Doron
or someone from the KMDF team. I do know I would never want such a
piece of crap on my system, this is not a reflection of you but of the
arrogant stupidity of your client.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@hotmail.com” wrote in message
news:xxxxx@ntdev:

> Thanks don for your reply.
> But it’s not my choice, our client want to have just one .sys file for their reader.
> I have already created 2 .sys file in WDM and it’s work fine, but now they want in the same .sys file.
>
> Thanks,

Yes Don I’m totally agree with you, but I don’t have the choice :frowning:
I’m forced to find a way to do this driver ( BusDriver for USB Exchange and SlotDriver for smartcard reader ).
Have you got any help to suggest me.

Thanks Don for your reply you confirm me this idea is stupid but for our customer it’s possible ( A reader with two slots exist and work with just one .sys file).

Thanks in advance,

Best regard,

Kamel

It can be done. Kmdf doesn’t care about rolesin multiple stacks, it is just pnp. Instead of a bus driver, did you try registering and enabling multiple instances of the smart card device interface , each with their own instance string, on the fdo? You don’t need a child stack per slot, just a dev interface instance
Per slot.
d

dent from a phpne with no keynoard

-----Original Message-----
From: Don Burn
Sent: November 25, 2010 7:55 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF 2 driver in same .sys file

I am not sure this can be made to work with KMDF, I will defer to Doron
or someone from the KMDF team. I do know I would never want such a
piece of crap on my system, this is not a reflection of you but of the
arrogant stupidity of your client.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@hotmail.com” wrote in message
news:xxxxx@ntdev:

> Thanks don for your reply.
> But it’s not my choice, our client want to have just one .sys file for their reader.
> I have already created 2 .sys file in WDM and it’s work fine, but now they want in the same .sys file.
>
> Thanks,


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thanks Doron for your help, when you say a device interface per slot means call
“WdfDeviceAddQueryInterface” ?, I have try it
but problem I have just one interface defined in the deviceDescriptor,
This behavior is defined in my first post ( SlotDevD0Entry SUCCESS and After execute BusDevAddDevice failed ).

Have you got any help (link, sample, …) for try it ?
For this subject the “Developing drivers with WDF” and “Walter Oney” books don’t present this features :frowning:

Thanks by advance.

WdfDeviceCreateDeviceInterface, http://msdn.microsoft.com/en-us/library/ff545935(VS.85).aspx

Use a unique ReferenceString (“Slot0”, “Slot1”, etc is fine) each time create the device interface, and then check for that unique reference string in EvtDeviceFileCreate, read http://blogs.msdn.com/b/doronh/archive/2006/08/18/706717.aspx for how to do that

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, November 25, 2010 8:18 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF 2 driver in same .sys file

Thanks Doron for your help, when you say a device interface per slot means call “WdfDeviceAddQueryInterface” ?, I have try it but problem I have just one interface defined in the deviceDescriptor, This behavior is defined in my first post ( SlotDevD0Entry SUCCESS and After execute BusDevAddDevice failed ).

Have you got any help (link, sample, …) for try it ?
For this subject the “Developing drivers with WDF” and “Walter Oney” books don’t present this features :frowning:

Thanks by advance.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thnaks a lot Doron for your useful help.
I have called 2 times WdfDeviceCreateDeviceInterface with different UnicodeName.
Install executed successfully, but in the device manager I have just one smartcard device.
I continue to read your blog and any informations from MSDN.
If you have some tips thanks in advance :slight_smile:

Best regard,

Kamel

Yes, there will be only one device in device manager. There is no 1:1 mapping between device interface instances and device stack instances, it can be 1:N. the smart card subsystem in user mode detects smart card by the smart card device interface instance, which means if you register 2 instances, it will see 2 readers

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, November 25, 2010 9:44 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF 2 driver in same .sys file

Thnaks a lot Doron for your useful help.
I have called 2 times WdfDeviceCreateDeviceInterface with different UnicodeName.
Install executed successfully, but in the device manager I have just one smartcard device.
I continue to read your blog and any informations from MSDN.
If you have some tips thanks in advance :slight_smile:

Best regard,

Kamel


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thanks a lot Doron for your advise.
If I understand you, in the device manager, only one devise must be visible.
Problem for me, If I want to disable one Slot interface that become impossible ( without IOCTL use ).

But If I use a listSmartcardReader function ( from winscard.dll ) I could see two readers ?
I try to suggest this functionnal to the customer :slight_smile:

Thanks a lot for your appreciate device.

Regards,

Kamel

Why do you need to disable a particular slot?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, November 25, 2010 10:29 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF 2 driver in same .sys file

Thanks a lot Doron for your advise.
If I understand you, in the device manager, only one devise must be visible.
Problem for me, If I want to disable one Slot interface that become impossible ( without IOCTL use ).

But If I use a listSmartcardReader function ( from winscard.dll ) I could see two readers ?
I try to suggest this functionnal to the customer :slight_smile:

Thanks a lot for your appreciate device.

Regards,

Kamel


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Because this driver must work with a various reader from the same manufacturer.
this reader exist in monoSlot version, 2, 3, 4 , 5 Slot, he want to disable some slot ( use case of securyty SAM for example).

This sounds like a pre determined, have a reg value in the devnode that your driver reads before creating the device interfaces. This value will indicate if you should create fewer than what the hw reports.

d

dent from a phpne with no keynoard

-----Original Message-----
From: xxxxx@hotmail.com
Sent: November 25, 2010 10:56 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF 2 driver in same .sys file

Because this driver must work with a various reader from the same manufacturer.
this reader exist in monoSlot version, 2, 3, 4 , 5 Slot, he want to disable some slot ( use case of securyty SAM for example).


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Ok, I gotta know why your client insists the drivers co-habit one sys file?

If they aren’t arrogant twits, which is what they sound like, perhaps there
is a reasonable explanation for such crap. Mostly however it sounds like
someone who thinks they know trying to control a project, when really, if
they were sitting on their head they could not find their ass with both
hands.

Gary G. Little
H (952) 223-1349
C (952) 454-4629
xxxxx@comcast.net

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Thursday, November 25, 2010 9:31 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF 2 driver in same .sys file

Thanks don for your reply.
But it’s not my choice, our client want to have just one .sys file for their
reader.
I have already created 2 .sys file in WDM and it’s work fine, but now they
want in the same .sys file.

Thanks,


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

__________ Information from ESET Smart Security, version of virus signature
database 5649 (20101125) __________

The message was checked by ESET Smart Security.

http://www.eset.com