Blame src/tty/ntapi_tty_query_server_pts_slot_info.c

45dcc8
/********************************************************/
45dcc8
/*  ntapi: Native API core library                      */
45dcc8
/*  Copyright (C) 2013--2018  Z. Gilboa                 */
45dcc8
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
45dcc8
/********************************************************/
45dcc8
45dcc8
#include <psxtypes/psxtypes.h>
45dcc8
#include <ntapi/nt_tty.h>
45dcc8
#include <ntapi/ntapi.h>
45dcc8
#include "ntapi_impl.h"
45dcc8
45dcc8
#define __MSGBUF_ELEMENTS (NT_LPC_MAX_MSG_DATA_SIZE/sizeof(size_t)) + 1
45dcc8
45dcc8
int32_t	__stdcall __ntapi_tty_query_server_pts_slot_info(
45dcc8
	__in	void *			hport,
45dcc8
	__out	 nt_tty_pts_slot_info *	pts_slot_info,
45dcc8
	__in	intptr_t		blkidx)
45dcc8
{
45dcc8
	int32_t			status;
45dcc8
	nt_tty_server_msg *	msg;
45dcc8
	uintptr_t		msgbuf[__MSGBUF_ELEMENTS];
45dcc8
45dcc8
	__ntapi->tt_aligned_block_memset(
45dcc8
		msgbuf,0,
45dcc8
		sizeof(msgbuf));
45dcc8
45dcc8
	msg				= (nt_tty_server_msg *)msgbuf;
45dcc8
	msg->header.msg_type		= NT_LPC_NEW_MESSAGE;
45dcc8
	msg->header.data_size		= sizeof(msg->data);
45dcc8
	msg->header.msg_size		= sizeof(*msg);
45dcc8
	msg->data.ttyinfo.exarg         = (void *)blkidx;
45dcc8
	msg->data.ttyinfo.opcode	= NT_TTY_QUERY_INFORMATION_SERVER;
45dcc8
	msg->data.srvinfo.info_class	= NT_TTY_SERVER_PTS_SLOT_INFORMATION;
45dcc8
45dcc8
	if ((status = __ntapi->zw_request_wait_reply_port(hport,msg,msg)))
45dcc8
		return status;
45dcc8
45dcc8
	else if (msg->data.ttyinfo.status)
45dcc8
		return msg->data.ttyinfo.status;
45dcc8
45dcc8
	if (sizeof(*pts_slot_info) < msg->data.srvinfo.info_length)
45dcc8
		return NT_STATUS_INTERNAL_ERROR;
45dcc8
45dcc8
	__ntapi->tt_generic_memcpy(
45dcc8
		pts_slot_info,
45dcc8
		msg->data.srvinfo.info_buffer,
45dcc8
		msg->data.srvinfo.info_length);
45dcc8
45dcc8
	return NT_STATUS_SUCCESS;
45dcc8
}