Optimal way to attach to removable devices

[ I sent this message earlier to the mailing list, but didn’t get an
acknowledgment, nor did I see the message on the list ]

Hi,

I was wondering what the optimal way is to connect to the device object
that represent CD-Rom drives, floppy disk drives, mounted network shares
etc, with respect to the media change possibilities. Right now, my driver
attaches to Fat, CDFS and NTFS, and if a mount operation has succeeded, I
go through all possible drive letters to so if there’s a valid disk in the
drive, which I need to attach to.

Currently I’m experimenting with user-mode notifications of media
insertions/removal, which seems more efficient, beause I can determine what
driver letter was added, or received new media.

Also, I’m struggling with the FastIODetach for removable disks, it seems to
be activated too late (for my perception)

Any comments on the above ?


Bartjan.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

IMO, IoRegisterFsRegistrationChange is the easier way here. I
already tried
your idea, and found that I can have trouble of not getting a
FastIoDetach…

Regards, Dejan.

Bartjan Wattel wrote:

[ I sent this message earlier to the mailing list, but didn’t get an
acknowledgment, nor did I see the message on the list ]

Hi,

I was wondering what the optimal way is to connect to the device object
that represent CD-Rom drives, floppy disk drives, mounted network shares
etc, with respect to the media change possibilities. Right now, my driver
attaches to Fat, CDFS and NTFS, and if a mount operation has succeeded, I
go through all possible drive letters to so if there’s a valid disk in the
drive, which I need to attach to.

Currently I’m experimenting with user-mode notifications of media
insertions/removal, which seems more efficient, beause I can determine what
driver letter was added, or received new media.

Also, I’m struggling with the FastIODetach for removable disks, it seems to
be activated too late (for my perception)

Any comments on the above ?


Bartjan.


You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa Registry Monitor - Registry monitoring library for Win32
developers.
Alfa Registry Protector - Registry protection library for Win32
developers.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Removable media does not delete the partition device object like a fixed
disk does when you repartition. It is a static device object. Your
fastiodetachdevice() will not be called in this case.

Maybe this is related… I do not have much experience in filtering
removable media.

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Friday, January 11, 2002 12:12 PM
To: File Systems Developers
Subject: [ntfsd] Re: Optimal way to attach to removable devices

IMO, IoRegisterFsRegistrationChange is the easier way here. I
already tried your idea, and found that I can have trouble of not
getting a FastIoDetach…

Regards, Dejan.

Bartjan Wattel wrote:

[ I sent this message earlier to the mailing list, but didn’t get an
acknowledgment, nor did I see the message on the list ]

Hi,

I was wondering what the optimal way is to connect to the device
object that represent CD-Rom drives, floppy disk drives, mounted
network shares etc, with respect to the media change possibilities.
Right now, my driver attaches to Fat, CDFS and NTFS, and if a mount
operation has succeeded, I go through all possible drive letters to so

if there’s a valid disk in the drive, which I need to attach to.

Currently I’m experimenting with user-mode notifications of media
insertions/removal, which seems more efficient, beause I can determine

what driver letter was added, or received new media.

Also, I’m struggling with the FastIODetach for removable disks, it
seems to be activated too late (for my perception)

Any comments on the above ?


Bartjan.


You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers. Alfa
File Protector - File protection and hiding library for Win32
developers. Alfa Registry Monitor - Registry monitoring library for
Win32 developers. Alfa Registry Protector - Registry protection library
for Win32 developers.


You are currently subscribed to ntfsd as: xxxxx@storagecraft.com To
unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Removable media does not delete the partition device object like a fixed

disk does when you repartition. It is a static device object. Your
fastiodetachdevice() will not be called in this case.

Exactly the reason, still if I do not reattach the IRPs will not be
passed for the new volume.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa Registry Monitor - Registry monitoring library for Win32 developers.
Alfa Registry Protector - Registry protection library for Win32 developers.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

There was a bug with removable media filtering - like wrong reference counting or such.
So, without the hack in the mount path, accessing a CD in Explorer caused BSOD for my filter.

Max

----- Original Message -----
From: “Jamey Kirby”
To: “File Systems Developers”
Sent: Friday, January 11, 2002 11:35 PM
Subject: [ntfsd] Re: Optimal way to attach to removable devices

>
> Removable media does not delete the partition device object like a fixed
> disk does when you repartition. It is a static device object. Your
> fastiodetachdevice() will not be called in this case.
>
> Maybe this is related… I do not have much experience in filtering
> removable media.
>
> Jamey
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
> Sent: Friday, January 11, 2002 12:12 PM
> To: File Systems Developers
> Subject: [ntfsd] Re: Optimal way to attach to removable devices
>
>
>
> IMO, IoRegisterFsRegistrationChange is the easier way here. I
> already tried your idea, and found that I can have trouble of not
> getting a FastIoDetach…
>
> Regards, Dejan.
>
> Bartjan Wattel wrote:
>
> > [I sent this message earlier to the mailing list, but didn’t get an <br>&gt; &gt; acknowledgment, nor did I see the message on the list]
> >
> > Hi,
> >
> > I was wondering what the optimal way is to connect to the device
> > object that represent CD-Rom drives, floppy disk drives, mounted
> > network shares etc, with respect to the media change possibilities.
> > Right now, my driver attaches to Fat, CDFS and NTFS, and if a mount
> > operation has succeeded, I go through all possible drive letters to so
>
> > if there’s a valid disk in the drive, which I need to attach to.
> >
> > Currently I’m experimenting with user-mode notifications of media
> > insertions/removal, which seems more efficient, beause I can determine
>
> > what driver letter was added, or received new media.
> >
> > Also, I’m struggling with the FastIODetach for removable disks, it
> > seems to be activated too late (for my perception)
> >
> > Any comments on the above ?
> >
> > –
> > Bartjan.
> >
> > —
> > You are currently subscribed to ntfsd as: xxxxx@alfasp.com
> > To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> –
> Kind regards, Dejan M. www.alfasp.com
> E-mail: xxxxx@alfasp.com ICQ#: 56570367
> Alfa File Monitor - File monitoring library for Win32 developers. Alfa
> File Protector - File protection and hiding library for Win32
> developers. Alfa Registry Monitor - Registry monitoring library for
> Win32 developers. Alfa Registry Protector - Registry protection library
> for Win32 developers.
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com To
> unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Maybe you can simply attach a new filter and be on your way. Eventually,
the DO will get deleted.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Friday, January 11, 2002 1:09 PM
To: File Systems Developers
Subject: [ntfsd] Re: Optimal way to attach to removable devices

Removable media does not delete the partition device object like a
fixed disk does when you repartition. It is a static device object.
Your
fastiodetachdevice() will not be called in this case.

Exactly the reason, still if I do not reattach the IRPs will not be
passed for the new volume.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers. Alfa
File Protector - File protection and hiding library for Win32
developers. Alfa Registry Monitor - Registry monitoring library for
Win32 developers. Alfa Registry Protector - Registry protection library
for Win32 developers.


You are currently subscribed to ntfsd as: xxxxx@storagecraft.com To
unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> So, without the hack in the mount path, accessing a CD in Explorer caused BSOD for my filter.

What hack was that?
I’m not getting a BSOD, but as I noted in another post, with InCD every possible filter
(including the simple SFIlter) causes the CD/DVD/CDRW to be inaccessible.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa Registry Monitor - Registry monitoring library for Win32 developers.
Alfa Registry Protector - Registry protection library for Win32 developers.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

It doesn’t matter now - with IoRegisterFsRegistrationChange it works the
way it should, and is much easier.

Maybe you can simply attach a new filter and be on your way. Eventually,
the DO will get deleted.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa Registry Monitor - Registry monitoring library for Win32 developers.
Alfa Registry Protector - Registry protection library for Win32 developers.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

At 22:53 11-1-2002 +0100, you wrote:
> It doesn’t matter now - with IoRegisterFsRegistrationChange it works the
> way it should, and is much easier.

A few questions here:

  1. Is IoRegisterFsRegistrationChange not used for notifying file system
    loading rather than media changes ?
  2. Does IoRegisterFsRegistrationChange work for CD’s as well as floppy’s as
    well as mounted network drives ?
  3. Is IoRegisterFsRegistrationChange supported on Windows NT4?


Bartjan.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> 2. Does IoRegisterFsRegistrationChange work for CD’s as well as floppy’s as

well as mounted network drives ?

For CD and floppy - yes, for network redirectors - no.
IoRegisterFsRegistrationChange is for on-disk filesystems only.

  1. Is IoRegisterFsRegistrationChange supported on Windows NT4?

Surely.

Max


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Thanks Maxim,

you didn’t answer my first question though.
> 1. Is IoRegisterFsRegistrationChange not used for notifying file
> system loading rather than media changes ?

With this question, I try to find an answer wether or not I can use this
function if my driver is loaded manually, and if I want to “detect”
insertions and ejections of removable media.


Bartjan.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

>if I want to “detect” insertions and ejections of removable media.

No, this function is not for this.
STATUS_VERIFY_REQUIRED thing is for this.

Max


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> 1. Is IoRegisterFsRegistrationChange not used for notifying file system

loading rather than media changes ?

Yes, but you get IRP_MJ_FILE_SYSTEM_CONTROL and by responding to
IRP_MN_MOUNT_VOLUME request, you can attach to any media - HD, CD, floppy,
ZIP…

  1. Does IoRegisterFsRegistrationChange work for CD’s as well as floppy’s as
    well as mounted network drives ?

Yes, except that you don’t get any knowledge about network drives.
These are passed to you because you attach to LanmanRedirector.
All network drives are handled by LR, so don’t attach to them, or you will
get all IRPs sent to any of them multiple times.
Path handling is a little uneasy here.

  1. Is IoRegisterFsRegistrationChange supported on Windows NT4?

Yes, except that you must attach to LanmanRedirector on NT, as it doesn’t
get through the the above path.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa Registry Monitor - Registry monitoring library for Win32 developers.
Alfa Registry Protector - Registry protection library for Win32 developers.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

No, your driver must be loaded BEFORE any file system or you won’t get
any calls for that particular file system or the volumes it controls.
The only safe way is to load it in the Filter group as the Boot driver.

you didn’t answer my first question though.
> 1. Is IoRegisterFsRegistrationChange not used for notifying file
> system loading rather than media changes ?

With this question, I try to find an answer wether or not I can use this
function if my driver is loaded manually, and if I want to “detect”
insertions and ejections of removable media.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa Registry Monitor - Registry monitoring library for Win32 developers.
Alfa Registry Protector - Registry protection library for Win32 developers.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Filespy in the XP IFS kit (NOT in the Win2k IFS kit) has extensive logic
demonstrating how to use IoRegisterFsRegistrationChange and hook
IRP_MN_MOUNT_VOLUME.

  • Nicholas Ryan

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Saturday, January 12, 2002 10:36 AM
To: File Systems Developers
Subject: [ntfsd] Re: Optimal way to attach to removable devices

  1. Is IoRegisterFsRegistrationChange not used for notifying file
    system
    loading rather than media changes ?

Yes, but you get IRP_MJ_FILE_SYSTEM_CONTROL and by responding to
IRP_MN_MOUNT_VOLUME request, you can attach to any media - HD, CD,
floppy,
ZIP…

  1. Does IoRegisterFsRegistrationChange work for CD’s as well as
    floppy’s as
    well as mounted network drives ?

Yes, except that you don’t get any knowledge about network drives.
These are passed to you because you attach to LanmanRedirector.
All network drives are handled by LR, so don’t attach to them, or
you will
get all IRPs sent to any of them multiple times.
Path handling is a little uneasy here.

  1. Is IoRegisterFsRegistrationChange supported on Windows NT4?

Yes, except that you must attach to LanmanRedirector on NT, as it
doesn’t
get through the the above path.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa Registry Monitor - Registry monitoring library for Win32
developers.
Alfa Registry Protector - Registry protection library for Win32
developers.


You are currently subscribed to ntfsd as: xxxxx@secretseal.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

There seems to be some confusion on this issue so let me explain how
this works:

A filters callback routine registered with
IoRegisterFsRegistrationChange is called whenever a file system calls
IoRegsterFileSystem.

In NT4 and Win2K you only received callbacks for any file systems that
called IoRegisterFileSystem after a filter called
IoRegisterFsRegistrationChange. As was mentioned earlier if your filter
needs to attach to any of the bootable file systems (ntfs or fat) then
your filter must load at boot time.

This functionality was changed in XP. In XP immediately upon calling
IoRegisterFsRegistrationChange the IO manager will call the filters
callback routine for all file systems that are already registered except
for the NULL file system.

When a filters registered callback routine is called they are given the
address of a file systems control device object. If they care about
filtering mounted volumes of this file system they should attach their
own device object to this given file systems device object. You are
doing this so that you can see volume mount requests for the file system
because they always go through the given file systems control device
object. It doesn’t matter whether this is removable media or not, all
mounts for local file systems occur this way.

As was stated earlier, the SFILTER and FILESPY samples in the XP version
of the IFSKit are very clear on how this all works and what exactly you
should do.

Do not worry about the fact that your FastIoDetach routine is not called
immediately after a volume is dismounted. There are lots of reasons
that the file systems keep around the old device objects for a period of
time. The system is doing the correct thing in these situations, don’t
worry about it.

All of the new RDR2 based redirectors now properly call
IoRegisterFileSystems. This means your IoRegisterFsRegistrationChange
callback will be called when one of these redirector file systems load.
For Win2K this was LanmanRedirector. For XP this includes
LanmanRedirector, WebDav, NFS, and RDPDR (terminal server redirector).
I am not currently aware of any plans by 3rd party redirectors (like
Netware) to switch over to the RDR2 model. For those guys you are going
to have to do some sort of polling to figure out when they load.

Neal Christiansen

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Nicholas Ryan [mailto:xxxxx@secretseal.com]
Sent: Saturday, January 12, 2002 01:45 PM
To: File Systems Developers
Subject: [ntfsd] Re: Optimal way to attach to removable devices

Filespy in the XP IFS kit (NOT in the Win2k IFS kit) has extensive logic
demonstrating how to use IoRegisterFsRegistrationChange and hook
IRP_MN_MOUNT_VOLUME.

  • Nicholas Ryan

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Saturday, January 12, 2002 10:36 AM
To: File Systems Developers
Subject: [ntfsd] Re: Optimal way to attach to removable devices

  1. Is IoRegisterFsRegistrationChange not used for notifying file
    system
    loading rather than media changes ?

Yes, but you get IRP_MJ_FILE_SYSTEM_CONTROL and by responding to
IRP_MN_MOUNT_VOLUME request, you can attach to any media - HD, CD,
floppy,
ZIP…

  1. Does IoRegisterFsRegistrationChange work for CD’s as well as
    floppy’s as
    well as mounted network drives ?

Yes, except that you don’t get any knowledge about network drives.
These are passed to you because you attach to LanmanRedirector.
All network drives are handled by LR, so don’t attach to them, or
you will
get all IRPs sent to any of them multiple times.
Path handling is a little uneasy here.

  1. Is IoRegisterFsRegistrationChange supported on Windows NT4?

Yes, except that you must attach to LanmanRedirector on NT, as it
doesn’t
get through the the above path.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com ICQ#: 56570367
Alfa File Monitor - File monitoring library for Win32 developers.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa Registry Monitor - Registry monitoring library for Win32
developers.
Alfa Registry Protector - Registry protection library for Win32
developers.


You are currently subscribed to ntfsd as: xxxxx@secretseal.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@Windows.Microsoft.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com