https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108350
--- Comment #22 from Bill Zissimopoulos <gnu.org at billz dot fastmail.fm> --- (In reply to niXman from comment #21) > another strange problem is that `CreateFile()` is able to open the special > file `nul` for reading, but `GetFinalPathNameByHandle()` cannot get the full > name of this file and returns 0 and setting `last error` to > `ERROR_INVALID_PARAMETER`. > > and so you don't get bored I'll add: `GetFullPathName()` can get the full > name of such a file. > > (how could this happen? %) ) Yes :) GetFinalPathNameByHandle internally performs a special request that only file system drivers respond to (IRP_MJ_QUERY_INFORMATION / FileNormalizedNameInformation). So a path like X:\Path\To\File will be resolved to an internal path like: \Device\<XVOLDEVICE>\Path\To\File Now \Device\<XVOLDEVICE> is a file system driver (or points to one via an elaborate mechanism, but let's not complicate matters further) and knows how to respond to FileNormalizedNameInformation queries. OTOH a path like nul will be resolved to an internal path like: \Device\Null This is a simple device and not a file system driver and does not know how to respond to FileNormalizedNameInformation queries. So GetFinalPathNameByHandle works on the first, but not the second. As for GetFullPathName: I think it works by doing simple string manipulations on the path (i.e. no attempts to open the file and query its path, etc.)