From 0d309b364fdde867b244db13a6c3c491c5b573c2 Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 6 Jan 2017 10:15:11 -0500 Subject: __ntapi_tty_create_session(): properly close the server ready event handle. --- src/tty/ntapi_tty_create_session.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/tty/ntapi_tty_create_session.c b/src/tty/ntapi_tty_create_session.c index dbc2842..6c57d39 100644 --- a/src/tty/ntapi_tty_create_session.c +++ b/src/tty/ntapi_tty_create_session.c @@ -9,14 +9,16 @@ #include "ntapi_impl.h" static int32_t __fastcall __tty_create_session_return( + void * hready, nt_create_process_params * params, int32_t status) { - if (status) + if (params->hprocess && status) __ntapi->zw_terminate_process( params->hprocess, NT_STATUS_UNEXPECTED_IO_ERROR); + __ntapi->zw_close(hready); __ntapi->zw_close(params->hprocess); __ntapi->zw_close(params->hthread); @@ -180,7 +182,7 @@ int32_t __stdcall __ntapi_tty_create_session( params.hsession = htty; if ((status = __ntapi->tt_create_native_process(¶ms))) - return status; + return __tty_create_session_return(ssattr.srv_ready,¶ms,status); __ntapi->zw_wait_for_multiple_objects( 2, @@ -195,17 +197,17 @@ int32_t __stdcall __ntapi_tty_create_session( &eready, sizeof(eready), &(size_t){0}))) - return __tty_create_session_return(¶ms,status); + return __tty_create_session_return(ssattr.srv_ready,¶ms,status); if (!eready.signal_state) - return __tty_create_session_return(¶ms,NT_STATUS_SYSTEM_PROCESS_TERMINATED); + return __tty_create_session_return(ssattr.srv_ready,¶ms,NT_STATUS_SYSTEM_PROCESS_TERMINATED); /* connect to subsystem */ if ((status = __ntapi->tty_connect( hport, &port_name->base_named_objects[0], NT_SECURITY_IMPERSONATION))) - return __tty_create_session_return(¶ms,status); + return __tty_create_session_return(ssattr.srv_ready,¶ms,status); /* finalize primary session */ if (type == NT_TTY_SESSION_PRIMARY) { @@ -219,5 +221,5 @@ int32_t __stdcall __ntapi_tty_create_session( sizeof(*port_name)); }; - return __tty_create_session_return(¶ms,NT_STATUS_SUCCESS); + return __tty_create_session_return(ssattr.srv_ready,¶ms,NT_STATUS_SUCCESS); } -- cgit v1.2.3