How to Find the PNP Device Id in File System Driver for windows

I have created a File system driver to allow or block the external storage devices in windows. For allowing a particular device I need to find out the PNP device id. Is there is any possible way to find the PNP id device? Please Help

Tough question: You’re really at the wrong level to block specific devices based on Hardware ID of a device that’s been plugged in. You’re waaaaaay up at the top of the branch of the device tree, above the file system. The devices are allllll the way at the bottom.

Assuming you could find the PDO for the device, you could call IoGetDeviceProperty on it… But finding the PDO for the hardware device you’re interested in will be far from trivial given where you are in the device tree.

The “right” way to block hardware devices is down at the level where those devices are enumerated…

Peter

See https://community.osr.com/discussion/comment/285595/#Comment_285595
As Peter pointed out, this is quite non-trivial at this (presumably the InstanceSetup minifilter callback) level since the underlying PDO for the storage device you are being mounted on has a complicated relationship with what you/the user perceive as the “device” the volume is on.