About WritePrivateProfileString and file operations

James Keane james.keane at gmail.com
Thu Aug 16 18:47:02 CDT 2007


I think there is a problem with the check_sharing function in server/fd.c.

At the end of the function when it is checking existing_access with
the sharing variable it doesn't seem to care about what the caller is
requesting.

I think this is what is causing problems with the CreateFile call,
because the check_sharing function doesn't care if you don't even want
write access it will still check if you have the sharing bit.

I have created a patch that will hopefully solve the real problem
instead of the hack in WriteProfileString, I am not sure it is the
100% correct way to do it yet.

On 8/16/07, Louis Lenders <xerox_xerox2000 at yahoo.co.uk> wrote:
> Zhongli Xu <zhongli.xu <at> gmail.com> writes:
>
> >
> > Hi all,I run some tests about mixed using WritePrivateProfileString and stand
> file operationsCodes look like this:GetPrivateProfileString(keyname,
> value);fopen();fprintf("# comments");
> > fclose();WritePrivateProfileString(keyname, newvalue);What I found in the file
> is that either WritePrivateProfileString operation succeeded(newvalue has been
> written) or fprintf succeeded("#comments" shows up in the file).
> > On windows hosts, there is no such problem.Any suggestion or idea is
> welcomed.Thanks.Milo
> >
> >
> >
>
> I don't know if it's the same issue but i know there is a bug in wine's
> implementation of WritePrivateProfileString.
> See http://bugs.winehq.org/show_bug.cgi?id=5024
>
> I currently use this hack http://bugs.winehq.org/attachment.cgi?id=6750 to
> install the game. Maybe it helps for your app too, and maybe someone could pick
> up this bug.
>
>
>
>
>
-------------- next part --------------
diff --git a/server/fd.c b/server/fd.c
index cf3a306..11bb457 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1478,9 +1478,10 @@ static int check_sharing( struct fd *fd, unsigned int access, unsigned int shari
     if ((access & FILE_UNIX_READ_ACCESS) && !(existing_sharing & FILE_SHARE_READ)) return 0;
     if ((access & FILE_UNIX_WRITE_ACCESS) && !(existing_sharing & FILE_SHARE_WRITE)) return 0;
     if ((access & DELETE) && !(existing_sharing & FILE_SHARE_DELETE)) return 0;
-    if ((existing_access & FILE_UNIX_READ_ACCESS) && !(sharing & FILE_SHARE_READ)) return 0;
-    if ((existing_access & FILE_UNIX_WRITE_ACCESS) && !(sharing & FILE_SHARE_WRITE)) return 0;
-    if ((existing_access & DELETE) && !(sharing & FILE_SHARE_DELETE)) return 0;
+    if ((access & FILE_UNIX_READ_ACCESS) && (existing_access & FILE_UNIX_READ_ACCESS) && !(sharing & FILE_SHARE_READ)) return 0;
+    if ((access & FILE_UNIX_WRITE_ACCESS) && (existing_access & FILE_UNIX_WRITE_ACCESS) && !(sharing & FILE_SHARE_WRITE)) return 0;
+    if ((access & DELETE) && (existing_access & DELETE) && !(sharing & FILE_SHARE_DELETE)) return 0;
     return 1;
 }
 


More information about the wine-devel mailing list