Blame include/ntapi/nt_port.h

dd89bb
#ifndef _NT_PORT_H_
dd89bb
#define _NT_PORT_H_
dd89bb
414ad3
#include "nt_abi.h"
dd89bb
#include "nt_object.h"
dd89bb
#include "nt_process.h"
dd89bb
dd89bb
typedef enum _nt_lpc_type {
dd89bb
	NT_LPC_NEW_MESSAGE		= 0,
dd89bb
	NT_LPC_REQUEST			= 1,
dd89bb
	NT_LPC_REPLY			= 2,
dd89bb
	NT_LPC_DATAGRAM			= 3,
dd89bb
	NT_LPC_LOST_REPLY		= 4,
dd89bb
	NT_LPC_PORT_CLOSED		= 5,
dd89bb
	NT_LPC_CLIENT_DIED		= 6,
dd89bb
	NT_LPC_EXCEPTION		= 7,
dd89bb
	NT_LPC_DEBUG_EVENT		= 8,
dd89bb
	NT_LPC_ERROR_EVENT		= 9,
dd89bb
	NT_LPC_CONNECTION_REQUEST	= 10,
dd89bb
	NT_ALPC_REQUEST			= 0x2000 | NT_LPC_REQUEST,
dd89bb
	NT_ALPC_CONNECTION_REQUEST	= 0x2000 | NT_LPC_CONNECTION_REQUEST,
dd89bb
} nt_lpc_type;
dd89bb
dd89bb
dd89bb
typedef enum _nt_port_info_class {
dd89bb
	NT_PORT_BASIC_INFORMATION
dd89bb
} nt_port_info_class;
dd89bb
dd89bb
dd89bb
/* friendly port types */
dd89bb
typedef enum _nt_port_type {
dd89bb
	NT_PORT_TYPE_DEFAULT,	/* {'s','v','c','a','n','y'} */
dd89bb
	NT_PORT_TYPE_SUBSYSTEM,	/* {'n','t','c','t','t','y'} */
dd89bb
	NT_PORT_TYPE_VMOUNT,	/* {'v','m','o','u','n','t'} */
dd89bb
	NT_PORT_TYPE_DAEMON,	/* {'d','a','e','m','o','n'} */
20527e
	NT_PORT_TYPE_BRIDGE,	/* {'b','r','i','d','g','e'} */
41d417
	NT_PORT_TYPE_NTPROC,	/* {'n','t','p','r','o','c'} */
4a2e49
	NT_PORT_TYPE_SEMCTL,	/* {'s','e','m','c','t','l'} */
4a2e49
	NT_PORT_TYPE_SEMSVC,	/* {'s','e','m','s','v','c'} */
a6563a
	NT_PORT_TYPE_MSQCTL,	/* {'m','s','q','c','t','l'} */
a6563a
	NT_PORT_TYPE_MSQSVC,	/* {'m','s','q','s','v','c'} */
b92a12
	NT_PORT_TYPE_AFLCTL,	/* {'a','f','l','c','t','l'} */
b92a12
	NT_PORT_TYPE_AFLSVC,	/* {'a','f','l','s','v','c'} */
dd89bb
	NT_PORT_TYPE_CAP
dd89bb
} nt_port_type;
dd89bb
dd89bb
dd89bb
typedef enum _nt_port_subtype {
dd89bb
	NT_PORT_SUBTYPE_DEFAULT,
dd89bb
	NT_PORT_SUBTYPE_PRIVATE,
dd89bb
	NT_PORT_SUBTYPE_CAP
dd89bb
} nt_port_subtype;
dd89bb
dd89bb
498a44
/* port access bits */
498a44
#define NT_PORT_CONNECT			0x00000001
498a44
#define NT_STANDARD_RIGHTS_REQUIRED	0x000F0000
498a44
#define NT_PORT_ALL_ACCESS		NT_PORT_CONNECT | NT_SEC_STANDARD_RIGHTS_ALL
498a44
498a44
dd89bb
/* friendly port guids */
dd89bb
#define NT_PORT_GUID_DEFAULT	{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
dd89bb
#define NT_PORT_GUID_SUBSYSTEM	{0xce7f8d40,0x81cd,0x41c6,{0xa4,0xb7,0xb8,0x35,0x67,0xdf,0x15,0xd9}}
dd89bb
#define NT_PORT_GUID_VMOUNT	{0x893d63d2,0x23e8,0x4caa,{0xa8,0x41,0x7f,0x6e,0x77,0x6b,0xd5,0x70}}
dd89bb
#define NT_PORT_GUID_DAEMON	{0xcf765d9e,0x6bd8,0x4a8d,{0x8a,0x21,0x17,0x34,0xcd,0x3a,0x8d,0xa7}}
20527e
#define NT_PORT_GUID_BRIDGE	{0xf5e259cc,0x8bab,0x4c1f,{0x9b,0xf9,0xa8,0xad,0x5a,0xd1,0x34,0xf6}}
41d417
#define NT_PORT_GUID_NTPROC	{0xd7f3f3a5,0x3e82,0x4f3e,{0x9d,0x6c,0x36,0x18,0xde,0xfa,0xc6,0x69}}
4a2e49
#define NT_PORT_GUID_SEMCTL	{0x7850be42,0x7eef,0x4c3d,{0xa7,0x05,0xa4,0xd8,0x47,0x3f,0x67,0x56}}
4a2e49
#define NT_PORT_GUID_SEMSVC	{0xa50f4380,0x854a,0x4260,{0x9d,0x8d,0xc2,0xc2,0xa1,0x16,0xde,0xf3}}
a6563a
#define NT_PORT_GUID_MSQCTL	{0xd2a8c20a,0x0e4b,0x4a7b,{0xb2,0x3a,0x86,0xa4,0x3b,0x87,0x9a,0x26}}
a6563a
#define NT_PORT_GUID_MSQSVC	{0x3e443cd7,0xdd08,0x4133,{0x9c,0x92,0x02,0x5d,0x9e,0xbd,0x3a,0xcd}}
b92a12
#define NT_PORT_GUID_AFLCTL	{0xb76ce06d,0x60c6,0x4404,{0xa8,0x31,0xc1,0x82,0xea,0xb8,0x1d,0xa2}}
b92a12
#define NT_PORT_GUID_AFLSVC	{0xdb346154,0xa096,0x450d,{0x80,0xb7,0x33,0x97,0x73,0xde,0xf4,0xbd}}
a6563a
dd89bb
dd89bb
/* lpc messages */
dd89bb
#define NT_LPC_REFUSE_CONNECTION	0x0000
dd89bb
#define NT_LPC_ACCEPT_CONNECTION	0x0001
dd89bb
#define NT_LPC_MAX_MSG_DATA_SIZE	0x0104
dd89bb
dd89bb
dd89bb
typedef struct _nt_port_basic_information {
dd89bb
	void *		dummy_invalid;
dd89bb
} nt_port_basic_information;
dd89bb
dd89bb
dd89bb
typedef struct _nt_port_message {
dd89bb
	uint16_t 	data_size;
dd89bb
	uint16_t 	msg_size;
dd89bb
	uint16_t 	msg_type;
dd89bb
	uint16_t 	virtual_ranges_offset;
dd89bb
	nt_client_id	client_id;
dd89bb
	uint32_t	msg_id;
dd89bb
	size_t		section_size;
dd89bb
} nt_port_message;
dd89bb
dd89bb
dd89bb
/* csrss port message structure: new process, first thread */
dd89bb
typedef struct _nt_port_message_csrss_process {
dd89bb
	nt_port_message		header;
dd89bb
	uintptr_t		unknown_1st;
dd89bb
	uint32_t		opcode;
dd89bb
	int32_t			status;
dd89bb
	uintptr_t		unknown_2nd;
dd89bb
	void *			hprocess;
dd89bb
	void *			hthread;
dd89bb
	uintptr_t		unique_process_id;
dd89bb
	uintptr_t		unique_thread_id;
dd89bb
	void *			reserved[8];
dd89bb
} nt_port_message_csrss_process;
dd89bb
dd89bb
/* csrss port message structure: existing process, new thread */
dd89bb
typedef struct _nt_port_message_csrss_thread {
dd89bb
	nt_port_message		header;
dd89bb
	uintptr_t		unknown_1st;
dd89bb
	uint32_t		opcode;
dd89bb
	int32_t			status;
dd89bb
	uintptr_t		unknown_2nd;
dd89bb
	void *			hthread;
dd89bb
	uintptr_t		unique_process_id;
dd89bb
	uintptr_t		unique_thread_id;
dd89bb
	void *			reserved[8];
dd89bb
} nt_port_message_csrss_thread;
dd89bb
dd89bb
dd89bb
typedef struct _nt_port_section_write {
dd89bb
	uint32_t	length;
dd89bb
	void * 		hsection;
dd89bb
	uint32_t	offset;
dd89bb
	size_t		view_size;
dd89bb
	void *		view_base;
dd89bb
	void *		target_vew_base;
dd89bb
} nt_port_section_write;
dd89bb
dd89bb
dd89bb
typedef struct _nt_port_section_read {
dd89bb
	uint32_t	length;
dd89bb
	size_t		view_size;
dd89bb
	void *		view_base;
dd89bb
} nt_port_section_read;
dd89bb
dd89bb
dd89bb
/* attributes of a friendly port */
dd89bb
typedef struct _nt_port_keys {
dd89bb
	uint32_t	reserved;
dd89bb
	uint32_t	key[6];
dd89bb
	uint32_t	padding;
dd89bb
} nt_port_keys;
dd89bb
dd89bb
typedef struct _nt_port_attr {
dd89bb
	nt_guid		guid;
dd89bb
	nt_port_type	type;
dd89bb
	nt_port_subtype	subtype;
dd89bb
	int32_t		ver_major;
dd89bb
	int32_t		ver_minor;
dd89bb
	uint32_t	options;
dd89bb
	uint32_t	flags;
dd89bb
	nt_port_keys	keys;
dd89bb
} nt_port_attr;
dd89bb
dd89bb
dd89bb
/* guid component of a friendly port name */
dd89bb
typedef struct _nt_port_guid {
dd89bb
	wchar16_t	uscore_guid;
dd89bb
	wchar16_t	port_guid[36];
dd89bb
	wchar16_t	uscore_keys;
dd89bb
} nt_port_guid;
dd89bb
dd89bb
/* keys component of a friendly port name */
dd89bb
typedef struct _nt_port_name_keys {
dd89bb
	wchar16_t	key_1st[8];
dd89bb
	wchar16_t	uscore_1st;
dd89bb
	wchar16_t	key_2nd[8];
dd89bb
	wchar16_t	uscore_2nd;
dd89bb
	wchar16_t	key_3rd[8];
dd89bb
	wchar16_t	uscore_3rd;
dd89bb
	wchar16_t	key_4th[8];
dd89bb
	wchar16_t	uscore_4th;
dd89bb
	wchar16_t	key_5th[8];
dd89bb
	wchar16_t	uscore_5th;
dd89bb
	wchar16_t	key_6th[8];
dd89bb
} nt_port_name_keys;
dd89bb
dd89bb
dd89bb
/* friendly port name */
dd89bb
typedef struct _nt_port_name {
dd89bb
	wchar16_t		base_named_objects[17];
dd89bb
	wchar16_t		backslash;
dd89bb
	wchar16_t		svc_prefix[6];
dd89bb
	nt_port_guid		port_guid;
dd89bb
	nt_port_name_keys	port_name_keys;
dd89bb
	wchar16_t 		null_termination;
dd89bb
} nt_port_name;
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_create_port(
dd89bb
	__out		void **			hport,
dd89bb
	__in 	 	nt_object_attributes *	obj_attr,
dd89bb
	__out	 	uint32_t		max_data_size,
dd89bb
	__out	 	uint32_t		max_msg_size,
dd89bb
	__in_out 	uint32_t		reserved);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_create_waitable_port(
dd89bb
	__out		void **			hport,
dd89bb
	__in 	 	nt_object_attributes *	obj_attr,
dd89bb
	__out	 	uint32_t		max_data_size,
dd89bb
	__out	 	uint32_t		max_msg_size,
dd89bb
	__in_out 	uint32_t		reserved);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_connect_port(
dd89bb
	__out 	 	void **					hport,
dd89bb
	__in 	 	nt_unicode_string *			port_name,
dd89bb
	__in 	 	nt_security_quality_of_service *	sec_qos,
dd89bb
	__in_out 	nt_port_section_write *			write_section	__optional,
dd89bb
	__in_out 	nt_port_section_read *			read_section	__optional,
dd89bb
	__out	 	uint32_t *				max_msg_size	__optional,
dd89bb
	__in_out 	void *					msg_data	__optional,
dd89bb
	__in_out 	uint32_t *				msg_data_length __optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_secure_connect_port(
dd89bb
	__out 	 	void **					hport,
dd89bb
	__in 	 	nt_unicode_string *			port_name,
dd89bb
	__in 	 	nt_security_quality_of_service *	sec_qos,
dd89bb
	__in_out 	nt_port_section_write *			write_section	__optional,
dd89bb
	__in		nt_sid *				server_dis	__optional,
dd89bb
	__in_out 	nt_port_section_read *			read_section	__optional,
dd89bb
	__out	 	uint32_t *				max_msg_size	__optional,
dd89bb
	__in_out 	void *					msg_data	__optional,
dd89bb
	__in_out 	uint32_t *				msg_data_length __optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_listen_port(
dd89bb
	__in 	 void *			hport,
dd89bb
	__in 	 nt_port_message *	port_message);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_accept_connect_port(
dd89bb
	__out 	void **			hport,
dd89bb
	__in	intptr_t		port_id,
dd89bb
	__in 	nt_port_message *	port_message,
dd89bb
	__in	int32_t			response,
dd89bb
	__out	nt_port_section_write *	write_section	__optional,
dd89bb
	__out	nt_port_section_read *	read_section	__optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_complete_connect_port(
dd89bb
	__in 	void *	hport);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_request_port(
dd89bb
	__in 	 void *		hport,
dd89bb
	__in 	 void *		request_msg);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_request_wait_reply_port(
dd89bb
	__in 	 void *		hport,
dd89bb
	__in 	 void *		request_msg,
dd89bb
	__out 	 void *		reply_msg);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_reply_port(
dd89bb
	__in 	 void *			hport,
dd89bb
	__in 	nt_port_message *	reply_message);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_reply_wait_reply_port(
dd89bb
	__in 	 	void *			hport,
dd89bb
	__in_out 	nt_port_message *	reply_message);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_reply_wait_receive_port(
dd89bb
	__in	void *			hport,
dd89bb
	__out	intptr_t *		port_id		__optional,
dd89bb
	__in	nt_port_message *	reply_message	__optional,
dd89bb
	__out	nt_port_message *	receive_message);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_reply_wait_receive_port_ex(
dd89bb
	__in	void *			hport,
dd89bb
	__out	intptr_t *		port_id		__optional,
dd89bb
	__in	nt_port_message *	reply_message	__optional,
dd89bb
	__out	nt_port_message *	receive_message,
dd89bb
	__in	nt_large_integer *	timeout);
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_read_request_data(
dd89bb
	__in	void *			hport,
dd89bb
	__in	nt_port_message *	message,
dd89bb
	__in	uint32_t		index,
dd89bb
	__out	void *			buffer,
dd89bb
	__in	size_t			buffer_length,
dd89bb
	__out	size_t *		returned_length	__optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_write_request_data(
dd89bb
	__in	void *			hport,
dd89bb
	__in	nt_port_message *	message,
dd89bb
	__in	uint32_t		index,
dd89bb
	__in	void *			buffer,
dd89bb
	__in	size_t			buffer_length,
dd89bb
	__out	size_t *		returned_length	__optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_query_information_port(
dd89bb
	__in	void *			hport,
dd89bb
	__in	nt_port_info_class	port_info_class,
dd89bb
	__out	void *			port_info,
dd89bb
	__in	size_t			port_info_length,
dd89bb
	__out	size_t *		returned_length	__optional);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_zw_impersonate_client_of_port(
dd89bb
	__in	void *			hport,
dd89bb
	__in	nt_port_message *	message);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_csr_client_call_server(
dd89bb
	__in	void *		msg_csrss,
dd89bb
	__in	void *		msg_unknown,
dd89bb
	__in	uint32_t	msg_opcode,
dd89bb
	__in	uint32_t	msg_size);
dd89bb
dd89bb
dd89bb
typedef void * __cdecl ntapi_csr_port_handle(int32_t * pstatus);
dd89bb
dd89bb
dd89bb
/* extensions */
dd89bb
typedef int32_t __stdcall ntapi_tt_port_guid_from_type(
dd89bb
	__out	nt_guid *		guid,
dd89bb
	__in	nt_port_type		type,
dd89bb
	__in	nt_port_subtype		subtype);
dd89bb
dd89bb
dd89bb
typedef int32_t __stdcall ntapi_tt_port_type_from_guid(
dd89bb
	__out	nt_port_type *		type,
dd89bb
	__out	nt_port_subtype *	subtype,
ae515f
	__in	const nt_guid *		guid);
dd89bb
dd89bb
94b7f5
typedef int32_t __stdcall ntapi_tt_port_prefix_from_type(
94b7f5
	__out	wchar16_t		(*prefix)[6],
94b7f5
	__in	nt_port_type		type,
94b7f5
	__in	nt_port_subtype		subtype);
94b7f5
94b7f5
dd89bb
typedef int32_t __stdcall	ntapi_tt_port_generate_keys(
dd89bb
	__out	nt_port_keys *		keys);
dd89bb
dd89bb
dd89bb
typedef void __stdcall	ntapi_tt_port_format_keys(
dd89bb
	__in	nt_port_keys *		keys,
dd89bb
	__out	nt_port_name_keys *	name_keys);
dd89bb
dd89bb
6d5726
typedef void __stdcall	ntapi_tt_port_name_from_attr(
dd89bb
	__out	nt_port_name *		name,
dd89bb
	__in	nt_port_attr *		attr);
dd89bb
d9d178
d9d178
typedef int32_t __stdcall	ntapi_tt_port_attr_from_name(
d9d178
	__out	nt_port_attr *		attr,
d9d178
	__in	const nt_port_name *	name);
d9d178
d9d178
d9d178
typedef int32_t __stdcall	ntapi_tt_port_attr_from_string(
d9d178
	__out	nt_port_attr *		attr,
d9d178
	__in	const nt_unicode_string*str);
d9d178
d9d178
d9d178
typedef int32_t __stdcall	ntapi_tt_port_attr_from_symlink(
d9d178
	__out	nt_port_attr *		attr,
d9d178
	__in	void *			symlink);
d9d178
dd89bb
#endif