Blame include/ntapi/nt_tty.h

dd89bb
#ifndef _NT_TTY_H_
dd89bb
#define _NT_TTY_H_
dd89bb
dd89bb
/**
dd89bb
 *  tty api:
dd89bb
 *  -----------
dd89bb
 *  this header describes the tty interfaces that are used
dd89bb
 *  by native applications and libraries to communicate with
dd89bb
 *  ntctty, the project's native subsystem and pty server.
dd89bb
**/
dd89bb
414ad3
#include "nt_abi.h"
414ad3
#include "nt_compiler.h"
dd89bb
#include "nt_object.h"
5ea20e
#include "nt_process.h"
dd89bb
#include "nt_port.h"
dd89bb
#include "nt_termios.h"
4a2e49
#include "nt_sem.h"
a6563a
#include "nt_msq.h"
b92a12
#include "nt_afl.h"
dd89bb
ad6132
/* tty affiliation */
ad6132
typedef struct _nt_tty_affiliation {
ad6132
	char	group1[8];
ad6132
	char	group2[4];
ad6132
	char	group3[4];
ad6132
	char	group4[4];
ad6132
	char	group5[12];
ad6132
} nt_tty_affiliation;
ad6132
ad6132
#define NT_TTY_AFFILIATION_GUID_DEFAULT	{0xeb564abf, 0x0714,0x4cc9,{0x83,0x55,0xf9,0x89,0xdb,0xab,0x49,0x5c}}
ad6132
#define NT_TTY_AFFILIATION_GUID_POSIX	{0xe35ed272, 0x9e55,0x46c1,{0x82,0x51,0x02,0x2a,0x59,0xe6,0xc4,0x80}}
ad6132
ad6132
#define NT_TTY_AFFILIATION_DEFAULT {				\
ad6132
	{'e','b','5','6','4','a','b','f'},			\
ad6132
	{'0','7','1','4'},					\
ad6132
	{'4','c','c','9'},					\
ad6132
	{'8','3','5','5'},					\
ad6132
	{'f','9','8','9','d','b','a','b','4','9','5','c'}}
ad6132
ad6132
#define NT_TTY_AFFILIATION_POSIX {				\
ad6132
	{'e','3','5','e','d','2','7','2'},			\
ad6132
	{'9','e','5','5'},					\
ad6132
	{'4','6','c','1'},					\
ad6132
	{'8','2','5','1'},					\
ad6132
	{'0','2','2','a','5','9','e','6','c','4','8','0'}}
ad6132
dd89bb
typedef enum _nt_tty_opcode {
dd89bb
	NT_TTY_CLIENT_OPCODE_BASE	= 0x40000,
dd89bb
	/* primary connection */
dd89bb
	NT_TTY_CLIENT_SESSION_CONNECT	= NT_TTY_CLIENT_OPCODE_BASE,
dd89bb
	NT_TTY_CLIENT_SESSION_DISCONNECT,
dd89bb
	NT_TTY_CLIENT_SESSION_QUERY,
dd89bb
	NT_TTY_CLIENT_SESSION_SET,
edb085
	/* server-to-server coordination */
edb085
	NT_TTY_CLIENT_SESSION_SYNCHRONIZE,
edb085
	NT_TTY_CLIENT_SESSION_TRANSFER,
dd89bb
	/* process registration */
dd89bb
	NT_TTY_CLIENT_PROCESS_REGISTER,
dd89bb
	NT_TTY_CLIENT_PROCESS_UNREGISTER,
dd89bb
	/* session information */
dd89bb
	NT_TTY_QUERY_INFORMATION_SERVER,
a1e25a
	NT_TTY_QUERY_INFORMATION_SERVICE,
dd89bb
	NT_TTY_QUERY_INFORMATION_SESSION,
dd89bb
	NT_TTY_QUERY_INFORMATION_PROCESS,
dd89bb
	NT_TTY_QUERY_INFORMATION_THREAD,
dd89bb
	NT_TTY_QUERY_INFORMATION_SECTION,
dd89bb
	NT_TTY_QUERY_INFORMATION_PTY,
4a2e49
	NT_TTY_QUERY_INFORMATION_SEMAPHORE,
a6563a
	NT_TTY_QUERY_INFORMATION_MSGQUEUE,
b92a12
	NT_TTY_QUERY_INFORMATION_AFLOCK,
c3620f
	/* network information */
c3620f
	NT_TTY_QUERY_INFORMATION_NETWORK,
c3620f
	NT_TTY_QUERY_INFORMATION_CLUSTER,
c3620f
	NT_TTY_QUERY_INFORMATION_HOST,
c3620f
	NT_TTY_QUERY_INFORMATION_SHARE,
c3620f
	NT_TTY_QUERY_INFORMATION_USER,
c3620f
	NT_TTY_QUERY_INFORMATION_GROUP,
c3620f
	NT_TTY_QUERY_INFORMATION_LOGON,
c3620f
	NT_TTY_QUERY_INFORMATION_POLICY,
02f584
	/* session log */
1c3ec4
	NT_TTY_LOG_ENTRY,
02f584
	NT_TTY_LOG_QUERY,
dd89bb
	/* peer daemon calls */
dd89bb
	NT_TTY_REQUEST_PEER,
dd89bb
	NT_TTY_SIGNAL_PEER,
dd89bb
	/* pty */
dd89bb
	NT_TTY_PTY_OPEN,
dd89bb
	NT_TTY_PTY_CLOSE,
dd89bb
	NT_TTY_PTY_READ,
dd89bb
	NT_TTY_PTY_WRITE,
dd89bb
	NT_TTY_PTY_QUERY,
dd89bb
	NT_TTY_PTY_SET,
dd89bb
	NT_TTY_PTY_FCNTL,
dd89bb
	NT_TTY_PTY_IOCTL,
dd89bb
	NT_TTY_PTY_CANCEL,
dd89bb
	NT_TTY_PTY_PEEK,
4a2e49
	/* semaphore */
4a2e49
	NT_TTY_SEM_ALLOC,
4a2e49
	NT_TTY_SEM_FREE,
4a2e49
	NT_TTY_SEM_OPEN,
4a2e49
	NT_TTY_SEM_CLOSE,
4a2e49
	NT_TTY_SEM_QUERY,
4a2e49
	NT_TTY_SEM_SET,
4a2e49
	NT_TTY_SEM_FCNTL,
4a2e49
	NT_TTY_SEM_IOCTL,
4a2e49
	NT_TTY_SEM_CANCEL,
4a2e49
	NT_TTY_SEM_TRACE,
edb085
	NT_TTY_SEM_TRANSFER,
edb085
	NT_TTY_SEM_WAIT,
a6563a
	/* msgqueue */
a6563a
	NT_TTY_MSQ_ALLOC,
a6563a
	NT_TTY_MSQ_FREE,
a6563a
	NT_TTY_MSQ_OPEN,
a6563a
	NT_TTY_MSQ_CLOSE,
a6563a
	NT_TTY_MSQ_SEND,
a6563a
	NT_TTY_MSQ_RECV,
a6563a
	NT_TTY_MSQ_QUERY,
a6563a
	NT_TTY_MSQ_SET,
a6563a
	NT_TTY_MSQ_FCNTL,
a6563a
	NT_TTY_MSQ_IOCTL,
a6563a
	NT_TTY_MSQ_CANCEL,
a6563a
	NT_TTY_MSQ_TRACE,
a6563a
	NT_TTY_MSQ_TRANSFER,
a6563a
	NT_TTY_MSQ_WAIT,
b92a12
	/* aflock */
b92a12
	NT_TTY_AFL_ALLOC,
b92a12
	NT_TTY_AFL_FREE,
b92a12
	NT_TTY_AFL_OPEN,
b92a12
	NT_TTY_AFL_CLOSE,
b92a12
	NT_TTY_AFL_QUERY,
b92a12
	NT_TTY_AFL_SET,
b92a12
	NT_TTY_AFL_FCNTL,
b92a12
	NT_TTY_AFL_IOCTL,
b92a12
	NT_TTY_AFL_CANCEL,
b92a12
	NT_TTY_AFL_TRACE,
b92a12
	NT_TTY_AFL_TRANSFER,
b92a12
	NT_TTY_AFL_WAIT,
dd89bb
	/* exclusive upper limit */
dd89bb
	NT_TTY_CLIENT_OPCODE_CAP
dd89bb
} nt_tty_opcode;
dd89bb
dd89bb
dd89bb
typedef enum _nt_tty_session_type {
dd89bb
	NT_TTY_SESSION_PRIMARY,
f61917
	NT_TTY_SESSION_SECONDARY,
dd89bb
	NT_TTY_SESSION_PRIVATE
dd89bb
} nt_tty_session_type;
dd89bb
dd89bb
e3e5a2
typedef enum _nt_tty_session_subtype {
e3e5a2
	NT_TTY_SESSION_SUBTYPE_DEFAULT,
e3e5a2
	NT_TTY_SESSION_SUBTYPE_CAP,
e3e5a2
} nt_tty_session_subtype;
e3e5a2
e3e5a2
c16244
typedef enum _nt_tty_server_info_class {
c16244
	NT_TTY_SERVER_BASIC_INFORMATION,
c16244
	NT_TTY_SERVER_PTM_SLOT_INFORMATION,
c16244
	NT_TTY_SERVER_PTS_SLOT_INFORMATION,
c16244
	NT_TTY_SERVER_DBM_SLOT_INFORMATION,
c16244
	NT_TTY_SERVER_DBG_SLOT_INFORMATION,
4a2e49
	NT_TTY_SERVER_SEM_SLOT_INFORMATION,
a6563a
	NT_TTY_SERVER_MSQ_SLOT_INFORMATION,
b92a12
	NT_TTY_SERVER_AFL_SLOT_INFORMATION,
c16244
	NT_TTY_SERVER_INFORMATION_CAP
c16244
} nt_tty_server_info_class;
c16244
c16244
dd89bb
typedef enum _nt_pty_info_class {
dd89bb
	NT_PTY_BASIC_INFORMATION,
f5c1c6
	NT_PTY_SLOT_INFORMATION,
dd89bb
	NT_PTY_CLIENT_INFORMATION,
dda7a6
	NT_PTY_CONTEXT_INFORMATION,
efc01e
	NT_PTY_INHERIT_INFORMATION,
dda7a6
	NT_PTY_OFD_INFORMATION,
dd89bb
	NT_PTY_INFORMATION_CAP
dd89bb
} nt_pty_info_class;
dd89bb
dd89bb
ccc0f9
typedef enum _nt_tty_log_info_type {
ccc0f9
	NT_TTY_LOG_INFO_BINARY_DATA,
ccc0f9
	NT_TTY_LOG_INFO_STRING_DATA,
ccc0f9
	NT_TTY_LOG_INFO_INTEGER_ARRAY,
ccc0f9
	NT_TTY_LOG_INFO_POINTER_ARRAY,
ccc0f9
	NT_TTY_LOG_INFO_EXCEPTION_RECORD,
49fdf6
	NT_TTY_LOG_INFO_EXCEPTION_ENTRY,
3e4395
	NT_TTY_LOG_INFO_FLOW_ENTRY,
3e4395
	NT_TTY_LOG_INFO_ERROR_ENTRY,
3e4395
	NT_TTY_LOG_INFO_IPC_ENTRY,
3e4395
	NT_TTY_LOG_INFO_SIGNAL_ENTRY,
ccc0f9
	NT_TTY_LOG_INFO_CAP,
ccc0f9
} nt_tty_log_info_type;
ccc0f9
6e70fb
/*************************************************************/
6e70fb
/* log entry data passing, populating loginfo.data[]         */
6e70fb
/*                                                           */
6e70fb
/* + start with structure-based elements;                    */
6e70fb
/* + continue with 8-byte elements;                          */
6e70fb
/* + continue with pointer-size elements                     */
6e70fb
/* + continue with 4-byte elements;                          */
6e70fb
/* + end with null-terminated utf-8 strings                  */
6e70fb
/*                                                           */
6e70fb
/* + use loginfo.meta to indicate which elements are present */
6e70fb
/*************************************************************/
6e70fb
6e70fb
6e70fb
/* log info entry data elements */
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_INTERPRETATION(x) ((x) & 0xff)
6e70fb
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_POINTER_ELEMENT_1 (1 << 12)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_POINTER_ELEMENT_2 (1 << 13)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_POINTER_ELEMENT_3 (1 << 14)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_POINTER_ELEMENT_4 (1 << 15)
6e70fb
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_STRUCT_ELEMENT_1  (1 << 16)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_STRUCT_ELEMENT_2  (1 << 17)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_STRUCT_ELEMENT_3  (1 << 18)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_STRUCT_ELEMENT_4  (1 << 19)
6e70fb
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_UINT64_ELEMENT_1  (1 << 20)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_UINT64_ELEMENT_2  (1 << 21)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_UINT64_ELEMENT_3  (1 << 22)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_UINT64_ELEMENT_4  (1 << 23)
6e70fb
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_UINT32_ELEMENT_1  (1 << 24)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_UINT32_ELEMENT_2  (1 << 25)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_UINT32_ELEMENT_3  (1 << 26)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_UINT32_ELEMENT_4  (1 << 27)
6e70fb
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_STRING_ELEMENT_1  (1 << 28)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_STRING_ELEMENT_2  (1 << 29)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_STRING_ELEMENT_3  (1 << 30)
6e70fb
#define NT_TTY_LOG_INFO_ENTRY_STRING_ELEMENT_4  (1 << 31)
ccc0f9
efc01e
/* client process registration flags */
efc01e
#define NT_TTY_INHERIT_HANDLES 	0x0001
efc01e
efc01e
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_msg_info {
71b1d8
	uintptr_t	opdata;
dd89bb
	uint32_t	opcode;
dd89bb
	int32_t		status;
554a0a
	void *		exarg;
dd89bb
} nt_tty_msg_info;
dd89bb
dd89bb
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_register_info {
dd89bb
	uintptr_t	process_id;
dd89bb
	uintptr_t	thread_id;
dd89bb
	uintptr_t	flags;
dd89bb
	uintptr_t	reserved;
dd89bb
} nt_tty_register_info;
dd89bb
dd89bb
c16244
typedef struct __attr_ptr_size_aligned__ _nt_tty_server_basic_info {
dd89bb
	nt_port_attr	attr;
dd89bb
	intptr_t	pid;
dd89bb
	intptr_t	tid;
c16244
} nt_tty_server_basic_info;
dd89bb
dd89bb
45dcc8
typedef struct __attr_ptr_size_aligned__ _nt_tty_pts_slot_info {
45dcc8
	int32_t		blkidx;
45dcc8
	int32_t		blkpts;
45dcc8
	int32_t		blkcnt;
45dcc8
	int32_t		blkcap;
45dcc8
	uint32_t	ptsmap[32];
45dcc8
} nt_tty_pts_slot_info;
45dcc8
45dcc8
c16244
typedef struct __attr_ptr_size_aligned__ _nt_tty_server_info {
c16244
	nt_tty_server_info_class	info_class;
c16244
	uint32_t			info_length;
c16244
	uintptr_t			info_buffer[];
c16244
} nt_tty_server_info;
c16244
a1e25a
a1e25a
typedef struct __attr_ptr_size_aligned__ _nt_tty_service_info {
a1e25a
	nt_port_attr	attr;
a1e25a
	uint32_t	key;
a1e25a
	uint32_t	id;
a1e25a
} nt_tty_service_info;
a1e25a
a1e25a
e20c3e
typedef struct __attr_ptr_size_aligned__ _nt_tty_service_data {
e20c3e
	uint32_t	meta[4];
e20c3e
	uint32_t	data[50];
e20c3e
} nt_tty_service_data;
e20c3e
e20c3e
1b6aec
typedef struct __attr_ptr_size_aligned__ _nt_tty_section_info {
1b6aec
	nt_port_attr	attr;
1b6aec
	void *		section;
1b6aec
	void *		section_addr;
1b6aec
	size_t		section_size;
1b6aec
} nt_tty_section_info;
1b6aec
1b6aec
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_peer_info {
dd89bb
	uint32_t	opcode;
dd89bb
	uint32_t	flags;
dd89bb
	nt_guid		service;
dd89bb
	nt_port_attr	peer;
dd89bb
} nt_tty_peer_info;
dd89bb
dd89bb
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_sigctl_info {
dd89bb
	void *			hpty;
dd89bb
	nt_guid			guid;
dd89bb
	nt_luid			luid;
dd89bb
	uint32_t		ctlcode;
dd89bb
	int32_t			cccode;
dd89bb
	nt_client_id		cid;
dd89bb
	uintptr_t		ctxarg[4];
dd89bb
	struct tty_termios	terminfo;
dd89bb
	struct tty_winsize	winsize;
dd89bb
	nt_iosb			iosb;
dd89bb
} nt_tty_sigctl_info;
dd89bb
dd89bb
ccc0f9
typedef struct __attr_ptr_size_aligned__ _nt_tty_log_info {
ccc0f9
	int32_t		type;
7969fc
	uint32_t	meta;
49fdf6
	nt_cid		cid;
ccc0f9
	uint32_t	data[0x30];
ccc0f9
} nt_tty_log_info;
ccc0f9
ccc0f9
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_pty_fd_info {
dd89bb
	void *		hpty;
dd89bb
	void *		section;
dd89bb
	void *		section_addr;
dd89bb
	size_t		section_size;
dd89bb
	nt_guid		guid;
dd89bb
	nt_luid		luid;
dd89bb
	uint32_t	access;
dd89bb
	uint32_t	flags;
dd89bb
	uint32_t	share;
dd89bb
	uint32_t	options;
dd89bb
	intptr_t	state;
dd89bb
	void *		hevent[2];
dd89bb
} nt_pty_fd_info;
dd89bb
dd89bb
576364
typedef struct __attr_ptr_size_aligned__ _nt_pty_context_info {
576364
	void *		hpty;
576364
	nt_guid		guid;
576364
	nt_luid		luid;
576364
	uintptr_t	ctxarg[4];
576364
} nt_pty_context_info;
576364
576364
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_pty_io_info {
dd89bb
	void *		hpty;
dd89bb
	void *		hevent;
dd89bb
	void *		reserved;
dd89bb
	void *		apc_routine;
dd89bb
	void *		apc_context;
dd89bb
	nt_iosb *	riosb;
dd89bb
	void *		raddr;
dd89bb
	nt_iosb		iosb;
dd89bb
	off_t		offset;
dd89bb
	size_t		nbytes;
dd89bb
	uint32_t	key;
dd89bb
	uint32_t	npending;
dd89bb
	nt_guid		guid;
dd89bb
	nt_luid		luid;
dd89bb
} nt_pty_io_info;
dd89bb
dd89bb
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_pty_client_info {
dd89bb
	uintptr_t	any[4];
dd89bb
} nt_pty_client_info;
dd89bb
dd89bb
efc01e
typedef struct __attr_ptr_size_aligned__ _nt_pty_inherit_info {
efc01e
	void *		hpty;
efc01e
	nt_guid		guid;
efc01e
	nt_luid		luid;
f2a7d3
	uint32_t	access;
f2a7d3
	uint32_t	flags;
f2a7d3
	uint32_t	share;
f2a7d3
	uint32_t	options;
efc01e
} nt_pty_inherit_info;
efc01e
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_session_info {
dd89bb
	int32_t		pid;
dd89bb
	int32_t		pgid;
dd89bb
	int32_t		sid;
c34b2c
	int32_t		syspid;
dd89bb
} nt_tty_session_info;
dd89bb
edb085
edb085
typedef struct __attr_ptr_size_aligned__ _nt_tty_ipc_info {
edb085
	nt_port_attr	ctrlsvc;
edb085
	uint32_t	ipckeys[6];
edb085
	void *		hevent;
edb085
	void *		apc_routine;
edb085
	void *		apc_context;
edb085
	nt_iosb *	riosb;
edb085
} nt_tty_ipc_info;
edb085
edb085
edb085
typedef struct __attr_ptr_size_aligned__ _nt_tty_sync_info {
edb085
	nt_client_id	cid;
edb085
	nt_port_attr	ipcsvc;
edb085
	uint32_t	ipckeys[6];
edb085
	void *		hevent;
edb085
	void *		apc_routine;
edb085
	void *		apc_context;
edb085
	nt_iosb *	riosb;
edb085
} nt_tty_sync_info;
edb085
edb085
edb085
edb085
typedef struct __attr_ptr_size_aligned__ _nt_tty_transfer_info {
edb085
	nt_client_id	ccid;
edb085
	nt_client_id	tcid;
edb085
	uint32_t	ipckeys[6];
edb085
	void *		hevent;
edb085
	void *		apc_routine;
edb085
	void *		apc_context;
edb085
	nt_iosb *	riosb;
edb085
} nt_tty_transfer_info;
edb085
edb085
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_register_msg {
dd89bb
	nt_port_message			header;
dd89bb
	struct {
dd89bb
		nt_tty_msg_info		ttyinfo;
dd89bb
		nt_tty_register_info	reginfo;
dd89bb
	} data;
dd89bb
} nt_tty_register_msg;
dd89bb
dd89bb
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_server_msg {
dd89bb
	nt_port_message			header;
dd89bb
	struct {
dd89bb
		nt_tty_msg_info		ttyinfo;
dd89bb
		nt_tty_server_info	srvinfo;
dd89bb
	} data;
dd89bb
} nt_tty_server_msg;
dd89bb
dd89bb
a1e25a
typedef struct __attr_ptr_size_aligned__ _nt_tty_service_msg {
a1e25a
	nt_port_message			header;
a1e25a
	struct {
a1e25a
		nt_tty_msg_info		ttyinfo;
a1e25a
		nt_tty_service_info	svcinfo;
a1e25a
	} data;
a1e25a
} nt_tty_service_msg;
a1e25a
a1e25a
1b6aec
typedef struct __attr_ptr_size_aligned__ _nt_tty_section_msg {
1b6aec
	nt_port_message			header;
1b6aec
	struct {
1b6aec
		nt_tty_msg_info		ttyinfo;
1b6aec
		nt_tty_section_info	secinfo;
1b6aec
	} data;
1b6aec
} nt_tty_section_msg;
1b6aec
1b6aec
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_peer_msg {
dd89bb
	nt_port_message			header;
dd89bb
	struct {
dd89bb
		nt_tty_msg_info		ttyinfo;
dd89bb
		nt_tty_peer_info	peerinfo;
dd89bb
	} data;
dd89bb
} nt_tty_peer_msg;
dd89bb
dd89bb
486c11
typedef struct __attr_ptr_size_aligned__ _nt_tty_pid_msg {
486c11
	nt_port_message			header;
486c11
	struct {
486c11
		nt_tty_msg_info		ttyinfo;
486c11
		nt_user_process_info	pidinfo;
486c11
	} data;
486c11
} nt_tty_pid_msg;
486c11
486c11
edb085
typedef struct __attr_ptr_size_aligned__ _nt_tty_ipc_msg {
edb085
	nt_port_message			header;
edb085
	struct {
edb085
		nt_tty_msg_info		ttyinfo;
edb085
		nt_tty_ipc_info		ipcinfo;
edb085
	} data;
edb085
} nt_tty_ipc_msg;
edb085
edb085
edb085
typedef struct __attr_ptr_size_aligned__ _nt_tty_sync_msg {
edb085
	nt_port_message			header;
edb085
	struct {
edb085
		nt_tty_msg_info		ttyinfo;
edb085
		nt_tty_sync_info	syncinfo;
edb085
	} data;
edb085
} nt_tty_sync_msg;
edb085
edb085
edb085
typedef struct __attr_ptr_size_aligned__ _nt_tty_transfer_msg {
edb085
	nt_port_message			header;
edb085
	struct {
edb085
		nt_tty_msg_info		ttyinfo;
edb085
		nt_tty_transfer_info	transferinfo;
edb085
	} data;
edb085
} nt_tty_transfer_msg;
edb085
edb085
ccc0f9
typedef struct __attr_ptr_size_aligned__ _nt_tty_log_msg {
ccc0f9
	nt_port_message			header;
ccc0f9
	struct {
ccc0f9
		nt_tty_msg_info		ttyinfo;
ccc0f9
		nt_tty_log_info		loginfo;
ccc0f9
	} data;
ccc0f9
} nt_tty_log_msg;
ccc0f9
ccc0f9
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_pty_fd_msg {
dd89bb
	nt_port_message			header;
dd89bb
	struct {
dd89bb
		nt_tty_msg_info		ttyinfo;
dd89bb
		nt_pty_fd_info		fdinfo;
dd89bb
	} data;
dd89bb
} nt_pty_fd_msg;
dd89bb
dd89bb
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_pty_io_msg {
dd89bb
	nt_port_message			header;
dd89bb
	struct {
dd89bb
		nt_tty_msg_info		ttyinfo;
dd89bb
		nt_pty_io_info		ioinfo;
dd89bb
	} data;
dd89bb
} nt_pty_io_msg;
dd89bb
dd89bb
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_pty_sigctl_msg {
dd89bb
	nt_port_message			header;
dd89bb
	struct {
dd89bb
		nt_tty_msg_info		ttyinfo;
dd89bb
		nt_tty_sigctl_info	ctlinfo;
dd89bb
	} data;
dd89bb
} nt_pty_sigctl_msg;
dd89bb
dd89bb
4a2e49
typedef struct __attr_ptr_size_aligned__ _nt_sem_info_msg {
4a2e49
	nt_port_message			header;
4a2e49
	struct {
4a2e49
		nt_tty_msg_info		ttyinfo;
4a2e49
		nt_sem_info		seminfo;
4a2e49
	} data;
4a2e49
} nt_sem_info_msg;
4a2e49
4a2e49
a6563a
typedef struct __attr_ptr_size_aligned__ _nt_msq_info_msg {
a6563a
	nt_port_message			header;
a6563a
	struct {
a6563a
		nt_tty_msg_info		ttyinfo;
a6563a
		nt_msq_info		msqinfo;
a6563a
	} data;
a6563a
} nt_msq_info_msg;
a6563a
a6563a
b92a12
typedef struct __attr_ptr_size_aligned__ _nt_afl_info_msg {
b92a12
	nt_port_message			header;
b92a12
	struct {
b92a12
		nt_tty_msg_info		ttyinfo;
b92a12
		nt_afl_info		aflinfo;
b92a12
	} data;
b92a12
} nt_afl_info_msg;
b92a12
b92a12
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_session_msg {
dd89bb
	nt_port_message			header;
dd89bb
	struct {
dd89bb
		nt_tty_msg_info		ttyinfo;
dd89bb
		nt_tty_session_info	sessioninfo;
dd89bb
	} data;
dd89bb
} nt_tty_session_msg;
dd89bb
dd89bb
dd89bb
typedef struct __attr_ptr_size_aligned__ _nt_tty_port_msg {
dd89bb
	nt_port_message			header;
dd89bb
	nt_tty_msg_info			ttyinfo;
dd89bb
	union {
dd89bb
		nt_tty_register_info	reginfo;
dd89bb
		nt_tty_peer_info	peerinfo;
dd89bb
		nt_tty_sigctl_info	ctlinfo;
edb085
		nt_tty_ipc_info		ipcinfo;
edb085
		nt_tty_sync_info	syncinfo;
ccc0f9
		nt_tty_log_info		loginfo;
edb085
		nt_user_process_info	pidinfo;
edb085
		nt_tty_transfer_info	transferinfo;
dd89bb
		nt_pty_fd_info		fdinfo;
dd89bb
		nt_pty_io_info		ioinfo;
dd89bb
		nt_pty_client_info	clientinfo;
dd89bb
		nt_tty_session_info	sessioninfo;
a1e25a
		nt_tty_service_info	svcinfo;
1b6aec
		nt_tty_section_info	secinfo;
e20c3e
		nt_tty_service_data	svcdata;
4a2e49
		nt_sem_info		seminfo;
a6563a
		nt_msq_info		msqinfo;
b92a12
		nt_afl_info		aflinfo;
dd89bb
	};
dd89bb
} nt_tty_port_msg;
dd89bb
dd89bb
dd89bb
__assert_aligned_size(nt_tty_msg_info,		__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_tty_register_info,	__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_tty_peer_info,		__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_tty_sigctl_info,	__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_pty_fd_info,		__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_pty_io_info,		__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_tty_register_msg,	__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_tty_peer_msg,		__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_pty_sigctl_msg,	__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_pty_fd_msg,		__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_pty_io_msg,		__SIZEOF_POINTER__);
dd89bb
__assert_aligned_size(nt_tty_port_msg,		__SIZEOF_POINTER__);
edb085
__assert_aligned_size(nt_tty_ipc_msg,		__SIZEOF_POINTER__);
edb085
__assert_aligned_size(nt_tty_sync_msg,		__SIZEOF_POINTER__);
edb085
__assert_aligned_size(nt_tty_transfer_msg,	__SIZEOF_POINTER__);
dd89bb
dd89bb
dd89bb
/* tty session */
dd89bb
typedef int32_t __stdcall	ntapi_tty_create_session(
dd89bb
	__out	void **			hport,
dd89bb
	__out	nt_port_name *		port_name,
dd89bb
	__in	nt_tty_session_type	type,
e3e5a2
	__in	nt_tty_session_subtype	subtype,
dd89bb
	__in	const nt_guid *		guid		__optional,
1f883a
	__in	wchar16_t *		image_name,
f61917
	__in	void *			htty		__optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall	ntapi_tty_join_session(
dd89bb
	__out	void **			hport,
dd89bb
	__out	nt_port_name *		port_name,
dd89bb
	__in	nt_port_attr *		port_attr,
dd89bb
	__in	nt_tty_session_type	type);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall	ntapi_tty_connect(
dd89bb
	__out	void **			hport,
dd89bb
	__in	wchar16_t *		tty_port_name,
dd89bb
	__in	int32_t			impersonation_level);
dd89bb
dd89bb
029ed1
typedef int32_t __stdcall	ntapi_tty_client_session_disconnect(
029ed1
	__in	void *			hport);
029ed1
029ed1
dd89bb
typedef int32_t __stdcall	ntapi_tty_client_session_query(
dd89bb
	__in	void *			hport,
dd89bb
	__out	nt_tty_session_info *	sessioninfo);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall	ntapi_tty_client_session_set(
dd89bb
	__in	void *			hport,
dd89bb
	__in	nt_tty_session_info *	sessioninfo);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall	ntapi_tty_client_process_register(
dd89bb
	__in	void *			hport,
dd89bb
	__in	uintptr_t		process_id,
dd89bb
	__in	uintptr_t		thread_id,
dd89bb
	__in	uintptr_t		flags,
dd89bb
	__in	nt_large_integer *	reserved);
dd89bb
dd89bb
1b6aec
typedef int32_t __stdcall ntapi_tty_query_information_section(
1b6aec
	__in	void *			hport,
1b6aec
	__out	nt_io_status_block *	iosb,
1b6aec
	__out	nt_tty_section_info *	secinfo,
1b6aec
	__in	const nt_guid *		guid);
1b6aec
1b6aec
dd89bb
typedef int32_t __stdcall ntapi_tty_query_information_server(
dd89bb
	__in	void *			hport,
c16244
	__out	nt_io_status_block *	iosb,
c16244
	__out	void *			tty_info,
c16244
	__in	uint32_t		tty_info_length,
c16244
	__in	int			tty_info_class);
dd89bb
dd89bb
a1e25a
typedef int32_t __stdcall ntapi_tty_query_information_service(
a1e25a
	__in	void *			hport,
a1e25a
	__out	nt_io_status_block *	iosb,
a1e25a
	__out	nt_tty_service_info *	svcinfo,
a1e25a
	__in	const nt_guid *		guid,
a1e25a
	__in	uint32_t		key,
a1e25a
	__in	uint32_t		id);
a1e25a
a1e25a
45dcc8
typedef 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
dd89bb
/* pty api */
dd89bb
typedef struct nt_pty_context nt_pty;
dd89bb
dd89bb
typedef int32_t	__stdcall ntapi_pty_open(
dd89bb
	__in	void *			hport,
dd89bb
	__out	nt_pty **		pty,
dd89bb
	__in	uint32_t		desired_access,
dd89bb
	__in	nt_object_attributes*	obj_attr,
dd89bb
	__out	nt_iosb *		iosb,
dd89bb
	__in	uint32_t		share_access,
dd89bb
	__in	uint32_t		open_options);
dd89bb
dd89bb
47aaf2
typedef int32_t	__stdcall ntapi_pty_open_pair(
47aaf2
	__in	void *			hport,
47aaf2
	__out	nt_pty **		pty,
47aaf2
	__in	uint32_t		desired_access,
47aaf2
	__in	nt_object_attributes*	obj_attr,
47aaf2
	__out	nt_iosb *		iosb,
47aaf2
	__in	uint32_t		share_access,
47aaf2
	__in	uint32_t		open_options);
47aaf2
47aaf2
dd89bb
typedef int32_t	__stdcall ntapi_pty_reopen(
dd89bb
	__in	void *			hport,
dd89bb
	__in	nt_pty *		pty);
dd89bb
dd89bb
efc01e
typedef int32_t	__stdcall ntapi_pty_inherit(
efc01e
	__in	void *			hport,
efc01e
	__out	nt_pty **		pty,
efc01e
	__in 	nt_pty_client_info * 	client_info);
efc01e
efc01e
5ea20e
typedef int32_t	__stdcall ntapi_pty_inherit_runtime_ctty(
5ea20e
	__in	void *			hport,
5ea20e
     __in_out	nt_runtime_data *	rtdata);
5ea20e
5ea20e
dd89bb
typedef int32_t __stdcall ntapi_pty_close(
dd89bb
	__in	nt_pty *		pty);
dd89bb
dd89bb
dd89bb
typedef int32_t	__stdcall ntapi_pty_read(
dd89bb
	__in	nt_pty *		pty,
dd89bb
	__in	void *			hevent		__optional,
dd89bb
	__in	nt_io_apc_routine *	apc_routine	__optional,
dd89bb
	__in	void *			apc_context	__optional,
dd89bb
	__out	nt_iosb *		iosb,
dd89bb
	__out	void *			buffer,
dd89bb
	__in	uint32_t		nbytes,
dd89bb
	__in	nt_large_integer *	offset		__optional,
dd89bb
	__in	uint32_t *		key		__optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_pty_write(
dd89bb
	__in	nt_pty *		pty,
dd89bb
	__in 	void *			hevent		__optional,
dd89bb
	__in	nt_io_apc_routine *	apc_routine	__optional,
dd89bb
	__in	void * 			apc_context	__optional,
dd89bb
	__out	nt_iosb *		iosb,
dd89bb
	__in	void * 			buffer,
dd89bb
	__in	uint32_t		nbytes,
dd89bb
	__in	nt_large_integer *	offset		__optional,
dd89bb
	__in	uint32_t *		key		__optional);
dd89bb
dd89bb
dd89bb
typedef int32_t	__stdcall ntapi_pty_fcntl(
dd89bb
	__in	nt_pty *		pty,
dd89bb
	__in	void *			hevent			__optional,
dd89bb
	__in	nt_io_apc_routine *	apc_routine		__optional,
dd89bb
	__in	void *			apc_context		__optional,
dd89bb
	__out	nt_iosb *		iosb,
dd89bb
	__in	uint32_t		fs_control_code,
dd89bb
	__in	void *			input_buffer		__optional,
dd89bb
	__in	uint32_t		input_buffer_length,
dd89bb
	__out	void *			output_buffer		__optional,
dd89bb
	__in	uint32_t		output_buffer_length);
dd89bb
dd89bb
dd89bb
typedef int32_t	__stdcall ntapi_pty_ioctl(
dd89bb
	__in	nt_pty *		pty,
dd89bb
	__in	void *			hevent			__optional,
dd89bb
	__in	nt_io_apc_routine *	apc_routine		__optional,
dd89bb
	__in	void *			apc_context		__optional,
dd89bb
	__out	nt_iosb *		iosb,
dd89bb
	__in	uint32_t		io_control_code,
dd89bb
	__in	void *			input_buffer		__optional,
dd89bb
	__in	uint32_t		input_buffer_length,
dd89bb
	__out	void *			output_buffer		__optional,
dd89bb
	__in	uint32_t		output_buffer_length);
dd89bb
dd89bb
dd89bb
typedef int32_t	__stdcall ntapi_pty_query(
dd89bb
	__in	nt_pty *		pty,
dd89bb
	__out	nt_io_status_block *	iosb,
dd89bb
	__out	void *			pty_info,
dd89bb
	__in	uint32_t		pty_info_length,
dd89bb
	__in	nt_pty_info_class	pty_info_class);
dd89bb
dd89bb
e62c29
typedef int32_t	__stdcall ntapi_pty_xquery(
e62c29
	__in	void *			hport,
e62c29
	__out	nt_io_status_block *	iosb,
e62c29
	__out	void *			pty_info,
e62c29
	__in	uint32_t		pty_info_length,
e62c29
	__in	nt_pty_info_class	pty_info_class,
e62c29
	__in	nt_pty_client_info *	pty_client_info);
e62c29
e62c29
dd89bb
typedef int32_t	__stdcall ntapi_pty_set(
dd89bb
	__in	nt_pty *		hfile,
dd89bb
	__out	nt_io_status_block *	iosb,
dd89bb
	__in	void *			pty_info,
dd89bb
	__in	uint32_t		pty_info_length,
dd89bb
	__in	nt_pty_info_class	pty_info_class);
dd89bb
dd89bb
dd89bb
typedef int32_t	__stdcall ntapi_pty_cancel(
dd89bb
	__in	nt_pty *		pty,
dd89bb
	__out	nt_iosb *		iosb);
dd89bb
dd89bb
dd89bb
/* peer daemon calls */
dd89bb
typedef 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
dd89bb
#endif