CreateFile access/sharing problem

Michael Ost most at
Mon Oct 3 13:20:16 CDT 2005

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

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:
In VC98:
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
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 PATH");
		puts("Tests the access used by the Ivory Library Tools program that doesn't work with wine.");

	HANDLE file = ::CreateFile(argv[1], 0x1f01ff, FILE_SHARE_WRITE, 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);
			printf("ReadFile error: %d\n", ::GetLastError());
		printf("CreateFile error: %d\n", ::GetLastError());


More information about the wine-devel mailing list