Commit 2f8fd106 authored by Alexandre Julliard's avatar Alexandre Julliard

OF_CREATE should force write access in OpenFile.

parent 095752a1
...@@ -74,10 +74,18 @@ static WINE_EXCEPTION_FILTER(page_fault) ...@@ -74,10 +74,18 @@ static WINE_EXCEPTION_FILTER(page_fault)
* *
* Wrapper for CreateFile that takes OF_* mode flags. * Wrapper for CreateFile that takes OF_* mode flags.
*/ */
static HANDLE create_file_OF( LPCSTR path, INT mode, DWORD creation ) static HANDLE create_file_OF( LPCSTR path, INT mode )
{ {
DWORD access, sharing; DWORD access, sharing, creation;
if (mode & OF_CREATE)
{
creation = CREATE_ALWAYS;
access = GENERIC_READ | GENERIC_WRITE;
}
else
{
creation = OPEN_EXISTING;
switch(mode & 0x03) switch(mode & 0x03)
{ {
case OF_READ: access = GENERIC_READ; break; case OF_READ: access = GENERIC_READ; break;
...@@ -85,6 +93,8 @@ static HANDLE create_file_OF( LPCSTR path, INT mode, DWORD creation ) ...@@ -85,6 +93,8 @@ static HANDLE create_file_OF( LPCSTR path, INT mode, DWORD creation )
case OF_READWRITE: access = GENERIC_READ | GENERIC_WRITE; break; case OF_READWRITE: access = GENERIC_READ | GENERIC_WRITE; break;
default: access = 0; break; default: access = 0; break;
} }
}
switch(mode & 0x70) switch(mode & 0x70)
{ {
case OF_SHARE_EXCLUSIVE: sharing = 0; break; case OF_SHARE_EXCLUSIVE: sharing = 0; break;
...@@ -539,7 +549,7 @@ HFILE WINAPI _lcreat( LPCSTR path, INT attr ) ...@@ -539,7 +549,7 @@ HFILE WINAPI _lcreat( LPCSTR path, INT attr )
HFILE WINAPI _lopen( LPCSTR path, INT mode ) HFILE WINAPI _lopen( LPCSTR path, INT mode )
{ {
TRACE("(%s,%04x)\n", debugstr_a(path), mode ); TRACE("(%s,%04x)\n", debugstr_a(path), mode );
return (HFILE)create_file_OF( path, mode, OPEN_EXISTING ); return (HFILE)create_file_OF( path, mode & ~OF_CREATE );
} }
...@@ -1944,7 +1954,7 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode ) ...@@ -1944,7 +1954,7 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
if (mode & OF_CREATE) if (mode & OF_CREATE)
{ {
if ((handle = create_file_OF( name, mode, CREATE_ALWAYS )) == INVALID_HANDLE_VALUE) if ((handle = create_file_OF( name, mode )) == INVALID_HANDLE_VALUE)
goto error; goto error;
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment