Knowing a specific registry key before plugging a USB device

Discussion in 'Windows Vista Drivers' started by olivier.riff, Aug 3, 2006.

  1. olivier.riff

    olivier.riff Guest

    Hello,

    My question concerns the way to know a specific registry key that is created
    by Windows the first time a USB device is plugged.
    Let me explain it in detail:
    When plugging for the first time my USB device (vid=xxxx, pid = xxxx) to a
    given USB port: Windows creates a specific key (for example 5&206acfca&0&1)
    under the directory:
    HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\Vid_xxxx&Pid_xxxx
    What I would like to know is how this key 5&206acfca&0&1 is generated and if
    it is possible to know it (with a function from Windows API) BEFORE the USB
    device is plugged. I have notice that this key is the same if the same USB
    device is plugged in the same USB port.
    To summarize: I have 6 USB ports in my computer and I know all information
    of my USB device, is it possible to know WITHOUT plugging my device each key
    (?&????????&?&?) of each port ?

    Thanks,

    Olivier
     
    olivier.riff, Aug 3, 2006
    #1
    1. Advertisements

  2. To summarize: I have 6 USB ports in my computer and I know all information
    Surely no. These IDs are not connected to USB ports. The Windows USB subsystem
    does not pay much attention about _to what namely downstream hub port_ the
    device is plugged, and the PnP IDs are not dependant upon this.
     
    Maxim S. Shatskih, Aug 3, 2006
    #2
    1. Advertisements

  3. olivier.riff

    olivier.riff Guest

    Thanks for the answer Maxim,
    So if these IDs are not linked to USB ports, what do they represent and how
    are they generated ? because they are obviously not randoms and when erasing
    them, the same ID values are re-generated in the registry when I replug my
    USB device. They seems to be a concatenation of several string/number
    representing machine dependant information.
    That is why I thought that there might be a Windows function that enables to
    generate them but I do not find any information about them in Windows msdn
    documentation. Any idea ?

    Olivier
     
    olivier.riff, Aug 3, 2006
    #3
  4. olivier.riff

    Pavel A. Guest

    As you answered your own question below -
    Undocumented, period. Why do you want to create these strings
    yourself? Are you writing an USB bus driver?

    --PA
     
    Pavel A., Aug 3, 2006
    #4
  5. So if these IDs are not linked to USB ports, what do they represent and how
    If the device has a unique ID feature in its config descriptor - then this is
    device's unique ID, which does not depend on to what port of what hub is it
    connected.

    If the device has no such feature - then this ID is a random undocumented junk,
    and the driver install process is runned on each device insert.
    Do you have the unique IDs support in your device?
     
    Maxim S. Shatskih, Aug 3, 2006
    #5
  6. olivier.riff

    olivier.riff Guest

    Thanks for your answers,
    I do not find what you call “unique ID feature in its config descriptorâ€.
    Here is what I do:
    I have developed a USB smartcard reader which using standard Microsoft
    smartcard driver. I know all about the USB descriptor because I have
    developed the reader embedded software.
    To allow sending proprietary commands to the reader, Microsoft driver
    imposes to modify the registry key: cf.
    http://www.microsoft.com/whdc/device/input/smartcard/USB_CCID.mspx#EEAA
    : “In order to send or receive an Escape command to a reader, the DWORD
    registry value EscapeCommandEnable must be added and set to a non-zero value
    under the HKLM\SYSTEM\CCS\Enum\USB\Vid*Pid*\*\Device Properties key.â€
    Without plugging the reader, I cannot know the full path to create the key.
    Now why I want to create the key before plugging the reader ? -> because if
    the reader is plugged, a re-enumeration of it (either manually unplug it and
    replug it, or by software) is necessary to enable the proprietary commands.
    From the point of you of the user: it is strange to see that a re-enumeration
    of the reader is done the first time he uses its reader and takes 4-5
    seconds. Moreover, the first time he plugs the reader on a new USB port: a
    new registry key is created and the DWORD value should be added.
    What I clearly notice is if I plug the same reader on different port, key
    path x&xxxxxxxx&x&x is different and I do not find these generated values
    anywhere in my embedded code.
    To conclude: this makes many things just to avoid a simple re-enumeration,
    but I thought that maybe the solution was simple. Thanks for your help.


    Olivier
     
    olivier.riff, Aug 11, 2006
    #6
  7. : “In order to send or receive an Escape command to a reader, the DWORD
    Such values are added using the INF file, which is executed when the registry
    key is first set up on the first device insert.

    So, add the appropriate AddReg statements to your INF file.

    If the task is too non-trivial for the INF file - then add a coinstaller DLL to
    your package, and add all registry values from this coinstaller DLL.
     
    Maxim S. Shatskih, Aug 11, 2006
    #7
  8. olivier.riff

    olivier.riff Guest

    - The problem is that modifying the .inf file will break the driver Microsoft
    signature and customers demand a signed driver.
    - Using a co-installer Dll is what I try to do but the problem of the path
    remains: how can I know the full path where the key values should be created
    (?&????????&?&?)

    Regards,

    Olivier
     
    olivier.riff, Aug 11, 2006
    #8
  9. olivier.riff

    Pavel A. Guest

    OK, besides of the obvious (but not doable) advice "go sign your driver" -
    can you persuade the user to run a program after installation of the device?
    The program will find your reader, if the registry value is absent it will
    add it and then restart the device. Only once.
    ( it is possible to run such program from the INF - but this route is blocked since you can't modify it).

    --PA
     
    Pavel A., Aug 11, 2006
    #9
  10. olivier.riff

    olivier.riff Guest

    After the installation of the device, the user starts the application
    installed. This application does already what your are suggesting: checking
    registry value, create it if necessary and re-enumerate the reader. But as
    explained, the aim was to avoid this re-enumeration and the 4-5 seconds it
    takes (and the fact that the user see that something strange happens: icon
    disappear and appears again in the bottom right of the screen, the led of the
    reader shows that a retstart has been done...). I agree, this is not a real
    problem, but I would be happy if I find a way to remove this.

    Thanks for your help

    Olivier
     
    olivier.riff, Aug 11, 2006
    #10
  11. Maybe he wants to have the same as me: Everytime you connect a device to
    a different port, Windows reinstalls the driver for the specific port.
    When the driver is not signed and/or cached, it will present a popup.

    I thought of a solution in this direction too, but I'm quite sure that
    this is not a possibility.
     
    Dietmar Marek, Oct 12, 2006
    #11
  12. Maybe he wants to have the same as me: Everytime you connect a device to
    No. If the device has unique ID in its config descriptor - then the driver is
    only installed first time the device is inserted, regardless of ports.

    If the device has no such ID - then the driver installation will be done _each
    insert_, even to the same port.
     
    Maxim S. Shatskih, Oct 12, 2006
    #12
  13. No. The installation is done once per USB port. Each different path creates
    different instance ID, unless the device has serial number string descriptor
    (composed of valid characters), in which case this descriptor will be used
    as instance ID.

    Generation of per-port instance ID can be suppressed by a registry value
    GlobalDisableSerNumGen in HKLM\System\CurrentControlSet\Control\UsbFlags.
    This will apply to all devices.
     
    Alexander Grigoriev, Oct 13, 2006
    #13
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.