Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Attach to unnamed device.

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Hello,
please, somebody answer me how I can attach to an unnamed device.

--------
<Ratmil>

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    From: "Ratmil Torres Vargas" <[email protected]>
    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
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    On Wed, 15 Mar 2000, Matt Arnold wrote:

    > From: "Ratmil Torres Vargas" <[email protected]>
    > 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: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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:[email protected]]
    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" <[email protected]>
    > 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: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    >


    ---
    You are currently subscribed to ntdev as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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:[email protected]]
    > 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" <[email protected]>
    > > 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: [email protected]
    > > To unsubscribe send a blank email to $subst('Email.Unsub')
    > >
    >
    >
    > ---
    > You are currently subscribed to ntdev as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    >
    > ---
    > You are currently subscribed to ntdev as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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:[email protected]]
    > 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:[email protected]]
    > > 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" <[email protected]>
    > > > 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:
    > [email protected]
    > > > To unsubscribe send a blank email to
    > $subst('Email.Unsub')
    > > >
    > >
    > >
    > > ---
    > > You are currently subscribed to ntdev as: [email protected]
    > > To unsubscribe send a blank email to $subst('Email.Unsub')
    > >
    > > ---
    > > You are currently subscribed to ntdev as: [email protected]
    > > To unsubscribe send a blank email to $subst('Email.Unsub')
    > >
    >
    >
    > ---
    > You are currently subscribed to ntdev as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    >
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 January 2023 Live, Online
Developing Minifilters 20 March 2023 Live, Online
Internals & Software Drivers 17 April 2023 Live, Online
Writing WDF Drivers 22 May 2023 Live, Online