I am using IoRegisterPlugPlayNotification to enumerate all the devices
of a particular type (and to notice when new devices are added).
I want to use IoGetDeviceProperty to retrieve the “FriendlyName” of the
device, but the symbolic link returned in the callback does not refer
to the PDO - which IoGetDeviceProperty requires.
Can anyone suggest how I can get the PDO for a FDO, so I can call
IoGetDeviceProperty, or am I going about this the entirely wrong way?
Thanks,
Cliff
Cliff Russell wrote:
I want to use IoGetDeviceProperty to retrieve the “FriendlyName” of the
device, but the symbolic link returned in the callback does not refer
to the PDO - which IoGetDeviceProperty requires.
Actually, it does, which is one of the points of the registered device
interface mechanism. However, when you do an IoGetDeviceObjectPointer,
you’re going to get back the address of the topmost FiDO in that PnP
stack. I know this sounds a bit metaphysical, but it’s the truth.
To find the PDO, you can send an IRP_MN_QUERY_DEVICE_RELATIONS to the
DEVICE_OBJECT pointer you’ve got. You’d ask for TargetDeviceRelations.
Don’t forget to set the IRP status to STATUS_NOT_SUPPORTED beforehand
(to avoid verifier bug checks) and to call ObDereferenceObject on the
PDO pointer you eventually get back.
Incidentally, I found that IoGetDeviceProperty doesn’t work right for
FriendlyName in 98/Me. It goes to the driver’s software key instead of
to the hardware key. My guess would be that whoever originally
programmed this DDI had in mind the case of a serial port, for which the
software key holds the COMx name. Consequently, I’ve always used
IoOpenDeviceRegistryKey when I was trying to get the FriendlyName in
98/Me.
–
Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Check out our schedule at http://www.oneysoft.com
Thanks very much, exactly what I was looking for!
On Tuesday, May 20, 2003, at 02:03 AM, Walter Oney wrote:
Cliff Russell wrote:
> I want to use IoGetDeviceProperty to retrieve the “FriendlyName” of
> the
> device, but the symbolic link returned in the callback does not refer
> to the PDO - which IoGetDeviceProperty requires.
Actually, it does, which is one of the points of the registered device
interface mechanism. However, when you do an IoGetDeviceObjectPointer,
you’re going to get back the address of the topmost FiDO in that PnP
stack. I know this sounds a bit metaphysical, but it’s the truth.
Ah, that makes sense (well not really, but…)
To find the PDO, you can send an IRP_MN_QUERY_DEVICE_RELATIONS to the
DEVICE_OBJECT pointer you’ve got. You’d ask for TargetDeviceRelations.
Don’t forget to set the IRP status to STATUS_NOT_SUPPORTED beforehand
(to avoid verifier bug checks) and to call ObDereferenceObject on the
PDO pointer you eventually get back.
I started wondering about IRP_MN_QUERY_DEVICE_RELATIONS shortly after I
sent the message.
Incidentally, I found that IoGetDeviceProperty doesn’t work right for
FriendlyName in 98/Me. It goes to the driver’s software key instead of
to the hardware key. My guess would be that whoever originally
programmed this DDI had in mind the case of a serial port, for which
the
software key holds the COMx name. Consequently, I’ve always used
IoOpenDeviceRegistryKey when I was trying to get the FriendlyName in
98/Me.
I’m only need Windows 2k and WinXP so this should work fine.
–
Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Check out our schedule at http://www.oneysoft.com
You are currently subscribed to ntdev as: xxxxx@telus.net
To unsubscribe send a blank email to xxxxx@lists.osr.com