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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
#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"
/* 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,
/* process registration */
NT_TTY_CLIENT_PROCESS_REGISTER,
NT_TTY_CLIENT_PROCESS_UNREGISTER,
/* session information */
NT_TTY_QUERY_INFORMATION_SERVER,
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,
/* 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,
/* 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_PRIVATE
} nt_tty_session_type;
typedef enum _nt_tty_info_class {
NT_TTY_SESSION_INFORMATION,
NT_TTY_INFORMATION_CAP
} nt_tty_info_class;
typedef enum _nt_pty_info_class {
NT_PTY_BASIC_INFORMATION,
NT_PTY_CLIENT_INFORMATION,
NT_PTY_INHERIT_INFORMATION,
NT_PTY_INFORMATION_CAP
} nt_pty_info_class;
/* client process registration flags */
#define NT_TTY_INHERIT_HANDLES 0x0001
typedef struct __attr_ptr_size_aligned__ _nt_tty_msg_info {
uintptr_t msg_id;
uint32_t opcode;
int32_t status;
void * reserved;
} 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_info {
nt_port_attr attr;
intptr_t pid;
intptr_t tid;
} nt_tty_server_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_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_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;
union {
struct {
uint32_t access;
uint32_t flags;
uint32_t share;
uint32_t options;
};
uintptr_t any[4];
};
} 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_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_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_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_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_pty_fd_info fdinfo;
nt_pty_io_info ioinfo;
nt_pty_client_info clientinfo;
nt_tty_session_info sessioninfo;
};
} 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__);
/* 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 const nt_guid * guid __optional,
__in wchar16_t * image_name __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_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_server(
__in void * hport,
__out nt_tty_server_info * srvinfo);
/* 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_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_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
|