EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Can I reparse into long unicode names ("\\?\")

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#32199
Posted: 02/14/2015 13:08:26
by david bennett (Standard support level)
Joined: 03/29/2013
Posts: 50

I am using a reparse function that may add a fairly significant number of characters to the filename. I am worried about exceeding the 256 character filename limit. Is it okay to reparse into long unicode names (i.e. those that start with "\\?\") or UNC names?

On a related note, will my reparse function receive long unicode names? I currently don't expect that so am not handling it. How would that interact with the reparse rules?
#32200
Posted: 02/16/2015 03:06:53
by Vladimir Cherniga (EldoS Corp.)

If you talk about reparse file name callback, the output buffer is limited in 2048 bytes. About reparse rule - it doesn't have specific limits, but for NTFS it 32,767 maximum path length where each component is maximum 255 characters length.
#32219
Posted: 02/16/2015 12:25:59
by david bennett (Standard support level)
Joined: 03/29/2013
Posts: 50

Please look at this page: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

According to this page, in order to support filenames longer than 260 characters (including drive letter and null terminator), you must prefix the the name with "\\?\". Are you suggesting that I can return a filename longer than 260 characters from the reparse callback without this prefix?

Also, the second part of my question asked whether I would ever see filenames with the "\\?\" or if that has been stripped off before the reparse callback is called?
#32220
Posted: 02/16/2015 13:11:05
by Vladimir Cherniga (EldoS Corp.)

Quote
david bennett wrote:
Are you suggesting that I can return a filename longer than 260 characters from the reparse callback without this prefix?

No, I meant that even with a "\\?\" prefix, you may put a string not greater than 2048 byte length. It is a current limit of Callback Filter. You should follow the rules stated by msdn in any cases.

Quote
david bennett wrote:
Also, the second part of my question asked whether I would ever see filenames with the "\\?\" or if that has been stripped off before the reparse callback is called?

It should be stripped off in Callback Filter during full path name resolution in pre-create/pre-open/reparse callbacks. All paths in kernel are represented in NT format, it just converted in user mode to DOS format by default ("\Device\HardiskVolume1" to "C:" , for example)
#32221
Posted: 02/16/2015 14:03:48
by david bennett (Standard support level)
Joined: 03/29/2013
Posts: 50

I'm sorry if I seem thick, but you say that they should be stripped off "during" ... "reparse callbacks." Does that mean it will happen before, during or after I get the reparse callback? Is it my responsibility to strip it off if I change the name? If it's stripped off before it gets to my callback, then it's probably not okay for me to return a file with '\\?\' in it, right?
#32228
Posted: 02/17/2015 05:02:14
by Vladimir Cherniga (EldoS Corp.)

Quote
david bennett wrote:
I'm sorry if I seem thick, but you say that they should be stripped off "during" ... "reparse callbacks." Does that mean it will happen before, during or after I get the reparse callback?

It must appear stripped in reparse callback as a "ReparsedFileName" parameter. Even if it was prefixed with "\\?\" in original request (CreateFile(...)), then it stripped in callback.
Quote
david bennett wrote:
Is it my responsibility to strip it off if I change the name? If it's stripped off before it gets to my callback, then it's probably not okay for me to return a file with '\\?\' in it, right?

You should strip it off from "NewFileName" parameter. This prefix doesn't have sense in kernel, it just used in winapi allowing to disable file path string parsing.
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.

Reply

Statistics

Topic viewed 2620 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!