|
|
dd89bb |
/********************************************************/
|
|
|
dd89bb |
/* ntapi: Native API core library */
|
|
|
64e606 |
/* Copyright (C) 2013--2021 SysDeer Technologies, LLC */
|
|
|
dd89bb |
/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
|
|
|
dd89bb |
/********************************************************/
|
|
|
dd89bb |
|
|
|
dd89bb |
#include <psxtypes/psxtypes.h>
|
|
|
dd89bb |
#include <ntapi/nt_port.h>
|
|
|
dd89bb |
#include <ntapi/nt_tty.h>
|
|
|
dd89bb |
#include <ntapi/nt_termios.h>
|
|
|
dd89bb |
#include <ntapi/ntapi.h>
|
|
|
dd89bb |
#include "ntapi_impl.h"
|
|
|
dd89bb |
#include "ntapi_pty.h"
|
|
|
dd89bb |
|
|
|
dd89bb |
int32_t __stdcall __ntapi_pty_ioctl(
|
|
|
dd89bb |
nt_pty * pty,
|
|
|
dd89bb |
void * hevent __optional,
|
|
|
dd89bb |
nt_io_apc_routine * apc_routine __optional,
|
|
|
dd89bb |
void * apc_context __optional,
|
|
|
dd89bb |
nt_iosb * iosb,
|
|
|
dd89bb |
uint32_t ctlcode,
|
|
|
dd89bb |
void * input_buffer __optional,
|
|
|
dd89bb |
uint32_t input_buffer_length,
|
|
|
dd89bb |
void * output_buffer __optional,
|
|
|
dd89bb |
uint32_t output_buffer_length)
|
|
|
dd89bb |
{
|
|
|
dd89bb |
int32_t status;
|
|
|
dd89bb |
nt_pty_sigctl_msg msg;
|
|
|
dd89bb |
nt_tty_sigctl_info * input;
|
|
|
dd89bb |
nt_tty_sigctl_info * output;
|
|
|
dd89bb |
|
|
|
c713d8 |
(void)hevent;
|
|
|
c713d8 |
(void)apc_routine;
|
|
|
c713d8 |
(void)apc_context;
|
|
|
c713d8 |
|
|
|
dd89bb |
if ((uintptr_t)input_buffer % sizeof(uintptr_t))
|
|
|
dd89bb |
return NT_STATUS_DATATYPE_MISALIGNMENT_ERROR;
|
|
|
dd89bb |
else if (input_buffer_length != sizeof(nt_tty_sigctl_info))
|
|
|
dd89bb |
return NT_STATUS_INVALID_BUFFER_SIZE;
|
|
|
dd89bb |
else if (!output_buffer)
|
|
|
dd89bb |
return NT_STATUS_ACCESS_DENIED;
|
|
|
dd89bb |
else if ((uintptr_t)output_buffer % sizeof(uintptr_t))
|
|
|
dd89bb |
return NT_STATUS_DATATYPE_MISALIGNMENT_ERROR;
|
|
|
dd89bb |
else if (output_buffer_length < sizeof(nt_tty_sigctl_info))
|
|
|
dd89bb |
return NT_STATUS_BUFFER_TOO_SMALL;
|
|
|
dd89bb |
|
|
|
dd89bb |
input = (nt_tty_sigctl_info *)input_buffer;
|
|
|
dd89bb |
output = (nt_tty_sigctl_info *)output_buffer;
|
|
|
dd89bb |
|
|
|
dd89bb |
__ntapi->tt_aligned_block_memset(
|
|
|
dd89bb |
&msg,0,sizeof(msg));
|
|
|
dd89bb |
|
|
|
dd89bb |
msg.header.msg_type = NT_LPC_NEW_MESSAGE;
|
|
|
dd89bb |
msg.header.data_size = sizeof(msg.data);
|
|
|
dd89bb |
msg.header.msg_size = sizeof(msg);
|
|
|
dd89bb |
msg.data.ttyinfo.opcode = NT_TTY_PTY_IOCTL;
|
|
|
dd89bb |
|
|
|
dd89bb |
msg.data.ctlinfo.hpty = pty->hpty;
|
|
|
dd89bb |
msg.data.ctlinfo.luid.high = pty->luid.high;
|
|
|
dd89bb |
msg.data.ctlinfo.luid.low = pty->luid.low;
|
|
|
dd89bb |
msg.data.ctlinfo.ctlcode = ctlcode;
|
|
|
dd89bb |
|
|
|
dd89bb |
__ntapi->tt_guid_copy(
|
|
|
dd89bb |
&msg.data.ctlinfo.guid,
|
|
|
dd89bb |
&pty->guid);
|
|
|
dd89bb |
|
|
|
dd89bb |
msg.data.ctlinfo.ctxarg[0] = input->ctxarg[0];
|
|
|
dd89bb |
msg.data.ctlinfo.ctxarg[1] = input->ctxarg[1];
|
|
|
dd89bb |
msg.data.ctlinfo.ctxarg[2] = input->ctxarg[2];
|
|
|
dd89bb |
msg.data.ctlinfo.ctxarg[3] = input->ctxarg[3];
|
|
|
dd89bb |
|
|
|
dd89bb |
__ntapi->tt_generic_memcpy(
|
|
|
dd89bb |
(char *)&msg.data.ctlinfo.terminfo,
|
|
|
e0f5d8 |
(char *)&input->terminfo,
|
|
|
dd89bb |
sizeof(input->terminfo));
|
|
|
dd89bb |
|
|
|
dd89bb |
__ntapi->tt_generic_memcpy(
|
|
|
dd89bb |
(char *)&msg.data.ctlinfo.winsize,
|
|
|
e0f5d8 |
(char *)&input->winsize,
|
|
|
dd89bb |
sizeof(input->winsize));
|
|
|
dd89bb |
|
|
|
dd89bb |
if ((status = __ntapi->zw_request_wait_reply_port(pty->hport,&msg,&msg)))
|
|
|
dd89bb |
return status;
|
|
|
dd89bb |
else if (msg.data.ttyinfo.status)
|
|
|
dd89bb |
return msg.data.ttyinfo.status;
|
|
|
dd89bb |
|
|
|
dd89bb |
__ntapi->tt_aligned_block_memcpy(
|
|
|
dd89bb |
(uintptr_t *)output,
|
|
|
dd89bb |
(uintptr_t *)&msg.data.ctlinfo,
|
|
|
dd89bb |
sizeof(*output));
|
|
|
dd89bb |
|
|
|
dd89bb |
iosb->info = msg.data.ctlinfo.iosb.info;
|
|
|
dd89bb |
iosb->status = msg.data.ctlinfo.iosb.status;
|
|
|
dd89bb |
|
|
|
dd89bb |
return NT_STATUS_SUCCESS;
|
|
|
dd89bb |
}
|