[PATCH v41 0/1] MR10192: Draft: kernelbase: Handle extended length path prefix in GetLongPathNameW
``` 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. ``` Signed-off-by: Vishnunithyasoundhar S svishnunithyasoundhar@gmail.com -- v41: kernelbase: Handle extended length path prefix in GetLongPathNameW https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
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 test. Signed-off-by: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 25 +++++++++++++++++++++++++ dlls/kernelbase/file.c | 22 +++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index aa1833504d8..377627890ad 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1255,6 +1255,9 @@ static void test_GetLongPathNameW(void) static const WCHAR prefix[] = { '\\','\\','?','\\', 0}; static const WCHAR backslash[] = { '\\', 0}; static const WCHAR letterX[] = { 'X', 0}; + WCHAR shortpath2[MAX_PATH]; + WCHAR extendedshortpath2[4 + MAX_PATH]; + WCHAR longpath[MAX_PATH]; SetLastError(0xdeadbeef); length = GetLongPathNameW(NULL,NULL,0); @@ -1327,6 +1330,28 @@ 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 */ + shortpath2[0] = 0; + trace("---Extended prefix file path test here---\n"); //to be removed + length = GetShortPathNameW(dirpath, shortpath2, ARRAY_SIZE(shortpath2)); + ok(length, "GetShortPathNameW failed: %lu\n", GetLastError()); + ok(lstrcmpiW(dirpath, shortpath2) != 0, + "short path name isn't created, got %s\n", debugstr_w(shortpath2)); + + trace("dirpath: %s\n", wine_dbgstr_w(dirpath)); //to be removed + trace("shortpath2: %s\n", wine_dbgstr_w(shortpath2)); //to be removed + + SetLastError(0xdeadbeef); + length = + GetLongPathNameW(shortpath2, longpath, ARRAY_SIZE(longpath)); + trace("longpath: %s\n", wine_dbgstr_w(longpath)); //to be removed + ok(length > 0, "GetLongPathNameW failed: %ld\n", GetLastError()); + ok(!wcsncmp(longpath, prefix, 4), + "Expected extended prefix in output, got %s\n", wine_dbgstr_w(longpath)); + ok(!wcsncmp(longpath + 4, dirpath, lstrlenW(dirpath)), + "Expected path in output, got %s\n", wine_dbgstr_w(longpath)); + /* 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..b3dcf23b64e 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -2116,7 +2116,27 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameW( LPCWSTR shortpath, LPWSTR longp return 0; } - if (shortpath[0] == '\\' && shortpath[1] == '\\') + /* Handle \\?\ prefix (Extended Length Path) */ + if (wcslen(shortpath) >= 4 && 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[0] = '\\'; + tmplongpath[1] = '\\'; + tmplongpath[2] = '?'; + tmplongpath[3] = '\\'; + tmplongpath[4] = shortpath[4]; + tmplongpath[5] = shortpath[5]; + lp = 6; + sp = 6; + } + } + + if (sp == 0 && shortpath[0] == '\\' && shortpath[1] == '\\') { FIXME( "UNC pathname %s\n", debugstr_w(shortpath) ); tmplen = lstrlenW( shortpath ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
participants (2)
-
Vishnunithyasoundhar S -
Vishnunithyasoundhar S (ï¼ svishnunithyasoundhar)