Are extended paths safe?

I just stumbled upon this article on MSDN, which says that the path can be 259 characters + NUL completion, but if you prefix it with "\\? \" WinAPI allows you to use

maximum total path length 32,767 characters.

Wanting to see it work, I tried using this prefix from Explorer (on XP SP3), but it does not work at all (on any path). If you put \\?\C:\Path\to\an\existing.file in the explorer panel, it will give a "file not found" error.

So I'm confused. Can I encode something for (not ancient) Windows that fully uses the specified path size in NTFS? Why is Explorer not using it?

+3
source share
3 answers

There are a set of API calls that work with extended paths, and some do not. MSDN usually mentions this.

Not that just entering this path in windows explorerunder xp doesn't work, because the extended path syntax is just an escape sequence for the WIn32 API, not for Windows Explorer. Now, in Win7, this works because many people expected this to work.

Also for long paths this helps if you change the working directory or open the explorer with a subdirectory as root.

+2
source

Before someone tells me RTFM ...

Please note that these examples are intended for use with the Windows API functions, and not all of them necessarily work with Windows shell applications, such as Windows Explorer.
[...]
For file input / output, the prefix "\\? \" To the path line tells the Windows API to disable all parsing of the line and send the line that follows it directly to the file system. For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that would otherwise be executed using the Windows API.

On a secondary note, this makes you think about the possibilities to hide files (or find such files) from the explorer using illegal file names.

+1
source

Are you asking why all the components on Windows do not support it, or are you asking if using these long paths is legal?

You can use them safely, but you can annoy those who want to use tools like Explorer to view them. We constantly see such paths in the wild. Sometimes people are very surprised when they cannot use MY_FAVORITE_TOOL to remove it ...

0
source

Source: https://habr.com/ru/post/986126/


All Articles