Commit 6a4c862
FIXED: Windows: UNC support for relative file names and shared object loading.
When the process working directory is a UNC path (e.g. set via a
Windows shortcut's "Start in" field), resolving a relative file name
via absolute_file_name/3, access_file/2 and friends failed, and
open_shared_object/2, use_foreign_library/1 could not load DLLs
identified by a UNC path.
_xos_os_filenameW() used to unconditionally prepend "\\?\" and let
GetFullPathNameW() append its result. When the CWD is UNC, that
produced a malformed "\\?\\\host\share\..." path that NT rejects.
Now run GetFullPathNameW() first, inspect the result, and use the
"\\?\UNC\" prefix when it resolves to a UNC path.
LoadLibraryExW() and AddDllDirectoryW() do not accept extended-length
"\\?\" or "\\?\UNC\" prefixes and return ERROR_INVALID_PARAMETER,
especially in combination with LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR.
Strip the prefix (converting "\\?\UNC\host\..." back to "\\host\...")
before calling them. This also fixes a latent bug in
win_add_dll_directory/2 where _xos_win_prefix_length() returned 4 for
"\\?\UNC\..." (WIN_PATH_PREFIX matches first), leaving "UNC\host\..."
as the directory passed to AddDllDirectoryW().
Discussion: https://swi-prolog.discourse.group/t/issues-with-unc-path/9010
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 355e941 commit 6a4c862
2 files changed
Lines changed: 55 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
397 | 418 | | |
398 | 419 | | |
399 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
721 | 739 | | |
722 | 740 | | |
723 | 741 | | |
| |||
733 | 751 | | |
734 | 752 | | |
735 | 753 | | |
736 | | - | |
| 754 | + | |
737 | 755 | | |
738 | 756 | | |
739 | 757 | | |
| |||
786 | 804 | | |
787 | 805 | | |
788 | 806 | | |
| 807 | + | |
789 | 808 | | |
790 | 809 | | |
791 | 810 | | |
792 | 811 | | |
793 | 812 | | |
794 | 813 | | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
795 | 818 | | |
796 | 819 | | |
797 | 820 | | |
| |||
809 | 832 | | |
810 | 833 | | |
811 | 834 | | |
812 | | - | |
| 835 | + | |
813 | 836 | | |
814 | | - | |
| 837 | + | |
815 | 838 | | |
816 | 839 | | |
817 | | - | |
| 840 | + | |
818 | 841 | | |
819 | 842 | | |
820 | 843 | | |
| |||
0 commit comments