My app calls UpdateDriverForPlugAndPlayDevices and it works. The driver is
installed, the device works, everybody is happy. Except...

If more than one instance of the model in question is on the bus (it's a USB
device), then I get not just one WHQL warning but at least one more. And the
pattern is very weird.

Let's say the user plugs in one of my devices, and my app calls
UpdateDriverForPlugAndPlayDevices, and the user gets a WHQL warning, and she
says continue, and everything works. Peachy, right? Now she plugs in a
second device and she gets two warnings. Weird! Let's say she says continue
two more times and then plugs in a third device. Now she gets three
warnings, but the weirdness is just getting started. She plugs in a fourth
instance of the device and she gets one warning (expected) but then she
plugs in a fifth instance and gets two warnings.

Remember, I get the extra warnings even if all but one instance of the
device in question already has the driver. But, just to be paranoid, I made
sure I was not calling UpdateDriverForPlugAndPlayDevices again due to
re-entrant delivery of messages to my window.

Of course, I am looking to inhibit the extra WHQL warnings. Any ideas?


Pete Gontier
http://www.m-audio.com/
pete (at) m-audio (dot) com

Re: extra WHQL warnings by Pete

Pete
Fri May 02 17:43:51 CDT 2008

I should have mentioned all this is happening on XP 32 SP2.

Pete Gontier
http://www.m-audio.com/
pete (at) m-audio (dot) com

On 5/2/08 3:39 PM, in article
C440E616.33108%kokorozashi@discussions.microsoft.com, "Pete Gontier"
<kokorozashi@discussions.microsoft.com> wrote:

> My app calls UpdateDriverForPlugAndPlayDevices and it works. The driver is
> installed, the device works, everybody is happy. Except...
>
> If more than one instance of the model in question is on the bus (it's a USB
> device), then I get not just one WHQL warning but at least one more. And the
> pattern is very weird.
>
> Let's say the user plugs in one of my devices, and my app calls
> UpdateDriverForPlugAndPlayDevices, and the user gets a WHQL warning, and she
> says continue, and everything works. Peachy, right? Now she plugs in a
> second device and she gets two warnings. Weird! Let's say she says continue
> two more times and then plugs in a third device. Now she gets three
> warnings, but the weirdness is just getting started. She plugs in a fourth
> instance of the device and she gets one warning (expected) but then she
> plugs in a fifth instance and gets two warnings.
>
> Remember, I get the extra warnings even if all but one instance of the
> device in question already has the driver. But, just to be paranoid, I made
> sure I was not calling UpdateDriverForPlugAndPlayDevices again due to
> re-entrant delivery of messages to my window.
>
> Of course, I am looking to inhibit the extra WHQL warnings. Any ideas?


Re: extra WHQL warnings by Ray

Ray
Fri May 02 17:55:32 CDT 2008

Wait... are you calling UpdateDriverforPlugAndPlayDevices every time one
of your USB devices is plugged in? That would be wrong. And it wouldn't
surprise me if you would get weird results (because the second and
subsequent calls will try to update the driver on all the devices
currently plugged in, resulting in multiple messages).

Pete Gontier wrote:
> My app calls UpdateDriverForPlugAndPlayDevices and it works. The driver is
> installed, the device works, everybody is happy. Except...
>
> If more than one instance of the model in question is on the bus (it's a USB
> device), then I get not just one WHQL warning but at least one more. And the
> pattern is very weird.
>
> Let's say the user plugs in one of my devices, and my app calls
> UpdateDriverForPlugAndPlayDevices, and the user gets a WHQL warning, and she
> says continue, and everything works. Peachy, right? Now she plugs in a
> second device and she gets two warnings. Weird! Let's say she says continue
> two more times and then plugs in a third device. Now she gets three
> warnings, but the weirdness is just getting started. She plugs in a fourth
> instance of the device and she gets one warning (expected) but then she
> plugs in a fifth instance and gets two warnings.
>
> Remember, I get the extra warnings even if all but one instance of the
> device in question already has the driver. But, just to be paranoid, I made
> sure I was not calling UpdateDriverForPlugAndPlayDevices again due to
> re-entrant delivery of messages to my window.
>
> Of course, I am looking to inhibit the extra WHQL warnings. Any ideas?
>
>
> Pete Gontier
> http://www.m-audio.com/
> pete (at) m-audio (dot) com
>


--
Ray

Re: extra WHQL warnings by Pete

Pete
Fri May 02 19:27:18 CDT 2008

We aren't calling UpdateDriverforPlugAndPlayDevices every time one of our
devices is plugged in, but that doesn't mean you'll like what we are doing.

Our device exports descriptors indicating it conforms to the USB audio class
specification. Nevertheless, we want it driven by our driver if our driver
is installed. Because our driver has not passed WHQL, the system decides its
own class driver is a better match than our driver, even though ours is a
better match according to the standard USB rules.

Because our plans do not include the driver ever passing WHQL, and because
we have a process lying around all the time anyway, we added code to detect
the appearance of an instance of our device and wait for it to be matched
with a driver. If that driver happens to be the system's class driver, we
instruct the system to replace its own driver with ours, which is where the
WHQL warning comes in. Once this is done, the system remembers that it has
been done, and we don't have to do it again, because the next time the
device comes online, the system will match it with our driver automagically,
and our happy little babysitter process will see that everything has already
gone according to plan and do nothing.

If you were to protest that this whole strategy stinks, I wouldn't be in a
position to argue otherwise. The strategy was chosen before my time, and we
have been employing it successfully for years in multiple products, and the
only reason this issue has come up now is that we haven't needed to support
multiple devices before. My job is only to make sure the implementation is
as clean and smooth as it can be.

You mention that the second and subsequent calls will try to replace the
driver on all instances of the device, but the story can't be quite that
simple. If it were, I would expect the second instance to cause two WHQL
warnings, the third instance to cause three WHQL warnings, the fourth
instance to cause four WHQL warnings, and so on. Instead, what happens is
that the fourth instance causes one warning and the fifth instance causes
two warnings. So something weird is going on. My tester thinks it might have
something to do with the fact that different instances are on different
controllers, but we haven't yet found any practical value to that theory.

Any insight welcome.

Pete Gontier
http://www.m-audio.com/
pete (at) m-audio (dot) com


On 5/2/08 3:55 PM, in article #9iWheKrIHA.2064@TK2MSFTNGP05.phx.gbl, "Ray
Trent" <rat@nospam.nospam> wrote:

> Wait... are you calling UpdateDriverforPlugAndPlayDevices every time one
> of your USB devices is plugged in? That would be wrong. And it wouldn't
> surprise me if you would get weird results (because the second and
> subsequent calls will try to update the driver on all the devices
> currently plugged in, resulting in multiple messages).
>
> Pete Gontier wrote:
>> My app calls UpdateDriverForPlugAndPlayDevices and it works. The driver is
>> installed, the device works, everybody is happy. Except...
>>
>> If more than one instance of the model in question is on the bus (it's a USB
>> device), then I get not just one WHQL warning but at least one more. And the
>> pattern is very weird.
>>
>> Let's say the user plugs in one of my devices, and my app calls
>> UpdateDriverForPlugAndPlayDevices, and the user gets a WHQL warning, and she
>> says continue, and everything works. Peachy, right? Now she plugs in a
>> second device and she gets two warnings. Weird! Let's say she says continue
>> two more times and then plugs in a third device. Now she gets three
>> warnings, but the weirdness is just getting started. She plugs in a fourth
>> instance of the device and she gets one warning (expected) but then she
>> plugs in a fifth instance and gets two warnings.
>>
>> Remember, I get the extra warnings even if all but one instance of the
>> device in question already has the driver. But, just to be paranoid, I made
>> sure I was not calling UpdateDriverForPlugAndPlayDevices again due to
>> re-entrant delivery of messages to my window.
>>
>> Of course, I am looking to inhibit the extra WHQL warnings. Any ideas?


Re: extra WHQL warnings by chris

chris
Sat May 03 08:28:30 CDT 2008

On May 2, 7:27 pm, Pete Gontier
<kokoroza...@discussions.microsoft.com> wrote:

> Because our plans do not include the driver ever passing WHQL, and because
> we have a process lying around all the time anyway, we added code to detect
> the appearance of an instance of our device and wait for it to be matched
> with a driver.

This is an ugly, ugly hack. Anyway, you might look at this link to
learn how to force-install a driver on a given device node, without
touching anybody else:

http://support.microsoft.com/kb/889763

Re: extra WHQL warnings by Pete

Pete
Sun May 04 18:35:12 CDT 2008

On 5/3/08 6:28 AM, in article
dedf9e87-a439-4534-9972-a2f1070c83c0@l64g2000hse.googlegroups.com,
"chris.aseltine@gmail.com" <chris.aseltine@gmail.com> wrote:

> ... you might look at this link to learn how to force-install a driver on a
> given device node, without touching anybody else:
>
> http://support.microsoft.com/kb/889763

Thanks. That seems to work well enough for me to send in another build to my
tester in hopes of ending this problem. Four notes for posterity:

-- The DDK contradicts the Knowledge Base article about the last
parameter. I trusted the KB article.

-- The sample code's declaration of the function pointer should
use APIENTRY.

-- InstallSelectedDriver has a file copying step unnecessary for
my usage, where UpdateDriverforPlugAndPlayDevices does not.
While the WHQL warning is posted, the progress window for this
copying step is sitting behind the warning, not painting, and
looking like a bug. Nice.

-- If you pass false for the backup parameter (probably not wise,
but I experimented with it to see if I could inhibit the copying
step) and the user says STOP at the WHQL warning, what appears
to be the last phase of the Found New Hardware Wizard appears
and reports the same error which will eventually be returned
by GetLastError after InstallSelectedDriver returns false.



Pete Gontier
http://www.m-audio.com/
pete (at) m-audio (dot) com


Re: extra WHQL warnings by chris

chris
Sun May 04 22:26:25 CDT 2008

On May 4, 6:35 pm, Pete Gontier
<kokoroza...@discussions.microsoft.com> wrote:

> -- The DDK contradicts the Knowledge Base article about the last
> parameter. I trusted the KB article.

By the way, the article is also wrong about the "LPCWSTR Reserved"
argument. It says it should be null, but you really need to pass it a
pointer to a wchar_t buffer. Otherwise I think it crashes, but only
on Win2k, or only on XP, or something like that.

Re: extra WHQL warnings by Pete

Pete
Mon May 05 11:23:18 CDT 2008

On 5/4/08 8:26 PM, in article
44ca0226-1a8b-408b-a846-28b12f3db37b@b64g2000hsa.googlegroups.com,
"chris.aseltine@gmail.com" <chris.aseltine@gmail.com> wrote:

> By the way, the (KB) article is also wrong about the "LPCWSTR Reserved"
> argument. It says it should be null, but you really need to pass it a
> pointer to a wchar_t buffer. Otherwise I think it crashes, but only
> on Win2k, or only on XP, or something like that.

Yes, I saw that somewhere on the web. The DDK documentation also says this
parameter is reserved and must be NULL, so it would seem both docs are at
least somewhat incorrect. However, I didn't have any problems on XP SP2, and
we don't support anything less than that, so I don't have to guess how big
to make a dummy buffer for an undocumented value. Thanks again...


Pete Gontier
http://www.m-audio.com/
pete (at) m-audio (dot) com