aboutsummaryrefslogtreecommitdiff
path: root/ksocket/ksocket.h
blob: e44035bd7a1d0c3e5ca7822f044053b13e1d45d2 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef KSOCKET_H
#define KSOCKET_H 1

#ifdef BUILD_USERMODE
#error                                                                         \
    "This file should only be included if building for kernel mode! Include <ksocket/ksocket.hpp> wrapper instead."
#endif

#include <ksocket/wsk.h>
#include <ntddk.h>

#define STATUS_UNSUPPORTED_WINDOWS_VERSION                                     \
  (STATUS_SEVERITY_ERROR | (1 << 29) | (1 << 16) | 1)

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _KSOCKET KSOCKET, *PKSOCKET;

NTSTATUS
NTAPI
KsInitialize(VOID);

VOID NTAPI KsDestroy(VOID);

NTSTATUS
NTAPI
KsGetAddrInfo(_In_ PUNICODE_STRING NodeName, _In_ PUNICODE_STRING ServiceName,
              _In_ PADDRINFOEXW Hints, _Out_ PADDRINFOEXW *Result);

VOID NTAPI KsFreeAddrInfo(_In_ PADDRINFOEXW AddrInfo);

NTSTATUS
NTAPI
KsCreateSocket(_Out_ PKSOCKET *Socket, _In_ ADDRESS_FAMILY AddressFamily,
               _In_ USHORT SocketType, _In_ ULONG Protocol, _In_ ULONG Flags);

NTSTATUS
NTAPI
KsCreateConnectionSocket(_Out_ PKSOCKET *Socket,
                         _In_ ADDRESS_FAMILY AddressFamily,
                         _In_ USHORT SocketType, _In_ ULONG Protocol);

NTSTATUS
NTAPI
KsCreateListenSocket(_Out_ PKSOCKET *Socket, _In_ ADDRESS_FAMILY AddressFamily,
                     _In_ USHORT SocketType, _In_ ULONG Protocol);

NTSTATUS
NTAPI
KsCreateDatagramSocket(_Out_ PKSOCKET *Socket,
                       _In_ ADDRESS_FAMILY AddressFamily,
                       _In_ USHORT SocketType, _In_ ULONG Protocol);

NTSTATUS
NTAPI
KsCloseSocket(_In_ PKSOCKET Socket);

NTSTATUS
NTAPI
KsBind(_In_ PKSOCKET Socket, _In_ PSOCKADDR LocalAddress);

NTSTATUS
NTAPI
KsAccept(_In_ PKSOCKET Socket, _Out_ PKSOCKET *NewSocket,
         _Out_opt_ PSOCKADDR LocalAddress, _Out_opt_ PSOCKADDR RemoteAddress);

NTSTATUS
NTAPI
KsConnect(_In_ PKSOCKET Socket, _In_ PSOCKADDR RemoteAddress);

NTSTATUS
NTAPI
KsSendRecv(_In_ PKSOCKET Socket, _In_ PVOID Buffer, _Inout_ PULONG Length,
           _In_ ULONG Flags, _In_ BOOLEAN Send);

NTSTATUS
NTAPI
KsSendRecvUdp(_In_ PKSOCKET Socket, _In_ PVOID Buffer, _Inout_ PULONG Length,
              _In_ ULONG Flags, _In_ PSOCKADDR RemoteAddress,
              _In_ BOOLEAN Send);

NTSTATUS
NTAPI
KsSend(_In_ PKSOCKET Socket, _In_ PVOID Buffer, _Inout_ PULONG Length,
       _In_ ULONG Flags);

NTSTATUS
NTAPI
KsRecv(_In_ PKSOCKET Socket, _In_ PVOID Buffer, _Inout_ PULONG Length,
       _In_ ULONG Flags);

NTSTATUS
NTAPI
KsSendTo(_In_ PKSOCKET Socket, _In_ PVOID Buffer, _Inout_ PULONG Length,
         _In_ ULONG Flags, _In_ PSOCKADDR RemoteAddress);

NTSTATUS
NTAPI
KsRecvFrom(_In_ PKSOCKET Socket, _In_ PVOID Buffer, _Inout_ PULONG Length,
           _In_ ULONG Flags, _In_ PSOCKADDR RemoteAddress);

#ifdef __cplusplus
}
#endif

#endif