Can’t create file named “con” or “con.txt” in windows.
is it a bug? or can this be justified from file system perspective?
File system doesn’t prevent you form creating “con” or “con.txt” file. But if
you are using Win32 “CreateFile” function then the name is considered a
reserved name that matches console - request to create such file will not
reach file system at all.
Alexei.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Mani
Sent: Sunday, November 06, 2005 9:25 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] con from FS perspective
Can’t create file named “con” or “con.txt” in windows.
is it a bug? or can this be justified from file system perspective?
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@vmware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
CON Is the Windwos reserved name for CONSOLE and hence cannot be used to
name a file.
> File system doesn't prevent you form creating "con" or "con.txt" file.
But if you are using Win32 "CreateFile" function then the name is
considered a reserved name that matches console - request to create such
file will not reach file system at all.
I believe this is not fully correct. Since I have recently reversed a trojan
(keylogger type) creating exactly a path with 'CON' somewhere in its name
with CreateDirectory() (a Win32 API) it has to be possible - creating in the
sense of establishing a directory entry.
If I remember correctly, it is even possible to access and delete such
things from Win32 by accessing it via the NT path naming convention (e.g
"??\C:\bla\CON").
Oliver
--
May the source be with you, stranger ![]()
ICQ: #281645
URL: http://assarbad.net
Ok. “con” as a reserved name is fine. what about “con.xxx”? any justifiable
answer?
“Alexei Jelvis” wrote in message news:xxxxx@ntfsd…
File system doesn’t prevent you form creating “con” or “con.txt” file. But
if
you are using Win32 “CreateFile” function then the name is considered a
reserved name that matches console - request to create such file will not
reach file system at all.
Alexei.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Mani
Sent: Sunday, November 06, 2005 9:25 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] con from FS perspective
Can’t create file named “con” or “con.txt” in windows.
is it a bug? or can this be justified from file system perspective?
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@vmware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
> Ok. "con" as a reserved name is fine. what about "con.xxx"? any
justifiable answer?
The answer is exactly the same. You have to consider, that during some parts
of the processing the extension is treated separate from the rest of the
name. I guess that is the reason.
But what hinders you to take any other reasonable name?
Oliver
--
May the source be with you, stranger ![]()
ICQ: #281645
URL: http://assarbad.net
>
But what hinders you to take any other reasonable name?
A relative of mine “converted” his files to some other format on
linux, and named the directory as “con” and burnt a CD when he moved
out of the university. Now two years later he realized he cannot open
these files on Windows.
You could create those files on DOS (and some version of windows) with a
stupid trick.
create a file called ‘aon’, delete it, then undelete it, it will ask for
the first character, specify ‘c’. You will have a file with the name con ![]()
On 11/7/05, Oliver Schneider wrote:
>
> > Ok. “con” as a reserved name is fine. what about “con.xxx”? any
> > justifiable answer?
> The answer is exactly the same. You have to consider, that during some
> parts
> of the processing the extension is treated separate from the rest of the
> name. I guess that is the reason.
>
> But what hinders you to take any other reasonable name?
>
> Oliver
>
> –
> ---------------------------------------------------
> May the source be with you, stranger ![]()
>
> ICQ: #281645
> URL: http://assarbad.net
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
This is provide compatability in Cmd.EXE with DOS.
>> xxxxx@hotmail.com 2005-11-07 00:25 >>>
Can’t create file named “con” or “con.txt” in windows.
is it a bug? or can this be justified from file system perspective?
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@evitechnology.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
It isa system defined file name that represents the console.
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mani
Sent: Sunday, November 06, 2005 9:25 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] con from FS perspective
Can’t create file named “con” or “con.txt” in windows.
is it a bug? or can this be justified from file system perspective?
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@rocketdivision.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
You can't access "con" using Win32 API "CreateFile" but there is no problem
accessing it using native "NtCreateFile" API.
Alexei.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Oliver Schneider
Sent: Monday, November 07, 2005 12:21 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] con from FS perspective
File system doesn't prevent you form creating "con" or "con.txt" file.
But if you are using Win32 "CreateFile" function then the name is
considered a reserved name that matches console - request to create such
file will not reach file system at all.
I believe this is not fully correct. Since I have recently reversed a trojan
(keylogger type) creating exactly a path with 'CON' somewhere in its name
with CreateDirectory() (a Win32 API) it has to be possible - creating in the
sense of establishing a directory entry.
If I remember correctly, it is even possible to access and delete such
things from Win32 by accessing it via the NT path naming convention (e.g
"??\C:\bla\CON").
Oliver
--
May the source be with you, stranger ![]()
ICQ: #281645
URL: http://assarbad.net
Questions? First check the IFS FAQ at
You are currently subscribed to ntfsd as: xxxxx@vmware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
>A relative of mine “converted” his files to some other format on
linux, and named the directory as “con” and burnt a CD when he moved
out of the university. Now two years later he realized he cannot open
hese files on Windows.
well snow white, ask him to shift back to linux ![]()
As I hope has been pointed out, you can access the files using
\?\c:\foo\bar\con syntax. However, I really, really, really wish this were
fixed. It’s just embarassing, for a modern OS to impose such broken naming
constraints on applications, when the underlying filesystems do not have
these constraints.
I know, I know, backward compatability… groan.
– arlie
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Developer
Sent: Tuesday, November 08, 2005 1:09 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] con from FS perspective
A relative of mine “converted” his files to some other format on
linux, and named the directory as “con” and burnt a CD when he moved
out of the university. Now two years later he realized he cannot open
hese files on Windows.
well snow white, ask him to shift back to linux ![]()
— Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17 You are currently subscribed to
ntfsd as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email
to xxxxx@lists.osr.com
Arlie,
As I hope has been pointed out, you can access the files using
\?\c:\foo\bar\con syntax.
Are you sure? I believe it is either via network (\.\c:\foo\bar\con - \.
being the local machine) or NT native (??\c:\foo\bar\con) naming
convention, where the latter may not be available in common Win32 tools, but
it is usually passed down to the Native API unchanged when being a parameter
to, let's say, CreateFile().
However, I really, really, really wish this were
fixed. It's just embarassing, for a modern OS to impose such broken
naming constraints on applications, when the underlying filesystems do
not have these constraints.
It's only the Win32 subsystem, not the OS having these constraints!
Regards,
Oliver
--
May the source be with you, stranger ![]()
ICQ: #281645
URL: http://assarbad.net
> Are you sure? I believe it is either via network […]
Yes, I am sure. The MSDN CreateFile documentation is quite clear on this:
Parameters
lpFileName
[in] A pointer to a null-terminated string that specifies the
name of an object to create or open. In the ANSI version of this
function,
the name is limited to MAX_PATH characters. To extend this limit to
32,767
wide characters, call the Unicode version of the function and prepend
"\?" to the path. For more information, see Naming a File.
Calls to CreateFile that begin with \?\ bypass much of the “old” name
processing, including checking against “CON:”, etc. This is the closest
Win32 gets to direct access to NtCreateFile, and for many purposes, it is
adequate.
[D:\temp\example] mkdir con
The directory name is invalid.
[D:\temp\example] mkdir \?\d:\temp\example\con
[D:\temp\example] cd con
The system cannot find the path specified.
[D:\temp\example] dir
Volume in drive D is Data
Volume Serial Number is 42AF-FBDD
Directory of D:\temp\example
11/08/2005 12:31 PM
.11/08/2005 12:31 PM ..
11/08/2005 12:31 PM con
0 File(s) 0 bytes
3 Dir(s) 256,326,963,200 bytes free
[D:\temp\example] cd \\?\d:\temp\example\con
'\\?\d:\temp\example\con'
CMD does not support UNC paths as current directories.
Windows *sort of* supports the \\?\ syntax. Command-line tools that tend to
pass their arguments directly to CreateFile tend to work. Others that
interpret the path tend to believe that \\?\ is a UNC path, and that ? is a
hostname. This belief usually deteriorates quickly.
> It's only the Win32 subsystem, not the OS having these constraints!
I realize this. But to the common user, there is no distinction between
"Win32 subsystem" and "OS". I resent the fact that I cannot name a file to
"con.jpg" or "con.txt" or whatever. The computer should respect my (quite
reasonable) requests; it is there to serve me.
-- arlie
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Oliver Schneider
Sent: Tuesday, November 08, 2005 12:11 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] con from FS perspective
Arlie,
> As I hope has been pointed out, you can access the files using
> \\?\c:\foo\bar\con syntax.
Are you sure? I believe it is either via network (\\.\c:\foo\bar\con - \\.
being the local machine) or NT native (\??\c:\foo\bar\con) naming
convention, where the latter may not be available in common Win32 tools, but
it is usually passed down to the Native API unchanged when being a parameter
to, let's say, CreateFile().
> However, I really, really, really wish this were fixed. It's just
> embarassing, for a modern OS to impose such broken naming constraints
> on applications, when the underlying filesystems do not have these
> constraints.
It's only the Win32 subsystem, not the OS having these constraints!
Regards,
Oliver
--
---------------------------------------------------
May the source be with you, stranger ;)
ICQ: #281645
URL: http://assarbad.net
---
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@stonestreetone.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
No you cannot. This is by design in Windows.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Mani”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”
Sent: Monday, November 07, 2005 8:25 AM
Subject: [ntfsd] con from FS perspective
> Can’t create file named “con” or “con.txt” in windows.
> is it a bug? or can this be justified from file system perspective?
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
> Yes, I am sure.
Ooops :-[
Sorry! You are right, of course.
It was inside CreateFileW() (actually one of the functions called by
CreateFileW!), that "\?" is being "replaced" by "??".
On W2K3, by a non-exported symbol inside NTDLL:
__stdcall RtlpWin32NTNameToNtPathName_U(x,x,x,x)
called by CreateFileW() through some indirections (exported and non-exported
functions in NTDLL), and ultimately:
__declspec(dllimport) RtlDosPathNameToRelativeNtPathName_U(x,x,x,x)
directly called by CreateFileW().
BTW: when looking for CreateFile() I found the following:
CreateFileW() calls (not exported, Kernel32):
__stdcall BaseIsThisAConsoleName(x,x) [not exported]
which in turn calls (from NTDLL):
__declspec(dllimport) RtlIsDosDeviceName_U(x)
to determine whether a path is a "reserved" DOS device name (as the name
suggests). But the checking at this point seems a little weired, so I did
not verify my assumption!
Cheers,
Oliver
PS: Found by stepping into CreateFileW() - passing an NT-style path - using
my favorite user-mode debugger (IDA 4.9 :-)) and the appropriate symbols ![]()
Investigation was performed on Windows 2003 (no SP).
--
May the source be with you, stranger ![]()
ICQ: #281645
URL: http://assarbad.net
Mani wrote:
Ok. “con” as a reserved name is fine. what about “con.xxx”? any justifiable
answer?
DOS used to behave that way, so Windows kept the compatibility up.
Exactly the same happens with any device name (LPT, etc.)
Provided you have a FAT* partition to write to, boot a Knoppix CD and
copy the files using it (taking care to rename the directory before
booting back into windows!).
Tony
* I believe later versions of knoppix can write to NTFS (calling
ntfs.sys directly I believe) but I’d be wary of trying it.