Blame src/afl/ntapi_afl_fdio.c

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
static int32_t __afl_fdio(
6a4793
	nt_afl_info *		afl,
6a4793
	nt_iosb *		iosb,
6a4793
	uint32_t		opcode)
6a4793
{
6a4793
	int32_t			status;
6a4793
	nt_afl_info_msg		msg;
6a4793
6a4793
	/* validate */
6a4793
	if (!iosb)
6a4793
		return NT_STATUS_INVALID_PARAMETER;
6a4793
6a4793
	/* msg */
6a4793
	__ntapi->tt_aligned_block_memset(
6a4793
		&msg,0,sizeof(msg));
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		= opcode;
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   = 0;
6a4793
6a4793
	return NT_STATUS_SUCCESS;
6a4793
}
6a4793
6a4793
int32_t	__stdcall __ntapi_afl_cancel(
6a4793
	__in	nt_afl_info *		afl,
6a4793
	__out	nt_iosb *		iosb)
6a4793
{
6a4793
	return __afl_fdio(afl,iosb,NT_TTY_AFL_CANCEL);
6a4793
}
6a4793
6a4793
int32_t	__stdcall __ntapi_afl_free(
6a4793
	__in	nt_afl_info *		afl,
6a4793
	__out	nt_iosb *		iosb)
6a4793
{
6a4793
	return __afl_fdio(afl,iosb,NT_TTY_AFL_FREE);
6a4793
}