From: Mark White chopinbig2@gmail.com
Fixes https://bugs.winehq.org/show_bug.cgi?id=42446
GetVolumePathNameW is causing some incompatibity problems with some Windows applications such as Native Instruments "Native Access" because of an inability to handle path names containing forward slash's whereas the Windows GetVolumePathName's behaviour handles path names with both forward and back slash's.
Tested on Debian Stretch and Windows Vista
Signed-off-by: Mark White chopinbig2@gmail.com --- dlls/kernel32/tests/volume.c | 4 ++++ dlls/kernel32/volume.c | 3 +++ 2 files changed, 7 insertions(+)
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c index 365e38c444..c47043d288 100644 --- a/dlls/kernel32/tests/volume.c +++ b/dlls/kernel32/tests/volume.c @@ -772,6 +772,10 @@ static void test_GetVolumePathNameA(void) "s:omefile", "S:\" /* win2k, winxp */, sizeof(volume_path), ERROR_FILE_NOT_FOUND, NO_ERROR }, + { /* test 42: a reasonable forward slash path that is guaranteed to exist */ + "C:/windows/system32", "C:\", sizeof(volume_path), + NO_ERROR, NO_ERROR + }, }; BOOL ret, success; DWORD error; diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c index b4163f02eb..ac887b2f3f 100644 --- a/dlls/kernel32/volume.c +++ b/dlls/kernel32/volume.c @@ -1670,6 +1670,7 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu WCHAR fallbackpathW[] = { 'C',':','\',0 }; NTSTATUS status = STATUS_SUCCESS; WCHAR *volumenameW = NULL, *c; + WCHAR *fwdslash; int pos, last_pos, stop_pos; UNICODE_STRING nt_name; ANSI_STRING unix_name; @@ -1693,6 +1694,8 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu return FALSE; } strcpyW( volumenameW, filename ); + /* forward slash backslash replace */ + for (fwdslash = volumenameW; *fwdslash; fwdslash++) if (*fwdslash == '/') *fwdslash = '\'; stop_pos = 0; /* stop searching slashes early for NT-type and nearly NT-type paths */ if (strncmpW(ntprefixW, filename, strlenW(ntprefixW)) == 0)
On 11/03/18 07:22, Mark White wrote:
- /* forward slash backslash replace */
- for (fwdslash = volumenameW; *fwdslash; fwdslash++) if (*fwdslash == '/') *fwdslash = '\';
Hello Mark, and thank you for contributing to Wine!
As stated on that bug report, I think a better solution is to use GetFullPathName() instead. Testing shows that GetVolumePathName() should also handle relative paths (and currently doesn't), and GetFullPathName() would take care of both problems.
ἔρρωσο, Zeb