3 Copyright (c) Alex Ionescu. All rights reserved.
11 Type definitions for the Loader.
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
26 //#include <pstypes.h>
29 // Internal helper macro
31 #define N_ROUND_UP(x,s) \
32 (((ULONG)(x)+(s)-1) & ~((ULONG)(s)-1))
35 // Maximum message size that can be sent through an LPC Port without a section
37 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
40 // Port Object Access Masks
42 #define PORT_CONNECT 0x1
43 #define PORT_ALL_ACCESS 0x1
48 #define LPCP_CONNECTION_PORT 0x00000001
49 #define LPCP_UNCONNECTED_PORT 0x00000002
50 #define LPCP_COMMUNICATION_PORT 0x00000003
51 #define LPCP_CLIENT_PORT 0x00000004
52 #define LPCP_PORT_TYPE_MASK 0x0000000F
53 #define LPCP_PORT_DELETED 0x10000000
54 #define LPCP_WAITABLE_PORT 0x20000000
55 #define LPCP_NAME_DELETED 0x40000000
56 #define LPCP_SECURITY_DYNAMIC 0x80000000
61 typedef enum _LPC_TYPE
73 LPC_CONNECTION_REQUEST
,
74 LPC_CONNECTION_REFUSED
,
79 // Information Classes for NtQueryInformationPort
81 typedef enum _PORT_INFORMATION_CLASS
84 } PORT_INFORMATION_CLASS
;
89 // Portable LPC Types for 32/64-bit compatibility
92 #define LPC_CLIENT_ID CLIENT_ID64
93 #define LPC_SIZE_T ULONGLONG
94 #define LPC_PVOID ULONGLONG
95 #define LPC_HANDLE ULONGLONG
97 #define LPC_CLIENT_ID CLIENT_ID
98 #define LPC_SIZE_T SIZE_T
99 #define LPC_PVOID PVOID
100 #define LPC_HANDLE HANDLE
106 typedef struct _PORT_MESSAGE
122 CSHORT DataInfoOffset
;
128 LPC_CLIENT_ID ClientId
;
129 double DoNotUseThisField
;
134 LPC_SIZE_T ClientViewSize
;
137 } PORT_MESSAGE
, *PPORT_MESSAGE
;
140 // Local and Remove Port Views
142 typedef struct _PORT_VIEW
145 LPC_HANDLE SectionHandle
;
149 LPC_PVOID ViewRemoteBase
;
150 } PORT_VIEW
, *PPORT_VIEW
;
152 typedef struct _REMOTE_PORT_VIEW
157 } REMOTE_PORT_VIEW
, *PREMOTE_PORT_VIEW
;
160 // LPC Kernel-Mode Message Structures defined for size only
162 typedef struct _LPCP_MESSAGE
165 PORT_MESSAGE Request
;
168 typedef struct _LPCP_CONNECTION_MESSAGE
171 } LPCP_CONNECTION_MESSAGE
;
176 // LPC Paged and Non-Paged Port Queues
178 typedef struct _LPCP_NONPAGED_PORT_QUEUE
180 KSEMAPHORE Semaphore
;
181 struct _LPCP_PORT_OBJECT
*BackPointer
;
182 } LPCP_NONPAGED_PORT_QUEUE
, *PLPCP_NONPAGED_PORT_QUEUE
;
184 typedef struct _LPCP_PORT_QUEUE
186 PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue
;
187 PKSEMAPHORE Semaphore
;
188 LIST_ENTRY ReceiveHead
;
189 } LPCP_PORT_QUEUE
, *PLPCP_PORT_QUEUE
;
194 typedef struct _LPCP_PORT_OBJECT
196 struct _LPCP_PORT_OBJECT
*ConnectionPort
;
197 struct _LPCP_PORT_OBJECT
*ConnectedPort
;
198 LPCP_PORT_QUEUE MsgQueue
;
200 PVOID ClientSectionBase
;
201 PVOID ServerSectionBase
;
203 PETHREAD ClientThread
;
204 SECURITY_QUALITY_OF_SERVICE SecurityQos
;
205 SECURITY_CLIENT_CONTEXT StaticSecurity
;
206 LIST_ENTRY LpcReplyChainHead
;
207 LIST_ENTRY LpcDataInfoChainHead
;
208 PEPROCESS ServerProcess
;
209 PEPROCESS MappingProcess
;
210 ULONG MaxMessageLength
;
211 ULONG MaxConnectionInfoLength
;
214 } LPCP_PORT_OBJECT
, *PLPCP_PORT_OBJECT
;
217 // LPC Kernel-Mode Message Structures
219 typedef struct _LPCP_MESSAGE
226 SINGLE_LIST_ENTRY FreeEntry
;
230 PLPCP_PORT_OBJECT SenderPort
;
231 PETHREAD RepliedToThread
;
233 PORT_MESSAGE Request
;
234 } LPCP_MESSAGE
, *PLPCP_MESSAGE
;
236 typedef struct _LPCP_CONNECTION_MESSAGE
238 PORT_VIEW ClientView
;
239 PLPCP_PORT_OBJECT ClientPort
;
241 REMOTE_PORT_VIEW ServerView
;
242 } LPCP_CONNECTION_MESSAGE
, *PLPCP_CONNECTION_MESSAGE
;
247 // Client Died LPC Message
249 typedef struct _CLIENT_DIED_MSG
252 LARGE_INTEGER CreateTime
;
253 } CLIENT_DIED_MSG
, *PCLIENT_DIED_MSG
;
256 // Maximum total Kernel-Mode LPC Message Structure Size
258 #define LPCP_MAX_MESSAGE_SIZE \
259 N_ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
260 sizeof(LPCP_MESSAGE) + \
261 sizeof(LPCP_CONNECTION_MESSAGE), 16)
264 // Maximum actual LPC Message Length
266 #define LPC_MAX_MESSAGE_LENGTH \
267 (LPCP_MAX_MESSAGE_SIZE - \
268 FIELD_OFFSET(LPCP_MESSAGE, Request))
271 // Maximum actual size of LPC Message Data
273 #define LPC_MAX_DATA_LENGTH \
274 (LPC_MAX_MESSAGE_LENGTH - \
275 sizeof(PORT_MESSAGE) - \
276 sizeof(LPCP_CONNECTION_MESSAGE))
278 #endif // _LPCTYPES_H