none
How to load specific driver for specific device not having PnP-ID? RRS feed

  • Question

  • Hello,

    as mentoined in a previous post I'm up to adapt an exisiting PCMCIA-based PC Card driver so that it can be used with a PCMCIA/USB adaptor (by using it's driver's IOCTLs), and already had some success on it: My driver loads and I can read files (for example, in Windows Explorer) from the card as it did before in "PCMCIA version" (I intend to support both with the same driver, which seems to work at the moment). As it did before, the driver currently creates a MTD (memory technology device). My main "problem" is how to load the driver. The situation is a bit complicated, I try to give as much details as possible.

    For better understanding
    The PCMCIA/USB adaptor's driver usually has following device stack: PCMCIA/SUB adaptors driver -> USB mass storage device (USBSTOR.SYS) -> Diskdrive (DISK.SYS [->PARTMGR.SYS]). For more ease - to see if my driver works in general - I installed my driver via INF using the PnP ID of the "USB mass storage device", with other words I "replaced" the USB mass storage driver with my own driver.

    This is my problem
    This means - and that is currently my problem - that may driver gets loaded regardless of what is attached to the PCMCIA/USB adaptor. Usually, when attached to PCMCIA, the PC card has a PnP ID the driver can be assigned to. In my case, I have no PnP ID for the PC card, and the driver may stop because the attached device is not supported The driver will unload properly, but the device remains with error code (in device manager).

    What I want to avoid
    I already thought about filter drivers between USBSTOR and the PCMCIA/USB adaptor's driver (#1), or above the USB mass storage device (#2). If I'm correct, that means that I have to handle URB/CBW requests for case #1 or at least SCSI requests for case #2 - but I'm currently not familiar with filter drivers, URB/CBW and/or SCSI. Porting the driver was quiete frustating until yet and I had to get familiar with a couple of technologies that belongs to the driver's functinaliy itselfs - I hope you understand that I want to avoid getting familiar with more technologies than required.

    I think there must be a way to check the device (PC card) at the PCMCIA/USB adaptor before my driver will be loaded, as well as removing the deivce completely if the PC card was removed (so that it disappears in device manager). But I'm currently have no idea how to do that. Is it possible to load my driver along the device/driver stack usually created by the PCMCIA/USB adaptor's driver?

    Some answerers likes to refer to WDK documentation and samples. In such case - because of their complexity, it would be nice to get a hint about where to start.

    Have much thanks in before for any suggestions!

    Regards,
    Willi K.

    Wednesday, February 11, 2015 9:19 AM

Answers

  • if the underlying device always reports media even if there is nothing inserted, there is no generic way to tell the device to report itself. you don't need to worry about other drivers attaching, an INF defines the entire stack as you need it to be constructed, there are no optional add ins later.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Willi K Friday, February 13, 2015 9:04 AM
    • Unmarked as answer by Willi K Friday, February 13, 2015 1:32 PM
    • Marked as answer by Willi K Friday, February 13, 2015 1:50 PM
    Thursday, February 12, 2015 8:27 PM

All replies

  • you need to write a driver that matches on some hardware ID in any of the stacks that are enumerated from the pccard and is pnp driver. You would do this by loading your driver through an INF that matches on a hardware ID.

    what is unclear is what you want exposed to the PC when your device is plugged in. do you want it to appear as storage and navigate to it in explorer? do you just want your custom driver loaded and custom things done?


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, February 11, 2015 6:06 PM
  • Hello Doron,

    thanks for you reply. Yes, that is what the driver previously did (and still does when on PCMCIA) - from view of users a volume should appear in Windows Explorer where they can transfer files from (and to) the PC card.

    Following your suggestions I may attach to the USBSTOR\DiskAdapterNameBlaBla - this device is the "last" device shown in "Device Manager" and "sits" above the "USB Mass Storage Device" [class]. But if I do so I fear I have to handle a lot of additional SCSI stuff, or not?


    • Edited by Willi K Wednesday, February 11, 2015 6:21 PM reply - not replay
    Wednesday, February 11, 2015 6:21 PM
  • why do you need to write a driver? The device shows up as mass storage properly. View by connection and find the disk, open the properties and look at the hardware ids in the details section. The first hwid is the most likely one you should match against if you need a driver.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, February 12, 2015 4:50 AM
  • Today's memory cards (like CFC) manage their FTL (flash translation layer) in their firmware. Our PC card is quiete old technology and does not have such firmware, this is why Windows cannot recognize the file system (FAT). For example, a request to offset 0 may be somewhere else on our PC Card.

    I followed your suggestion and used the HWID of device that appears "above" the USB mass storage device, and my driver seems to work as it did before - OK, made no difference.

    But if my driver does not recognize the card (because it is not present or it is another PCMCIA device -> STATUS_NOT_SUPPORTED or STATUS_NO_MEDIA in driver entry), and the device is shown with exclamation mark in device manager.

    Two questions remain:

    - How can I ensure that other drivers may attach if my driver does not support the device inserted in the adapter?
    - How can I force a "re-check" of my driver if there was no card present when driver was loaded?? -> Note: A disk drive always appears in device manager - regardless if a device is attached to the apator or not


    • Edited by Willi K Thursday, February 12, 2015 3:51 PM
    Thursday, February 12, 2015 3:47 PM
  • if the underlying device always reports media even if there is nothing inserted, there is no generic way to tell the device to report itself. you don't need to worry about other drivers attaching, an INF defines the entire stack as you need it to be constructed, there are no optional add ins later.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Willi K Friday, February 13, 2015 9:04 AM
    • Unmarked as answer by Willi K Friday, February 13, 2015 1:32 PM
    • Marked as answer by Willi K Friday, February 13, 2015 1:50 PM
    Thursday, February 12, 2015 8:27 PM