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
|
/********************************************************/
/* ntapi: Native API core library */
/* Copyright (C) 2013--2021 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
/********************************************************/
#include <psxtypes/psxtypes.h>
#include <ntapi/nt_object.h>
#include <ntapi/nt_file.h>
#include <ntapi/nt_socket.h>
#include <ntapi/ntapi.h>
#include "ntapi_impl.h"
typedef struct _nt_afd_server_accept_info {
uint32_t sequence;
uint32_t unknown;
uint32_t service_flags;
char sa_data[14];
} nt_afd_server_accept_info;
typedef struct __addr_memcpy {
uint16_t d0;
uint16_t d1;
uint16_t d2;
uint16_t d3;
uint16_t d4;
uint16_t d5;
uint16_t d6;
uint16_t d7;
} _addr_memcpy;
int32_t __cdecl __ntapi_sc_server_accept_connection_v1(
__in nt_socket * hssocket,
__out nt_afd_accept_info * accept_info,
__out nt_iosb volatile * iosb __optional)
{
nt_iosb volatile siosb;
nt_afd_server_accept_info accept_info_buffer;
_addr_memcpy * asrc;
_addr_memcpy * adst;
iosb = iosb ? iosb : &siosb;
hssocket->iostatus = __ntapi->zw_device_io_control_file(
hssocket->hsocket,
hssocket->hevent,
0,
0,
iosb,
NT_AFD_IOCTL_ACCEPT,
0,
0,
&accept_info_buffer,
sizeof(accept_info_buffer));
if (hssocket->iostatus && (hssocket->ntflags & __NT_FILE_SYNC_IO))
__ntapi->sc_wait(hssocket,iosb,&hssocket->timeout);
if (hssocket->iostatus)
return hssocket->iostatus;
accept_info->sequence = accept_info_buffer.sequence;
accept_info->addr.sa_addr_in4.sa_family = hssocket->domain;
asrc = (_addr_memcpy *)&(accept_info_buffer.sa_data);
adst = (_addr_memcpy *)&(accept_info->addr);
adst->d1 = asrc->d0;
adst->d2 = asrc->d1;
adst->d3 = asrc->d2;
adst->d4 = asrc->d3;
adst->d5 = asrc->d4;
adst->d6 = asrc->d5;
adst->d7 = asrc->d6;
return hssocket->iostatus;
}
|