I'm afraid this shall require some tests, esp. for the various return codes in case of failures (setting aside DIR output)
Added. I don't think there's a meaningful error here other than the file already existing. (Which, to be fair, was an error in my original patch. I've changed FILE_OPEN_IF to FILE_CREATE.) mklink /j, unlike the other variants, doesn't validate the destination at all.
also, native cmd doesn't handle path:s longer than MAX_PATH characters, so this shall be detected and failed upon
According to my testing it does here, actually. I've changed the NtDeviceIoControlFile() to DeviceIoControl().
This could also use a MAXIMUM_REPARSE_DATA_BUFFER_SIZE buffer.
Doh, yet again. Fixed. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9595#note_124637