From abc6f78b0efae0dc940e79be0d86a55271b7c22d Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 6 Jan 2017 10:07:24 -0500 Subject: __ntapi_tty_create_session(): check for a server's premature termination. --- src/tty/ntapi_tty_create_session.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/tty/ntapi_tty_create_session.c b/src/tty/ntapi_tty_create_session.c index e878160..dbc2842 100644 --- a/src/tty/ntapi_tty_create_session.c +++ b/src/tty/ntapi_tty_create_session.c @@ -42,6 +42,7 @@ int32_t __stdcall __ntapi_tty_create_session( nt_runtime_data ssattr; nt_runtime_data_block rtblock; nt_create_process_params params; + nt_event_basic_information eready; wchar16_t __attr_aligned__(8) __tty_image_name_fallback[] = { '\\','?','?','\\', @@ -181,12 +182,24 @@ int32_t __stdcall __ntapi_tty_create_session( if ((status = __ntapi->tt_create_native_process(¶ms))) return status; - if ((status = __ntapi->zw_wait_for_single_object( + __ntapi->zw_wait_for_multiple_objects( + 2, + (void *[]){ssattr.srv_ready,params.hprocess}, + NT_WAIT_ANY, + NT_SYNC_NON_ALERTABLE, + 0); + + if ((status = __ntapi->zw_query_event( ssattr.srv_ready, - NT_SYNC_NON_ALERTABLE, - 0))) + NT_EVENT_BASIC_INFORMATION, + &eready, + sizeof(eready), + &(size_t){0}))) return __tty_create_session_return(¶ms,status); + if (!eready.signal_state) + return __tty_create_session_return(¶ms,NT_STATUS_SYSTEM_PROCESS_TERMINATED); + /* connect to subsystem */ if ((status = __ntapi->tty_connect( hport, -- cgit v1.2.3