Removing removable device from appearing in Devices and Printers / Win8 Devices

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

From the dev who owns this area:

Please read the MSDN documentation: http://msdn.microsoft.com/en-us/library/windows/hardware/ff546193(v=vs.85).aspx
and then this white paper: http://msdn.microsoft.com/en-us/windows/hardware/gg463141.aspx

The best option is to make an ACPI firmware change for the system. Use the _RMV object to make the device non-removable. (page 26)

If an ACPI change is not possible, then the second but less desirable option is to use the removable capability override (page 28).

Both methods will work on Win7 and 8. However, the first will correctly describe the hardware from the get go and does not require the FDO to fiddle with the removable capability, which it’s not supposed to do.

The bugcheck when you fiddle with the container id in the registry is most likely caused by the in pnp object caches’ constraint lists being out of sync with the container id on the devnode and the devices in the container map in the registry. On Win8 there is just no way you can fiddle with registry state underneath the cache and get away with it. Running with a CHK kernel will detect the inconsistency and assert.

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jay Talbott
Sent: Monday, August 20, 2012 3:14 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Removing removable device from appearing in Devices and Printers / Win8 Devices

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

NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi Doron,

Thanks for the info - that looks like the removable override capability is
the answer I was looking for.

We can’t change the firmware, since the board with the hardware bug could go
into any arbitrary system with an available x16 PCIe slot.

However, contrary to your statement about the checked build catching this,
even when running the checked kernel and hal (after I got them working), I
still go the same BAD_POOL_ERROR crash as with the retail kernel and hal,
and not an assertion failure. Frankly, I was really hoping that the checked
build would help point me to the source of the problem. But I suspected all
along that the problem probably had to do with something where I was
stepping outside the lines a bit, so it was just a matter of elimination
until I discovered the cause.

I’ll report back after implementing this change to let everyone know how it
works out.

  • Jay

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, August 20, 2012 10:57 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Removing removable device from appearing in Devices and
Printers / Win8 Devices

From the dev who owns this area:

Please read the MSDN documentation:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff546193(v=vs.85).a
spx

and then this white paper:
http://msdn.microsoft.com/en-us/windows/hardware/gg463141.aspx

The best option is to make an ACPI firmware change for the system. Use the
_RMV object to make the device non-removable. (page 26)

If an ACPI change is not possible, then the second but less desirable option
is to use the removable capability override (page 28).

Both methods will work on Win7 and 8. However, the first will correctly
describe the hardware from the get go and does not require the FDO to fiddle
with the removable capability, which it’s not supposed to do.

The bugcheck when you fiddle with the container id in the registry is most
likely caused by the in pnp object caches’ constraint lists being out of
sync with the container id on the devnode and the devices in the container
map in the registry. On Win8 there is just no way you can fiddle with
registry state underneath the cache and get away with it. Running with a
CHK kernel will detect the inconsistency and assert.

d

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jay Talbott
Sent: Monday, August 20, 2012 3:14 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Removing removable device from appearing in Devices and
Printers / Win8 Devices

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

NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

The solution works as desired on both Win7 and Win8.

From: Jay Talbott [mailto:xxxxx@sysproconsulting.com]
Sent: Tuesday, August 21, 2012 10:56 AM
To: ‘Windows System Software Devs Interest List’
Subject: RE: [ntdev] Removing removable device from appearing in Devices and
Printers / Win8 Devices

Hi Doron,

Thanks for the info - that looks like the removable override capability is
the answer I was looking for.

We can’t change the firmware, since the board with the hardware bug could go
into any arbitrary system with an available x16 PCIe slot.

However, contrary to your statement about the checked build catching this,
even when running the checked kernel and hal (after I got them working), I
still go the same BAD_POOL_ERROR crash as with the retail kernel and hal,
and not an assertion failure. Frankly, I was really hoping that the checked
build would help point me to the source of the problem. But I suspected all
along that the problem probably had to do with something where I was
stepping outside the lines a bit, so it was just a matter of elimination
until I discovered the cause.

I’ll report back after implementing this change to let everyone know how it
works out.

  • Jay

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, August 20, 2012 10:57 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Removing removable device from appearing in Devices and
Printers / Win8 Devices

From the dev who owns this area:

Please read the MSDN documentation:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff546193(v=vs.85).a
spx

and then this white paper:
http://msdn.microsoft.com/en-us/windows/hardware/gg463141.aspx

The best option is to make an ACPI firmware change for the system. Use the
_RMV object to make the device non-removable. (page 26)

If an ACPI change is not possible, then the second but less desirable option
is to use the removable capability override (page 28).

Both methods will work on Win7 and 8. However, the first will correctly
describe the hardware from the get go and does not require the FDO to fiddle
with the removable capability, which it’s not supposed to do.

The bugcheck when you fiddle with the container id in the registry is most
likely caused by the in pnp object caches’ constraint lists being out of
sync with the container id on the devnode and the devices in the container
map in the registry. On Win8 there is just no way you can fiddle with
registry state underneath the cache and get away with it. Running with a
CHK kernel will detect the inconsistency and assert.

d

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jay Talbott
Sent: Monday, August 20, 2012 3:14 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Removing removable device from appearing in Devices and
Printers / Win8 Devices

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

NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer