summaryrefslogtreecommitdiffhomepage
path: root/src/vmount/ntapi_vms_client_connect.c
blob: 364d4d10187f034c1e6c7f55cad66896b7074e76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/********************************************************/
/*  ntapi: Native API core library                      */
/*  Copyright (C) 2013,2014,2015  Z. Gilboa             */
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
/********************************************************/

#include <psxtypes/psxtypes.h>
#include <ntapi/nt_port.h>
#include <ntapi/nt_tty.h>
#include <ntapi/nt_vmount.h>
#include <ntapi/ntapi.h>
#include "ntapi_impl.h"


static void __vms_port_name_from_server_info(
	__out	nt_port_name *		vms_port_name,
	__in	nt_tty_vms_info *	vmsinfo)
{
	nt_port_attr	port_attr;

	port_attr.type		= NT_PORT_TYPE_VMOUNT;
	port_attr.subtype	= NT_PORT_SUBTYPE_DEFAULT;

	__ntapi->tt_aligned_block_memcpy(
		(uintptr_t *)&port_attr.keys,
		(uintptr_t *)&vmsinfo->vms_keys,
		sizeof(nt_port_keys));

	__ntapi->tt_port_guid_from_type(
		&port_attr.guid,
		port_attr.type,
		port_attr.subtype);

	__ntapi->tt_port_name_from_attributes(
		vms_port_name,
		&port_attr);
}


int32_t __stdcall __ntapi_vms_client_connect(
	__out	void **			hvms,
	__in	nt_tty_vms_info *	vmsinfo)
{
	int32_t			status;
	nt_port_name		vms_port_name;

	nt_unicode_string	name;
	nt_sqos			sqos;
	nt_oa			oa;

	/* vmount daemon port name */
	__vms_port_name_from_server_info(
		&vms_port_name,
		vmsinfo);

	/* port name init */
	name.buffer = (wchar16_t *)&vms_port_name;
	name.maxlen = 0;
	name.strlen = (uint16_t)(size_t)(&((nt_port_name *)0)->null_termination);

	/* init security structure */
	sqos.length 			= sizeof(sqos);
	sqos.impersonation_level	= NT_SECURITY_IMPERSONATION;
	sqos.context_tracking_mode	= NT_SECURITY_TRACKING_DYNAMIC;
	sqos.effective_only		= 1;

	/* init the port's object attributes */
	oa.len		= sizeof(oa);
	oa.root_dir	= (void *)0;
	oa.obj_name	= &name;
	oa.obj_attr	= 0;
	oa.sec_desc	= (nt_security_descriptor *)0;
	oa.sec_qos	= &sqos;

	status = __ntapi->zw_connect_port(
		hvms,
		&name,
		&sqos,
		(nt_port_section_write *)0,
		(nt_port_section_read *)0,
		(uint32_t *)0,
		(void *)0,
		(uint32_t *)0);

	return status;
}