Commit bcfa5b09 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

ReadFile and WriteFile must be passed a parameter for the number of

handled bytes when no overlapped operation is done.
parent c7d80ccf
...@@ -2357,9 +2357,10 @@ HENHMETAFILE WINAPI CopyEnhMetaFileA( ...@@ -2357,9 +2357,10 @@ HENHMETAFILE WINAPI CopyEnhMetaFileA(
hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE ); hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE );
} else { } else {
HANDLE hFile; HANDLE hFile;
DWORD w;
hFile = CreateFileA( file, GENERIC_WRITE | GENERIC_READ, 0, hFile = CreateFileA( file, GENERIC_WRITE | GENERIC_READ, 0,
NULL, CREATE_ALWAYS, 0, 0); NULL, CREATE_ALWAYS, 0, 0);
WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0); WriteFile( hFile, emrSrc, emrSrc->nBytes, &w, NULL);
CloseHandle( hFile ); CloseHandle( hFile );
/* Reopen file for reading only, so that apps can share /* Reopen file for reading only, so that apps can share
read access to the file while hmf is still valid */ read access to the file while hmf is still valid */
...@@ -2396,9 +2397,10 @@ HENHMETAFILE WINAPI CopyEnhMetaFileW( ...@@ -2396,9 +2397,10 @@ HENHMETAFILE WINAPI CopyEnhMetaFileW(
hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE ); hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE );
} else { } else {
HANDLE hFile; HANDLE hFile;
DWORD w;
hFile = CreateFileW( file, GENERIC_WRITE | GENERIC_READ, 0, hFile = CreateFileW( file, GENERIC_WRITE | GENERIC_READ, 0,
NULL, CREATE_ALWAYS, 0, 0); NULL, CREATE_ALWAYS, 0, 0);
WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0); WriteFile( hFile, emrSrc, emrSrc->nBytes, &w, NULL);
CloseHandle( hFile ); CloseHandle( hFile );
/* Reopen file for reading only, so that apps can share /* Reopen file for reading only, so that apps can share
read access to the file while hmf is still valid */ read access to the file while hmf is still valid */
......
...@@ -411,12 +411,13 @@ HMETAFILE16 WINAPI CopyMetaFile16( HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename) ...@@ -411,12 +411,13 @@ HMETAFILE16 WINAPI CopyMetaFile16( HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename)
MF_ReleaseMetaHeader16( hSrcMetaFile ); MF_ReleaseMetaHeader16( hSrcMetaFile );
if(lpFilename) { /* disk based metafile */ if(lpFilename) { /* disk based metafile */
DWORD w;
if((hFile = CreateFileA(lpFilename, GENERIC_WRITE, 0, NULL, if((hFile = CreateFileA(lpFilename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
HeapFree( GetProcessHeap(), 0, mh2 ); HeapFree( GetProcessHeap(), 0, mh2 );
return 0; return 0;
} }
WriteFile(hFile, mh2, mh2->mtSize * 2, NULL, NULL); WriteFile(hFile, mh2, mh2->mtSize * 2, &w, NULL);
CloseHandle(hFile); CloseHandle(hFile);
mh2 = MF_CreateMetaHeaderDisk(mh2, lpFilename, FALSE); mh2 = MF_CreateMetaHeaderDisk(mh2, lpFilename, FALSE);
} }
...@@ -460,12 +461,13 @@ HMETAFILE WINAPI CopyMetaFileW( ...@@ -460,12 +461,13 @@ HMETAFILE WINAPI CopyMetaFileW(
} }
if(lpFilename) { /* disk based metafile */ if(lpFilename) { /* disk based metafile */
DWORD w;
if((hFile = CreateFileW(lpFilename, GENERIC_WRITE, 0, NULL, if((hFile = CreateFileW(lpFilename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) { CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
HeapFree( GetProcessHeap(), 0, mh2 ); HeapFree( GetProcessHeap(), 0, mh2 );
return 0; return 0;
} }
WriteFile(hFile, mh2, mh2->mtSize * 2, NULL, NULL); WriteFile(hFile, mh2, mh2->mtSize * 2, &w, NULL);
CloseHandle(hFile); CloseHandle(hFile);
mh2 = MF_CreateMetaHeaderDisk(mh2, lpFilename, TRUE); mh2 = MF_CreateMetaHeaderDisk(mh2, lpFilename, TRUE);
} }
......
...@@ -1735,9 +1735,10 @@ BOOL WINAPI TransmitCommChar( ...@@ -1735,9 +1735,10 @@ BOOL WINAPI TransmitCommChar(
HANDLE hComm, /* [in] The communication device in need of a command character. */ HANDLE hComm, /* [in] The communication device in need of a command character. */
CHAR chTransmit) /* [in] The character to transmit. */ CHAR chTransmit) /* [in] The character to transmit. */
{ {
DWORD w;
WARN("(%p,'%c') not perfect!\n",hComm,chTransmit); WARN("(%p,'%c') not perfect!\n",hComm,chTransmit);
return WriteFile( hComm, &chTransmit, 1, NULL, NULL ); return WriteFile( hComm, &chTransmit, 1, &w, NULL );
} }
......
...@@ -1508,7 +1508,7 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid) ...@@ -1508,7 +1508,7 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
pat=ReadPatternFromRegistry(i,j); pat=ReadPatternFromRegistry(i,j);
hFile=CreateFileW(filePathName,,,,,,hFile); hFile=CreateFileW(filePathName,,,,,,hFile);
SetFilePosition(hFile,pat.offset); 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){ if (memcmp(buf&pat.mask,pat.pattern.pat.size)==0){
*pclsid=ReadCLSIDFromRegistry(i); *pclsid=ReadCLSIDFromRegistry(i);
......
...@@ -423,6 +423,7 @@ void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize) ...@@ -423,6 +423,7 @@ void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
if (This->fileBased) if (This->fileBased)
{ {
char buf[10]; char buf[10];
DWORD w;
/* /*
* close file-mapping object, must be done before call to SetEndFile * close file-mapping object, must be done before call to SetEndFile
...@@ -445,7 +446,7 @@ void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize) ...@@ -445,7 +446,7 @@ void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
*/ */
memset(buf, '0', 10); memset(buf, '0', 10);
SetFilePointer(This->hfile, newSize.u.LowPart, NULL, FILE_BEGIN); 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 * END HACK
*/ */
......
...@@ -273,6 +273,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) ...@@ -273,6 +273,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx)
BYTE *curbuffer = (lol->offs_unread_CON) ? BYTE *curbuffer = (lol->offs_unread_CON) ?
(((BYTE*)dataseg) + lol->offs_unread_CON) : (BYTE*)NULL; (((BYTE*)dataseg) + lol->offs_unread_CON) : (BYTE*)NULL;
DOS_DEVICE_HEADER *con = dataseg->dev; DOS_DEVICE_HEADER *con = dataseg->dev;
DWORD w;
switch (hdr->command) { switch (hdr->command) {
case CMD_INPUT: case CMD_INPUT:
...@@ -364,7 +365,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) ...@@ -364,7 +365,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx)
/* a character */ /* a character */
if ((len+1)<CON_BUFFER) { if ((len+1)<CON_BUFFER) {
linebuffer[len] = LOBYTE(data); linebuffer[len] = LOBYTE(data);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &linebuffer[len++], 1, NULL, NULL); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &linebuffer[len++], 1, &w, NULL);
} }
/* else beep, but I don't like noise */ /* else beep, but I don't like noise */
} }
...@@ -372,7 +373,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) ...@@ -372,7 +373,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx)
case '\b': case '\b':
if (len>0) { if (len>0) {
len--; len--;
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\b \b", 3, NULL, NULL); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\b \b", 3, &w, NULL);
} }
break; break;
} }
......
...@@ -4208,7 +4208,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context ) ...@@ -4208,7 +4208,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
LPSTR data = CTX_SEG_OFF_TO_LIN( context, LPSTR data = CTX_SEG_OFF_TO_LIN( context,
context->SegDs, context->Edx ); context->SegDs, context->Edx );
LPSTR p = data; LPSTR p = data;
DWORD w;
/* /*
* Do NOT use strchr() to calculate the string length, * Do NOT use strchr() to calculate the string length,
* as '\0' is valid string content, too! * as '\0' is valid string content, too!
...@@ -4218,7 +4218,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context ) ...@@ -4218,7 +4218,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
if (DOSVM_IsWin16()) if (DOSVM_IsWin16())
WriteFile( DosFileHandleToWin32Handle(1), WriteFile( DosFileHandleToWin32Handle(1),
data, p - data, 0, 0 ); data, p - data, &w, NULL );
else else
for(; data != p; data++) for(; data != p; data++)
DOSVM_PutChar( *data ); DOSVM_PutChar( *data );
......
...@@ -52,9 +52,10 @@ BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL f ...@@ -52,9 +52,10 @@ BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL f
FILE_FLAG_BACKUP_SEMANTICS, NULL); FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (h != INVALID_HANDLE_VALUE) if (h != INVALID_HANDLE_VALUE)
{ {
DWORD r;
SetFilePointer(h, begin * 512, NULL, SEEK_SET ); SetFilePointer(h, begin * 512, NULL, SEEK_SET );
/* FIXME: check errors */ /* FIXME: check errors */
ReadFile(h, dataptr, nr_sect * 512, NULL, NULL ); ReadFile(h, dataptr, nr_sect * 512, &r, NULL );
CloseHandle(h); CloseHandle(h);
} }
else else
......
...@@ -41,6 +41,7 @@ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL ...@@ -41,6 +41,7 @@ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL
{ {
WCHAR root[] = {'\\','\\','.','\\','A',':',0}; WCHAR root[] = {'\\','\\','.','\\','A',':',0};
HANDLE h; HANDLE h;
DWORD w;
TRACE( "abs diskwrite, drive %d, sector %ld, " TRACE( "abs diskwrite, drive %d, sector %ld, "
"count %ld, buffer %p\n", "count %ld, buffer %p\n",
...@@ -53,7 +54,7 @@ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL ...@@ -53,7 +54,7 @@ BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL
{ {
SetFilePointer(h, begin * 512, NULL, SEEK_SET ); SetFilePointer(h, begin * 512, NULL, SEEK_SET );
/* FIXME: check errors */ /* FIXME: check errors */
WriteFile( h, dataptr, nr_sect * 512, NULL, NULL ); WriteFile( h, dataptr, nr_sect * 512, &w, NULL );
CloseHandle( h ); CloseHandle( h );
} }
else if (!fake_success) else if (!fake_success)
......
...@@ -835,6 +835,8 @@ void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count) ...@@ -835,6 +835,8 @@ void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count)
void VGA_PutChar(BYTE ascii) void VGA_PutChar(BYTE ascii)
{ {
DWORD w;
EnterCriticalSection(&vga_lock); EnterCriticalSection(&vga_lock);
switch(ascii) { switch(ascii) {
...@@ -885,7 +887,7 @@ void VGA_PutChar(BYTE ascii) ...@@ -885,7 +887,7 @@ void VGA_PutChar(BYTE ascii)
* If we don't have a console, write directly to standard output. * If we don't have a console, write directly to standard output.
*/ */
if(!vga_text_console) if(!vga_text_console)
WriteFile(VGA_AlphaConsole(), &ascii, 1, NULL, NULL); WriteFile(VGA_AlphaConsole(), &ascii, 1, &w, NULL);
LeaveCriticalSection(&vga_lock); LeaveCriticalSection(&vga_lock);
} }
......
...@@ -62,6 +62,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineboot); ...@@ -62,6 +62,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineboot);
static BOOL GetLine( HANDLE hFile, char *buf, size_t buflen ) static BOOL GetLine( HANDLE hFile, char *buf, size_t buflen )
{ {
unsigned int i=0; unsigned int i=0;
DWORD r;
buf[0]='\0'; buf[0]='\0';
do do
...@@ -75,7 +76,7 @@ static BOOL GetLine( HANDLE hFile, char *buf, size_t buflen ) ...@@ -75,7 +76,7 @@ static BOOL GetLine( HANDLE hFile, char *buf, size_t buflen )
} while( isspace( *buf ) ); } while( isspace( *buf ) );
while( buf[i]!='\n' && i<=buflen && while( buf[i]!='\n' && i<=buflen &&
ReadFile( hFile, buf+i+1, 1, NULL, NULL ) ) ReadFile( hFile, buf+i+1, 1, &r, NULL ) )
{ {
++i; ++i;
} }
......
...@@ -454,16 +454,17 @@ void apply_drive_changes() ...@@ -454,16 +454,17 @@ void apply_drive_changes()
NULL); NULL);
if (hFile != INVALID_HANDLE_VALUE) if (hFile != INVALID_HANDLE_VALUE)
{ {
DWORD w;
WINE_TRACE(" writing serial number of '%s'\n", drives[i].serial); WINE_TRACE(" writing serial number of '%s'\n", drives[i].serial);
WriteFile(hFile, WriteFile(hFile,
drives[i].serial, drives[i].serial,
strlen(drives[i].serial), strlen(drives[i].serial),
NULL, &w,
NULL); NULL);
WriteFile(hFile, WriteFile(hFile,
"\n", "\n",
strlen("\n"), strlen("\n"),
NULL, &w,
NULL); NULL);
CloseHandle(hFile); CloseHandle(hFile);
} }
......
...@@ -454,7 +454,7 @@ char *arg_command = NULL; ...@@ -454,7 +454,7 @@ char *arg_command = NULL;
int input_fetch_entire_line(const char* pfx, char** line, size_t* alloc, BOOL check_nl) int input_fetch_entire_line(const char* pfx, char** line, size_t* alloc, BOOL check_nl)
{ {
char buf_line[256]; char buf_line[256];
DWORD nread; DWORD nread, nwritten;
size_t len; size_t len;
if (arg_command) { if (arg_command) {
...@@ -466,7 +466,7 @@ int input_fetch_entire_line(const char* pfx, char** line, size_t* alloc, BO ...@@ -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 /* as of today, console handles can be file handles... so better use file APIs rather than
* console's * console's
*/ */
WriteFile(dbg_parser_output, pfx, strlen(pfx), NULL, NULL); WriteFile(dbg_parser_output, pfx, strlen(pfx), &nwritten, NULL);
len = 0; len = 0;
do do
......
...@@ -92,7 +92,8 @@ static HANDLE dbg_houtput; ...@@ -92,7 +92,8 @@ static HANDLE dbg_houtput;
void dbg_outputA(const char* buffer, int len) 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) void dbg_outputW(const WCHAR* buffer, int len)
......
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