summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/ntapi/nt_tty.h9
-rw-r--r--include/ntapi/ntapi.h1
-rw-r--r--project/common.mk1
-rw-r--r--src/internal/ntapi.c1
-rw-r--r--src/internal/ntapi_fnapi.h1
-rw-r--r--src/pty/ntapi_pty_fd.c10
-rw-r--r--src/pty/ntapi_pty_query.c33
-rw-r--r--src/pty/ntapi_pty_xquery.c87
8 files changed, 106 insertions, 37 deletions
diff --git a/include/ntapi/nt_tty.h b/include/ntapi/nt_tty.h
index 07797d4..2b3aa39 100644
--- a/include/ntapi/nt_tty.h
+++ b/include/ntapi/nt_tty.h
@@ -712,6 +712,15 @@ typedef int32_t __stdcall ntapi_pty_query(
__in nt_pty_info_class pty_info_class);
+typedef int32_t __stdcall ntapi_pty_xquery(
+ __in void * hport,
+ __out nt_io_status_block * iosb,
+ __out void * pty_info,
+ __in uint32_t pty_info_length,
+ __in nt_pty_info_class pty_info_class,
+ __in nt_pty_client_info * pty_client_info);
+
+
typedef int32_t __stdcall ntapi_pty_set(
__in nt_pty * hfile,
__out nt_io_status_block * iosb,
diff --git a/include/ntapi/ntapi.h b/include/ntapi/ntapi.h
index a78d8f1..7714bce 100644
--- a/include/ntapi/ntapi.h
+++ b/include/ntapi/ntapi.h
@@ -611,6 +611,7 @@ typedef struct _ntapi_vtbl {
ntapi_pty_fcntl * pty_fcntl;
ntapi_pty_ioctl * pty_ioctl;
ntapi_pty_query * pty_query;
+ ntapi_pty_xquery * pty_xquery;
ntapi_pty_set * pty_set;
ntapi_pty_cancel * pty_cancel;
diff --git a/project/common.mk b/project/common.mk
index eb876f9..a5eb5ab 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -67,6 +67,7 @@ COMMON_SRCS = \
src/pty/ntapi_pty_ioctl.c \
src/pty/ntapi_pty_query.c \
src/pty/ntapi_pty_set.c \
+ src/pty/ntapi_pty_xquery.c \
src/seh/ntapi_tt_seh_frame.c \
src/sem/ntapi_sem_connect.c \
src/sem/ntapi_sem_fcntl.c \
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index f29fa69..95abd45 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -405,6 +405,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->pty_write = __ntapi_pty_write;
__ntapi->pty_ioctl = __ntapi_pty_ioctl;
__ntapi->pty_query = __ntapi_pty_query;
+ __ntapi->pty_xquery = __ntapi_pty_xquery;
__ntapi->pty_set = __ntapi_pty_set;
__ntapi->pty_cancel = __ntapi_pty_cancel;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 37237de..3477127 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -271,6 +271,7 @@ ntapi_pty_read __ntapi_pty_read;
ntapi_pty_write __ntapi_pty_write;
ntapi_pty_ioctl __ntapi_pty_ioctl;
ntapi_pty_query __ntapi_pty_query;
+ntapi_pty_xquery __ntapi_pty_xquery;
ntapi_pty_set __ntapi_pty_set;
ntapi_pty_cancel __ntapi_pty_cancel;
diff --git a/src/pty/ntapi_pty_fd.c b/src/pty/ntapi_pty_fd.c
index 8d21fd0..45a58ff 100644
--- a/src/pty/ntapi_pty_fd.c
+++ b/src/pty/ntapi_pty_fd.c
@@ -280,15 +280,11 @@ int32_t __stdcall __ntapi_pty_inherit(
nt_pty_inherit_info inherit;
nt_pty * ctx;
- inherit.any[0] = client_info->any[0];
- inherit.any[1] = client_info->any[1];
- inherit.any[2] = client_info->any[2];
- inherit.any[3] = client_info->any[3];
-
- if ((status = __ntapi_pty_query(
+ if ((status = __ntapi_pty_xquery(
hport,&iosb,
&inherit,sizeof(inherit),
- NT_PTY_INHERIT_INFORMATION)))
+ NT_PTY_INHERIT_INFORMATION,
+ client_info)))
return status;
/* control block */
diff --git a/src/pty/ntapi_pty_query.c b/src/pty/ntapi_pty_query.c
index 72b3b31..329516a 100644
--- a/src/pty/ntapi_pty_query.c
+++ b/src/pty/ntapi_pty_query.c
@@ -22,11 +22,13 @@ int32_t __stdcall __ntapi_pty_query(
void * hport;
nt_pty_sigctl_msg msg;
uintptr_t * info;
- nt_pty_inherit_info * inherit;
if (pty_info_class>=NT_PTY_INFORMATION_CAP)
return NT_STATUS_INVALID_INFO_CLASS;
+ if (pty_info_class == NT_PTY_INHERIT_INFORMATION)
+ return NT_STATUS_CONTEXT_MISMATCH;
+
if (pty_info_class == NT_PTY_BASIC_INFORMATION)
return NT_STATUS_NOT_IMPLEMENTED;
@@ -34,10 +36,6 @@ int32_t __stdcall __ntapi_pty_query(
if (pty_info_length < sizeof(nt_pty_client_info))
return NT_STATUS_INVALID_PARAMETER;
- if (pty_info_class == NT_PTY_INHERIT_INFORMATION)
- if (pty_info_length != sizeof(nt_pty_inherit_info))
- return NT_STATUS_INVALID_PARAMETER;
-
__ntapi->tt_aligned_block_memset(
&msg,0,sizeof(msg));
@@ -57,17 +55,6 @@ int32_t __stdcall __ntapi_pty_query(
&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];
-
- hport = pty ? pty : __ntapi_internals()->hport_tty_session;
} else {
return NT_STATUS_INVALID_INFO_CLASS;
}
@@ -88,20 +75,6 @@ int32_t __stdcall __ntapi_pty_query(
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 = (uint32_t)msg.data.ctlinfo.ctxarg[0];
- inherit->flags = (uint32_t)msg.data.ctlinfo.ctxarg[1];
- inherit->share = (uint32_t)msg.data.ctlinfo.ctxarg[2];
- inherit->options = (uint32_t)msg.data.ctlinfo.ctxarg[3];
-
- __ntapi->tt_guid_copy(
- &inherit->guid,
- &msg.data.ctlinfo.guid);
}
return NT_STATUS_SUCCESS;
diff --git a/src/pty/ntapi_pty_xquery.c b/src/pty/ntapi_pty_xquery.c
new file mode 100644
index 0000000..075d9b1
--- /dev/null
+++ b/src/pty/ntapi_pty_xquery.c
@@ -0,0 +1,87 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013--2018 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <ntapi/nt_port.h>
+#include <ntapi/nt_tty.h>
+#include <ntapi/ntapi.h>
+#include "ntapi_impl.h"
+#include "ntapi_pty.h"
+
+
+static int32_t __pty_xquery_inherit_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_inherit_info * inherit;
+
+ 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_INHERIT_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];
+
+ if ((status = __ntapi->zw_request_wait_reply_port(hport,&msg,&msg)))
+ return status;
+
+ 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;
+ inherit->luid.high = msg.data.ctlinfo.luid.high;
+
+ inherit->access = (uint32_t)msg.data.ctlinfo.ctxarg[0];
+ inherit->flags = (uint32_t)msg.data.ctlinfo.ctxarg[1];
+ inherit->share = (uint32_t)msg.data.ctlinfo.ctxarg[2];
+ inherit->options = (uint32_t)msg.data.ctlinfo.ctxarg[3];
+
+ __ntapi->tt_guid_copy(
+ &inherit->guid,
+ &msg.data.ctlinfo.guid);
+
+ return NT_STATUS_SUCCESS;
+}
+
+
+int32_t __stdcall __ntapi_pty_xquery(
+ void * hport,
+ nt_io_status_block * iosb,
+ void * pty_info,
+ uint32_t pty_info_length,
+ nt_pty_info_class pty_info_class,
+ nt_pty_client_info * pty_client_info)
+{
+ if (pty_info_class == NT_PTY_INHERIT_INFORMATION)
+ return __pty_xquery_inherit_info(
+ hport,iosb,pty_info,
+ pty_info_length,
+ pty_client_info);
+
+ return NT_STATUS_WRONG_COMPARTMENT;
+}