Re: finding the parent of a device

From: Peter Wieland [MSFT] (peterwie_at_online.microsoft.com)
Date: 06/24/04


Date: Thu, 24 Jun 2004 09:34:07 -0700

that will only work if the function driver sends unrecognized I/O controls
to the lower devices, which is not guaranteed.

-p

-- 
This posting is provided "AS IS" with no warranties, and confers no rights.
"shahar" <shahar@discussions.microsoft.com> wrote in message 
news:1D539EDF-5B28-49C7-801A-27B169B97376@microsoft.com...
> The only way I can think about detecting if a device is connected by USB 
> is to build a bus filter that attaches to every new PDO it sees when 
> IRP_MN_QUERY_DEVICE_RELATIONS returns.
> This way it will be able to see all the IRP's for all the device tree 
> under the USB,
> and by querying a device stack for a device interface that is implemented 
> by my driver I can detect if the device is connected to the USB.
> this is realy realy ugly, can you think of a better way ?
>
>
> "Doron Holan [MS]" wrote:
>
>> The more generic answer outside of storage, is that given a PDO, there is 
>> no
>> way to find it's parent FDO in a standardized manner.
>>
>> d
>>
>> -- 
>> Please do not send e-mail directly to this alias. this alias is for
>> newsgroup purposes only.
>> This posting is provided "AS IS" with no warranties, and confers no 
>> rights.
>>
>>
>> "Peter Wieland [MSFT]" <peterwie@online.microsoft.com> wrote in message
>> news:%23pg0oNfWEHA.3972@TK2MSFTNGP12.phx.gbl...
>> > Have you tried using IOCTL_STORAGE_QUERY_PROPERTY to get the device
>> > descriptor for the disk you're talking to?  It contains a field that 
>> > could
>> > tell you the underlying bus type (assuming the drivers running the 
>> > device
>> > set it)
>> >
>> > why only support USB?  Why not smart-cards?  Why not SD media?
>> >
>> > -p
>> >
>> > -- 
>> > This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> > "shahar" <shahar@discussions.microsoft.com> wrote in message
>> > news:E2AA1E9D-3F74-4CD6-A0CF-183A299AB329@microsoft.com...
>> > >I need to distinguish a USB  disk from a IDE disk from a SCSI disk.
>> > >
>> > > "Peter Wieland [MSFT]" wrote:
>> > >
>> > >> why does it matter how it's connected?  Either you've identified 
>> > >> your
>> > >> disk-on-key device by its inquiry data, or you have no idea what the
>> > >> device
>> > >> is.  Were you going to add code that distingushed a USB hard-disk 
>> > >> from
>> a
>> > >> smart-card from an SD card from a disk-on-key?
>> > >>
>> > >> If you're trying to just work with your device there are plenty of 
>> > >> ways
>> > >> to
>> > >> do it that will work better than trying to walk through the chain of
>> > >> connected devices to see if one happens to be a USB hub.
>> > >>
>> > >> if you have a different goal you'll probably get better advice if 
>> > >> you
>> > >> tell
>> > >> us what the goal is, rather than asking how you implement a single
>> > >> solution.
>> > >>
>> > >> -p
>> > >>
>> > >> -- 
>> > >> This posting is provided "AS IS" with no warranties, and confers no
>> > >> rights.
>> > >> "shahar" <shahar@discussions.microsoft.com> wrote in message
>> > >> news:12DB0C3E-7994-4F4C-BE4A-E025C0625588@microsoft.com...
>> > >> > But when for example I plug my disk-on-key to the USB hub,
>> > >> > three devices are created:
>> > >> > 1) A mass storage device with enumerator name USB
>> > >> > 2) A disk drive device with enumerator name USBSTOR
>> > >> > 3) A storage volume device with enumerator name STORAGE
>> > >> > let's say my driver has a pointer to the storage volume's PDO,
>> > >> > how can I know that this storage volume device is connected to a 
>> > >> > USB
>> > >> > hub
>> > >> > and not to the IDE for example ?
>> > >> > the enumerator name can't help me in this case.
>> > >> > knowing that the enumerator name is STORAGE says nothing about the
>> > >> > parent
>> > >> > of the device...
>> > >> > Is there a way to get a pointer to PDO of the creator of some 
>> > >> > other
>> PDO
>> > >> > ?
>> > >> >
>> > >> > "Doron Holan [MS]" wrote:
>> > >> >
>> > >> >> you should never *ever* *ever* (did i say ever?  i mean it!) send 
>> > >> >> a
>> > >> >> query
>> > >> >> device relations / BusRelations to the driver in question.  this 
>> > >> >> irp
>> > >> >> is
>> > >> >> strictly for the pnp subsystem to send.
>> > >> >>
>> > >> >> why?
>> > >> >>
>> > >> >> because if there is a state change based on the relations 
>> > >> >> reported
>> (a
>> > >> >> new
>> > >> >> PDO or the removal of one), you cannot enact that change. You 
>> > >> >> cannot
>> > >> >> create
>> > >> >> a new stack nor invoke a surprise removal on the removed PDO. 
>> > >> >> State
>> > >> >> get's
>> > >> >> lost, the driver who reported the change in its relations gets 
>> > >> >> put
>> > >> >> into a
>> > >> >> weird state and things go south really quickly.
>> > >> >>
>> > >> >> what you want is to ask the DO in question who its enumerator is,
>> > >> >> IoGetDeviceProperty(..., DevicePropertyEnumeratorName, ..) will
>> return
>> > >> >> a
>> > >> >> strig of the enumerator.  So for a usb device it would be L"USB",
>> for
>> > >> >> a
>> > >> >> parallel device probably L"LPT".
>> > >> >>
>> > >> >> d
>> > >> >>
>> > >> >> -- 
>> > >> >> Please do not send e-mail directly to this alias. this alias is 
>> > >> >> for
>> > >> >> newsgroup purposes only.
>> > >> >> This posting is provided "AS IS" with no warranties, and confers 
>> > >> >> no
>> > >> >> rights.
>> > >> >>
>> > >> >>
>> > >> >> "shahar" <shahar@discussions.microsoft.com> wrote in message
>> > >> >> news:4B8B0986-1DA0-4CFB-9AFB-B9DF98046642@microsoft.com...
>> > >> >> > When I want to know who are the children of a device I can send 
>> > >> >> > an
>> > >> >> IRP_MN_QUERY_DEVICE_RELATIONS request to it with "type =
>> > >> >> BusRelations",
>> > >> >> but
>> > >> >> how to I make the reversed operation ?
>> > >> >> > Let's say I have a printer DO, how can I know if it is 
>> > >> >> > connected
>> to
>> > >> >> > a
>> > >> >> parallel port or to a USB hub ?
>> > >> >>
>> > >> >>
>> > >> >>
>> > >>
>> > >>
>> > >>
>> >
>> >
>>
>>
>> 


Relevant Pages

  • Re: 0x0000007B
    ... If Windows XP Pro cannot install, then you will not get very far with XPe. ... Next I augmented my USB boot with every file system I could find, ... "Windows could not start because of a computer disk hardware configuration ... > Warning:Could not find a driver for Video Controller ...
    (microsoft.public.windowsxp.embedded)
  • Re: 0x0000007B
    ... XP Pro install should have reconized the USB flash disk as a removable device. ... Warning:Could not find a driver for Video Controller ...
    (microsoft.public.windowsxp.embedded)
  • Re: ROM-only FS and persisting registry on USB HD
    ... You actually would not expect everything to be copied to the 'hard disk' ... At present my device hangs after some time into boot process. ... of just loaded at initial (as IDE Hard Driver driver). ... the USB Disk driver is depends on and loaded USB Host driver ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Large HDD
    ... experienced the error message "Delayed Wirte Failed" error. ... As you are using USB external hard disk, I wonder if you have any other USB ... This posting is provided "AS IS" with no warranties, ...
    (microsoft.public.windows.server.sbs)
  • Re: Removable Device with partition tables
    ... Where in the USB device is that stored? ... I have a 256USB disk with a partition table having two entries: ... assigned a drive letter. ... You need a driver that makes Windows think it's a fixed drive. ...
    (microsoft.public.win32.programmer.kernel)

Loading