https://bugs.winehq.org/show_bug.cgi?id=37834
Bug ID: 37834 Summary: RtlSetCurrentDirectory_U prepends "UNC" for network paths; the resulting path is invalid Product: Wine Version: 1.7.33 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: minor Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: atakama0512@yahoo.com Distribution: ---
Created attachment 50382 --> https://bugs.winehq.org/attachment.cgi?id=50382 cmd.exe output showing how UNC\ gets prepended when running cd \server\share
Calling RtlSetCurrentDirectory_U with a network share argument like "\server\share" sets the current directory to "UNC\server\share". Subsequent calls to GetCurrentDirectory will return the modified path. The resulting path is invalid and unusable: attempting to read the directory or writing a file to it results in ERROR_PATH_NOT_FOUND. The bug can be reproduced using the internal command prompt, as seen in the attachment.
From what I've gathered from the source code, RtlSetCurrentDirectory_U calls
RtlDosPathNameToNtPathName_U, which prepends UncPfxW to the supplied path. The last edits to dlls/ntdll/path.c were made in 2003-2004.
I stumbled across this behavior while investigating why Total Commander cannot copy files to network shares. The sequence of calls in Total Commander is: SetCurrentDirectory to the network path, then GetCurrentDirectory (which returns the modified path in the form "UNC\server\share") and then it builds the destination parameter by concatenating this path with the destination file name. This gets passed to CopyFileEx, which fails with ERROR_PATH_NOT_FOUND because of the "UNC" prefix.