How to determine logical volume given a device instance

Does anyone know how to determine the volume associated with a given device
instance from user mode? For example, given a 1394 storage device, I can
walk the device tree using SetupDi or CM_ functions and get as far as the
SBP2 device instance. However, there are no children below that instance
even though there are volumes.

In looking at the output from DeviceTree (view system from PnP perspective)
I see that DeviceTree does indeed show a continuing child relationship
which leads to an entry like:

\device\Harddisk2\DR7

which in turn leads to device object for individual volumes.

The Windows “device removal applet” also knows how to enumerate the
relationship between physical devices and their logical volumes.

I’m guessing that the key might be to use functions like
IRP_MN_QUERY_DEVICE_RELATIONS, but I’m at a loss as to how to issue such a
request from user mode. Or, is there a different approach?

TIA for any help.

Regards,
-Robert

> I see that DeviceTree does indeed show a continuing child relationship

which leads to an entry like:

\device\Harddisk2\DR7

which in turn leads to device object for individual volumes.

Maybe IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS can help?

The Windows “device removal applet” also knows how to enumerate the
relationship between physical devices and their logical volumes.

Not necessary. Only the volume manager in the kernel can know this. This is enough for the removal to be handled OK.

Max