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