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

handled bytes when no overlapped operation is done.
oldstable
Eric Pouech 2004-12-22 18:38:31 +00:00 committed by Alexandre Julliard
parent c7d80ccf52
commit bcfa5b0900
14 changed files with 34 additions and 20 deletions

View File

@ -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 */

View File

@ -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);
}

View File

@ -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 );
}

View File

@ -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);

View File

@ -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
*/

View File

@ -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)<CON_BUFFER) {
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 */
}
@ -372,7 +373,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx)
case '\b':
if (len>0) {
len--;
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\b \b", 3, NULL, NULL);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\b \b", 3, &w, NULL);
}
break;
}

View File

@ -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 );

View File

@ -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

View File

@ -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)

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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

View File

@ -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)