[PATCH] InternetReadFileEx*
Brian Gerst <[email protected]> Mon, 07 Nov 2005 23:56:33 -0500
| Newsgroups | gmane.comp.emulators.winex.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------040307080400020407090906
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
This patch implements the InternetReadFileExA and InternetReadFileExW
functions. I don't know if this completely implements it to MSDN specs
which are fairly vague, but it is enough to allow World of Warcraft to
read and display the server status message.
--
Brian Gerst
--------------040307080400020407090906
Content-Type: text/x-patch;
name="InternetReadFileEx.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="InternetReadFileEx.diff"
Index: internet.c
===================================================================
RCS file: /cvsroot/winex/dlls/wininet/internet.c,v
retrieving revision 1.16
diff -u -r1.16 internet.c
--- internet.c 25 May 2005 15:46:35 -0000 1.16
+++ internet.c 8 Nov 2005 03:42:28 -0000
@@ -1377,11 +1377,53 @@
* FALSE on failure
*
*/
-BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffer,
+BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOut,
DWORD dwFlags, DWORD dwContext)
{
- FIXME("stub\n");
- return FALSE;
+ BOOL retval = FALSE;
+ int nSocket = -1;
+ LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
+
+ TRACE("%p %p %ld %ld\n", hFile, lpBuffersOut, dwFlags, dwContext);
+
+ if (NULL == lpwh)
+ return FALSE;
+
+ /* FIXME: this should use NETCON functions! */
+ switch (lpwh->htype)
+ {
+ case WH_HHTTPREQ:
+ if (!NETCON_recv(&((LPWININETHTTPREQA)lpwh)->netConnection,
+ lpBuffersOut->lpvBuffer,
+ lpBuffersOut->dwBufferLength,
+ dwFlags & IRF_NO_WAIT ? 0 : MSG_WAITALL,
+ (int*)&lpBuffersOut->dwBufferLength))
+ {
+ lpBuffersOut->dwBufferLength = 0;
+ retval = TRUE; /* Under windows, it seems to return 0 even if nothing was read... */
+ }
+ else
+ retval = TRUE;
+ break;
+
+ case WH_HFILE:
+ /* FIXME: FTP should use NETCON_ stuff */
+ nSocket = ((LPWININETFILE)lpwh)->nDataSocket;
+ if (nSocket != -1)
+ {
+ int res = recv(nSocket, lpBuffersOut->lpvBuffer, lpBuffersOut->dwBufferLength,
+ dwFlags & IRF_NO_WAIT ? 0 : MSG_WAITALL);
+ retval = (res >= 0);
+ lpBuffersOut->dwBufferLength = retval ? res : 0;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ TRACE("-- %s (bytes read: %ld)\n", retval ? "TRUE": "FALSE", lpBuffersOut->dwBufferLength);
+ return retval;
}
/***********************************************************************
@@ -1394,13 +1436,53 @@
* FALSE on failure
*
*/
-BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
+BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffersOut,
DWORD dwFlags, DWORD dwContext)
{
- FIXME("stub\n");
+ BOOL retval = FALSE;
+ int nSocket = -1;
+ LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
+
+ TRACE("%p %p %ld %ld\n", hFile, lpBuffersOut, dwFlags, dwContext);
+
+ if (NULL == lpwh)
+ return FALSE;
+
+ /* FIXME: this should use NETCON functions! */
+ switch (lpwh->htype)
+ {
+ case WH_HHTTPREQ:
+ if (!NETCON_recv(&((LPWININETHTTPREQA)lpwh)->netConnection,
+ lpBuffersOut->lpvBuffer,
+ lpBuffersOut->dwBufferLength,
+ dwFlags & IRF_NO_WAIT ? 0 : MSG_WAITALL,
+ (int*)&lpBuffersOut->dwBufferLength))
+ {
+ lpBuffersOut->dwBufferLength = 0;
+ retval = TRUE; /* Under windows, it seems to return 0 even if nothing was read... */
+ }
+ else
+ retval = TRUE;
+ break;
+
+ case WH_HFILE:
+ /* FIXME: FTP should use NETCON_ stuff */
+ nSocket = ((LPWININETFILE)lpwh)->nDataSocket;
+ if (nSocket != -1)
+ {
+ int res = recv(nSocket, lpBuffersOut->lpvBuffer, lpBuffersOut->dwBufferLength,
+ dwFlags & IRF_NO_WAIT ? 0 : MSG_WAITALL);
+ retval = (res >= 0);
+ lpBuffersOut->dwBufferLength = retval ? res : 0;
+ }
+ break;
+
+ default:
+ break;
+ }
- INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ TRACE("-- %s (bytes read: %ld)\n", retval ? "TRUE": "FALSE", lpBuffersOut->dwBufferLength);
+ return retval;
}
/***********************************************************************
--------------040307080400020407090906--