From bcfa5b0900c053c408883e81111503af01e213c3 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Wed, 22 Dec 2004 18:38:31 +0000 Subject: [PATCH] ReadFile and WriteFile must be passed a parameter for the number of handled bytes when no overlapped operation is done. --- dlls/gdi/enhmetafile.c | 6 ++++-- dlls/gdi/metafile.c | 6 ++++-- dlls/kernel/comm.c | 3 ++- dlls/ole32/compobj.c | 2 +- dlls/ole32/stg_bigblockfile.c | 3 ++- dlls/winedos/devices.c | 5 +++-- dlls/winedos/int21.c | 4 ++-- dlls/winedos/int25.c | 3 ++- dlls/winedos/int26.c | 3 ++- dlls/winedos/vga.c | 4 +++- programs/wineboot/wineboot.c | 3 ++- programs/winecfg/drive.c | 5 +++-- programs/winedbg/dbg.y | 4 ++-- programs/winedbg/winedbg.c | 3 ++- 14 files changed, 34 insertions(+), 20 deletions(-) diff --git a/dlls/gdi/enhmetafile.c b/dlls/gdi/enhmetafile.c index 1207bf88ddb..8e4aadafa9e 100644 --- a/dlls/gdi/enhmetafile.c +++ b/dlls/gdi/enhmetafile.c @@ -2357,9 +2357,10 @@ HENHMETAFILE WINAPI CopyEnhMetaFileA( hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE ); } else { HANDLE hFile; + DWORD w; hFile = CreateFileA( file, GENERIC_WRITE | GENERIC_READ, 0, NULL, CREATE_ALWAYS, 0, 0); - WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0); + WriteFile( hFile, emrSrc, emrSrc->nBytes, &w, NULL); CloseHandle( hFile ); /* Reopen file for reading only, so that apps can share read access to the file while hmf is still valid */ @@ -2396,9 +2397,10 @@ HENHMETAFILE WINAPI CopyEnhMetaFileW( hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE ); } else { HANDLE hFile; + DWORD w; hFile = CreateFileW( file, GENERIC_WRITE | GENERIC_READ, 0, NULL, CREATE_ALWAYS, 0, 0); - WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0); + WriteFile( hFile, emrSrc, emrSrc->nBytes, &w, NULL); CloseHandle( hFile ); /* Reopen file for reading only, so that apps can share read access to the file while hmf is still valid */ diff --git a/dlls/gdi/metafile.c b/dlls/gdi/metafile.c index 9c917eee7ed..8ea31369574 100644 --- a/dlls/gdi/metafile.c +++ b/dlls/gdi/metafile.c @@ -411,12 +411,13 @@ HMETAFILE16 WINAPI CopyMetaFile16( HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename) MF_ReleaseMetaHeader16( hSrcMetaFile ); if(lpFilename) { /* disk based metafile */ + DWORD w; if((hFile = CreateFileA(lpFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { HeapFree( GetProcessHeap(), 0, mh2 ); return 0; } - WriteFile(hFile, mh2, mh2->mtSize * 2, NULL, NULL); + WriteFile(hFile, mh2, mh2->mtSize * 2, &w, NULL); CloseHandle(hFile); mh2 = MF_CreateMetaHeaderDisk(mh2, lpFilename, FALSE); } @@ -460,12 +461,13 @@ HMETAFILE WINAPI CopyMetaFileW( } if(lpFilename) { /* disk based metafile */ + DWORD w; if((hFile = CreateFileW(lpFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { HeapFree( GetProcessHeap(), 0, mh2 ); return 0; } - WriteFile(hFile, mh2, mh2->mtSize * 2, NULL, NULL); + WriteFile(hFile, mh2, mh2->mtSize * 2, &w, NULL); CloseHandle(hFile); mh2 = MF_CreateMetaHeaderDisk(mh2, lpFilename, TRUE); } diff --git a/dlls/kernel/comm.c b/dlls/kernel/comm.c index 290f4fcf0ef..8980debc7b8 100644 --- a/dlls/kernel/comm.c +++ b/dlls/kernel/comm.c @@ -1735,9 +1735,10 @@ BOOL WINAPI TransmitCommChar( HANDLE hComm, /* [in] The communication device in need of a command character. */ CHAR chTransmit) /* [in] The character to transmit. */ { + DWORD w; WARN("(%p,'%c') not perfect!\n",hComm,chTransmit); - return WriteFile( hComm, &chTransmit, 1, NULL, NULL ); + return WriteFile( hComm, &chTransmit, 1, &w, NULL ); } diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index d4cac195ef1..3a4d568ec04 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -1508,7 +1508,7 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid) pat=ReadPatternFromRegistry(i,j); hFile=CreateFileW(filePathName,,,,,,hFile); SetFilePosition(hFile,pat.offset); - ReadFile(hFile,buf,pat.size,NULL,NULL); + ReadFile(hFile,buf,pat.size,&r,NULL); if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){ *pclsid=ReadCLSIDFromRegistry(i); diff --git a/dlls/ole32/stg_bigblockfile.c b/dlls/ole32/stg_bigblockfile.c index 7532facccc6..6e71548ebdc 100644 --- a/dlls/ole32/stg_bigblockfile.c +++ b/dlls/ole32/stg_bigblockfile.c @@ -423,6 +423,7 @@ void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize) if (This->fileBased) { char buf[10]; + DWORD w; /* * close file-mapping object, must be done before call to SetEndFile @@ -445,7 +446,7 @@ void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize) */ memset(buf, '0', 10); SetFilePointer(This->hfile, newSize.u.LowPart, NULL, FILE_BEGIN); - WriteFile(This->hfile, buf, 10, NULL, NULL); + WriteFile(This->hfile, buf, 10, &w, NULL); /* * END HACK */ diff --git a/dlls/winedos/devices.c b/dlls/winedos/devices.c index d5f193ee048..d8f341d3ae6 100644 --- a/dlls/winedos/devices.c +++ b/dlls/winedos/devices.c @@ -273,6 +273,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) BYTE *curbuffer = (lol->offs_unread_CON) ? (((BYTE*)dataseg) + lol->offs_unread_CON) : (BYTE*)NULL; DOS_DEVICE_HEADER *con = dataseg->dev; + DWORD w; switch (hdr->command) { case CMD_INPUT: @@ -364,7 +365,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) /* a character */ if ((len+1)0) { len--; - WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\b \b", 3, NULL, NULL); + WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\b \b", 3, &w, NULL); } break; } diff --git a/dlls/winedos/int21.c b/dlls/winedos/int21.c index 6df193ce80e..a487df6666f 100644 --- a/dlls/winedos/int21.c +++ b/dlls/winedos/int21.c @@ -4208,7 +4208,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context ) LPSTR data = CTX_SEG_OFF_TO_LIN( context, context->SegDs, context->Edx ); LPSTR p = data; - + DWORD w; /* * Do NOT use strchr() to calculate the string length, * as '\0' is valid string content, too! @@ -4218,7 +4218,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context ) if (DOSVM_IsWin16()) WriteFile( DosFileHandleToWin32Handle(1), - data, p - data, 0, 0 ); + data, p - data, &w, NULL ); else for(; data != p; data++) DOSVM_PutChar( *data ); diff --git a/dlls/winedos/int25.c b/dlls/winedos/int25.c index d3b8b37db27..6c245539e7f 100644 --- a/dlls/winedos/int25.c +++ b/dlls/winedos/int25.c @@ -52,9 +52,10 @@ BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL f FILE_FLAG_BACKUP_SEMANTICS, NULL); if (h != INVALID_HANDLE_VALUE) { + DWORD r; SetFilePointer(h, begin * 512, NULL, SEEK_SET ); /* FIXME: check errors */ - ReadFile(h, dataptr, nr_sect * 512, NULL, NULL ); + ReadFile(h, dataptr, nr_sect * 512, &r, NULL ); CloseHandle(h); } else diff --git a/dlls/winedos/int26.c b/dlls/winedos/int26.c index a351fc1e022..25e74aff3ff 100644 --- a/dlls/winedos/int26.c +++ b/dlls/winedos/int26.c @@ -41,6 +41,7 @@ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL { WCHAR root[] = {'\\','\\','.','\\','A',':',0}; HANDLE h; + DWORD w; TRACE( "abs diskwrite, drive %d, sector %ld, " "count %ld, buffer %p\n", @@ -53,7 +54,7 @@ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL { SetFilePointer(h, begin * 512, NULL, SEEK_SET ); /* FIXME: check errors */ - WriteFile( h, dataptr, nr_sect * 512, NULL, NULL ); + WriteFile( h, dataptr, nr_sect * 512, &w, NULL ); CloseHandle( h ); } else if (!fake_success) diff --git a/dlls/winedos/vga.c b/dlls/winedos/vga.c index 39110574e8e..c9c115c920d 100644 --- a/dlls/winedos/vga.c +++ b/dlls/winedos/vga.c @@ -835,6 +835,8 @@ void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count) void VGA_PutChar(BYTE ascii) { + DWORD w; + EnterCriticalSection(&vga_lock); switch(ascii) { @@ -885,7 +887,7 @@ void VGA_PutChar(BYTE ascii) * If we don't have a console, write directly to standard output. */ if(!vga_text_console) - WriteFile(VGA_AlphaConsole(), &ascii, 1, NULL, NULL); + WriteFile(VGA_AlphaConsole(), &ascii, 1, &w, NULL); LeaveCriticalSection(&vga_lock); } diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 8fcbcfb7d19..4a93ad4f6fa 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -62,6 +62,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineboot); static BOOL GetLine( HANDLE hFile, char *buf, size_t buflen ) { unsigned int i=0; + DWORD r; buf[0]='\0'; do @@ -75,7 +76,7 @@ static BOOL GetLine( HANDLE hFile, char *buf, size_t buflen ) } while( isspace( *buf ) ); while( buf[i]!='\n' && i<=buflen && - ReadFile( hFile, buf+i+1, 1, NULL, NULL ) ) + ReadFile( hFile, buf+i+1, 1, &r, NULL ) ) { ++i; } diff --git a/programs/winecfg/drive.c b/programs/winecfg/drive.c index 01c8349d593..f44b82888b6 100644 --- a/programs/winecfg/drive.c +++ b/programs/winecfg/drive.c @@ -454,16 +454,17 @@ void apply_drive_changes() NULL); if (hFile != INVALID_HANDLE_VALUE) { + DWORD w; WINE_TRACE(" writing serial number of '%s'\n", drives[i].serial); WriteFile(hFile, drives[i].serial, strlen(drives[i].serial), - NULL, + &w, NULL); WriteFile(hFile, "\n", strlen("\n"), - NULL, + &w, NULL); CloseHandle(hFile); } diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index b7f2b5c13ae..3aaca17cf0c 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -454,7 +454,7 @@ char *arg_command = NULL; int input_fetch_entire_line(const char* pfx, char** line, size_t* alloc, BOOL check_nl) { char buf_line[256]; - DWORD nread; + DWORD nread, nwritten; size_t len; if (arg_command) { @@ -466,7 +466,7 @@ int input_fetch_entire_line(const char* pfx, char** line, size_t* alloc, BO /* as of today, console handles can be file handles... so better use file APIs rather than * console's */ - WriteFile(dbg_parser_output, pfx, strlen(pfx), NULL, NULL); + WriteFile(dbg_parser_output, pfx, strlen(pfx), &nwritten, NULL); len = 0; do diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 4299e00e84f..5f141487437 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -92,7 +92,8 @@ static HANDLE dbg_houtput; void dbg_outputA(const char* buffer, int len) { - WriteFile(dbg_houtput, buffer, len, NULL, NULL); + DWORD w; + WriteFile(dbg_houtput, buffer, len, &w, NULL); } void dbg_outputW(const WCHAR* buffer, int len)