|
|
6a4793 |
/********************************************************/
|
|
|
6a4793 |
/* ntapi: Native API core library */
|
|
|
6a4793 |
/* Copyright (C) 2013--2017 Z. Gilboa */
|
|
|
6a4793 |
/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
|
|
|
6a4793 |
/********************************************************/
|
|
|
6a4793 |
|
|
|
6a4793 |
#include <psxtypes/psxtypes.h>
|
|
|
6a4793 |
#include <ntapi/nt_file.h>
|
|
|
6a4793 |
#include <ntapi/nt_string.h>
|
|
|
6a4793 |
#include <ntapi/nt_atomic.h>
|
|
|
6a4793 |
#include <ntapi/nt_port.h>
|
|
|
6a4793 |
#include <ntapi/nt_ipc.h>
|
|
|
6a4793 |
#include <ntapi/nt_afl.h>
|
|
|
6a4793 |
#include <ntapi/ntapi.h>
|
|
|
6a4793 |
#include "ntapi_impl.h"
|
|
|
6a4793 |
|
|
|
6a4793 |
int32_t __stdcall __ntapi_afl_ioctl(
|
|
|
6a4793 |
__in nt_afl_info * afl,
|
|
|
6a4793 |
__in void * hevent __optional,
|
|
|
6a4793 |
__in nt_io_apc_routine * apc_routine __optional,
|
|
|
6a4793 |
__in void * apc_context __optional,
|
|
|
6a4793 |
__out nt_iosb * iosb,
|
|
|
6a4793 |
__in uint32_t io_control_code,
|
|
|
6a4793 |
__in void * input_buffer __optional,
|
|
|
6a4793 |
__in uint32_t input_buffer_length,
|
|
|
6a4793 |
__out void * output_buffer __optional,
|
|
|
6a4793 |
__in uint32_t output_buffer_length)
|
|
|
6a4793 |
{
|
|
|
6a4793 |
int32_t status;
|
|
|
6a4793 |
nt_afl_info_msg msg;
|
|
|
6a4793 |
nt_afl_op * aflop;
|
|
|
6a4793 |
|
|
|
6a4793 |
/* validate */
|
|
|
6a4793 |
if (io_control_code)
|
|
|
6a4793 |
return NT_STATUS_NOT_SUPPORTED;
|
|
|
6a4793 |
|
|
|
6a4793 |
else if (!iosb)
|
|
|
6a4793 |
return NT_STATUS_INVALID_PARAMETER;
|
|
|
6a4793 |
|
|
|
6a4793 |
else if (!(aflop = (nt_afl_op *)input_buffer))
|
|
|
6a4793 |
return NT_STATUS_INVALID_PARAMETER;
|
|
|
6a4793 |
|
|
|
6a4793 |
else if (input_buffer_length != sizeof(nt_afl_op))
|
|
|
6a4793 |
return NT_STATUS_INFO_LENGTH_MISMATCH;
|
|
|
6a4793 |
|
|
|
6a4793 |
if (output_buffer)
|
|
|
6a4793 |
if (output_buffer_length < sizeof(nt_afl_op))
|
|
|
6a4793 |
return NT_STATUS_BUFFER_TOO_SMALL;
|
|
|
6a4793 |
|
|
|
6a4793 |
/* msg */
|
|
|
6a4793 |
__ntapi->tt_aligned_block_memset(
|
|
|
6a4793 |
&msg,0,sizeof(msg));
|
|
|
6a4793 |
|
|
|
6a4793 |
__ntapi->tt_guid_copy(
|
|
|
6a4793 |
&msg.data.aflinfo.afldev,
|
|
|
6a4793 |
&afl->afldev);
|
|
|
6a4793 |
|
|
|
6a4793 |
msg.header.msg_type = NT_LPC_NEW_MESSAGE;
|
|
|
6a4793 |
msg.header.data_size = sizeof(msg.data);
|
|
|
6a4793 |
msg.header.msg_size = sizeof(msg);
|
|
|
6a4793 |
msg.data.ttyinfo.opcode = NT_TTY_AFL_IOCTL;
|
|
|
6a4793 |
|
|
|
6a4793 |
msg.data.aflinfo.l_fileid = aflop->l_fileid;
|
|
|
6a4793 |
msg.data.aflinfo.l_start = aflop->l_start;
|
|
|
6a4793 |
msg.data.aflinfo.l_len = aflop->l_len;
|
|
|
6a4793 |
msg.data.aflinfo.l_pid = aflop->l_pid;
|
|
|
6a4793 |
msg.data.aflinfo.l_cmd = aflop->l_cmd;
|
|
|
6a4793 |
|
|
|
6a4793 |
msg.data.aflinfo.hevent = hevent;
|
|
|
6a4793 |
msg.data.aflinfo.apc_routine = apc_routine;
|
|
|
6a4793 |
msg.data.aflinfo.apc_context = apc_context;
|
|
|
6a4793 |
msg.data.aflinfo.riosb = iosb;
|
|
|
6a4793 |
|
|
|
6a4793 |
if ((status = __ntapi->zw_request_wait_reply_port(afl->hport,&msg,&msg)))
|
|
|
6a4793 |
return status;
|
|
|
6a4793 |
else if (msg.data.ttyinfo.status)
|
|
|
6a4793 |
return msg.data.ttyinfo.status;
|
|
|
6a4793 |
|
|
|
6a4793 |
iosb->status = NT_STATUS_SUCCESS;
|
|
|
6a4793 |
iosb->info = msg.data.aflinfo.ntiosb.info;
|
|
|
6a4793 |
|
|
|
6a4793 |
if (msg.data.aflinfo.ntiosb.info && output_buffer) {
|
|
|
6a4793 |
aflop = (nt_afl_op *)output_buffer;
|
|
|
6a4793 |
aflop->l_fileid = msg.data.aflinfo.l_fileid;
|
|
|
6a4793 |
aflop->l_start = msg.data.aflinfo.l_start;
|
|
|
6a4793 |
aflop->l_len = msg.data.aflinfo.l_len;
|
|
|
6a4793 |
aflop->l_pid = msg.data.aflinfo.l_pid;
|
|
|
6a4793 |
aflop->l_cmd = msg.data.aflinfo.l_cmd;
|
|
|
6a4793 |
}
|
|
|
6a4793 |
|
|
|
6a4793 |
return NT_STATUS_SUCCESS;
|
|
|
6a4793 |
}
|