- Update NDK to remove zwfuncs.h and place the native functions in their respective...
[reactos.git] / reactos / include / ndk / lpctypes.h
1 /*++ NDK Version: 0095
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 lpctypes.h
8
9 Abstract:
10
11 Type definitions for the Loader.
12
13 Author:
14
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
16
17 --*/
18
19 #ifndef _LPCTYPES_H
20 #define _LPCTYPES_H
21
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 #include <pstypes.h>
27
28 //
29 // Maximum message size that can be sent through an LPC Port without a section
30 //
31 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
32
33 //
34 // LPC Message Types
35 //
36 typedef enum _LPC_TYPE
37 {
38 LPC_NEW_MESSAGE,
39 LPC_REQUEST,
40 LPC_REPLY,
41 LPC_DATAGRAM,
42 LPC_LOST_REPLY,
43 LPC_PORT_CLOSED,
44 LPC_CLIENT_DIED,
45 LPC_EXCEPTION,
46 LPC_DEBUG_EVENT,
47 LPC_ERROR_EVENT,
48 LPC_CONNECTION_REQUEST,
49 LPC_CONNECTION_REFUSED,
50 LPC_MAXIMUM
51 } LPC_TYPE;
52
53 //
54 // Information Classes for NtQueryInformationPort
55 //
56 typedef enum _PORT_INFORMATION_CLASS
57 {
58 PortNoInformation
59 } PORT_INFORMATION_CLASS;
60
61 #ifdef NTOS_MODE_USER
62
63 //
64 // Portable LPC Types for 32/64-bit compatibility
65 //
66 #ifdef USE_LPC6432
67 #define LPC_CLIENT_ID CLIENT_ID64
68 #define LPC_SIZE_T ULONGLONG
69 #define LPC_PVOID ULONGLONG
70 #define LPC_HANDLE ULONGLONG
71 #else
72 #define LPC_CLIENT_ID CLIENT_ID
73 #define LPC_SIZE_T SIZE_T
74 #define LPC_PVOID PVOID
75 #define LPC_HANDLE HANDLE
76 #endif
77
78 //
79 // LPC Port Message
80 //
81 typedef struct _PORT_MESSAGE
82 {
83 union
84 {
85 struct
86 {
87 CSHORT DataLength;
88 CSHORT TotalLength;
89 } s1;
90 ULONG Length;
91 } u1;
92 union
93 {
94 struct
95 {
96 CSHORT Type;
97 CSHORT DataInfoOffset;
98 } s2;
99 ULONG ZeroInit;
100 } u2;
101 union
102 {
103 LPC_CLIENT_ID ClientId;
104 double DoNotUseThisField;
105 };
106 ULONG MessageId;
107 union
108 {
109 LPC_SIZE_T ClientViewSize;
110 ULONG CallbackId;
111 };
112 } PORT_MESSAGE, *PPORT_MESSAGE;
113
114 //
115 // Local and Remove Port Views
116 //
117 typedef struct _PORT_VIEW
118 {
119 ULONG Length;
120 LPC_HANDLE SectionHandle;
121 ULONG SectionOffset;
122 LPC_SIZE_T ViewSize;
123 LPC_PVOID ViewBase;
124 LPC_PVOID ViewRemoteBase;
125 } PORT_VIEW, *PPORT_VIEW;
126
127 typedef struct _REMOTE_PORT_VIEW
128 {
129 ULONG Length;
130 LPC_SIZE_T ViewSize;
131 LPC_PVOID ViewBase;
132 } REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW;
133
134 //
135 // LPC Kernel-Mode Message Structures defined for size only
136 //
137 typedef struct _LPCP_MESSAGE
138 {
139 UCHAR Data[0x14];
140 PORT_MESSAGE Request;
141 } LPCP_MESSAGE;
142
143 typedef struct _LPCP_CONNECTION_MESSAGE
144 {
145 UCHAR Data[0x2C];
146 } LPCP_CONNECTION_MESSAGE;
147
148 #else
149
150 //
151 // LPC Paged and Non-Paged Port Queues
152 //
153 typedef struct _LPCP_NONPAGED_PORT_QUEUE
154 {
155 KSEMAPHORE Semaphore;
156 struct _LPCP_PORT_OBJECT *BackPointer;
157 } LPCP_NONPAGED_PORT_QUEUE, *PLPCP_NONPAGED_PORT_QUEUE;
158
159 typedef struct _LPCP_PORT_QUEUE
160 {
161 PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue;
162 KSEMAPHORE Semaphore;
163 LIST_ENTRY ReceiveHead;
164 } LPCP_PORT_QUEUE, *PLPCP_PORT_QUEUE;
165
166 //
167 // LPC Port Object
168 //
169 typedef struct _LPCP_PORT_OBJECT
170 {
171 ULONG Length;
172 ULONG Flags;
173 struct _LPCP_PORT_OBJECT *ConnectionPort;
174 struct _LPCP_PORT_OBJECT *ConnectedPort;
175 LPCP_PORT_QUEUE MsgQueue;
176 CLIENT_ID Creator;
177 PVOID ClientSectionBase;
178 PVOID ServerSectionBase;
179 PVOID PortContext;
180 ULONG MaxMessageLength;
181 ULONG MaxConnectionInfoLength;
182 PETHREAD ClientThread;
183 SECURITY_QUALITY_OF_SERVICE SecurityQos;
184 SECURITY_CLIENT_CONTEXT StaticSecurity;
185 LIST_ENTRY LpcReplyChainHead;
186 LIST_ENTRY LpcDataInfoChainHead;
187 } LPCP_PORT_OBJECT, *PLPCP_PORT_OBJECT;
188
189 //
190 // LPC Kernel-Mode Message Structures
191 //
192 typedef struct _LPCP_MESSAGE
193 {
194 union
195 {
196 LIST_ENTRY Entry;
197 struct
198 {
199 SINGLE_LIST_ENTRY FreeEntry;
200 ULONG Reserved0;
201 };
202 };
203 PLPCP_PORT_OBJECT SenderPort;
204 PETHREAD RepliedToThread;
205 PVOID PortContext;
206 PORT_MESSAGE Request;
207 } LPCP_MESSAGE, *PLPCP_MESSAGE;
208
209 typedef struct _LPCP_CONNECTION_MESSAGE
210 {
211 PORT_VIEW ClientView;
212 PLPCP_PORT_OBJECT ClientPort;
213 PVOID SectionToMap;
214 REMOTE_PORT_VIEW ServerView;
215 } LPCP_CONNECTION_MESSAGE, *PLPCP_CONNECTION_MESSAGE;
216
217 #endif
218
219 //
220 // Client Died LPC Message (FIXME: should go in pstypes.h?)
221 //
222 typedef struct _CLIENT_DIED_MSG
223 {
224 PORT_MESSAGE h;
225 LARGE_INTEGER CreateTime;
226 } CLIENT_DIED_MSG, *PCLIENT_DIED_MSG;
227
228 //
229 // Maximum total Kernel-Mode LPC Message Structure Size
230 //
231 #define LPCP_MAX_MESSAGE_SIZE \
232 ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
233 sizeof(LPCP_MESSAGE) + \
234 sizeof(LPCP_CONNECTION_MESSAGE), 16)
235
236 //
237 // Maximum actual LPC Message Length
238 //
239 #define LPC_MAX_MESSAGE_LENGTH \
240 (LPCP_MAX_MESSAGE_SIZE - \
241 FIELD_OFFSET(LPCP_MESSAGE, Request))
242
243 //
244 // Maximum actual size of LPC Message Data
245 //
246 #define LPC_MAX_DATA_LENGTH \
247 (LPC_MAX_MESSAGE_LENGTH - \
248 sizeof(PORT_MESSAGE) - \
249 sizeof(LPCP_CONNECTION_MESSAGE))
250
251 #endif // _LPCTYPES_H