Any suggestions for how to handle a difference in file access and sharing handling between Wine (20050830) and WinXP? A program demonstrating the problem is attached below.
A 3rd party installer program for a VST plugin is calling CreateFile with dwDesiredAccess = 0x1f01ff and dwSharedMode = FILE_SHARE_WRITE. It then calls ReadFile, which fails in Wine (error 5) but succeeds in WinXP.
My "solution" (polite term) was to force GENERIC_READ|GENERIC_WRITE access in ntdll/NtCreateFile if the sharing type is FILE_SHARE_WRITE.
I have not been able to figure out from the header files what named constants the program used for dwDesiredAccess, so I hard coded it with the values the program used in my example.
But I did notice that FILE_ALL_ACCESS is a different value in Wine and my VC98 headers from DevStudio 6. In Wine it is: (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff) In VC98: (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff) Is this a Wine bug?
The "access" and "sharing" parameters to CreateFile are making me feel stupid. I read and read and read the docs at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/c... and still can't really figure out what they are supposed to do! I am pretty sure that my hack wouldn't stand and would love to hear the right way to fix this problem.
Thanks... mo
#include <stdio.h> // printf #include <windows.h>
int main(int argc, char *argv[]) { if (argc < 2) { puts("usage: wine file-access-test.exe.so PATH"); puts("Tests the access used by the Ivory Library Tools program that doesn't work with wine."); return(1); }
HANDLE file = ::CreateFile(argv[1], 0x1f01ff, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (file != INVALID_HANDLE_VALUE) { DWORD bytesRead; char bufr[32];
// passes in winxp; fails (error 5) in wine if (::ReadFile(file, bufr, sizeof(bufr), &bytesRead, NULL)) printf("Read %ld bytes\n", bytesRead); else printf("ReadFile error: %d\n", ::GetLastError()); ::CloseHandle(file); } else printf("CreateFile error: %d\n", ::GetLastError());
return(0); }