summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-01-06 10:15:11 -0500
committermidipix <writeonce@midipix.org>2017-01-07 09:02:30 -0500
commit0d309b364fdde867b244db13a6c3c491c5b573c2 (patch)
tree937c32a463bb898e24038cad88874b6cce95e244
parentabc6f78b0efae0dc940e79be0d86a55271b7c22d (diff)
downloadntapi-0d309b364fdde867b244db13a6c3c491c5b573c2.tar.bz2
ntapi-0d309b364fdde867b244db13a6c3c491c5b573c2.tar.xz
__ntapi_tty_create_session(): properly close the server ready event handle.
-rw-r--r--src/tty/ntapi_tty_create_session.c14
1 files changed, 8 insertions, 6 deletions
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(&params)))
- return status;
+ return __tty_create_session_return(ssattr.srv_ready,&params,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(&params,status);
+ return __tty_create_session_return(ssattr.srv_ready,&params,status);
if (!eready.signal_state)
- return __tty_create_session_return(&params,NT_STATUS_SYSTEM_PROCESS_TERMINATED);
+ return __tty_create_session_return(ssattr.srv_ready,&params,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(&params,status);
+ return __tty_create_session_return(ssattr.srv_ready,&params,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(&params,NT_STATUS_SUCCESS);
+ return __tty_create_session_return(ssattr.srv_ready,&params,NT_STATUS_SUCCESS);
}