View Single Post
  #14  
Old Sunday, August 12, 2007
dangerrule's Avatar
dangerrule dangerrule is offline
Junior Member
 
Join Date: Aug 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
dangerrule is on a distinguished road
Default

READ FROM HERE LOL

Start with the MSDN documentation on file naming (http://msdn.microsoft.com/library/de...ing_a_file.asp) . It provides the list of reserved file names. It also explains the "\\?\D:\foo" syntax, with focus on overcoming the MAX_PATH length limitations in the ANSI APIs.

What it doesn't do is tie these ideas together. (It also doesn't mention the "\\.\" prefix, but it basically works like "\\?\".)

In NT-based versions of Windows (NT 3.1-4.0, Win2K, WinXP, Vista, etc) Win32 is implemented as a subsystem on top of the NT OS. One function of this subsystem is to translate filenames and pathnames from the Win32 object namespace to the NT object namespace. It is in this translation layer that the reserved names are handled. (This is also where concepts like "current directory" and "relative paths" are implemented.)

The "\\?\d:\foo" syntax provides a way to bypass the translation mechanism. This is why relative paths are not permitted using this syntax. This is also why you can create files with "Win32 reserved names" using this syntax.

The reserved names "feature" is done for backwards compability with Win16 and DOS applications. Modern versions of Windows and still run 16-bit applications via the included Virtual DOS Machine (VDM). Also, the initial Win32 APIs were, whenever possible, a simple 32-bit "widening" of the 16-bit APIs. I suspect 32-bit support for these reserved names was included to ease the porting of 16-bit apps.

The connection between reserved names and "\\?\d:\foo" may be subtle and not documented very clearly, but there's no magic, no conspiracy, no "MS FORGOT TO REMOVE SOME DOS CODE" mistakes. It may seem unnecessary now, but the industry was very different 16 years ago when Win32 was designed.
__________________
"some people only look good in war"
Reply With Quote