Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to detect whether Windows is installing a device driver?

Tags:

c#

windows

usb

hid

The situation: We have a software suite that interacts with a device we built in-house. The device uses WinUSB for communications, EXCEPT when in boot mode during firmware updates. When in boot mode, the device uses a different VendorID and ProductID and uses HID for communication.

The problem: To update firmware, we send a command across and tell the device to enter boot mode. The device re-enumerates with the new VID and PID. When updating firmware on a new machine that hasn't had a device in boot mode connected before, Windows does the "installing driver" dance when the bootloader shows up. (There's no driver to be installed). Software gets a DEVICE ATTACHED event, and so we begin the firmware update. Once Windows finishes "installing" the driver, it de-enumerates and re-enumerates the device, closing our file handle in the middle of the update.

The question: Is there a way to detect if Windows is installing a driver so that we can wait for the device to be re-enumerated before beginning the update process? Is there something we can do in our install to preempt this behavior? Maybe a way to tell Windows that we don't want to allow driver installation while we're connected to the device?

like image 989
GPearson Avatar asked Oct 12 '16 16:10

GPearson


1 Answers

Maybe a way to tell Windows that we don't want to allow driver installation while we're connected to the device?

Microsoft's Developer Network has a section for Hardware Development. They have an article specifically about this issue. Importantly, the document states that your device installation application should "determine whether other installation activities are in progress before performing its installations" (emphasis mine) and - if pending installations are found - "should exit".

This last part of the statement seems to indicate Microsoft gives precedence to already installing or pending device application installations.

If your problem statement is accurate:

When updating firmware on a new machine that hasn't had a device in boot mode connected before, Windows does the "installing driver" dance when the bootloader shows up.

It sounds like you may be out of luck - or breaking a convention - by attempting to preempt the driver installation behavior.

I would utilize the above mentioned CMP_WaitNoPendingInstallEvents function, and then firmware update your device. I think the VID/PID are irrelevant, here, depending upon where your firmware update code is running. It looks like the OSR Online Forum has a question of the same nature and assumes the same precedence (driver installation).

like image 198
Thomas Avatar answered Oct 18 '22 20:10

Thomas