summaryrefslogtreecommitdiffhomepage
path: root/src/tty
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-01-06 10:07:24 -0500
committermidipix <writeonce@midipix.org>2017-01-07 09:02:28 -0500
commitabc6f78b0efae0dc940e79be0d86a55271b7c22d (patch)
tree807b932a03d72e96885c3d395730f9d6588f7dbc /src/tty
parentf619173799ff7c4d3a8449615797babd05ad8739 (diff)
downloadntapi-abc6f78b0efae0dc940e79be0d86a55271b7c22d.tar.bz2
ntapi-abc6f78b0efae0dc940e79be0d86a55271b7c22d.tar.xz
__ntapi_tty_create_session(): check for a server's premature termination.
Diffstat (limited to 'src/tty')
-rw-r--r--src/tty/ntapi_tty_create_session.c19
1 files 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(&params)))
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(&params,status);
+ if (!eready.signal_state)
+ return __tty_create_session_return(&params,NT_STATUS_SYSTEM_PROCESS_TERMINATED);
+
/* connect to subsystem */
if ((status = __ntapi->tty_connect(
hport,