console separation 3/4
Eric Pouech
eric.pouech at wanadoo.fr
Tue Jul 30 14:24:40 CDT 2002
no more direct callout in file handling from ntdll to console
-------------- next part --------------
Name: con_file
ChangeLog: made the calls the (Read|Write)Console thru a function pointer to ease up ntdll/kernel separation
License: X11
GenDate: 2002/07/30 19:18:45 UTC
ModifiedFiles: files/file.c
AddedFiles:
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/files/file.c,v
retrieving revision 1.149
diff -u -u -r1.149 file.c
--- files/file.c 5 Jun 2002 00:47:38 -0000 1.149
+++ files/file.c 30 Jul 2002 17:18:42 -0000
@@ -361,9 +361,50 @@
ret = reply->handle;
}
SERVER_END_REQ;
+ if (!ret && 0)
+ {
+ if (wine_server_fd_to_handle(output ? 1 : 0, access, sharing, &ret))
+ ret = 0;
+ }
return ret;
}
+/* FIXME: those routines defined as pointers are needed, because this file is
+ * currently compiled into NTDLL whereas it belongs to kernel32.
+ * this shall go away once all the DLL separation process is done
+ */
+typedef BOOL (WINAPI* pRW)(HANDLE, const void*, DWORD, DWORD*, void*);
+
+static BOOL FILE_ReadConsole(HANDLE hCon, void* buf, DWORD nb, DWORD* nr, void* p)
+{
+ static HANDLE hKernel /* = 0 */;
+ static pRW pReadConsole /* = 0 */;
+
+ if ((!hKernel && !(hKernel = LoadLibraryA("kernel32"))) ||
+ (!pReadConsole &&
+ !(pReadConsole = GetProcAddress(hKernel, "ReadConsoleA"))))
+ {
+ *nr = 0;
+ return 0;
+ }
+ return (pReadConsole)(hCon, buf, nb, nr, p);
+}
+
+static BOOL FILE_WriteConsole(HANDLE hCon, const void* buf, DWORD nb, DWORD* nr, void* p)
+{
+ static HANDLE hKernel /* = 0 */;
+ static pRW pWriteConsole /* = 0 */;
+
+ if ((!hKernel && !(hKernel = LoadLibraryA("kernel32"))) ||
+ (!pWriteConsole &&
+ !(pWriteConsole = GetProcAddress(hKernel, "WriteConsoleA"))))
+ {
+ *nr = 0;
+ return 0;
+ }
+ return (pWriteConsole)(hCon, buf, nb, nr, p);
+}
+/* end of FIXME */
/***********************************************************************
* FILE_CreateFile
@@ -1644,7 +1685,7 @@
case FD_TYPE_SMB:
return SMB_ReadFile(hFile, buffer, bytesToRead, bytesRead, NULL);
case FD_TYPE_CONSOLE:
- return ReadConsoleA(hFile, buffer, bytesToRead, bytesRead, NULL);
+ return FILE_ReadConsole(hFile, buffer, bytesToRead, bytesRead, NULL);
default:
/* normal unix files */
@@ -1844,7 +1885,7 @@
case FD_TYPE_CONSOLE:
TRACE("%d %s %ld %p %p\n", hFile, debugstr_an(buffer, bytesToWrite), bytesToWrite,
bytesWritten, overlapped );
- return WriteConsoleA(hFile, buffer, bytesToWrite, bytesWritten, NULL);
+ return FILE_WriteConsole(hFile, buffer, bytesToWrite, bytesWritten, NULL);
default:
if (unix_handle == -1)
return FALSE;
More information about the wine-patches
mailing list