https://bugs.winehq.org/show_bug.cgi?id=47054
Bug ID: 47054 Summary: SHCreateDirectory/SHCreateDirectoryEx error result incorrect when hwnd is not NULL and directory already exists Product: Wine Version: 4.6 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: shell32 Assignee: wine-bugs@winehq.org Reporter: ubuntor2000@gmail.com Distribution: ---
Created attachment 64221 --> https://bugs.winehq.org/attachment.cgi?id=64221 Test case (source)
When SHCreateDirectory/SHCreateDirectoryEx is called with a non-NULL hwnd and a path to a directory that already exists, Wine returns 1223 (ERROR_CANCELLED) instead of 183 (ERROR_ALREADY_EXISTS). This is being set in https://source.winehq.org/git/wine.git/blob/fabde842ede40fc53cf6f5743d5b4778...
According to the MSDN (https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_c...): it seems that ERROR_CANCELLED should only be returned in special cases, independent of whether hwnd is NULL or not.
This may also affect other error conditions.
Windows XP (VM) test case output (no warning messagebox is created):
SHCreateDirectory, NULL hwnd: 183 SHCreateDirectory, actual hwnd: 183 SHCreateDirectoryExW, NULL hwnd: 183 SHCreateDirectoryExW, actual hwnd: 183
Wine test case output:
SHCreateDirectory, NULL hwnd: 183 0009:fixme:shell:SHCreateDirectoryExW Show system error message, creating path L"C:\Windows\Temp\test", failed with error 183 SHCreateDirectory, actual hwnd: 1223 SHCreateDirectoryExW, NULL hwnd: 183 0009:fixme:shell:SHCreateDirectoryExW Show system error message, creating path L"C:\Windows\Temp\test", failed with error 183 SHCreateDirectoryExW, actual hwnd: 1223
This affects Atelier Lydie and Suelle: saving doesn't work when the SAVEDATA directory already exists. This probably happens since the game is checking if SHCreateDirectoryExW succeeds or returns ERROR_ALREADY_EXISTS, as manually patching shell32.dll.so to skip the FIXME section fixes the issue.
Associated Proton issue: https://github.com/ValveSoftware/Proton/issues/2452