summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);
}