how to compare the path given by IRP_CREATE to "C:\My document"

In a file system filter driver IRP_CREATE routine,how to get the file
path,then check if it in the directo C:\My document

First, you need to figure out what device is “C:”. You can do this
using IoGetDeviceObjectPointer and passing in the name “\??\C:” with
FILE_ANY_ACCESS (this prevents a pop-up if this is a removable media
volume without media). Having that, the comparison then becomes:

if (FileObject->DeviceObject == DeviceObjectForTheCDrive) { … }

Keep in mind that this technique will not work for a myriad of cases:

  • Drives without drive letters
  • Drives that are mounted on the C: drive
  • In the presence of drive letter changes

Using drive letters is the worst possible choice - better to associate
it with the volume GUID (links are created by the volume managers)
because that works even if the drive letters change and it shifts the
burden of knowing about mount points to the user (different volume,
different GUID). However, drive letters are where most application
programmers start because they have this incorrect assumption that drive
letters have meaning inside the OS - they do not. By the time they get
to the file system, the drive letter is gone.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of cnmmd
Sent: Wednesday, July 07, 2004 3:55 AM
To: ntfsd redirect
Subject: [ntfsd] how to compare the path given by IRP_CREATE to “C:\My
document”

In a file system filter driver IRP_CREATE routine,how to get the file
path,then check if it in the directo C:\My document


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com

How does a filter driver get the volume GUID?
IOCTL_MOUNTDEV_QUERY_UNIQUE_ID gives something, but it doesn’t resemble the
contents of the GUIDs in HKLM\System\MountedDevices. I’ve searched and
can’t find it. (IOCTL_MOUNTDEV_QUERY_STABLE_GUID might be close, but it’s
not documented?)

Thanks,
Ken

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
Sent: Wednesday, July 07, 2004 9:49 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] how to compare the path given by IRP_CREATE to “C:\My
document”

First, you need to figure out what device is “C:”. You can do this
using IoGetDeviceObjectPointer and passing in the name “\??\C:” with
FILE_ANY_ACCESS (this prevents a pop-up if this is a removable media
volume without media). Having that, the comparison then becomes:

if (FileObject->DeviceObject == DeviceObjectForTheCDrive) { … }

Keep in mind that this technique will not work for a myriad of cases:

  • Drives without drive letters
  • Drives that are mounted on the C: drive
  • In the presence of drive letter changes

Using drive letters is the worst possible choice - better to associate
it with the volume GUID (links are created by the volume managers)
because that works even if the drive letters change and it shifts the
burden of knowing about mount points to the user (different volume,
different GUID). However, drive letters are where most application
programmers start because they have this incorrect assumption that drive
letters have meaning inside the OS - they do not. By the time they get
to the file system, the drive letter is gone.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of cnmmd
Sent: Wednesday, July 07, 2004 3:55 AM
To: ntfsd redirect
Subject: [ntfsd] how to compare the path given by IRP_CREATE to “C:\My
document”

In a file system filter driver IRP_CREATE routine,how to get the file
path,then check if it in the directo C:\My document


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@comcast.net
To unsubscribe send a blank email to xxxxx@lists.osr.com

You have to know who “owns” the volume before sending the IOCTL to the
owner. But if you have the right owner, you should get the same value as
that in the registry node.


James Antognini
Windows DDK Support

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

“Ken Cross” wrote in message news:xxxxx@ntfsd…
> How does a filter driver get the volume GUID?
> IOCTL_MOUNTDEV_QUERY_UNIQUE_ID gives something, but it doesn’t resemble
the
> contents of the GUIDs in HKLM\System\MountedDevices. I’ve searched and
> can’t find it. (IOCTL_MOUNTDEV_QUERY_STABLE_GUID might be close, but it’s
> not documented?)
>
> Thanks,
> Ken
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
> Sent: Wednesday, July 07, 2004 9:49 AM
> To: Windows File Systems Devs Interest List
> Subject: RE: [ntfsd] how to compare the path given by IRP_CREATE to “C:\My
> document”
>
> First, you need to figure out what device is “C:”. You can do this
> using IoGetDeviceObjectPointer and passing in the name “\??\C:” with
> FILE_ANY_ACCESS (this prevents a pop-up if this is a removable media
> volume without media). Having that, the comparison then becomes:
>
> if (FileObject->DeviceObject == DeviceObjectForTheCDrive) { … }
>
> Keep in mind that this technique will not work for a myriad of cases:
>
> - Drives without drive letters
> - Drives that are mounted on the C: drive
> - In the presence of drive letter changes
>
> Using drive letters is the worst possible choice - better to associate
> it with the volume GUID (links are created by the volume managers)
> because that works even if the drive letters change and it shifts the
> burden of knowing about mount points to the user (different volume,
> different GUID). However, drive letters are where most application
> programmers start because they have this incorrect assumption that drive
> letters have meaning inside the OS - they do not. By the time they get
> to the file system, the drive letter is gone.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of cnmmd
> Sent: Wednesday, July 07, 2004 3:55 AM
> To: ntfsd redirect
> Subject: [ntfsd] how to compare the path given by IRP_CREATE to “C:\My
> document”
>
> In a file system filter driver IRP_CREATE routine,how to get the file
> path,then check if it in the directo C:\My document
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
> send a blank email to xxxxx@lists.osr.com
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@comcast.net
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>