Thread/Process Termination/Repeaing Rewrite + Fixes
[reactos.git] / reactos / ntoskrnl / include / internal / port.h
1 #ifndef __INCLUDE_INTERNAL_PORT_H
2 #define __INCLUDE_INTERNAL_PORT_H
3
4 typedef struct _EPORT_LISTENER
5 {
6 HANDLE ListenerPid;
7 LIST_ENTRY ListenerListEntry;
8 } EPORT_LISTENER, *PEPORT_LISTENER;
9
10 typedef struct _EPORT
11 {
12 KSPIN_LOCK Lock;
13 KSEMAPHORE Semaphore;
14
15 USHORT Type;
16 USHORT State;
17
18 struct _EPORT * RequestPort;
19 struct _EPORT * OtherPort;
20
21 ULONG QueueLength;
22 LIST_ENTRY QueueListHead;
23
24 ULONG ConnectQueueLength;
25 LIST_ENTRY ConnectQueueListHead;
26
27 ULONG MaxDataLength;
28 ULONG MaxConnectInfoLength;
29 ULONG MaxPoolUsage; /* size of NP zone */
30 } EPORT, * PEPORT;
31
32 typedef struct _EPORT_CONNECT_REQUEST_MESSAGE
33 {
34 LPC_MESSAGE MessageHeader;
35 PEPROCESS ConnectingProcess;
36 struct _SECTION_OBJECT* SendSectionObject;
37 LARGE_INTEGER SendSectionOffset;
38 ULONG SendViewSize;
39 ULONG ConnectDataLength;
40 UCHAR ConnectData[0];
41 } EPORT_CONNECT_REQUEST_MESSAGE, *PEPORT_CONNECT_REQUEST_MESSAGE;
42
43 typedef struct _EPORT_CONNECT_REPLY_MESSAGE
44 {
45 LPC_MESSAGE MessageHeader;
46 PVOID SendServerViewBase;
47 ULONG ReceiveClientViewSize;
48 PVOID ReceiveClientViewBase;
49 ULONG MaximumMessageSize;
50 ULONG ConnectDataLength;
51 UCHAR ConnectData[0];
52 } EPORT_CONNECT_REPLY_MESSAGE, *PEPORT_CONNECT_REPLY_MESSAGE;
53
54 typedef struct _TERMINATION_PORT {
55 LIST_ENTRY Links;
56 PVOID Port;
57 } TERMINATION_PORT, *PTERMINATION_PORT;
58
59 NTSTATUS STDCALL
60 LpcRequestPort (PEPORT Port,
61 PLPC_MESSAGE LpcMessage);
62 NTSTATUS
63 STDCALL
64 LpcSendTerminationPort (PEPORT Port,
65 LARGE_INTEGER CreationTime);
66
67 /* EPORT.Type */
68
69 #define EPORT_TYPE_SERVER_RQST_PORT (0)
70 #define EPORT_TYPE_SERVER_COMM_PORT (1)
71 #define EPORT_TYPE_CLIENT_COMM_PORT (2)
72
73 /* EPORT.State */
74
75 #define EPORT_INACTIVE (0)
76 #define EPORT_WAIT_FOR_CONNECT (1)
77 #define EPORT_WAIT_FOR_ACCEPT (2)
78 #define EPORT_WAIT_FOR_COMPLETE_SRV (3)
79 #define EPORT_WAIT_FOR_COMPLETE_CLT (4)
80 #define EPORT_CONNECTED_CLIENT (5)
81 #define EPORT_CONNECTED_SERVER (6)
82 #define EPORT_DISCONNECTED (7)
83
84 /* Pool Tags */
85
86 #define TAG_LPC_MESSAGE TAG('L', 'p', 'c', 'M')
87 #define TAG_LPC_ZONE TAG('L', 'p', 'c', 'Z')
88
89
90 typedef struct _QUEUEDMESSAGE
91 {
92 PEPORT Sender;
93 LIST_ENTRY QueueListEntry;
94 LPC_MESSAGE Message;
95 UCHAR MessageData [MAX_MESSAGE_DATA];
96 } QUEUEDMESSAGE, *PQUEUEDMESSAGE;
97
98 /* Code in ntoskrnl/lpc/close.h */
99
100 VOID STDCALL
101 NiClosePort (PVOID ObjectBody,
102 ULONG HandleCount);
103 VOID STDCALL
104 NiDeletePort (IN PVOID ObjectBody);
105
106 /* Code in ntoskrnl/lpc/queue.c */
107
108 VOID STDCALL
109 EiEnqueueConnectMessagePort (IN OUT PEPORT Port,
110 IN PQUEUEDMESSAGE Message);
111 VOID STDCALL
112 EiEnqueueMessagePort (IN OUT PEPORT Port,
113 IN PQUEUEDMESSAGE Message);
114 VOID STDCALL
115 EiEnqueueMessageAtHeadPort (IN OUT PEPORT Port,
116 IN PQUEUEDMESSAGE Message);
117 PQUEUEDMESSAGE
118 STDCALL
119 EiDequeueConnectMessagePort (IN OUT PEPORT Port);
120 PQUEUEDMESSAGE STDCALL
121 EiDequeueMessagePort (IN OUT PEPORT Port);
122
123 /* Code in ntoskrnl/lpc/create.c */
124
125 NTSTATUS STDCALL
126 NiCreatePort (PVOID ObjectBody,
127 PVOID Parent,
128 PWSTR RemainingPath,
129 POBJECT_ATTRIBUTES ObjectAttributes);
130
131 /* Code in ntoskrnl/lpc/port.c */
132
133 NTSTATUS STDCALL
134 LpcpInitializePort (IN OUT PEPORT Port,
135 IN USHORT Type,
136 IN PEPORT Parent OPTIONAL);
137 NTSTATUS
138 LpcpInitSystem (VOID);
139
140 extern POBJECT_TYPE LpcPortObjectType;
141 extern ULONG LpcpNextMessageId;
142 extern FAST_MUTEX LpcpLock;
143
144 /* Code in ntoskrnl/lpc/reply.c */
145
146 NTSTATUS STDCALL
147 EiReplyOrRequestPort (IN PEPORT Port,
148 IN PLPC_MESSAGE LpcReply,
149 IN ULONG MessageType,
150 IN PEPORT Sender);
151
152
153 #endif /* __INCLUDE_INTERNAL_PORT_H */