0

Is there a reason why Microsoft doesn't just step in and fix the MAX_PATH limitation in newer versions of Windows? By the looks of it, one could even hook CreateFile and reimplement it in terms of NtCreateFile with a full 32K canonical path length (and virtually unlimited un-canonized path).

(Ditto for other APIs.)

Ilya
  • 5,533
  • 2
  • 29
  • 57
  • 1
    Um, CreateFile does not have a MAX_PATH limit. – Raymond Chen Jul 28 '14 at 02:29
  • Additionally: MS won't fix issues like this because it can break a lot of released software. – slugster Jul 28 '14 at 02:44
  • `CreateFile` is documented as having a `MAX_PATH` limit, even though you can get around it with the `\\?\` hack. And yah, fixing it'll break a lot of software, Microsoft's first and foremost. – Ross Ridge Jul 28 '14 at 04:07
  • @RaymondChen MSDN says CreateFileA version is, and if I use CreateFileW with \\?\, I lose path processing – Ilya Jul 28 '14 at 15:06
  • An application that is still using ANSI should work on converting to Unicode before worrying about `MAX_PATH`. – Raymond Chen Jul 28 '14 at 15:17
  • @RaymondChen Yep. My concern is about the path processing I'm losing by accepting the \\?\ solution (which is probably half-way to using NtCreateFile directly, right?) – Ilya Jul 28 '14 at 16:10
  • Yes, you lose out on things like relative paths and other Win32 path normalization steps. There would have to be some new syntax to say "I want Win32 normalization to occur, but operate on NT paths." – Raymond Chen Jul 28 '14 at 18:00
  • @RaymondChen I couldn't avoid but noticing "notepad \\?\c:\foo\..\foo\test.txt" works just as well as "notepad \\?\c:\foo\test.txt". What is behind Notepad's magic? – Ilya Jul 31 '14 at 18:16
  • That is still an absolute path. A relative path would be \\?\relative.txt – Raymond Chen Jul 31 '14 at 18:35
  • @RaymondChen I didn't mean to say it's absolute, but rather that it contains ".." which wouldn't be normalized when prefixed with \\?\, i.e. CreateFileW(L"\\\\?\\c:\\foo\\..\\foo\\test.txt", ...) == INVALID_HANDLE_VALUE, but Notepad groks it just fine – Ilya Jul 31 '14 at 19:13

0 Answers0