Blame src/tty/ntapi_tty_request_peer.c

dd89bb
/********************************************************/
dd89bb
/*  ntapi: Native API core library                      */
dd89bb
/*  Copyright (C) 2013,2014,2015  Z. Gilboa             */
dd89bb
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
dd89bb
/********************************************************/
dd89bb
dd89bb
#include <psxtypes/psxtypes.h>
dd89bb
#include <ntapi/nt_tty.h>
dd89bb
#include <ntapi/ntapi.h>
dd89bb
#include "ntapi_impl.h"
dd89bb
dd89bb
int32_t __stdcall __ntapi_tty_request_peer(
dd89bb
	__in	void *		hport,
dd89bb
	__in	int32_t		opcode,
dd89bb
	__in	uint32_t	flags,
dd89bb
	__in	const nt_guid *	service,
dd89bb
	__in	nt_port_attr *	peer)
dd89bb
{
dd89bb
	int32_t		status;
dd89bb
	nt_tty_peer_msg	msg;
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_REQUEST_PEER;
dd89bb
dd89bb
	msg.data.peerinfo.opcode= opcode;
dd89bb
	msg.data.peerinfo.flags = flags;
dd89bb
dd89bb
	if (service) __ntapi->tt_guid_copy(
dd89bb
		&msg.data.peerinfo.service,
dd89bb
		service);
dd89bb
dd89bb
	__ntapi->tt_aligned_block_memcpy(
dd89bb
		(uintptr_t *)&msg.data.peerinfo.peer,
dd89bb
		(uintptr_t *)peer,
dd89bb
		sizeof(*peer));
dd89bb
dd89bb
	if ((status = __ntapi->zw_request_wait_reply_port(hport,&msg,&msg)))
dd89bb
		return status;
dd89bb
dd89bb
	return msg.data.ttyinfo.status;
dd89bb
}