Commit 52144829 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Don't take INTERNET_BUFFERSW as argument in object's ReadFileEx entry.

parent 9cf630fc
...@@ -1207,10 +1207,10 @@ static DWORD FTPFILE_ReadFileExA(object_header_t *hdr, INTERNET_BUFFERSA *buffer ...@@ -1207,10 +1207,10 @@ static DWORD FTPFILE_ReadFileExA(object_header_t *hdr, INTERNET_BUFFERSA *buffer
return FTPFILE_ReadFile(hdr, buffers->lpvBuffer, buffers->dwBufferLength, &buffers->dwBufferLength); return FTPFILE_ReadFile(hdr, buffers->lpvBuffer, buffers->dwBufferLength, &buffers->dwBufferLength);
} }
static DWORD FTPFILE_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffers, static DWORD FTPFILE_ReadFileEx(object_header_t *hdr, void *buf, DWORD size, DWORD *ret_size,
DWORD flags, DWORD_PTR context) DWORD flags, DWORD_PTR context)
{ {
return FTPFILE_ReadFile(hdr, buffers->lpvBuffer, buffers->dwBufferLength, &buffers->dwBufferLength); return FTPFILE_ReadFile(hdr, buf, size, ret_size);
} }
static DWORD FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written) static DWORD FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written)
...@@ -1300,7 +1300,7 @@ static const object_vtbl_t FTPFILEVtbl = { ...@@ -1300,7 +1300,7 @@ static const object_vtbl_t FTPFILEVtbl = {
INET_SetOption, INET_SetOption,
FTPFILE_ReadFile, FTPFILE_ReadFile,
FTPFILE_ReadFileExA, FTPFILE_ReadFileExA,
FTPFILE_ReadFileExW, FTPFILE_ReadFileEx,
FTPFILE_WriteFile, FTPFILE_WriteFile,
FTPFILE_QueryDataAvailable, FTPFILE_QueryDataAvailable,
NULL NULL
......
...@@ -2980,31 +2980,27 @@ done: ...@@ -2980,31 +2980,27 @@ done:
static void HTTPREQ_AsyncReadFileExWProc(WORKREQUEST *workRequest) static void HTTPREQ_AsyncReadFileExWProc(WORKREQUEST *workRequest)
{ {
struct WORKREQ_INTERNETREADFILEEXW const *data = &workRequest->u.InternetReadFileExW; struct WORKREQ_HTTPREADFILEEX const *data = &workRequest->u.HttpReadFileEx;
http_request_t *req = (http_request_t*)workRequest->hdr; http_request_t *req = (http_request_t*)workRequest->hdr;
DWORD res; DWORD res;
TRACE("INTERNETREADFILEEXW %p\n", workRequest->hdr); TRACE("INTERNETREADFILEEXW %p\n", workRequest->hdr);
res = HTTPREQ_Read(req, data->lpBuffersOut->lpvBuffer, res = HTTPREQ_Read(req, data->buf, data->size, data->ret_read, TRUE);
data->lpBuffersOut->dwBufferLength, &data->lpBuffersOut->dwBufferLength, TRUE);
send_request_complete(req, res == ERROR_SUCCESS, res); send_request_complete(req, res == ERROR_SUCCESS, res);
} }
static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffers, static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, void *buf, DWORD size, DWORD *ret_read,
DWORD flags, DWORD_PTR context) DWORD flags, DWORD_PTR context)
{ {
http_request_t *req = (http_request_t*)hdr; http_request_t *req = (http_request_t*)hdr;
DWORD res, size, read, error = ERROR_SUCCESS; DWORD res, read, cread, error = ERROR_SUCCESS;
if (flags & ~(IRF_ASYNC|IRF_NO_WAIT)) if (flags & ~(IRF_ASYNC|IRF_NO_WAIT))
FIXME("these dwFlags aren't implemented: 0x%x\n", flags & ~(IRF_ASYNC|IRF_NO_WAIT)); FIXME("these dwFlags aren't implemented: 0x%x\n", flags & ~(IRF_ASYNC|IRF_NO_WAIT));
if (buffers->dwStructSize != sizeof(*buffers))
return ERROR_INVALID_PARAMETER;
INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0);
if (hdr->dwFlags & INTERNET_FLAG_ASYNC) if (hdr->dwFlags & INTERNET_FLAG_ASYNC)
...@@ -3015,9 +3011,7 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer ...@@ -3015,9 +3011,7 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer
{ {
if (get_avail_data(req)) if (get_avail_data(req))
{ {
res = HTTPREQ_Read(req, buffers->lpvBuffer, buffers->dwBufferLength, res = HTTPREQ_Read(req, buf, size, &read, FALSE);
&buffers->dwBufferLength, FALSE);
size = buffers->dwBufferLength;
LeaveCriticalSection( &req->read_section ); LeaveCriticalSection( &req->read_section );
goto done; goto done;
} }
...@@ -3026,7 +3020,9 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer ...@@ -3026,7 +3020,9 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer
workRequest.asyncproc = HTTPREQ_AsyncReadFileExWProc; workRequest.asyncproc = HTTPREQ_AsyncReadFileExWProc;
workRequest.hdr = WININET_AddRef(&req->hdr); workRequest.hdr = WININET_AddRef(&req->hdr);
workRequest.u.InternetReadFileExW.lpBuffersOut = buffers; workRequest.u.HttpReadFileEx.buf = buf;
workRequest.u.HttpReadFileEx.size = size;
workRequest.u.HttpReadFileEx.ret_read = ret_read;
INTERNET_AsyncCall(&workRequest); INTERNET_AsyncCall(&workRequest);
...@@ -3034,7 +3030,6 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer ...@@ -3034,7 +3030,6 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer
} }
read = 0; read = 0;
size = buffers->dwBufferLength;
EnterCriticalSection( &req->read_section ); EnterCriticalSection( &req->read_section );
if(hdr->dwError == ERROR_SUCCESS) if(hdr->dwError == ERROR_SUCCESS)
...@@ -3043,19 +3038,18 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer ...@@ -3043,19 +3038,18 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer
hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR;
while(1) { while(1) {
res = HTTPREQ_Read(req, (char*)buffers->lpvBuffer+read, size-read, res = HTTPREQ_Read(req, (char*)buf+read, size-read, &cread, !(flags & IRF_NO_WAIT));
&buffers->dwBufferLength, !(flags & IRF_NO_WAIT));
if(res != ERROR_SUCCESS) if(res != ERROR_SUCCESS)
break; break;
read += buffers->dwBufferLength; read += cread;
if(read == size || end_of_read_data(req)) if(read == size || end_of_read_data(req))
break; break;
LeaveCriticalSection( &req->read_section ); LeaveCriticalSection( &req->read_section );
INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED,
&buffers->dwBufferLength, sizeof(buffers->dwBufferLength)); &cread, sizeof(cread));
INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_SendCallback(&req->hdr, req->hdr.dwContext,
INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0);
...@@ -3068,13 +3062,12 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer ...@@ -3068,13 +3062,12 @@ static DWORD HTTPREQ_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer
error = hdr->dwError; error = hdr->dwError;
LeaveCriticalSection( &req->read_section ); LeaveCriticalSection( &req->read_section );
size = buffers->dwBufferLength;
buffers->dwBufferLength = read;
done: done:
*ret_read = read;
if (res == ERROR_SUCCESS) { if (res == ERROR_SUCCESS) {
INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED,
&size, sizeof(size)); &read, sizeof(read));
} }
return res==ERROR_SUCCESS ? error : res; return res==ERROR_SUCCESS ? error : res;
......
...@@ -2269,14 +2269,20 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, ...@@ -2269,14 +2269,20 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
TRACE("(%p %p 0x%x 0x%lx)\n", hFile, lpBuffer, dwFlags, dwContext); TRACE("(%p %p 0x%x 0x%lx)\n", hFile, lpBuffer, dwFlags, dwContext);
if (lpBuffer->dwStructSize != sizeof(*lpBuffer)) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
hdr = get_handle_object(hFile); hdr = get_handle_object(hFile);
if (!hdr) { if (!hdr) {
INTERNET_SetLastError(ERROR_INVALID_HANDLE); INTERNET_SetLastError(ERROR_INVALID_HANDLE);
return FALSE; return FALSE;
} }
if(hdr->vtbl->ReadFileExW) if(hdr->vtbl->ReadFileEx)
res = hdr->vtbl->ReadFileExW(hdr, lpBuffer, dwFlags, dwContext); res = hdr->vtbl->ReadFileEx(hdr, lpBuffer->lpvBuffer, lpBuffer->dwBufferLength, &lpBuffer->dwBufferLength,
dwFlags, dwContext);
WININET_Release(hdr); WININET_Release(hdr);
......
...@@ -234,7 +234,7 @@ typedef struct { ...@@ -234,7 +234,7 @@ typedef struct {
DWORD (*SetOption)(object_header_t*,DWORD,void*,DWORD); DWORD (*SetOption)(object_header_t*,DWORD,void*,DWORD);
DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*); DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*);
DWORD (*ReadFileExA)(object_header_t*,INTERNET_BUFFERSA*,DWORD,DWORD_PTR); DWORD (*ReadFileExA)(object_header_t*,INTERNET_BUFFERSA*,DWORD,DWORD_PTR);
DWORD (*ReadFileExW)(object_header_t*,INTERNET_BUFFERSW*,DWORD,DWORD_PTR); DWORD (*ReadFileEx)(object_header_t*,void*,DWORD,DWORD*,DWORD,DWORD_PTR);
DWORD (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*); DWORD (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*);
DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR); DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR);
DWORD (*FindNextFileW)(object_header_t*,void*); DWORD (*FindNextFileW)(object_header_t*,void*);
...@@ -467,9 +467,11 @@ struct WORKREQ_INTERNETREADFILEEXA ...@@ -467,9 +467,11 @@ struct WORKREQ_INTERNETREADFILEEXA
LPINTERNET_BUFFERSA lpBuffersOut; LPINTERNET_BUFFERSA lpBuffersOut;
}; };
struct WORKREQ_INTERNETREADFILEEXW struct WORKREQ_HTTPREADFILEEX
{ {
LPINTERNET_BUFFERSW lpBuffersOut; void *buf;
DWORD size;
DWORD *ret_read;
}; };
typedef struct WORKREQ typedef struct WORKREQ
...@@ -494,7 +496,7 @@ typedef struct WORKREQ ...@@ -494,7 +496,7 @@ typedef struct WORKREQ
struct WORKREQ_SENDCALLBACK SendCallback; struct WORKREQ_SENDCALLBACK SendCallback;
struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW; struct WORKREQ_INTERNETOPENURLW InternetOpenUrlW;
struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA; struct WORKREQ_INTERNETREADFILEEXA InternetReadFileExA;
struct WORKREQ_INTERNETREADFILEEXW InternetReadFileExW; struct WORKREQ_HTTPREADFILEEX HttpReadFileEx;
} u; } u;
} WORKREQUEST, *LPWORKREQUEST; } WORKREQUEST, *LPWORKREQUEST;
......
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