Check for virtual disk volume

I am writing a upper filter driver for volume manager.
My driver’s AddDevice will receive call for volume on physical driver(C:)
and for VHD also.
I want to check whether volume for which AddDevice was called is created on
VHD or actual physical drive.

It depends on virtual drive implementation.

To achieve this for the broadest range of implementations you need to traverse the PnP device tree from a volume PDO to a physical bus PDO ( USB, SATA etc ) and employ heuristic as some virtual drives register a bus that looks like a physical one.

Some virtual drives intentionally emulate a physical drive by attaching to a physical bus by intercepting IRP_MN_QUERY_DEVICE_RELATIONS so it is not possible to figure out that drive is a virtual one.

If you just care about VHDs you can use FsRtlGetVirtualDiskNestingLevel.
Note that this API won’t work until the volume is online (e.g. it won’t work
from EvtDriverDeviceAdd).

-scott
OSR
@OSRDrivers

wrote in message news:xxxxx@ntfsd…

It depends on virtual drive implementation.

To achieve this for the broadest range of implementations you need to
traverse the PnP device tree from a volume PDO to a physical bus PDO ( USB,
SATA etc ) and employ heuristic as some virtual drives register a bus that
looks like a physical one.

Some virtual drives intentionally emulate a physical drive by attaching to a
physical bus by intercepting IRP_MN_QUERY_DEVICE_RELATIONS so it is not
possible to figure out that drive is a virtual one.