summaryrefslogtreecommitdiffhomepage
path: root/src/pty/ntapi_pty_query.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-08-14 00:38:16 +0300
committermidipix <writeonce@midipix.org>2015-09-26 11:17:01 -0400
commitefc01e81a13322864775f13003a22c786dc357ed (patch)
treea376e339003fca93a1eaa8dd9d1f808071cfa277 /src/pty/ntapi_pty_query.c
parent188aac80bc344c30d15e82931391c833953fd432 (diff)
downloadntapi-efc01e81a13322864775f13003a22c786dc357ed.tar.bz2
ntapi-efc01e81a13322864775f13003a22c786dc357ed.tar.xz
pty inheritance: client-side implementation.
Diffstat (limited to 'src/pty/ntapi_pty_query.c')
-rw-r--r--src/pty/ntapi_pty_query.c62
1 files changed, 49 insertions, 13 deletions
diff --git a/src/pty/ntapi_pty_query.c b/src/pty/ntapi_pty_query.c
index 57d31ee..06feace 100644
--- a/src/pty/ntapi_pty_query.c
+++ b/src/pty/ntapi_pty_query.c
@@ -19,8 +19,10 @@ int32_t __stdcall __ntapi_pty_query(
nt_pty_info_class pty_info_class)
{
int32_t status;
+ void * hport;
nt_pty_sigctl_msg msg;
uintptr_t * info;
+ nt_pty_inherit_info * inherit;
if ((pty_info_class<NT_PTY_BASIC_INFORMATION) || (pty_info_class>=NT_PTY_INFORMATION_CAP))
return NT_STATUS_INVALID_INFO_CLASS;
@@ -28,6 +30,8 @@ int32_t __stdcall __ntapi_pty_query(
return NT_STATUS_NOT_IMPLEMENTED;
else if ((pty_info_class == NT_PTY_CLIENT_INFORMATION) && (pty_info_length != sizeof(nt_pty_client_info)))
return NT_STATUS_INVALID_PARAMETER;
+ else if ((pty_info_class == NT_PTY_INHERIT_INFORMATION) && (pty_info_length != sizeof(nt_pty_inherit_info)))
+ return NT_STATUS_INVALID_PARAMETER;
__ntapi->tt_aligned_block_memset(
&msg,0,sizeof(msg));
@@ -37,16 +41,31 @@ int32_t __stdcall __ntapi_pty_query(
msg.header.msg_size = sizeof(msg);
msg.data.ttyinfo.opcode = NT_TTY_PTY_QUERY;
- msg.data.ctlinfo.hpty = pty->hpty;
- msg.data.ctlinfo.luid.high = pty->luid.high;
- msg.data.ctlinfo.luid.low = pty->luid.low;
- msg.data.ctlinfo.ctlcode = pty_info_class;
+ if (pty_info_class == NT_PTY_CLIENT_INFORMATION) {
+ hport = pty->hport;
+ msg.data.ctlinfo.hpty = pty->hpty;
+ msg.data.ctlinfo.luid.high = pty->luid.high;
+ msg.data.ctlinfo.luid.low = pty->luid.low;
+ msg.data.ctlinfo.ctlcode = pty_info_class;
+
+ __ntapi->tt_guid_copy(
+ &msg.data.ctlinfo.guid,
+ &pty->guid);
+
+ } else if (pty_info_class == NT_PTY_INHERIT_INFORMATION) {
+ msg.data.ctlinfo.hpty = NT_INVALID_HANDLE_VALUE;
+ msg.data.ctlinfo.ctlcode = pty_info_class;
+
+ inherit = (nt_pty_inherit_info *)pty_info;
+ msg.data.ctlinfo.ctxarg[0] = inherit->any[0];
+ msg.data.ctlinfo.ctxarg[1] = inherit->any[1];
+ msg.data.ctlinfo.ctxarg[2] = inherit->any[2];
+ msg.data.ctlinfo.ctxarg[3] = inherit->any[3];
- __ntapi->tt_guid_copy(
- &msg.data.ctlinfo.guid,
- &pty->guid);
+ hport = pty ? pty : __ntapi_internals()->hport_tty_session;
+ }
- if ((status = __ntapi->zw_request_wait_reply_port(pty->hport,&msg,&msg)))
+ if ((status = __ntapi->zw_request_wait_reply_port(hport,&msg,&msg)))
return status;
else if (msg.data.ttyinfo.status)
return msg.data.ttyinfo.status;
@@ -54,11 +73,28 @@ int32_t __stdcall __ntapi_pty_query(
iosb->info = msg.data.ctlinfo.iosb.info;
iosb->status = msg.data.ctlinfo.iosb.status;
- info = (uintptr_t *)pty_info;
- info[0] = msg.data.ctlinfo.ctxarg[0];
- info[1] = msg.data.ctlinfo.ctxarg[1];
- info[2] = msg.data.ctlinfo.ctxarg[2];
- info[3] = msg.data.ctlinfo.ctxarg[3];
+ if (pty_info_class == NT_PTY_CLIENT_INFORMATION) {
+ info = (uintptr_t *)pty_info;
+ info[0] = msg.data.ctlinfo.ctxarg[0];
+ info[1] = msg.data.ctlinfo.ctxarg[1];
+ info[2] = msg.data.ctlinfo.ctxarg[2];
+ info[3] = msg.data.ctlinfo.ctxarg[3];
+
+ } else if (pty_info_class == NT_PTY_INHERIT_INFORMATION) {
+ inherit = (nt_pty_inherit_info *)pty_info;
+ inherit->hpty = msg.data.ctlinfo.hpty;
+ inherit->luid.low = msg.data.ctlinfo.luid.low;
+ inherit->luid.high = msg.data.ctlinfo.luid.high;
+
+ inherit->access = msg.data.ctlinfo.ctxarg[0];
+ inherit->flags = msg.data.ctlinfo.ctxarg[1];
+ inherit->share = msg.data.ctlinfo.ctxarg[2];
+ inherit->options = msg.data.ctlinfo.ctxarg[3];
+
+ __ntapi->tt_guid_copy(
+ &inherit->guid,
+ &msg.data.ctlinfo.guid);
+ }
return NT_STATUS_SUCCESS;
}