mirror of
git://source.winehq.org/git/wine.git
synced 2024-08-31 08:34:07 +00:00
Made the calls to (Read|Write)Console through a function pointer to
ease up ntdll/kernel separation.
This commit is contained in:
parent
3d4d7e0153
commit
7fcae15632
40
files/file.c
40
files/file.c
|
@ -364,6 +364,42 @@ static HANDLE FILE_OpenConsole( BOOL output, DWORD access, DWORD sharing, LPSECU
|
|||
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
|
||||
|
@ -1640,7 +1676,7 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
|
|||
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 */
|
||||
|
@ -1840,7 +1876,7 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue