Ok, so I’m working on a driver for a PCIe device that’s behind a PLX
PCIe-PCIe switch.
Due to an error made when the hardware was spun, the downstream PCIe port of
the PLX chip connecting to the device was incorrectly configured as hot
pluggable, even though the attached device is not actually removable (it’s
all physically on the same board). This will be corrected in some future
re-spin of the hardware, but for now we need to work around it.
To eliminate the device from appearing in the removable device system tray
icon’s list of removable devices, the following was added to the driver’s
EvtDeviceAdd callback:
// Set the device capabilities so that when the capabilities
are
// queried, we override the results that are returned by the
PCI
// bus driver, fixing the problem of the PLX chip reporting
that
// one of the devices on the board is removable.
WDF_DEVICE_PNP_CAPABILITIES_INIT(&capabilities);
capabilities.EjectSupported = WdfFalse;
capabilities.Removable = WdfFalse;
WdfDeviceSetPnpCapabilities(device, &capabilities);
This works as desired, including on Windows 8. So far, so good.
Unfortunately, that by itself still left the device appearing in Devices and
Printers, which was not desired by my client. I figured out that what
triggers a device to appear in Devices and Printers in Windows 7 is that the
ContainerID value in the registry for the devices devnode contains a value
other than “{00000000-0000-0000-ffff-ffffffffffff}”. So the driver’s
EvtDeviceAdd callback was modified to change this registry value from
whatever gets returned by the underlying bus driver to
“{00000000-0000-0000-ffff-ffffffffffff}”. The driver also intercepts the
requests to the bus driver to query this information and changes the value
that is returned by the bus driver in a completion routine. Although the
change doesn’t take effect until after the next reboot, it otherwise worked
successfully to remove the device from appearing in Devices and Printers in
Windows 7. Yes, I know this is a hack, but sometimes you gotta do what you
gotta do to work around a hardware bug.
Unfortunately, this solution does NOT work in Windows 8. In fact, not only
does it not remove the device from Devices and Printers (or the new Devices
page in the new Win8 UI), but it also results in the system crashing with a
BAD_POOL_HEADER bugcheck if you uninstall or disable the device via Device
Manager. I’m not quite sure how changing the ContainerID registry value
caused that sort of a bugcheck, (the cause wasn’t revealed by verifier, wdf
verifier, special pool, using the checked kernel/hal, or any other method
that I tried to use to find it). Ultimately, I figured it out by trial and
error, confirming that if I remove that bit of code from the driver, the
bugcheck never occurs, and by leaving it in there, it occurs 100% of the
time (fortunately, especially for a BAD_POOL_HEADER type of bugcheck, it was
100% reproducible, so it was easy to confirm the fix).
So, I’ve modified the driver to check the OS version, and only execute that
code for Windows 7 (it’s obviously not applicable to Windows versions prior
to Win7 since Devices and Printers didn’t exist before Win7), and now it
doesn’t crash Win8 anymore. But now I need a new Win8-specific solution that
will remove the device from appearing in both Devices and Printers and the
new Devices page in the new Win8 UI. I’ll entertain any
ideas/hacks/whatever, but the change must a) fix the problem, b) not crash
Win8, and c) still allow the driver to pass the signature-only hardware
certification program.
Does anybody have any good suggestions?
Thanks,
- Jay