From 47aaf28e9060c837e3c0d3a7ac009c434f95eda7 Mon Sep 17 00:00:00 2001 From: midipix Date: Jan 07 2017 14:02:19 +0000 Subject: pty interfaces: added __ntapi_pty_open_pair(). --- diff --git a/include/ntapi/nt_tty.h b/include/ntapi/nt_tty.h index 06dbd08..b0d9205 100644 --- a/include/ntapi/nt_tty.h +++ b/include/ntapi/nt_tty.h @@ -407,6 +407,16 @@ typedef int32_t __stdcall ntapi_pty_open( __in uint32_t open_options); +typedef int32_t __stdcall ntapi_pty_open_pair( + __in void * hport, + __out nt_pty ** pty, + __in uint32_t desired_access, + __in nt_object_attributes* obj_attr, + __out nt_iosb * iosb, + __in uint32_t share_access, + __in uint32_t open_options); + + typedef int32_t __stdcall ntapi_pty_reopen( __in void * hport, __in nt_pty * pty); diff --git a/include/ntapi/ntapi.h b/include/ntapi/ntapi.h index 5b19340..780f11b 100644 --- a/include/ntapi/ntapi.h +++ b/include/ntapi/ntapi.h @@ -523,6 +523,7 @@ typedef struct _ntapi_vtbl { ntapi_tty_vms_query * tty_vms_query; ntapi_tty_vms_request * tty_vms_request; ntapi_pty_open * pty_open; + ntapi_pty_open_pair * pty_open_pair; ntapi_pty_reopen * pty_reopen; ntapi_pty_inherit * pty_inherit; ntapi_pty_inherit_runtime_ctty * pty_inherit_runtime_ctty; diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c index a4f6ac8..8456569 100644 --- a/src/internal/ntapi.c +++ b/src/internal/ntapi.c @@ -298,6 +298,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl) __ntapi->tty_vms_query = __ntapi_tty_vms_query; __ntapi->tty_vms_request = __ntapi_tty_vms_request; __ntapi->pty_open = __ntapi_pty_open; + __ntapi->pty_open_pair = __ntapi_pty_open_pair; __ntapi->pty_reopen = __ntapi_pty_reopen; __ntapi->pty_inherit = __ntapi_pty_inherit; __ntapi->pty_inherit_runtime_ctty = __ntapi_pty_inherit_runtime_ctty; diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h index 6b90734..1e2c8f4 100644 --- a/src/internal/ntapi_fnapi.h +++ b/src/internal/ntapi_fnapi.h @@ -187,6 +187,7 @@ ntapi_tty_request_peer __ntapi_tty_request_peer; ntapi_tty_vms_query __ntapi_tty_vms_query; ntapi_tty_vms_request __ntapi_tty_vms_request; ntapi_pty_open __ntapi_pty_open; +ntapi_pty_open_pair __ntapi_pty_open_pair; ntapi_pty_reopen __ntapi_pty_reopen; ntapi_pty_inherit __ntapi_pty_inherit; ntapi_pty_inherit_runtime_ctty __ntapi_pty_inherit_runtime_ctty; diff --git a/src/pty/ntapi_pty_fd.c b/src/pty/ntapi_pty_fd.c index 3071482..b35804e 100644 --- a/src/pty/ntapi_pty_fd.c +++ b/src/pty/ntapi_pty_fd.c @@ -167,14 +167,15 @@ static int32_t __ntapi_pty_connect( } -int32_t __stdcall __ntapi_pty_open( +static int32_t __ntapi_pty_open_impl( void * hport, nt_pty ** pty, uint32_t desired_access, nt_object_attributes* obj_attr, nt_iosb * iosb, uint32_t share_access, - uint32_t open_options) + uint32_t open_options, + nt_pty * rpty) { int32_t status; nt_guid guid; @@ -221,10 +222,12 @@ int32_t __stdcall __ntapi_pty_open( ctx->options = open_options; /* pts */ - if (obj_attr->root_dir) { - ctx->hpty = ((nt_pty *)obj_attr->root_dir)->hpty; - ctx->luid.high = ((nt_pty *)obj_attr->root_dir)->luid.high; - ctx->luid.low = ((nt_pty *)obj_attr->root_dir)->luid.low; + if (rpty) { + ctx->hpty = rpty->hpty; + ctx->luid.high = rpty->luid.high; + ctx->luid.low = rpty->luid.low; + } else { + ctx->hpty = obj_attr->root_dir; } if ((status = __ntapi_pty_connect(hport,ctx,iosb))) @@ -235,6 +238,42 @@ int32_t __stdcall __ntapi_pty_open( return NT_STATUS_SUCCESS; } +int32_t __stdcall __ntapi_pty_open( + void * hport, + nt_pty ** pty, + uint32_t desired_access, + nt_object_attributes* obj_attr, + nt_iosb * iosb, + uint32_t share_access, + uint32_t open_options) +{ + return __ntapi_pty_open_impl( + hport,pty, + desired_access, + obj_attr,iosb, + share_access, + open_options, + (nt_pty *)obj_attr->root_dir); +} + +int32_t __stdcall __ntapi_pty_open_pair( + void * hport, + nt_pty ** pty, + uint32_t desired_access, + nt_object_attributes* obj_attr, + nt_iosb * iosb, + uint32_t share_access, + uint32_t open_options) +{ + return __ntapi_pty_open_impl( + hport,pty, + desired_access, + obj_attr,iosb, + share_access, + open_options, + 0); +} + int32_t __stdcall __ntapi_pty_inherit( __in void * hport, __out nt_pty ** pty,