[PATCH v11 0/13] MR10192: kernelbase: Handle \\?\ prefix in GetLongPathNameW
The current implementation of GetLongPathNameW triggers a FIXME and returns the original path when it encounters a UNC prefix. While true network UNC paths remain unimplemented, this change allows extended-length local paths (starting with \\?\) to be resolved by stripping the prefix and processing the underlying local path. This fixes issues where applications (such as xalia) passing absolute paths with the extended-length prefix would fail to receive a normalized or resolved long path. ``` 881.036:00d4:00d8:fixme:file:GetLongPathNameW UNC pathname L"\\\\?\\Z:\\home\\vishnunithyasoundhars\\.steam\\debian-installation\\compatibilitytools.d\\debug_build\\files\\share\\wine/../xalia/xalia.exe" ``` Tested: After change with added debug log ``` 22272.558:00d4:00d8:fixme:file:GetLongPathNameW DEBUG: Success! Returning path: L"Z:\\home\\vishnunithyasoundhars\\.steam\\debian-installation\\compatibilitytools.d\\debug_build\\files\\share\\wine/../xalia/xalia.exe" (Length: 125) ``` Signed-off-by: Vishnunithyasoundhar S svishnunithyasoundhar@gmail.com -- v11: Fix tests Debug 5 https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> Signed-off-by: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernelbase/file.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index c206e2f9cc2..249238025c4 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -2117,10 +2117,22 @@ 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] == '\\') + { + if (iswalpha(shortpath[4]) && shortpath[5] == ':' && + shortpath[6] == '\\') + { + return GetLongPathNameW(shortpath + 4, longpath, longlen); + } + } + if (shortpath[0] == '\\' && shortpath[1] == '\\') { FIXME( "UNC pathname %s\n", debugstr_w(shortpath) ); tmplen = lstrlenW( shortpath ); + if (tmplen < longlen) { if (longpath != shortpath) lstrcpyW( longpath, shortpath ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernelbase/file.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index 249238025c4..94a93f7548c 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -2132,7 +2132,6 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameW( LPCWSTR shortpath, LPWSTR longp { FIXME( "UNC pathname %s\n", debugstr_w(shortpath) ); tmplen = lstrlenW( shortpath ); - if (tmplen < longlen) { if (longpath != shortpath) lstrcpyW( longpath, shortpath ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernelbase/file.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index 94a93f7548c..c9e46ab6f5b 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -2121,11 +2121,8 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameW( LPCWSTR shortpath, LPWSTR longp if (shortpath[0] == '\\' && shortpath[1] == '\\' && shortpath[2] == '?' && shortpath[3] == '\\') { - if (iswalpha(shortpath[4]) && shortpath[5] == ':' && - shortpath[6] == '\\') - { + if (iswalpha(shortpath[4]) && shortpath[5] == ':' && shortpath[6] == '\\') return GetLongPathNameW(shortpath + 4, longpath, longlen); - } } if (shortpath[0] == '\\' && shortpath[1] == '\\') -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index aa1833504d8..b93ade939fc 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -360,7 +360,7 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive) lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0, "GetTempFileNameA returned '%s' which doesn't match '%s' or '%s'. id=%x\n", newdir,tmpstr,tmpstr1,id); - ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n"); + ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n"); id=GetTempFileNameA(tmppath,NULL,0,newdir); sprintf(tmpstr,"%.4x.tmp",id & 0xffff); @@ -1164,13 +1164,13 @@ static void test_GetLongPathNameA(void) ok(length >= strlen(tempfile) + 1, "Wrong length\n"); ok(temppath[0] == 0, "Buffer should not have been touched\n"); - /* Some UNC syntax tests */ + /* Extended file path syntax test */ memset(temppath, 0, MAX_PATH); memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - explength = length + 4; + explength = length; SetLastError(0xdeadbeef); length = GetLongPathNameA(temppath2, NULL, 0); @@ -1256,12 +1256,12 @@ static void test_GetLongPathNameW(void) static const WCHAR backslash[] = { '\\', 0}; static const WCHAR letterX[] = { 'X', 0}; - SetLastError(0xdeadbeef); + SetLastError(0xdeadbeef); length = GetLongPathNameW(NULL,NULL,0); ok(0==length,"GetLongPathNameW returned %ld but expected 0\n",length); ok(GetLastError()==ERROR_INVALID_PARAMETER,"GetLastError returned %ld but expected ERROR_INVALID_PARAMETER\n",GetLastError()); - SetLastError(0xdeadbeef); + SetLastError(0xdeadbeef); empty[0]=0; length = GetLongPathNameW(empty,NULL,0); ok(0==length,"GetLongPathNameW returned %ld but expected 0\n",length); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index b93ade939fc..5a37cdef282 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,7 +1170,7 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - explength = length; + explength = length + 1; SetLastError(0xdeadbeef); length = GetLongPathNameA(temppath2, NULL, 0); @@ -1322,7 +1322,7 @@ static void test_GetLongPathNameW(void) ok(GetLastError() == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError()); } /* With prefix */ - expanded = 4 + (GetLongPathNameW(tempdir, NULL, 0) - 1) + lstrlenW(name) + 1 + lstrlenW(name) + 1; + expanded = (GetLongPathNameW(tempdir, NULL, 0) - 1) + lstrlenW(name) + 1 + lstrlenW(name) + 1; SetLastError(0xdeadbeef); length = GetLongPathNameW(shortpath, NULL, 0); ok(length == expanded, "Expected %ld, got %ld\n", expanded, length); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 5a37cdef282..50bd93dda44 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,9 +1170,10 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - explength = length + 1; SetLastError(0xdeadbeef); + explength = GetLongPathNameA(tempfile, NULL, 0); + length = GetLongPathNameA(temppath2, NULL, 0); ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 50bd93dda44..1d3d17786ee 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,10 +1170,9 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); + explength = strlen(temppath2) - 4; SetLastError(0xdeadbeef); - explength = GetLongPathNameA(tempfile, NULL, 0); - length = GetLongPathNameA(temppath2, NULL, 0); ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 1d3d17786ee..7d34630c6b1 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,7 +1170,7 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - explength = strlen(temppath2) - 4; + trace("DEBUG: Path: %s - Length: %d\n", temppath2, strlen(temppath2)); SetLastError(0xdeadbeef); length = GetLongPathNameA(temppath2, NULL, 0); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 7d34630c6b1..eba8b564c95 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,7 +1170,7 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - trace("DEBUG: Path: %s - Length: %d\n", temppath2, strlen(temppath2)); + trace("DEBUG: Path: %s - Length: %lu\n", temppath2, strlen(temppath2)); SetLastError(0xdeadbeef); length = GetLongPathNameA(temppath2, NULL, 0); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index eba8b564c95..ab724f6283a 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,7 +1170,7 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - trace("DEBUG: Path: %s - Length: %lu\n", temppath2, strlen(temppath2)); + trace("DEBUG: Path: %s - Length: %d\n", temppath2, (int)strlen(temppath2)); SetLastError(0xdeadbeef); length = GetLongPathNameA(temppath2, NULL, 0); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index ab724f6283a..737ce03b336 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,7 +1170,8 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - trace("DEBUG: Path: %s - Length: %d\n", temppath2, (int)strlen(temppath2)); + trace("DEBUG: Path: %s - Length: %zu\n", temppath2, (int)strlen(temppath2)); + explength = length + 4; SetLastError(0xdeadbeef); length = GetLongPathNameA(temppath2, NULL, 0); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 737ce03b336..3fe86c690c2 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,7 +1170,7 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - trace("DEBUG: Path: %s - Length: %zu\n", temppath2, (int)strlen(temppath2)); + trace("DEBUG: Path: %s - Length: %zu\n", temppath2, strlen(temppath2)); explength = length + 4; SetLastError(0xdeadbeef); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
From: Vishnunithyasoundhar S <svishnunithyasoundhar@gmail.com> --- dlls/kernel32/tests/path.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 3fe86c690c2..438159d752e 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1170,7 +1170,8 @@ static void test_GetLongPathNameA(void) memset(temppath2, 0, MAX_PATH); lstrcpyA(temppath2, "\\\\?\\"); lstrcatA(temppath2, tempfile); - trace("DEBUG: Path: %s - Length: %zu\n", temppath2, strlen(temppath2)); + int temppath2length = strlen(temppath2); + trace("DEBUG: Path: %s - Length: %zu\n", temppath2, temppath2length); explength = length + 4; SetLastError(0xdeadbeef); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10192
participants (2)
-
Vishnunithyasoundhar S -
Vishnunithyasoundhar S (ï¼ svishnunithyasoundhar)