Converting special case filepaths/names

My mini filter sends unicode path & file names up to user space. User
code then converts the
“\Device…” format to the user-friendly “X:.…” format.

In user space, I use GetLogicalDriveStringsW() and QueryDosDeviceW() to
produce
lookup strings like so:

C: is \Device\HarddiskVolume1
S: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume1
T: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume2

Converting “\Device\HarddiskVolume1\File.ext” to “C:\File.ext” is no
problem.

For simple dynamic disks (S: & T: above) however, I get:

“\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1\File.ext”

I need to convert this into “S:\File.ext”

Is there an ‘approved’ method for doing this? I’m only processing
pre-create file.

I expect I’ll run into the same issue with shares and other forms of
dynamic disks.

Regards,
Mickey.

You can instead do RtlVolumeDeviceToDosName (or IoVolumeDeviceToDosName if you’re
running XP+) during the volume mount (or InstanceSetup for mini-filters), get the DOS
volume name, cache it in the device object extension (or volume context for
mini-filters), and pass the names by using the DOS name instead of the names below.

Mickey & Eileen Lane wrote:

My mini filter sends unicode path & file names up to user space. User
code then converts the
“\Device…” format to the user-friendly “X:.…” format.

In user space, I use GetLogicalDriveStringsW() and QueryDosDeviceW() to
produce
lookup strings like so:

C: is \Device\HarddiskVolume1
S: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume1
T: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume2

Converting “\Device\HarddiskVolume1\File.ext” to “C:\File.ext” is no
problem.

For simple dynamic disks (S: & T: above) however, I get:

“\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1\File.ext”

I need to convert this into “S:\File.ext”

Is there an ‘approved’ method for doing this? I’m only processing
pre-create file.

I expect I’ll run into the same issue with shares and other forms of
dynamic disks.

Regards,
Mickey.


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

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


Kind regards, Dejan M.
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa File Monitor - File monitoring library for Win32 developers.

Check out FilterGetDosName(). Also, consider using volume GUID names,
instead of kernel device names. The GUID name is usable in both user mode
and kernel mode, and FilterGetDosName will convert it to a drive letter or
mount point path.

  • Dan.

----- Original Message -----
From: “Mickey & Eileen Lane”
To: “Windows File Systems Devs Interest List”
Sent: Thursday, December 29, 2005 5:47 AM
Subject: [ntfsd] Converting special case filepaths/names

> My mini filter sends unicode path & file names up to user space. User code
> then converts the
> “\Device…” format to the user-friendly “X:.…” format.
>
> In user space, I use GetLogicalDriveStringsW() and QueryDosDeviceW() to
> produce
> lookup strings like so:
>
> C: is \Device\HarddiskVolume1
> S: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume1
> T: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume2
>
> Converting “\Device\HarddiskVolume1\File.ext” to “C:\File.ext” is no
> problem.
>
> For simple dynamic disks (S: & T: above) however, I get:
>
> “\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1\File.ext”
>
> I need to convert this into “S:\File.ext”
>
> Is there an ‘approved’ method for doing this? I’m only processing
> pre-create file.
>
> I expect I’ll run into the same issue with shares and other forms of
> dynamic disks.
>
> Regards,
> Mickey.
>
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@privtek.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Good thought, but it doesn’t work.

FilterGetDosName() fails on dynamic disks regardless of the string passed to
it. Try it, you’ll see.

My solution to the OP’s problem was to do it in the driver. Dynamic disks
are attached to the driver with a name like:

\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1

However, at the user level, the name is like:

\Device\HarddiskDmVolumes\W2ksrvDg0\Volume1

The latter is actually a symbolic link to the former. So my driver tries to
look up the symbolic link:

InitializeObjectAttributes();
ZwOpenSymbolicLinkObject();
ZwQuerySymbolicLinkObject();

Then I pass the symbolic link to the user-mode program, which can translate
it. Ugly, but it works.

HTH,
Ken

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dan Kyler
Sent: Thursday, December 29, 2005 9:09 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Converting special case filepaths/names

Check out FilterGetDosName(). Also, consider using volume GUID names,
instead of kernel device names. The GUID name is usable in both user mode
and kernel mode, and FilterGetDosName will convert it to a drive letter or
mount point path.

  • Dan.

----- Original Message -----
From: “Mickey & Eileen Lane”
To: “Windows File Systems Devs Interest List”
Sent: Thursday, December 29, 2005 5:47 AM
Subject: [ntfsd] Converting special case filepaths/names

> My mini filter sends unicode path & file names up to user space. User code

> then converts the
> “\Device…” format to the user-friendly “X:.…” format.
>
> In user space, I use GetLogicalDriveStringsW() and QueryDosDeviceW() to
> produce
> lookup strings like so:
>
> C: is \Device\HarddiskVolume1
> S: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume1
> T: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume2
>
> Converting “\Device\HarddiskVolume1\File.ext” to “C:\File.ext” is no
> problem.
>
> For simple dynamic disks (S: & T: above) however, I get:
>
> “\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1\File.ext”
>
> I need to convert this into “S:\File.ext”
>
> Is there an ‘approved’ method for doing this? I’m only processing
> pre-create file.
>
> I expect I’ll run into the same issue with shares and other forms of
> dynamic disks.
>
> Regards,
> Mickey.
>
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@privtek.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

That’s really bad. I found the previous discussion of this problem in the
archives, and the estimable Mr. Craig had a very apt typo:

“You may still need to sue FilterGetDosName()”

I think this is deserving of a Windows Update hotfix for all the affected
platforms.

  • Dan.

----- Original Message -----
From: “Ken Cross”
To: “Windows File Systems Devs Interest List”
Sent: Thursday, December 29, 2005 7:48 AM
Subject: RE: [ntfsd] Converting special case filepaths/names

> Good thought, but it doesn’t work.
>
> FilterGetDosName() fails on dynamic disks regardless of the string passed
> to
> it. Try it, you’ll see.
>
> My solution to the OP’s problem was to do it in the driver. Dynamic disks
> are attached to the driver with a name like:
>
> \Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1
>
> However, at the user level, the name is like:
>
> \Device\HarddiskDmVolumes\W2ksrvDg0\Volume1
>
> The latter is actually a symbolic link to the former. So my driver tries
> to
> look up the symbolic link:
>
> InitializeObjectAttributes();
> ZwOpenSymbolicLinkObject();
> ZwQuerySymbolicLinkObject();
>
> Then I pass the symbolic link to the user-mode program, which can
> translate
> it. Ugly, but it works.
>
> HTH,
> Ken
>
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dan Kyler
> Sent: Thursday, December 29, 2005 9:09 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] Converting special case filepaths/names
>
> Check out FilterGetDosName(). Also, consider using volume GUID names,
> instead of kernel device names. The GUID name is usable in both user mode
> and kernel mode, and FilterGetDosName will convert it to a drive letter or
> mount point path.
>
> - Dan.
>
> ----- Original Message -----
> From: “Mickey & Eileen Lane”
> To: “Windows File Systems Devs Interest List”
> Sent: Thursday, December 29, 2005 5:47 AM
> Subject: [ntfsd] Converting special case filepaths/names
>
>
>> My mini filter sends unicode path & file names up to user space. User
>> code
>
>> then converts the
>> “\Device…” format to the user-friendly “X:.…” format.
>>
>> In user space, I use GetLogicalDriveStringsW() and QueryDosDeviceW() to
>> produce
>> lookup strings like so:
>>
>> C: is \Device\HarddiskVolume1
>> S: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume1
>> T: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume2
>>
>> Converting “\Device\HarddiskVolume1\File.ext” to “C:\File.ext” is no
>> problem.
>>
>> For simple dynamic disks (S: & T: above) however, I get:
>>
>> “\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1\File.ext”
>>
>> I need to convert this into “S:\File.ext”
>>
>> Is there an ‘approved’ method for doing this? I’m only processing
>> pre-create file.
>>
>> I expect I’ll run into the same issue with shares and other forms of
>> dynamic disks.
>>
>> Regards,
>> Mickey.
>>
>>
>>
>>
>> —
>> Questions? First check the IFS FAQ at
>> https://www.osronline.com/article.cfm?id=17
>>
>> You are currently subscribed to ntfsd as: xxxxx@privtek.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
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@privtek.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Yes, his comments were actually “Look both of those names up via the mount
manager and you can get a common name for them.” I haven’t tried that –
seems like more work than what I’m doing.

Ken

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dan Kyler
Sent: Thursday, December 29, 2005 10:12 AM
To: Windows File Systems Devs Interest List
Cc: xxxxx@microsoft.com
Subject: Re: [ntfsd] Converting special case filepaths/names

That’s really bad. I found the previous discussion of this problem in the
archives, and the estimable Mr. Craig had a very apt typo:

“You may still need to sue FilterGetDosName()”

I think this is deserving of a Windows Update hotfix for all the affected
platforms.

  • Dan.

----- Original Message -----
From: “Ken Cross”
To: “Windows File Systems Devs Interest List”
Sent: Thursday, December 29, 2005 7:48 AM
Subject: RE: [ntfsd] Converting special case filepaths/names

> Good thought, but it doesn’t work.
>
> FilterGetDosName() fails on dynamic disks regardless of the string passed
> to
> it. Try it, you’ll see.
>
> My solution to the OP’s problem was to do it in the driver. Dynamic disks
> are attached to the driver with a name like:
>
> \Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1
>
> However, at the user level, the name is like:
>
> \Device\HarddiskDmVolumes\W2ksrvDg0\Volume1
>
> The latter is actually a symbolic link to the former. So my driver tries
> to
> look up the symbolic link:
>
> InitializeObjectAttributes();
> ZwOpenSymbolicLinkObject();
> ZwQuerySymbolicLinkObject();
>
> Then I pass the symbolic link to the user-mode program, which can
> translate
> it. Ugly, but it works.
>
> HTH,
> Ken
>
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Dan Kyler
> Sent: Thursday, December 29, 2005 9:09 AM
> To: Windows File Systems Devs Interest List
> Subject: Re: [ntfsd] Converting special case filepaths/names
>
> Check out FilterGetDosName(). Also, consider using volume GUID names,
> instead of kernel device names. The GUID name is usable in both user mode
> and kernel mode, and FilterGetDosName will convert it to a drive letter or
> mount point path.
>
> - Dan.
>
> ----- Original Message -----
> From: “Mickey & Eileen Lane”
> To: “Windows File Systems Devs Interest List”
> Sent: Thursday, December 29, 2005 5:47 AM
> Subject: [ntfsd] Converting special case filepaths/names
>
>
>> My mini filter sends unicode path & file names up to user space. User
>> code
>
>> then converts the
>> “\Device…” format to the user-friendly “X:.…” format.
>>
>> In user space, I use GetLogicalDriveStringsW() and QueryDosDeviceW() to
>> produce
>> lookup strings like so:
>>
>> C: is \Device\HarddiskVolume1
>> S: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume1
>> T: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume2
>>
>> Converting “\Device\HarddiskVolume1\File.ext” to “C:\File.ext” is no
>> problem.
>>
>> For simple dynamic disks (S: & T: above) however, I get:
>>
>> “\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1\File.ext”
>>
>> I need to convert this into “S:\File.ext”
>>
>> Is there an ‘approved’ method for doing this? I’m only processing
>> pre-create file.
>>
>> I expect I’ll run into the same issue with shares and other forms of
>> dynamic disks.
>>
>> Regards,
>> Mickey.
>>
>>
>>
>>
>> —
>> Questions? First check the IFS FAQ at
>> https://www.osronline.com/article.cfm?id=17
>>
>> You are currently subscribed to ntfsd as: xxxxx@privtek.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
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@privtek.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

re:

InitializeObjectAttributes();
ZwOpenSymbolicLinkObject();
ZwQuerySymbolicLinkObject();

You do this for every pre create file call? Does it resolve basic,
simple dynamic & striped disks?
What about mount point volumes?

My pre create file call starts out “get PID” followed by
“FltGetFileNameInformation” more or less.

For basic, simple dynamic & striped disks, I get a name like
“\Device.…” string like we have
been discussing. For accesses to mount point volumens,
FltGetFileNameInformation returns
STATUS_NOT_SAME_DEVICE on XP SP 2. It works on Windows 2000.

C: has \DiskTest\Dir and a volume is mounted there. I use Notepad to
create a file.
In the callback I get a trace message:

FltGetFileNameInformation returned
“\Device\HarddiskVolume1\DiskTest\Dir”

I then try to open the file to verify its properties (it doesn’t exist)
and (on 2000) FltCreateFile
returns 0xC0000369 which is STATUS_MOUNT_POINT_NOT_RESOLVED in the XP
headers and undefined in 2000.

I keep telling these folks that developing code to run on all these
platforms is like dealing
with an N dimension matrix. Every time you add some functionality, N
jumps by 2 or 3.

I was hoping for identical performance on 2000 & XP SP 2. Oh well.

Mickey.

Ken Cross wrote:

My solution to the OP’s problem was to do it in the driver. Dynamic disks
are attached to the driver with a name like:

\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1

However, at the user level, the name is like:

\Device\HarddiskDmVolumes\W2ksrvDg0\Volume1

The latter is actually a symbolic link to the former. So my driver tries to
look up the symbolic link:

InitializeObjectAttributes();
ZwOpenSymbolicLinkObject();
ZwQuerySymbolicLinkObject();

Then I pass the symbolic link to the user-mode program, which can translate
it. Ugly, but it works.

HTH,
Ken

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dan Kyler
Sent: Thursday, December 29, 2005 9:09 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Converting special case filepaths/names

Check out FilterGetDosName(). Also, consider using volume GUID names,
instead of kernel device names. The GUID name is usable in both user mode
and kernel mode, and FilterGetDosName will convert it to a drive letter or
mount point path.

  • Dan.

----- Original Message -----
From: “Mickey & Eileen Lane”
>To: “Windows File Systems Devs Interest List”
>Sent: Thursday, December 29, 2005 5:47 AM
>Subject: [ntfsd] Converting special case filepaths/names
>
>
>
>>My mini filter sends unicode path & file names up to user space. User code
>>
>
>>then converts the
>>“\Device…” format to the user-friendly “X:.…” format.
>>
>>In user space, I use GetLogicalDriveStringsW() and QueryDosDeviceW() to
>>produce
>>lookup strings like so:
>>
>>C: is \Device\HarddiskVolume1
>>S: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume1
>>T: is \Device\HarddiskDmVolumes\Stig2000proDg0\Volume2
>>
>>Converting “\Device\HarddiskVolume1\File.ext” to “C:\File.ext” is no
>>problem.
>>
>>For simple dynamic disks (S: & T: above) however, I get:
>>
>>“\Device\HarddiskDmVolumes\PhysicalDmVolumes\BlockVolume1\File.ext”
>>
>>I need to convert this into “S:\File.ext”
>>
>>Is there an ‘approved’ method for doing this? I’m only processing
>>pre-create file.
>>
>>I expect I’ll run into the same issue with shares and other forms of
>>dynamic disks.
>>
>>Regards,
>>Mickey.
>>
>>
>>
>>
>>—
>>Questions? First check the IFS FAQ at
>>https://www.osronline.com/article.cfm?id=17
>>
>>You are currently subscribed to ntfsd as: xxxxx@privtek.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
>
>
>
>—
>Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
>
>You are currently subscribed to ntfsd as: xxxxx@earthlink.net
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

> You can instead do RtlVolumeDeviceToDosName (or
IoVolumeDeviceToDosName if you’re

running XP+) during the volume mount (or InstanceSetup for mini-filters), get
the
DOS
volume name, cache it in the device object extension (or volume context for

Bad idea, this cached name will be invalid if the user will change the drive
letter.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com