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

Re: Knowing a specific registry key before plugging a USB device by Maxim

Maxim
Thu Aug 03 04:22:02 CDT 2006

> 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 ?

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 Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: Knowing a specific registry key before plugging a USB device by olivierriff

olivierriff
Thu Aug 03 06:41:02 CDT 2006

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

Re: Knowing a specific registry key before plugging a USB device by pavel_a

pavel_a
Thu Aug 03 11:51:02 CDT 2006

"olivier.riff" wrote:
> 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

As you answered your own question below -

> 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 ?

Undocumented, period. Why do you want to create these strings
yourself? Are you writing an USB bus driver?

--PA

Re: Knowing a specific registry key before plugging a USB device by Maxim

Maxim
Thu Aug 03 11:58:00 CDT 2006

> So if these IDs are not linked to USB ports, what do they represent and how
> are they generated ?

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.

>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.

Do you have the unique IDs support in your device?

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: Knowing a specific registry key before plugging a USB device by olivierriff

olivierriff
Fri Aug 11 05:07:02 CDT 2006


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

Re: Knowing a specific registry key before plugging a USB device by Maxim

Maxim
Fri Aug 11 05:28:35 CDT 2006

> : â??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

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 Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: Knowing a specific registry key before plugging a USB device by olivierriff

olivierriff
Fri Aug 11 06:54:01 CDT 2006

- 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


Re: Knowing a specific registry key before plugging a USB device by Pavel

Pavel
Fri Aug 11 10:56:21 CDT 2006

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


"olivier.riff" <olivierriff@discussions.microsoft.com> wrote in message
news:F0B5AC0D-BBE6-4575-A46D-8433A6AB8B97@microsoft.com...
>- 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
>



Re: Knowing a specific registry key before plugging a USB device by olivierriff

olivierriff
Fri Aug 11 10:58:02 CDT 2006

"Pavel A." wrote:

> 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?

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

Re: Knowing a specific registry key before plugging a USB device by Dietmar

Dietmar
Thu Oct 12 09:07:28 CDT 2006

Pavel A. wrote:
> "olivier.riff" wrote:
>> 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
>
> As you answered your own question below -
>
>> 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 ?
>
> Undocumented, period. Why do you want to create these strings
> yourself? Are you writing an USB bus driver?
>
> --PA
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.

Re: Knowing a specific registry key before plugging a USB device by Maxim

Maxim
Thu Oct 12 15:29:58 CDT 2006

> 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.

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 Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: Knowing a specific registry key before plugging a USB device by Alexander

Alexander
Fri Oct 13 00:07:17 CDT 2006

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.

"Maxim S. Shatskih" <maxim@storagecraft.com> wrote in message
news:e%23iyY0j7GHA.844@TK2MSFTNGP03.phx.gbl...
>> 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.
>
> 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 Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>