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
;
212 PEPROCESS ServerProcess
;
213 PEPROCESS MappingProcess
;
214 ULONG MaxMessageLength
;
215 ULONG MaxConnectionInfoLength
;
218 } LPCP_PORT_OBJECT
, *PLPCP_PORT_OBJECT
;
221 // LPC Kernel-Mode Message Structures
223 typedef struct _LPCP_MESSAGE
230 SINGLE_LIST_ENTRY FreeEntry
;
234 PLPCP_PORT_OBJECT SenderPort
;
235 PETHREAD RepliedToThread
;
237 PORT_MESSAGE Request
;
238 } LPCP_MESSAGE
, *PLPCP_MESSAGE
;
240 typedef struct _LPCP_CONNECTION_MESSAGE
242 PORT_VIEW ClientView
;
243 PLPCP_PORT_OBJECT ClientPort
;
245 REMOTE_PORT_VIEW ServerView
;
246 } LPCP_CONNECTION_MESSAGE
, *PLPCP_CONNECTION_MESSAGE
;
251 // Client Died LPC Message
253 typedef struct _CLIENT_DIED_MSG
256 LARGE_INTEGER CreateTime
;
257 } CLIENT_DIED_MSG
, *PCLIENT_DIED_MSG
;
260 // Maximum total Kernel-Mode LPC Message Structure Size
262 #define LPCP_MAX_MESSAGE_SIZE \
263 N_ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
264 sizeof(LPCP_MESSAGE) + \
265 sizeof(LPCP_CONNECTION_MESSAGE), 16)
268 // Maximum actual LPC Message Length
270 #define LPC_MAX_MESSAGE_LENGTH \
271 (LPCP_MAX_MESSAGE_SIZE - \
272 FIELD_OFFSET(LPCP_MESSAGE, Request))
275 // Maximum actual size of LPC Message Data
277 #define LPC_MAX_DATA_LENGTH \
278 (LPC_MAX_MESSAGE_LENGTH - \
279 sizeof(PORT_MESSAGE) - \
280 sizeof(LPCP_CONNECTION_MESSAGE))
282 #endif // _LPCTYPES_H