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 // Port Object Access Masks
37 #define PORT_CONNECT 0x1
38 #define PORT_ALL_ACCESS 0x1
43 #define LPCP_CONNECTION_PORT 0x00000001
44 #define LPCP_UNCONNECTED_PORT 0x00000002
45 #define LPCP_COMMUNICATION_PORT 0x00000003
46 #define LPCP_CLIENT_PORT 0x00000004
47 #define LPCP_PORT_TYPE_MASK 0x0000000F
48 #define LPCP_PORT_DELETED 0x10000000
49 #define LPCP_WAITABLE_PORT 0x20000000
50 #define LPCP_NAME_DELETED 0x40000000
51 #define LPCP_SECURITY_DYNAMIC 0x80000000
56 typedef enum _LPC_TYPE
68 LPC_CONNECTION_REQUEST
,
69 LPC_CONNECTION_REFUSED
,
74 // Information Classes for NtQueryInformationPort
76 typedef enum _PORT_INFORMATION_CLASS
79 } PORT_INFORMATION_CLASS
;
84 // Maximum message size that can be sent through an LPC Port without a section
87 #define PORT_MAXIMUM_MESSAGE_LENGTH 512
89 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
93 // Portable LPC Types for 32/64-bit compatibility
96 #define LPC_CLIENT_ID CLIENT_ID64
97 #define LPC_SIZE_T ULONGLONG
98 #define LPC_PVOID ULONGLONG
99 #define LPC_HANDLE ULONGLONG
101 #define LPC_CLIENT_ID CLIENT_ID
102 #define LPC_SIZE_T SIZE_T
103 #define LPC_PVOID PVOID
104 #define LPC_HANDLE HANDLE
110 typedef struct _PORT_MESSAGE
126 CSHORT DataInfoOffset
;
132 LPC_CLIENT_ID ClientId
;
133 double DoNotUseThisField
;
138 LPC_SIZE_T ClientViewSize
;
141 } PORT_MESSAGE
, *PPORT_MESSAGE
;
144 // Local and Remove Port Views
146 typedef struct _PORT_VIEW
149 LPC_HANDLE SectionHandle
;
153 LPC_PVOID ViewRemoteBase
;
154 } PORT_VIEW
, *PPORT_VIEW
;
156 typedef struct _REMOTE_PORT_VIEW
161 } REMOTE_PORT_VIEW
, *PREMOTE_PORT_VIEW
;
164 // LPC Kernel-Mode Message Structures defined for size only
166 typedef struct _LPCP_MESSAGE
169 PORT_MESSAGE Request
;
172 typedef struct _LPCP_CONNECTION_MESSAGE
175 } LPCP_CONNECTION_MESSAGE
;
180 // LPC Paged and Non-Paged Port Queues
182 typedef struct _LPCP_NONPAGED_PORT_QUEUE
184 KSEMAPHORE Semaphore
;
185 struct _LPCP_PORT_OBJECT
*BackPointer
;
186 } LPCP_NONPAGED_PORT_QUEUE
, *PLPCP_NONPAGED_PORT_QUEUE
;
188 typedef struct _LPCP_PORT_QUEUE
190 PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue
;
191 PKSEMAPHORE Semaphore
;
192 LIST_ENTRY ReceiveHead
;
193 } LPCP_PORT_QUEUE
, *PLPCP_PORT_QUEUE
;
198 typedef struct _LPCP_PORT_OBJECT
200 struct _LPCP_PORT_OBJECT
*ConnectionPort
;
201 struct _LPCP_PORT_OBJECT
*ConnectedPort
;
202 LPCP_PORT_QUEUE MsgQueue
;
204 PVOID ClientSectionBase
;
205 PVOID ServerSectionBase
;
207 PETHREAD ClientThread
;
208 SECURITY_QUALITY_OF_SERVICE SecurityQos
;
209 SECURITY_CLIENT_CONTEXT StaticSecurity
;
210 LIST_ENTRY LpcReplyChainHead
;
211 LIST_ENTRY LpcDataInfoChainHead
;
214 PEPROCESS ServerProcess
;
215 PEPROCESS MappingProcess
;
217 ULONG MaxMessageLength
;
218 ULONG MaxConnectionInfoLength
;
221 } LPCP_PORT_OBJECT
, *PLPCP_PORT_OBJECT
;
224 // LPC Kernel-Mode Message Structures
226 typedef struct _LPCP_MESSAGE
233 SINGLE_LIST_ENTRY FreeEntry
;
237 PLPCP_PORT_OBJECT SenderPort
;
238 PETHREAD RepliedToThread
;
240 PORT_MESSAGE Request
;
241 } LPCP_MESSAGE
, *PLPCP_MESSAGE
;
243 typedef struct _LPCP_CONNECTION_MESSAGE
245 PORT_VIEW ClientView
;
246 PLPCP_PORT_OBJECT ClientPort
;
248 REMOTE_PORT_VIEW ServerView
;
249 } LPCP_CONNECTION_MESSAGE
, *PLPCP_CONNECTION_MESSAGE
;
254 // Client Died LPC Message
256 typedef struct _CLIENT_DIED_MSG
259 LARGE_INTEGER CreateTime
;
260 } CLIENT_DIED_MSG
, *PCLIENT_DIED_MSG
;
263 // Maximum total Kernel-Mode LPC Message Structure Size
265 #define LPCP_MAX_MESSAGE_SIZE \
266 N_ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
267 sizeof(LPCP_MESSAGE) + \
268 sizeof(LPCP_CONNECTION_MESSAGE), 16)
271 // Maximum actual LPC Message Length
273 #define LPC_MAX_MESSAGE_LENGTH \
274 (LPCP_MAX_MESSAGE_SIZE - \
275 FIELD_OFFSET(LPCP_MESSAGE, Request))
278 // Maximum actual size of LPC Message Data
280 #define LPC_MAX_DATA_LENGTH \
281 (LPC_MAX_MESSAGE_LENGTH - \
282 sizeof(PORT_MESSAGE) - \
283 sizeof(LPCP_CONNECTION_MESSAGE))
285 #endif // _LPCTYPES_H