Blob Blame History Raw
#ifndef _NT_TTY_H_
#define _NT_TTY_H_

/**
 *  tty api:
 *  -----------
 *  this header describes the tty interfaces that are used
 *  by native applications and libraries to communicate with
 *  ntctty, the project's native subsystem and pty server.
**/

#include "nt_abi.h"
#include "nt_compiler.h"
#include "nt_object.h"
#include "nt_process.h"
#include "nt_port.h"
#include "nt_termios.h"
#include "nt_sem.h"
#include "nt_msq.h"
#include "nt_afl.h"

/* tty affiliation */
typedef struct _nt_tty_affiliation {
	char	group1[8];
	char	group2[4];
	char	group3[4];
	char	group4[4];
	char	group5[12];
} nt_tty_affiliation;

#define NT_TTY_AFFILIATION_GUID_DEFAULT	{0xeb564abf, 0x0714,0x4cc9,{0x83,0x55,0xf9,0x89,0xdb,0xab,0x49,0x5c}}
#define NT_TTY_AFFILIATION_GUID_POSIX	{0xe35ed272, 0x9e55,0x46c1,{0x82,0x51,0x02,0x2a,0x59,0xe6,0xc4,0x80}}

#define NT_TTY_AFFILIATION_DEFAULT {				\
	{'e','b','5','6','4','a','b','f'},			\
	{'0','7','1','4'},					\
	{'4','c','c','9'},					\
	{'8','3','5','5'},					\
	{'f','9','8','9','d','b','a','b','4','9','5','c'}}

#define NT_TTY_AFFILIATION_POSIX {				\
	{'e','3','5','e','d','2','7','2'},			\
	{'9','e','5','5'},					\
	{'4','6','c','1'},					\
	{'8','2','5','1'},					\
	{'0','2','2','a','5','9','e','6','c','4','8','0'}}

typedef enum _nt_tty_opcode {
	NT_TTY_CLIENT_OPCODE_BASE	= 0x40000,
	/* primary connection */
	NT_TTY_CLIENT_SESSION_CONNECT	= NT_TTY_CLIENT_OPCODE_BASE,
	NT_TTY_CLIENT_SESSION_DISCONNECT,
	NT_TTY_CLIENT_SESSION_QUERY,
	NT_TTY_CLIENT_SESSION_SET,
	/* server-to-server coordination */
	NT_TTY_CLIENT_SESSION_SYNCHRONIZE,
	NT_TTY_CLIENT_SESSION_TRANSFER,
	/* process registration */
	NT_TTY_CLIENT_PROCESS_REGISTER,
	NT_TTY_CLIENT_PROCESS_UNREGISTER,
	/* session information */
	NT_TTY_QUERY_INFORMATION_SERVER,
	NT_TTY_QUERY_INFORMATION_SERVICE,
	NT_TTY_QUERY_INFORMATION_SESSION,
	NT_TTY_QUERY_INFORMATION_PROCESS,
	NT_TTY_QUERY_INFORMATION_THREAD,
	NT_TTY_QUERY_INFORMATION_SECTION,
	NT_TTY_QUERY_INFORMATION_PTY,
	NT_TTY_QUERY_INFORMATION_SEMAPHORE,
	NT_TTY_QUERY_INFORMATION_MSGQUEUE,
	NT_TTY_QUERY_INFORMATION_AFLOCK,
	/* session log */
	NT_TTY_LOG_ENTRY,
	NT_TTY_LOG_QUERY,
	/* peer daemon calls */
	NT_TTY_REQUEST_PEER,
	NT_TTY_SIGNAL_PEER,
	/* pty */
	NT_TTY_PTY_OPEN,
	NT_TTY_PTY_CLOSE,
	NT_TTY_PTY_READ,
	NT_TTY_PTY_WRITE,
	NT_TTY_PTY_QUERY,
	NT_TTY_PTY_SET,
	NT_TTY_PTY_FCNTL,
	NT_TTY_PTY_IOCTL,
	NT_TTY_PTY_CANCEL,
	NT_TTY_PTY_PEEK,
	/* semaphore */
	NT_TTY_SEM_ALLOC,
	NT_TTY_SEM_FREE,
	NT_TTY_SEM_OPEN,
	NT_TTY_SEM_CLOSE,
	NT_TTY_SEM_QUERY,
	NT_TTY_SEM_SET,
	NT_TTY_SEM_FCNTL,
	NT_TTY_SEM_IOCTL,
	NT_TTY_SEM_CANCEL,
	NT_TTY_SEM_TRACE,
	NT_TTY_SEM_TRANSFER,
	NT_TTY_SEM_WAIT,
	/* msgqueue */
	NT_TTY_MSQ_ALLOC,
	NT_TTY_MSQ_FREE,
	NT_TTY_MSQ_OPEN,
	NT_TTY_MSQ_CLOSE,
	NT_TTY_MSQ_SEND,
	NT_TTY_MSQ_RECV,
	NT_TTY_MSQ_QUERY,
	NT_TTY_MSQ_SET,
	NT_TTY_MSQ_FCNTL,
	NT_TTY_MSQ_IOCTL,
	NT_TTY_MSQ_CANCEL,
	NT_TTY_MSQ_TRACE,
	NT_TTY_MSQ_TRANSFER,
	NT_TTY_MSQ_WAIT,
	/* aflock */
	NT_TTY_AFL_ALLOC,
	NT_TTY_AFL_FREE,
	NT_TTY_AFL_OPEN,
	NT_TTY_AFL_CLOSE,
	NT_TTY_AFL_QUERY,
	NT_TTY_AFL_SET,
	NT_TTY_AFL_FCNTL,
	NT_TTY_AFL_IOCTL,
	NT_TTY_AFL_CANCEL,
	NT_TTY_AFL_TRACE,
	NT_TTY_AFL_TRANSFER,
	NT_TTY_AFL_WAIT,
	/* virtual mount system */
	NT_TTY_VMS_QUERY,
	NT_TTY_VMS_REQUEST,
	/* exclusive upper limit */
	NT_TTY_CLIENT_OPCODE_CAP
} nt_tty_opcode;


typedef enum _nt_tty_session_type {
	NT_TTY_SESSION_PRIMARY,
	NT_TTY_SESSION_SECONDARY,
	NT_TTY_SESSION_PRIVATE
} nt_tty_session_type;


typedef enum _nt_tty_session_subtype {
	NT_TTY_SESSION_SUBTYPE_DEFAULT,
	NT_TTY_SESSION_SUBTYPE_CAP,
} nt_tty_session_subtype;


typedef enum _nt_tty_server_info_class {
	NT_TTY_SERVER_BASIC_INFORMATION,
	NT_TTY_SERVER_PTM_SLOT_INFORMATION,
	NT_TTY_SERVER_PTS_SLOT_INFORMATION,
	NT_TTY_SERVER_DBM_SLOT_INFORMATION,
	NT_TTY_SERVER_DBG_SLOT_INFORMATION,
	NT_TTY_SERVER_SEM_SLOT_INFORMATION,
	NT_TTY_SERVER_MSQ_SLOT_INFORMATION,
	NT_TTY_SERVER_AFL_SLOT_INFORMATION,
	NT_TTY_SERVER_INFORMATION_CAP
} nt_tty_server_info_class;


typedef enum _nt_pty_info_class {
	NT_PTY_BASIC_INFORMATION,
	NT_PTY_SLOT_INFORMATION,
	NT_PTY_CLIENT_INFORMATION,
	NT_PTY_CONTEXT_INFORMATION,
	NT_PTY_INHERIT_INFORMATION,
	NT_PTY_OFD_INFORMATION,
	NT_PTY_INFORMATION_CAP
} nt_pty_info_class;


typedef enum _nt_tty_log_info_type {
	NT_TTY_LOG_INFO_BINARY_DATA,
	NT_TTY_LOG_INFO_STRING_DATA,
	NT_TTY_LOG_INFO_INTEGER_ARRAY,
	NT_TTY_LOG_INFO_POINTER_ARRAY,
	NT_TTY_LOG_INFO_EXCEPTION_RECORD,
	NT_TTY_LOG_INFO_EXCEPTION_ENTRY,
	NT_TTY_LOG_INFO_CAP,
} nt_tty_log_info_type;


/* client process registration flags */
#define NT_TTY_INHERIT_HANDLES 	0x0001


typedef struct __attr_ptr_size_aligned__ _nt_tty_msg_info {
	uintptr_t	msgid;
	uint32_t	opcode;
	int32_t		status;
	void *		exarg;
} nt_tty_msg_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_register_info {
	uintptr_t	process_id;
	uintptr_t	thread_id;
	uintptr_t	flags;
	uintptr_t	reserved;
} nt_tty_register_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_server_basic_info {
	nt_port_attr	attr;
	intptr_t	pid;
	intptr_t	tid;
} nt_tty_server_basic_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_pts_slot_info {
	int32_t		blkidx;
	int32_t		blkpts;
	int32_t		blkcnt;
	int32_t		blkcap;
	uint32_t	ptsmap[32];
} nt_tty_pts_slot_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_server_info {
	nt_tty_server_info_class	info_class;
	uint32_t			info_length;
	uintptr_t			info_buffer[];
} nt_tty_server_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_service_info {
	nt_port_attr	attr;
	uint32_t	key;
	uint32_t	id;
} nt_tty_service_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_section_info {
	nt_port_attr	attr;
	void *		section;
	void *		section_addr;
	size_t		section_size;
} nt_tty_section_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_vms_info {
	void *		hroot;
	uint32_t	hash;
	uint32_t	flags;
	int64_t		key;
	nt_guid		vms_guid;
	nt_port_keys	vms_keys;
} nt_tty_vms_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_peer_info {
	uint32_t	opcode;
	uint32_t	flags;
	nt_guid		service;
	nt_port_attr	peer;
} nt_tty_peer_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_sigctl_info {
	void *			hpty;
	nt_guid			guid;
	nt_luid			luid;
	uint32_t		ctlcode;
	int32_t			cccode;
	nt_client_id		cid;
	uintptr_t		ctxarg[4];
	struct tty_termios	terminfo;
	struct tty_winsize	winsize;
	nt_iosb			iosb;
} nt_tty_sigctl_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_log_info {
	int32_t		type;
	uint32_t	meta;
	nt_cid		cid;
	uint32_t	data[0x30];
} nt_tty_log_info;


typedef struct __attr_ptr_size_aligned__ _nt_pty_fd_info {
	void *		hpty;
	void *		section;
	void *		section_addr;
	size_t		section_size;
	nt_guid		guid;
	nt_luid		luid;
	uint32_t	access;
	uint32_t	flags;
	uint32_t	share;
	uint32_t	options;
	intptr_t	state;
	void *		hevent[2];
} nt_pty_fd_info;


typedef struct __attr_ptr_size_aligned__ _nt_pty_context_info {
	void *		hpty;
	nt_guid		guid;
	nt_luid		luid;
	uintptr_t	ctxarg[4];
} nt_pty_context_info;


typedef struct __attr_ptr_size_aligned__ _nt_pty_io_info {
	void *		hpty;
	void *		hevent;
	void *		reserved;
	void *		apc_routine;
	void *		apc_context;
	nt_iosb *	riosb;
	void *		raddr;
	nt_iosb		iosb;
	off_t		offset;
	size_t		nbytes;
	uint32_t	key;
	uint32_t	npending;
	nt_guid		guid;
	nt_luid		luid;
} nt_pty_io_info;


typedef struct __attr_ptr_size_aligned__ _nt_pty_client_info {
	uintptr_t	any[4];
} nt_pty_client_info;


typedef struct __attr_ptr_size_aligned__ _nt_pty_inherit_info {
	void *		hpty;
	nt_guid		guid;
	nt_luid		luid;
	uint32_t	access;
	uint32_t	flags;
	uint32_t	share;
	uint32_t	options;
} nt_pty_inherit_info;

typedef struct __attr_ptr_size_aligned__ _nt_tty_session_info {
	int32_t		pid;
	int32_t		pgid;
	int32_t		sid;
	int32_t		syspid;
} nt_tty_session_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_ipc_info {
	nt_port_attr	ctrlsvc;
	uint32_t	ipckeys[6];
	void *		hevent;
	void *		apc_routine;
	void *		apc_context;
	nt_iosb *	riosb;
} nt_tty_ipc_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_sync_info {
	nt_client_id	cid;
	nt_port_attr	ipcsvc;
	uint32_t	ipckeys[6];
	void *		hevent;
	void *		apc_routine;
	void *		apc_context;
	nt_iosb *	riosb;
} nt_tty_sync_info;



typedef struct __attr_ptr_size_aligned__ _nt_tty_transfer_info {
	nt_client_id	ccid;
	nt_client_id	tcid;
	uint32_t	ipckeys[6];
	void *		hevent;
	void *		apc_routine;
	void *		apc_context;
	nt_iosb *	riosb;
} nt_tty_transfer_info;


typedef struct __attr_ptr_size_aligned__ _nt_tty_register_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_register_info	reginfo;
	} data;
} nt_tty_register_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_server_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_server_info	srvinfo;
	} data;
} nt_tty_server_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_service_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_service_info	svcinfo;
	} data;
} nt_tty_service_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_section_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_section_info	secinfo;
	} data;
} nt_tty_section_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_vms_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_vms_info		vmsinfo;
	} data;
} nt_tty_vms_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_peer_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_peer_info	peerinfo;
	} data;
} nt_tty_peer_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_pid_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_user_process_info	pidinfo;
	} data;
} nt_tty_pid_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_ipc_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_ipc_info		ipcinfo;
	} data;
} nt_tty_ipc_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_sync_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_sync_info	syncinfo;
	} data;
} nt_tty_sync_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_transfer_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_transfer_info	transferinfo;
	} data;
} nt_tty_transfer_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_log_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_log_info		loginfo;
	} data;
} nt_tty_log_msg;


typedef struct __attr_ptr_size_aligned__ _nt_pty_fd_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_pty_fd_info		fdinfo;
	} data;
} nt_pty_fd_msg;


typedef struct __attr_ptr_size_aligned__ _nt_pty_io_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_pty_io_info		ioinfo;
	} data;
} nt_pty_io_msg;


typedef struct __attr_ptr_size_aligned__ _nt_pty_sigctl_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_sigctl_info	ctlinfo;
	} data;
} nt_pty_sigctl_msg;


typedef struct __attr_ptr_size_aligned__ _nt_sem_info_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_sem_info		seminfo;
	} data;
} nt_sem_info_msg;


typedef struct __attr_ptr_size_aligned__ _nt_msq_info_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_msq_info		msqinfo;
	} data;
} nt_msq_info_msg;


typedef struct __attr_ptr_size_aligned__ _nt_afl_info_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_afl_info		aflinfo;
	} data;
} nt_afl_info_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_session_msg {
	nt_port_message			header;
	struct {
		nt_tty_msg_info		ttyinfo;
		nt_tty_session_info	sessioninfo;
	} data;
} nt_tty_session_msg;


typedef struct __attr_ptr_size_aligned__ _nt_tty_port_msg {
	nt_port_message			header;
	nt_tty_msg_info			ttyinfo;
	union {
		nt_tty_register_info	reginfo;
		nt_tty_vms_info		vmsinfo;
		nt_tty_peer_info	peerinfo;
		nt_tty_sigctl_info	ctlinfo;
		nt_tty_ipc_info		ipcinfo;
		nt_tty_sync_info	syncinfo;
		nt_tty_log_info		loginfo;
		nt_user_process_info	pidinfo;
		nt_tty_transfer_info	transferinfo;
		nt_pty_fd_info		fdinfo;
		nt_pty_io_info		ioinfo;
		nt_pty_client_info	clientinfo;
		nt_tty_session_info	sessioninfo;
		nt_tty_service_info	svcinfo;
		nt_tty_section_info	secinfo;
		nt_sem_info		seminfo;
		nt_msq_info		msqinfo;
		nt_afl_info		aflinfo;
	};
} nt_tty_port_msg;


__assert_aligned_size(nt_tty_msg_info,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_register_info,	__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_vms_info,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_peer_info,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_sigctl_info,	__SIZEOF_POINTER__);
__assert_aligned_size(nt_pty_fd_info,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_pty_io_info,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_register_msg,	__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_vms_msg,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_peer_msg,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_pty_sigctl_msg,	__SIZEOF_POINTER__);
__assert_aligned_size(nt_pty_fd_msg,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_pty_io_msg,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_port_msg,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_ipc_msg,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_sync_msg,		__SIZEOF_POINTER__);
__assert_aligned_size(nt_tty_transfer_msg,	__SIZEOF_POINTER__);


/* tty session */
typedef int32_t __stdcall	ntapi_tty_create_session(
	__out	void **			hport,
	__out	nt_port_name *		port_name,
	__in	nt_tty_session_type	type,
	__in	nt_tty_session_subtype	subtype,
	__in	const nt_guid *		guid		__optional,
	__in	wchar16_t *		image_name,
	__in	void *			htty		__optional);


typedef int32_t __stdcall	ntapi_tty_join_session(
	__out	void **			hport,
	__out	nt_port_name *		port_name,
	__in	nt_port_attr *		port_attr,
	__in	nt_tty_session_type	type);


typedef int32_t __stdcall	ntapi_tty_connect(
	__out	void **			hport,
	__in	wchar16_t *		tty_port_name,
	__in	int32_t			impersonation_level);


typedef int32_t __stdcall	ntapi_tty_client_session_disconnect(
	__in	void *			hport);


typedef int32_t __stdcall	ntapi_tty_client_session_query(
	__in	void *			hport,
	__out	nt_tty_session_info *	sessioninfo);


typedef int32_t __stdcall	ntapi_tty_client_session_set(
	__in	void *			hport,
	__in	nt_tty_session_info *	sessioninfo);


typedef int32_t __stdcall	ntapi_tty_client_process_register(
	__in	void *			hport,
	__in	uintptr_t		process_id,
	__in	uintptr_t		thread_id,
	__in	uintptr_t		flags,
	__in	nt_large_integer *	reserved);


typedef int32_t __stdcall ntapi_tty_query_information_section(
	__in	void *			hport,
	__out	nt_io_status_block *	iosb,
	__out	nt_tty_section_info *	secinfo,
	__in	const nt_guid *		guid);


typedef int32_t __stdcall ntapi_tty_query_information_server(
	__in	void *			hport,
	__out	nt_io_status_block *	iosb,
	__out	void *			tty_info,
	__in	uint32_t		tty_info_length,
	__in	int			tty_info_class);


typedef int32_t __stdcall ntapi_tty_query_information_service(
	__in	void *			hport,
	__out	nt_io_status_block *	iosb,
	__out	nt_tty_service_info *	svcinfo,
	__in	const nt_guid *		guid,
	__in	uint32_t		key,
	__in	uint32_t		id);


typedef int32_t __stdcall ntapi_tty_query_server_pts_slot_info(
	__in	void *			hport,
	__out	nt_tty_pts_slot_info *	pts_slot_info,
	__in	intptr_t		blkidx);


/* pty api */
typedef struct nt_pty_context nt_pty;

typedef int32_t	__stdcall ntapi_pty_open(
	__in	void *			hport,
	__out	nt_pty **		pty,
	__in	uint32_t		desired_access,
	__in	nt_object_attributes*	obj_attr,
	__out	nt_iosb *		iosb,
	__in	uint32_t		share_access,
	__in	uint32_t		open_options);


typedef int32_t	__stdcall ntapi_pty_open_pair(
	__in	void *			hport,
	__out	nt_pty **		pty,
	__in	uint32_t		desired_access,
	__in	nt_object_attributes*	obj_attr,
	__out	nt_iosb *		iosb,
	__in	uint32_t		share_access,
	__in	uint32_t		open_options);


typedef int32_t	__stdcall ntapi_pty_reopen(
	__in	void *			hport,
	__in	nt_pty *		pty);


typedef int32_t	__stdcall ntapi_pty_inherit(
	__in	void *			hport,
	__out	nt_pty **		pty,
	__in 	nt_pty_client_info * 	client_info);


typedef int32_t	__stdcall ntapi_pty_inherit_runtime_ctty(
	__in	void *			hport,
     __in_out	nt_runtime_data *	rtdata);


typedef int32_t __stdcall ntapi_pty_close(
	__in	nt_pty *		pty);


typedef int32_t	__stdcall ntapi_pty_read(
	__in	nt_pty *		pty,
	__in	void *			hevent		__optional,
	__in	nt_io_apc_routine *	apc_routine	__optional,
	__in	void *			apc_context	__optional,
	__out	nt_iosb *		iosb,
	__out	void *			buffer,
	__in	uint32_t		nbytes,
	__in	nt_large_integer *	offset		__optional,
	__in	uint32_t *		key		__optional);


typedef int32_t __stdcall ntapi_pty_write(
	__in	nt_pty *		pty,
	__in 	void *			hevent		__optional,
	__in	nt_io_apc_routine *	apc_routine	__optional,
	__in	void * 			apc_context	__optional,
	__out	nt_iosb *		iosb,
	__in	void * 			buffer,
	__in	uint32_t		nbytes,
	__in	nt_large_integer *	offset		__optional,
	__in	uint32_t *		key		__optional);


typedef int32_t	__stdcall ntapi_pty_fcntl(
	__in	nt_pty *		pty,
	__in	void *			hevent			__optional,
	__in	nt_io_apc_routine *	apc_routine		__optional,
	__in	void *			apc_context		__optional,
	__out	nt_iosb *		iosb,
	__in	uint32_t		fs_control_code,
	__in	void *			input_buffer		__optional,
	__in	uint32_t		input_buffer_length,
	__out	void *			output_buffer		__optional,
	__in	uint32_t		output_buffer_length);


typedef int32_t	__stdcall ntapi_pty_ioctl(
	__in	nt_pty *		pty,
	__in	void *			hevent			__optional,
	__in	nt_io_apc_routine *	apc_routine		__optional,
	__in	void *			apc_context		__optional,
	__out	nt_iosb *		iosb,
	__in	uint32_t		io_control_code,
	__in	void *			input_buffer		__optional,
	__in	uint32_t		input_buffer_length,
	__out	void *			output_buffer		__optional,
	__in	uint32_t		output_buffer_length);


typedef int32_t	__stdcall ntapi_pty_query(
	__in	nt_pty *		pty,
	__out	nt_io_status_block *	iosb,
	__out	void *			pty_info,
	__in	uint32_t		pty_info_length,
	__in	nt_pty_info_class	pty_info_class);


typedef int32_t	__stdcall ntapi_pty_xquery(
	__in	void *			hport,
	__out	nt_io_status_block *	iosb,
	__out	void *			pty_info,
	__in	uint32_t		pty_info_length,
	__in	nt_pty_info_class	pty_info_class,
	__in	nt_pty_client_info *	pty_client_info);


typedef int32_t	__stdcall ntapi_pty_set(
	__in	nt_pty *		hfile,
	__out	nt_io_status_block *	iosb,
	__in	void *			pty_info,
	__in	uint32_t		pty_info_length,
	__in	nt_pty_info_class	pty_info_class);


typedef int32_t	__stdcall ntapi_pty_cancel(
	__in	nt_pty *		pty,
	__out	nt_iosb *		iosb);


/* peer daemon calls */
typedef int32_t __stdcall ntapi_tty_request_peer(
	__in	void *		hport,
	__in	int32_t		opcode,
	__in	uint32_t	flags,
	__in	const nt_guid *	service,
	__in	nt_port_attr *	peer);


/* virtual mount system */
typedef int32_t __stdcall	ntapi_tty_vms_query(
	__in	void *			hport,
	__in	nt_tty_vms_info *	vmsinfo);


typedef int32_t __stdcall	ntapi_tty_vms_request(
	__in	void *			hport,
	__in	nt_tty_vms_info *	vmsinfo);

#endif