Blame include/ntapi/nt_port.h

dd89bb
#ifndef _NT_PORT_H_
dd89bb
#define _NT_PORT_H_
dd89bb
dd89bb
#include <psxtypes/psxtypes.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'} */
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
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}}
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,
dd89bb
	__in	nt_guid *		guid);
dd89bb
dd89bb
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
dd89bb
typedef void __stdcall	ntapi_tt_port_name_from_attributes(
dd89bb
	__out	nt_port_name *		name,
dd89bb
	__in	nt_port_attr *		attr);
dd89bb
dd89bb
#endif