mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-15 09:12:25 +00:00
kernelbase: Invalidate console wait handle in FreeConsole.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f0696f7e33
commit
4031265f69
|
@ -53,6 +53,8 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
|
||||||
};
|
};
|
||||||
static CRITICAL_SECTION console_section = { &critsect_debug, -1, 0, 0, 0, 0 };
|
static CRITICAL_SECTION console_section = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
static HANDLE console_wait_event;
|
||||||
|
|
||||||
static WCHAR input_exe[MAX_PATH + 1];
|
static WCHAR input_exe[MAX_PATH + 1];
|
||||||
|
|
||||||
struct ctrl_handler
|
struct ctrl_handler
|
||||||
|
@ -345,12 +347,31 @@ BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterW( HANDLE handle, WCHAR
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.@)
|
* FreeConsole (kernelbase.@)
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
|
BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
|
||||||
{
|
{
|
||||||
|
HANDLE event;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
SERVER_START_REQ( free_console )
|
SERVER_START_REQ( free_console )
|
||||||
|
@ -358,6 +379,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
|
||||||
ret = !wine_server_call_err( req );
|
ret = !wine_server_call_err( req );
|
||||||
}
|
}
|
||||||
SERVER_END_REQ;
|
SERVER_END_REQ;
|
||||||
|
if ((event = InterlockedExchangePointer( &console_wait_event, NULL ))) NtClose( event );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ extern WCHAR *file_name_AtoW( LPCSTR name, BOOL alloc ) DECLSPEC_HIDDEN;
|
||||||
extern DWORD file_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen ) DECLSPEC_HIDDEN;
|
extern DWORD file_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen ) DECLSPEC_HIDDEN;
|
||||||
extern void init_startup_info( RTL_USER_PROCESS_PARAMETERS *params ) DECLSPEC_HIDDEN;
|
extern void init_startup_info( RTL_USER_PROCESS_PARAMETERS *params ) DECLSPEC_HIDDEN;
|
||||||
extern void init_locale(void) DECLSPEC_HIDDEN;
|
extern void init_locale(void) DECLSPEC_HIDDEN;
|
||||||
|
extern HANDLE get_console_wait_handle( HANDLE handle ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
|
extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
|
||||||
extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
|
extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -213,8 +213,6 @@ ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
|
||||||
|
|
||||||
static HANDLE normalize_handle_if_console( HANDLE handle )
|
static HANDLE normalize_handle_if_console( HANDLE handle )
|
||||||
{
|
{
|
||||||
static HANDLE wait_event;
|
|
||||||
|
|
||||||
if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
|
if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
|
||||||
(handle == (HANDLE)STD_OUTPUT_HANDLE) ||
|
(handle == (HANDLE)STD_OUTPUT_HANDLE) ||
|
||||||
(handle == (HANDLE)STD_ERROR_HANDLE))
|
(handle == (HANDLE)STD_ERROR_HANDLE))
|
||||||
|
@ -223,23 +221,7 @@ static HANDLE normalize_handle_if_console( HANDLE handle )
|
||||||
/* even screen buffer console handles are waitable, and are
|
/* even screen buffer console handles are waitable, and are
|
||||||
* handled as a handle to the console itself
|
* handled as a handle to the console itself
|
||||||
*/
|
*/
|
||||||
if (is_console_handle( handle ))
|
return is_console_handle( 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( &wait_event, event, 0 )) NtClose( event );
|
|
||||||
handle = wait_event;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return handle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue