diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tty/ntapi_tty_create_session.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/src/tty/ntapi_tty_create_session.c b/src/tty/ntapi_tty_create_session.c index 3f8f1d7..e878160 100644 --- a/src/tty/ntapi_tty_create_session.c +++ b/src/tty/ntapi_tty_create_session.c @@ -28,10 +28,15 @@ int32_t __stdcall __ntapi_tty_create_session( __out nt_port_name * port_name, __in nt_tty_session_type type, __in const nt_guid * guid __optional, - __in wchar16_t * image_name __optional) + __in wchar16_t * image_name __optional, + __in void * htty __optional) { nt_status status; ntapi_internals * __internals; + void * shport; + nt_port_name sport_name; + nt_tty_server_basic_info ttyinfo; + nt_iosb iosb; nt_port_attr port_attr; nt_runtime_data ssattr; @@ -53,6 +58,9 @@ int32_t __stdcall __ntapi_tty_create_session( __ntapi->tt_aligned_block_memset( &port_attr,0,sizeof(port_attr)); + __ntapi->tt_aligned_block_memset( + &ssattr,0,sizeof(ssattr)); + switch (type) { case NT_TTY_SESSION_PRIMARY: port_attr.type = NT_PORT_TYPE_SUBSYSTEM; @@ -69,6 +77,21 @@ int32_t __stdcall __ntapi_tty_create_session( break; + case NT_TTY_SESSION_SECONDARY: + port_attr.type = NT_PORT_TYPE_SUBSYSTEM; + port_attr.subtype = NT_PORT_SUBTYPE_DEFAULT; + + if (!hport) + hport = &shport; + + if (!port_name) + port_name = &sport_name; + + if (!image_name) + image_name = __tty_image_name_fallback; + + break; + case NT_TTY_SESSION_PRIVATE: port_attr.type = NT_PORT_TYPE_SUBSYSTEM; port_attr.subtype = NT_PORT_SUBTYPE_PRIVATE; @@ -98,10 +121,30 @@ int32_t __stdcall __ntapi_tty_create_session( port_name, &port_attr); - /* subsystem attributes */ - __ntapi->tt_aligned_block_memset( - &ssattr,0,sizeof(ssattr)); + /* parent session) */ + if (htty && (htty != NT_INVALID_HANDLE_VALUE)) { + if ((status = __ntapi->tty_query_information_server( + htty,&iosb, + &ttyinfo,sizeof(ttyinfo), + NT_TTY_SERVER_BASIC_INFORMATION))) + return status; + ssattr.tty_type = ttyinfo.attr.type; + ssattr.tty_subtype = ttyinfo.attr.subtype; + + ssattr.tty_keys[0] = ttyinfo.attr.keys.key[0]; + ssattr.tty_keys[1] = ttyinfo.attr.keys.key[1]; + ssattr.tty_keys[2] = ttyinfo.attr.keys.key[2]; + ssattr.tty_keys[3] = ttyinfo.attr.keys.key[3]; + ssattr.tty_keys[4] = ttyinfo.attr.keys.key[4]; + ssattr.tty_keys[5] = ttyinfo.attr.keys.key[5]; + + __ntapi->tt_guid_copy( + &ssattr.tty_guid, + &ttyinfo.attr.guid); + } + + /* subsystem attributes */ ssattr.srv_type = port_attr.type; ssattr.srv_subtype = port_attr.subtype; ssattr.srv_keys[0] = port_attr.keys.key[0]; @@ -133,6 +176,7 @@ int32_t __stdcall __ntapi_tty_create_session( params.image_name = image_name; params.rtblock = &rtblock; + params.hsession = htty; if ((status = __ntapi->tt_create_native_process(¶ms))) return status; |