Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does \\?\ mean when prepended to a file path

I found a reference to a file in a log that had the following format:

\\?\C:\Path\path\file.log 

I cannot find a reference to what the sequence of \?\ means. I believe the part between the backslashes refers to a hostname.

For instance, on my Windows computer, the following works just fine:

dir \\?\C:\ 

and also, just fine with same result:

dir \\.\C:\ 

Questions:

  1. Is there a reference to what the question mark means in this particular path format?
  2. What might generate a file path in such a format?
like image 469
bjjer Avatar asked Jan 17 '14 19:01

bjjer


People also ask

What is meant by the path to the file?

Alternatively known as the pathname, the current path or path is the complete location or name of where a computer, file, device, or web page is located.

What does copying a file path do?

In the context menu that pops up, select “Copy As Path.” (The location of “Copy As Path” in the context menu list will vary, depending on your system setup and the type of file you are right-clicking on.) This will copy the full path of the file's location onto the Windows clipboard.


2 Answers

A long read, but worth reading if you are in this domain: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx

Extract:

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path".

and:

The "\\?\" prefix can also be used with paths constructed according to the universal naming convention (UNC). To specify such a path using UNC, use the "\\?\UNC\" prefix. For example, "\\?\UNC\server\share", where "server" is the name of the computer and "share" is the name of the shared folder. These prefixes are not used as part of the path itself. They indicate that the path should be passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory, or double dots to represent the parent directory. Because you cannot use the "\\?\" prefix with a relative path, relative paths are always limited to a total of MAX_PATH characters.

like image 92
Ferenc Deak Avatar answered Sep 23 '22 19:09

Ferenc Deak


The Windows API parses input strings for file I/O. Among other things, it translates / to \ as part of converting the name to an NT-style name, or interpreting the . and .. pseudo directories. With few exceptions, the Windows API also limits path names to 260 characters.

The documented purpose of the \\?\ prefix is:

For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system.

This allows the use of . or .. in path names, as well as relaxing the 260 character path name limit, if the underlying file system supports long paths and file names.

like image 31
IInspectable Avatar answered Sep 21 '22 19:09

IInspectable