Attach to unnamed device.

Hello,
please, somebody answer me how I can attach to an unnamed device.


From: “Ratmil Torres Vargas”
Sent: Wednesday, March 15, 2000 2:03 PM

> Hello,
> please, somebody answer me how I can attach to an unnamed device.

[snip]

The same way you attach to any device, using IoAttachDeviceToDeviceStack().
The problem is retrieving the pointer to DEVICE_OBJECT to attach.

If the device is unnamed, then you must some other (proprietary) way to
retrieve its pointer. So, to start with, who owns this DEVICE_OBJECT? What
is its role in the system?

Regards,

Matt Arnold
Professional Music Products
Mark of the Unicorn, Inc.
http://www.motu.com

On Wed, 15 Mar 2000, Matt Arnold wrote:

From: “Ratmil Torres Vargas”
> Sent: Wednesday, March 15, 2000 2:03 PM
>
>
> > Hello,
> > please, somebody answer me how I can attach to an unnamed device.
>
> [snip]
>
> The same way you attach to any device, using IoAttachDeviceToDeviceStack().
> The problem is retrieving the pointer to DEVICE_OBJECT to attach.

Actually, I use IoAttachDeviceByPointer but I guess there’s no much
difference.

>
> If the device is unnamed, then you must some other (proprietary) way to
> retrieve its pointer. So, to start with, who owns this DEVICE_OBJECT? What
> is its role in the system?
Let me tell you first what I want to do. I want to be called every time
there’s an access to a file on Drive A:. The way to do this is attaching
to “DosDevices\A:” but I can’t do it if the driver for Drive A: is not
loaded. I can already know when this driver is loaded. So in that moment I
attach to “DosDevices\A:”.
This works only if the user inserts a diskette and then accesses it, OK
I attach successfully. But if the user before inserting the
diskette accesses drive A: (getting an error) the system loads the driver,
I am called then and try to attach to “DosDevices\A:” but I can make it
because there’s no diskette.
I have noticed that the driver the system loads is “FatFileSystem”, it
has an unnamed device that I guess is the one I have to attach.

THANK YOU VERY MUCH
I hope I have written clear enough.

>
>
> Regards,
>
> Matt Arnold
> Professional Music Products
> Mark of the Unicorn, Inc.
> http://www.motu.com
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@ghost.matcom.uh.cu
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>

Why not do IoGetDeviceInterfaces on the GUID for the Floppy Device. That
should get you what your looking for, I believe.

-----Original Message-----
From: Ratmil Torres Vargas [mailto:xxxxx@ghost.matcom.uh.cu]
Sent: Thursday, March 16, 2000 9:12 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Attach to unnamed device.

On Wed, 15 Mar 2000, Matt Arnold wrote:

From: “Ratmil Torres Vargas”
> Sent: Wednesday, March 15, 2000 2:03 PM
>
>
> > Hello,
> > please, somebody answer me how I can attach to an unnamed device.
>
> [snip]
>
> The same way you attach to any device, using
IoAttachDeviceToDeviceStack().
> The problem is retrieving the pointer to DEVICE_OBJECT to attach.

Actually, I use IoAttachDeviceByPointer but I guess there’s no much
difference.

>
> If the device is unnamed, then you must some other (proprietary) way to
> retrieve its pointer. So, to start with, who owns this DEVICE_OBJECT?
What
> is its role in the system?
Let me tell you first what I want to do. I want to be called every time
there’s an access to a file on Drive A:. The way to do this is attaching
to “DosDevices\A:” but I can’t do it if the driver for Drive A: is not
loaded. I can already know when this driver is loaded. So in that moment I
attach to “DosDevices\A:”.
This works only if the user inserts a diskette and then accesses it, OK
I attach successfully. But if the user before inserting the
diskette accesses drive A: (getting an error) the system loads the driver,
I am called then and try to attach to “DosDevices\A:” but I can make it
because there’s no diskette.
I have noticed that the driver the system loads is “FatFileSystem”, it
has an unnamed device that I guess is the one I have to attach.

THANK YOU VERY MUCH
I hope I have written clear enough.

>
>
> Regards,
>
> Matt Arnold
> Professional Music Products
> Mark of the Unicorn, Inc.
> http://www.motu.com
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@ghost.matcom.uh.cu
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>


You are currently subscribed to ntdev as: xxxxx@osr.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

On Thu, 16 Mar 2000, Mark Cariddi wrote:

Why not do IoGetDeviceInterfaces on the GUID for the Floppy Device. That
should get you what your looking for, I believe.
I didn’t find that function in the DDK. Anyway I solved it by getting a
pointer to a named device in the same driver and searching by NextDevice.
But I guess this solution is not very elegant.

From: Ratmil Torres Vargas [mailto:xxxxx@ghost.matcom.uh.cu]
Sent: Thursday, March 16, 2000 9:12 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Attach to unnamed device.

On Wed, 15 Mar 2000, Matt Arnold wrote:

> From: “Ratmil Torres Vargas”
> > Sent: Wednesday, March 15, 2000 2:03 PM
> >
> >
> > > Hello,
> > > please, somebody answer me how I can attach to an unnamed device.
> >
> > [snip]
> >
> > The same way you attach to any device, using
> IoAttachDeviceToDeviceStack().
> > The problem is retrieving the pointer to DEVICE_OBJECT to attach.
>
> Actually, I use IoAttachDeviceByPointer but I guess there’s no much
> difference.
>
> >
> > If the device is unnamed, then you must some other (proprietary) way to
> > retrieve its pointer. So, to start with, who owns this DEVICE_OBJECT?
> What
> > is its role in the system?
> >
> >
> > Regards,
> >
> > Matt Arnold
> > Professional Music Products
> > Mark of the Unicorn, Inc.
> > http://www.motu.com
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@ghost.matcom.uh.cu
> > To unsubscribe send a blank email to $subst(‘Email.Unsub’)
> >
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@osr.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>
> —
> You are currently subscribed to ntdev as: xxxxx@ghost.matcom.uh.cu
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>

Not only is it not elegant, it is downright dangerous. You don’t own this
linked list, so there is no way for you to serialize access to it.
Consequently it can change while you are in the middle of enumerating it.
Elements can be added or removed, your pointer can be stale, and your list
enumeration may be incorrect. In general you should not be directly using
fields in system created objects that are not documented for your use.
Consider these fields to be ‘private data’ for these objects, accessible
only via the defined ‘methods’ that operate on them.

There is a basic flaw in what you are doing: if you are trying to attach to
a PnP device stack then you should be using the documented mechanisms for
doing this. If instead you are trying to send IO to a pnp device stack then
either you open the named interface using the legacy way (you know the
device name) or as Mark Cariddi suggested, you do it the W2K way and get the
device from IoGetDeviceInterfaces(). In either case you don’t care about the
unnamed devices, the OS will do the right thing for you, either attaching
you to the top filter driver in the stack or opening the top filter driver
for IO.

p.s. :
“NTSTATUS
IoGetDeviceInterfaces(
IN CONST GUID *InterfaceClassGuid,
IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
IN ULONG Flags,
OUT PWSTR *SymbolicLinkList
);
IoGetDeviceInterfaces returns a list of device interfaces of a particular
device interface class (such as all devices on the system that support a HID
interface).”

If you can’t find it in the table of contents, try the index.

-----Original Message-----
From: Ratmil Torres Vargas [mailto:xxxxx@ghost.matcom.uh.cu]
Sent: Friday, March 17, 2000 1:39 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Attach to unnamed device.

On Thu, 16 Mar 2000, Mark Cariddi wrote:

> Why not do IoGetDeviceInterfaces on the GUID for the Floppy
Device. That
> should get you what your looking for, I believe.
I didn’t find that function in the DDK. Anyway I solved it
by getting a
pointer to a named device in the same driver and searching by
NextDevice.
But I guess this solution is not very elegant.
>
> From: Ratmil Torres Vargas [mailto:xxxxx@ghost.matcom.uh.cu]
> Sent: Thursday, March 16, 2000 9:12 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: Attach to unnamed device.
>
>
>
> On Wed, 15 Mar 2000, Matt Arnold wrote:
>
> > From: “Ratmil Torres Vargas”
> > > Sent: Wednesday, March 15, 2000 2:03 PM
> > >
> > >
> > > > Hello,
> > > > please, somebody answer me how I can attach to an
> unnamed device.
> > >
> > > [snip]
> > >
> > > The same way you attach to any device, using
> > IoAttachDeviceToDeviceStack().
> > > The problem is retrieving the pointer to DEVICE_OBJECT to attach.
> >
> > Actually, I use IoAttachDeviceByPointer but I guess
> there’s no much
> > difference.
> >
> > >
> > > If the device is unnamed, then you must some other
> (proprietary) way to
> > > retrieve its pointer. So, to start with, who owns this
> DEVICE_OBJECT?
> > What
> > > is its role in the system?
> > >
> > >
> > > Regards,
> > >
> > > Matt Arnold
> > > Professional Music Products
> > > Mark of the Unicorn, Inc.
> > > http://www.motu.com
> > >
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as:
> xxxxx@ghost.matcom.uh.cu
> > > To unsubscribe send a blank email to
> $subst(‘Email.Unsub’)
> > >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@osr.com
> > To unsubscribe send a blank email to $subst(‘Email.Unsub’)
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@ghost.matcom.uh.cu
> > To unsubscribe send a blank email to $subst(‘Email.Unsub’)
> >
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@stratus.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>