From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> Support the \\?\ prefix by skipping it during path resolution while preserving it in the output. Added specific handling for extended UNC paths (\\?\UNC\) to mirror standard UNC behavior, ensuring these paths are treated as network shares and not local devices. Some paths that use the extended length path were filtered out as UNC paths - but not all of them are UNC. There can be UNC path that use extended length path but not all extended length paths are UNC paths. Added todo_wine test. Signed-off-by: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 24 ++++++++++++++++++++++++ dlls/kernelbase/file.c | 15 +++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index aa1833504d8..b64647af7dd 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1327,6 +1327,30 @@ static void test_GetLongPathNameW(void) length = GetLongPathNameW(shortpath, NULL, 0); ok(length == expanded, "Expected %ld, got %ld\n", expanded, length); + /* Test that extended prefix is preserved in output when converting from short to long path */ + { + WCHAR short_path[MAX_PATH], long_path[MAX_PATH], ext_short_path[4 + MAX_PATH]; + DWORD short_len, long_len; + + short_path[0] = 0; + short_len = GetShortPathNameW(tempdir, short_path, ARRAY_SIZE(short_path)); + ok(short_len, "GetShortPathNameW failed: %lu\n", GetLastError()); + + lstrcpyW(ext_short_path, prefix); + lstrcatW(ext_short_path, short_path); + lstrcatW(ext_short_path, name); + lstrcatW(ext_short_path, backslash); + lstrcatW(ext_short_path, name); + + SetLastError(0xdeadbeef); + long_len = GetLongPathNameW(ext_short_path, long_path, ARRAY_SIZE(long_path)); + todo_wine + { + ok(long_len > 0, "GetLongPathNameW failed: %ld\n", GetLastError()); + ok(!wcsncmp(long_path, prefix, 4), "Expected extended prefix in output, got %s\n", wine_dbgstr_w(long_path)); + } + } + /* NULL buffer with length crashes on Windows */ if (0) GetLongPathNameW(shortpath, NULL, 20); diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index 83977a2c40b..a4d85133909 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -2116,6 +2116,21 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameW( LPCWSTR shortpath, LPWSTR longp return 0; } + /* Handle \\?\ prefix (Extended Length Path) */ + if (shortpath[0] == '\\' && shortpath[1] == '\\' && shortpath[2] == '?' && + shortpath[3] == '\\') { + /* Filter out entended UNC */ + if (_wcsnicmp(shortpath + 4, L"UNC\\", 4) == 0) { + lstrcatW(tmplongpath, L"UNC\\"); + lp = sp = 8; + FIXME("UNC Extended pathname %s\n", debugstr_w(shortpath)); + } + else if (shortpath[4] && shortpath[5] == ':') { + tmplongpath[lp++] = shortpath[sp++]; + tmplongpath[lp++] = shortpath[sp++]; + } + } + if (shortpath[0] == '\\' && shortpath[1] == '\\') { FIXME( "UNC pathname %s\n", debugstr_w(shortpath) ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192