kernelbase: Wait directly on console handles.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2eb8644426
commit
cc5afe41ed
|
@ -37,8 +37,8 @@
|
|||
#include "winnls.h"
|
||||
#include "winerror.h"
|
||||
#include "wincon.h"
|
||||
#include "winternl.h"
|
||||
#include "wine/condrv.h"
|
||||
#include "wine/server.h"
|
||||
#include "wine/exception.h"
|
||||
#include "wine/debug.h"
|
||||
#include "kernelbase.h"
|
||||
|
@ -56,7 +56,6 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
|
|||
static CRITICAL_SECTION console_section = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
static HANDLE console_connection;
|
||||
static HANDLE console_wait_event;
|
||||
static unsigned int console_flags;
|
||||
|
||||
#define CONSOLE_INPUT_HANDLE 0x01
|
||||
|
@ -559,32 +558,12 @@ BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterW( HANDLE handle, WCHAR
|
|||
written, sizeof(*written), NULL );
|
||||
}
|
||||
|
||||
HANDLE get_console_wait_handle( HANDLE handle )
|
||||
{
|
||||
HANDLE event = 0;
|
||||
|
||||
SERVER_START_REQ( get_console_wait_event )
|
||||
{
|
||||
req->handle = wine_server_obj_handle( console_handle_map( handle ));
|
||||
if (!wine_server_call( req )) event = wine_server_ptr_handle( reply->event );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
if (event)
|
||||
{
|
||||
if (InterlockedCompareExchangePointer( &console_wait_event, event, 0 )) NtClose( event );
|
||||
handle = console_wait_event;
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* FreeConsole (kernelbase.@)
|
||||
*/
|
||||
BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
|
||||
{
|
||||
HANDLE event;
|
||||
|
||||
RtlEnterCriticalSection( &console_section );
|
||||
|
||||
NtClose( console_connection );
|
||||
|
@ -598,8 +577,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
|
|||
if (console_flags & CONSOLE_ERROR_HANDLE) NtClose( GetStdHandle( STD_ERROR_HANDLE ));
|
||||
console_flags = 0;
|
||||
|
||||
if ((event = InterlockedExchangePointer( &console_wait_event, NULL ))) NtClose( event );
|
||||
|
||||
RtlLeaveCriticalSection( &console_section );
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ extern DWORD file_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen )
|
|||
extern void init_startup_info( RTL_USER_PROCESS_PARAMETERS *params ) DECLSPEC_HIDDEN;
|
||||
extern void init_locale(void) DECLSPEC_HIDDEN;
|
||||
extern void init_console(void) DECLSPEC_HIDDEN;
|
||||
extern HANDLE get_console_wait_handle( HANDLE handle ) DECLSPEC_HIDDEN;
|
||||
|
||||
extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
|
||||
extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -211,17 +211,14 @@ ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
|
|||
***********************************************************************/
|
||||
|
||||
|
||||
static HANDLE normalize_handle_if_console( HANDLE handle )
|
||||
static HANDLE normalize_std_handle( HANDLE handle )
|
||||
{
|
||||
if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
|
||||
(handle == (HANDLE)STD_OUTPUT_HANDLE) ||
|
||||
(handle == (HANDLE)STD_ERROR_HANDLE))
|
||||
handle = GetStdHandle( HandleToULong(handle) );
|
||||
return GetStdHandle( HandleToULong(handle) );
|
||||
|
||||
/* even screen buffer console handles are waitable, and are
|
||||
* handled as a handle to the console itself
|
||||
*/
|
||||
return is_console_handle( handle ) ? get_console_wait_handle( handle ) : handle;
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
|
@ -235,7 +232,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH RegisterWaitForSingleObjectEx( HANDLE handle, WA
|
|||
|
||||
TRACE( "%p %p %p %d %d\n", handle, callback, context, timeout, flags );
|
||||
|
||||
handle = normalize_handle_if_console( handle );
|
||||
handle = normalize_std_handle( handle );
|
||||
if (!set_ntstatus( RtlRegisterWait( &ret, handle, callback, context, timeout, flags ))) return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
@ -340,7 +337,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH WaitForMultipleObjectsEx( DWORD count, const HAND
|
|||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return WAIT_FAILED;
|
||||
}
|
||||
for (i = 0; i < count; i++) hloc[i] = normalize_handle_if_console( handles[i] );
|
||||
for (i = 0; i < count; i++) hloc[i] = normalize_std_handle( handles[i] );
|
||||
|
||||
status = NtWaitForMultipleObjects( count, hloc, !wait_all, alertable,
|
||||
get_nt_timeout( &time, timeout ) );
|
||||
|
|
Loading…
Reference in New Issue