--- wine/dlls/kernel/file.c 2005-04-01 13:31:42.000000000 +0200 +++ mywine/dlls/kernel/file.c 2005-05-08 19:43:38.000000000 +0200 @@ -431,6 +431,7 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPC NTSTATUS status; IO_STATUS_BLOCK iosb; PIO_STATUS_BLOCK piosb = &iosb; + int FIUBflag = 0; /* Failed Invalid User Buffer flag */ TRACE("%p %p %ld %p %p\n", hFile, buffer, bytesToWrite, bytesWritten, overlapped ); @@ -448,8 +449,18 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPC piosb->u.Status = STATUS_PENDING; piosb->Information = 0; - status = NtWriteFile(hFile, hEvent, NULL, NULL, piosb, - buffer, bytesToWrite, poffset, NULL); + while(1) + { + status = NtWriteFile(hFile, hEvent, NULL, NULL, piosb, + buffer, bytesToWrite, poffset, NULL); + if( status != STATUS_INVALID_USER_BUFFER || FIUBflag) + break; + FIUBflag = 1; + /* NtWriteFile does not always cause page faults, generate them now */ + IsBadReadPtr( buffer, bytesToWrite); + } + if( FIUBflag && !status) /* failed first, but succeeded after access */ + FIXME("Could not access memory (%p,%ld) at first, now OK. Protected by DIBSection code?\n", buffer, bytesToWrite); if (status != STATUS_PENDING && bytesWritten) *bytesWritten = piosb->Information;