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