I was wondering what is the length of the longest possible name length allowed by the Windows kernel?
For example: I know that the kernel uses structures UNICODE_STRINGto store all the paths of the object, and since the byte length of the wide-character string is stored inside USHORT, which allows the maximum path length of 2 ^ 15 - 1 character to be used. Is there a similar hard restriction on the file name (and not the path)? (I don’t care that NTFS or FAT32 imposes a certain restriction: I am looking for the maximum possible theoretically resolved name in the kernel, avoiding additional restrictions on the file system or shell.)
(Edit: for those who wonder why this even matters, consider that the normal directory move is done by calling FindFirstFile/ FindNextFile, one call per file. For a function with a name NtQueryDirectoryFilethat is a basic system call and that returns multiple file names for of each call, you can actually take advantage of this maximum length limit on the path to make extremely fast directory traffic that uses only the stack as a buffer. Now I am trying to expand this concept and I need to know maximum file name size.)
source
share