diff --git a/include/ntapi/nt_tty.h b/include/ntapi/nt_tty.h index b574ce2..38a176d 100644 --- a/include/ntapi/nt_tty.h +++ b/include/ntapi/nt_tty.h @@ -274,6 +274,14 @@ typedef struct __attr_ptr_size_aligned__ _nt_pty_fd_info { } nt_pty_fd_info; +typedef struct __attr_ptr_size_aligned__ _nt_pty_context_info { + void * hpty; + nt_guid guid; + nt_luid luid; + uintptr_t ctxarg[4]; +} nt_pty_context_info; + + typedef struct __attr_ptr_size_aligned__ _nt_pty_io_info { void * hpty; void * hevent; diff --git a/src/pty/ntapi_pty_xquery.c b/src/pty/ntapi_pty_xquery.c index 075d9b1..bc28061 100644 --- a/src/pty/ntapi_pty_xquery.c +++ b/src/pty/ntapi_pty_xquery.c @@ -48,9 +48,6 @@ static int32_t __pty_xquery_inherit_info( else if (msg.data.ttyinfo.status) return msg.data.ttyinfo.status; - iosb->info = msg.data.ctlinfo.iosb.info; - iosb->status = msg.data.ctlinfo.iosb.status; - inherit = (nt_pty_inherit_info *)pty_info; inherit->hpty = msg.data.ctlinfo.hpty; inherit->luid.low = msg.data.ctlinfo.luid.low; @@ -65,6 +62,70 @@ static int32_t __pty_xquery_inherit_info( &inherit->guid, &msg.data.ctlinfo.guid); + iosb->status = NT_STATUS_SUCCESS; + iosb->info = sizeof(*inherit); + + return NT_STATUS_SUCCESS; +} + + +static int32_t __pty_xquery_context_info( + void * hport, + nt_io_status_block * iosb, + void * pty_info, + uint32_t pty_info_length, + nt_pty_client_info * pty_client_info) +{ + int32_t status; + nt_pty_sigctl_msg msg; + nt_pty_context_info * context; + + if (pty_info_length < sizeof(nt_pty_inherit_info)) + return NT_STATUS_INVALID_PARAMETER; + + __ntapi->tt_aligned_block_memset( + &msg,0,sizeof(msg)); + + msg.header.msg_type = NT_LPC_NEW_MESSAGE; + msg.header.data_size = sizeof(msg.data); + msg.header.msg_size = sizeof(msg); + msg.data.ttyinfo.opcode = NT_TTY_PTY_QUERY; + + msg.data.ctlinfo.hpty = NT_INVALID_HANDLE_VALUE; + msg.data.ctlinfo.ctlcode = NT_PTY_CONTEXT_INFORMATION; + + msg.data.ctlinfo.ctxarg[0] = pty_client_info->any[0]; + msg.data.ctlinfo.ctxarg[1] = pty_client_info->any[1]; + msg.data.ctlinfo.ctxarg[2] = pty_client_info->any[2]; + msg.data.ctlinfo.ctxarg[3] = pty_client_info->any[3]; + + __ntapi->tt_guid_copy( + &msg.data.ctlinfo.guid, + &(nt_guid)TTY_PTS_GUID); + + if ((status = __ntapi->zw_request_wait_reply_port(hport,&msg,&msg))) + return status; + + else if (msg.data.ttyinfo.status) + return msg.data.ttyinfo.status; + + context = (nt_pty_context_info *)pty_info; + context->hpty = msg.data.ctlinfo.hpty; + context->luid.low = msg.data.ctlinfo.luid.low; + context->luid.high = msg.data.ctlinfo.luid.high; + + context->ctxarg[0] = msg.data.ctlinfo.ctxarg[0]; + context->ctxarg[1] = msg.data.ctlinfo.ctxarg[1]; + context->ctxarg[2] = msg.data.ctlinfo.ctxarg[2]; + context->ctxarg[3] = msg.data.ctlinfo.ctxarg[3]; + + __ntapi->tt_guid_copy( + &context->guid, + &msg.data.ctlinfo.guid); + + iosb->status = NT_STATUS_SUCCESS; + iosb->info = sizeof(*context); + return NT_STATUS_SUCCESS; } @@ -83,5 +144,11 @@ int32_t __stdcall __ntapi_pty_xquery( pty_info_length, pty_client_info); + else if (pty_info_class == NT_PTY_CONTEXT_INFORMATION) + return __pty_xquery_context_info( + hport,iosb,pty_info, + pty_info_length, + pty_client_info); + return NT_STATUS_WRONG_COMPARTMENT; }