|
|
e62c29 |
/********************************************************/
|
|
|
e62c29 |
/* ntapi: Native API core library */
|
|
|
e62c29 |
/* Copyright (C) 2013--2018 Z. Gilboa */
|
|
|
e62c29 |
/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
|
|
|
e62c29 |
/********************************************************/
|
|
|
e62c29 |
|
|
|
e62c29 |
#include <psxtypes/psxtypes.h>
|
|
|
e62c29 |
#include <ntapi/nt_port.h>
|
|
|
e62c29 |
#include <ntapi/nt_tty.h>
|
|
|
e62c29 |
#include <ntapi/ntapi.h>
|
|
|
e62c29 |
#include "ntapi_impl.h"
|
|
|
e62c29 |
#include "ntapi_pty.h"
|
|
|
e62c29 |
|
|
|
e62c29 |
|
|
|
e62c29 |
static int32_t __pty_xquery_inherit_info(
|
|
|
e62c29 |
void * hport,
|
|
|
e62c29 |
nt_io_status_block * iosb,
|
|
|
e62c29 |
void * pty_info,
|
|
|
e62c29 |
uint32_t pty_info_length,
|
|
|
e62c29 |
nt_pty_client_info * pty_client_info)
|
|
|
e62c29 |
{
|
|
|
e62c29 |
int32_t status;
|
|
|
e62c29 |
nt_pty_sigctl_msg msg;
|
|
|
e62c29 |
nt_pty_inherit_info * inherit;
|
|
|
e62c29 |
|
|
|
e62c29 |
if (pty_info_length < sizeof(nt_pty_inherit_info))
|
|
|
e62c29 |
return NT_STATUS_INVALID_PARAMETER;
|
|
|
e62c29 |
|
|
|
e62c29 |
__ntapi->tt_aligned_block_memset(
|
|
|
e62c29 |
&msg,0,sizeof(msg));
|
|
|
e62c29 |
|
|
|
e62c29 |
msg.header.msg_type = NT_LPC_NEW_MESSAGE;
|
|
|
e62c29 |
msg.header.data_size = sizeof(msg.data);
|
|
|
e62c29 |
msg.header.msg_size = sizeof(msg);
|
|
|
e62c29 |
msg.data.ttyinfo.opcode = NT_TTY_PTY_QUERY;
|
|
|
e62c29 |
|
|
|
e62c29 |
msg.data.ctlinfo.hpty = NT_INVALID_HANDLE_VALUE;
|
|
|
e62c29 |
msg.data.ctlinfo.ctlcode = NT_PTY_INHERIT_INFORMATION;
|
|
|
e62c29 |
|
|
|
e62c29 |
msg.data.ctlinfo.ctxarg[0] = pty_client_info->any[0];
|
|
|
e62c29 |
msg.data.ctlinfo.ctxarg[1] = pty_client_info->any[1];
|
|
|
e62c29 |
msg.data.ctlinfo.ctxarg[2] = pty_client_info->any[2];
|
|
|
e62c29 |
msg.data.ctlinfo.ctxarg[3] = pty_client_info->any[3];
|
|
|
e62c29 |
|
|
|
e62c29 |
if ((status = __ntapi->zw_request_wait_reply_port(hport,&msg,&msg)))
|
|
|
e62c29 |
return status;
|
|
|
e62c29 |
|
|
|
e62c29 |
else if (msg.data.ttyinfo.status)
|
|
|
e62c29 |
return msg.data.ttyinfo.status;
|
|
|
e62c29 |
|
|
|
e62c29 |
iosb->info = msg.data.ctlinfo.iosb.info;
|
|
|
e62c29 |
iosb->status = msg.data.ctlinfo.iosb.status;
|
|
|
e62c29 |
|
|
|
e62c29 |
inherit = (nt_pty_inherit_info *)pty_info;
|
|
|
e62c29 |
inherit->hpty = msg.data.ctlinfo.hpty;
|
|
|
e62c29 |
inherit->luid.low = msg.data.ctlinfo.luid.low;
|
|
|
e62c29 |
inherit->luid.high = msg.data.ctlinfo.luid.high;
|
|
|
e62c29 |
|
|
|
e62c29 |
inherit->access = (uint32_t)msg.data.ctlinfo.ctxarg[0];
|
|
|
e62c29 |
inherit->flags = (uint32_t)msg.data.ctlinfo.ctxarg[1];
|
|
|
e62c29 |
inherit->share = (uint32_t)msg.data.ctlinfo.ctxarg[2];
|
|
|
e62c29 |
inherit->options = (uint32_t)msg.data.ctlinfo.ctxarg[3];
|
|
|
e62c29 |
|
|
|
e62c29 |
__ntapi->tt_guid_copy(
|
|
|
e62c29 |
&inherit->guid,
|
|
|
e62c29 |
&msg.data.ctlinfo.guid);
|
|
|
e62c29 |
|
|
|
e62c29 |
return NT_STATUS_SUCCESS;
|
|
|
e62c29 |
}
|
|
|
e62c29 |
|
|
|
e62c29 |
|
|
|
e62c29 |
int32_t __stdcall __ntapi_pty_xquery(
|
|
|
e62c29 |
void * hport,
|
|
|
e62c29 |
nt_io_status_block * iosb,
|
|
|
e62c29 |
void * pty_info,
|
|
|
e62c29 |
uint32_t pty_info_length,
|
|
|
e62c29 |
nt_pty_info_class pty_info_class,
|
|
|
e62c29 |
nt_pty_client_info * pty_client_info)
|
|
|
e62c29 |
{
|
|
|
e62c29 |
if (pty_info_class == NT_PTY_INHERIT_INFORMATION)
|
|
|
e62c29 |
return __pty_xquery_inherit_info(
|
|
|
e62c29 |
hport,iosb,pty_info,
|
|
|
e62c29 |
pty_info_length,
|
|
|
e62c29 |
pty_client_info);
|
|
|
e62c29 |
|
|
|
e62c29 |
return NT_STATUS_WRONG_COMPARTMENT;
|
|
|
e62c29 |
}
|