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>
28 #ifndef NTOS_MODE_USER
31 // Kernel Exported Object Types
33 extern POBJECT_TYPE NTSYSAPI LpcPortObjectType
;
35 #endif // !NTOS_MODE_USER
38 // Internal helper macro
40 #define N_ROUND_UP(x,s) \
41 (((ULONG)(x)+(s)-1) & ~((ULONG)(s)-1))
44 // Port Object Access Masks
46 #define PORT_CONNECT 0x1
47 #define PORT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
54 #define LPCP_CONNECTION_PORT 0x00000001
55 #define LPCP_UNCONNECTED_PORT 0x00000002
56 #define LPCP_COMMUNICATION_PORT 0x00000003
57 #define LPCP_CLIENT_PORT 0x00000004
58 #define LPCP_PORT_TYPE_MASK 0x0000000F
59 #define LPCP_PORT_DELETED 0x10000000
60 #define LPCP_WAITABLE_PORT 0x20000000
61 #define LPCP_NAME_DELETED 0x40000000
62 #define LPCP_SECURITY_DYNAMIC 0x80000000
67 typedef enum _LPC_TYPE
79 LPC_CONNECTION_REQUEST
,
80 LPC_CONNECTION_REFUSED
,
85 // Information Classes for NtQueryInformationPort
87 typedef enum _PORT_INFORMATION_CLASS
90 } PORT_INFORMATION_CLASS
;
95 // Maximum message size that can be sent through an LPC Port without a section
98 #define PORT_MAXIMUM_MESSAGE_LENGTH 512
100 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
104 // Portable LPC Types for 32/64-bit compatibility
107 #define LPC_CLIENT_ID CLIENT_ID64
108 #define LPC_SIZE_T ULONGLONG
109 #define LPC_PVOID ULONGLONG
110 #define LPC_HANDLE ULONGLONG
112 #define LPC_CLIENT_ID CLIENT_ID
113 #define LPC_SIZE_T SIZE_T
114 #define LPC_PVOID PVOID
115 #define LPC_HANDLE HANDLE
121 typedef struct _PORT_MESSAGE
137 CSHORT DataInfoOffset
;
143 LPC_CLIENT_ID ClientId
;
144 double DoNotUseThisField
;
149 LPC_SIZE_T ClientViewSize
;
152 } PORT_MESSAGE
, *PPORT_MESSAGE
;
155 // Local and Remove Port Views
157 typedef struct _PORT_VIEW
160 LPC_HANDLE SectionHandle
;
164 LPC_PVOID ViewRemoteBase
;
165 } PORT_VIEW
, *PPORT_VIEW
;
167 typedef struct _REMOTE_PORT_VIEW
172 } REMOTE_PORT_VIEW
, *PREMOTE_PORT_VIEW
;
175 // LPC Kernel-Mode Message Structures defined for size only
177 typedef struct _LPCP_MESSAGE
180 PORT_MESSAGE Request
;
183 typedef struct _LPCP_CONNECTION_MESSAGE
186 } LPCP_CONNECTION_MESSAGE
;
191 // LPC Paged and Non-Paged Port Queues
193 typedef struct _LPCP_NONPAGED_PORT_QUEUE
195 KSEMAPHORE Semaphore
;
196 struct _LPCP_PORT_OBJECT
*BackPointer
;
197 } LPCP_NONPAGED_PORT_QUEUE
, *PLPCP_NONPAGED_PORT_QUEUE
;
199 typedef struct _LPCP_PORT_QUEUE
201 PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue
;
202 PKSEMAPHORE Semaphore
;
203 LIST_ENTRY ReceiveHead
;
204 } LPCP_PORT_QUEUE
, *PLPCP_PORT_QUEUE
;
209 typedef struct _LPCP_PORT_OBJECT
211 struct _LPCP_PORT_OBJECT
*ConnectionPort
;
212 struct _LPCP_PORT_OBJECT
*ConnectedPort
;
213 LPCP_PORT_QUEUE MsgQueue
;
215 PVOID ClientSectionBase
;
216 PVOID ServerSectionBase
;
218 PETHREAD ClientThread
;
219 SECURITY_QUALITY_OF_SERVICE SecurityQos
;
220 SECURITY_CLIENT_CONTEXT StaticSecurity
;
221 LIST_ENTRY LpcReplyChainHead
;
222 LIST_ENTRY LpcDataInfoChainHead
;
225 PEPROCESS ServerProcess
;
226 PEPROCESS MappingProcess
;
228 ULONG MaxMessageLength
;
229 ULONG MaxConnectionInfoLength
;
232 } LPCP_PORT_OBJECT
, *PLPCP_PORT_OBJECT
;
235 // LPC Kernel-Mode Message Structures
237 typedef struct _LPCP_MESSAGE
244 SINGLE_LIST_ENTRY FreeEntry
;
248 PLPCP_PORT_OBJECT SenderPort
;
249 PETHREAD RepliedToThread
;
251 PORT_MESSAGE Request
;
252 } LPCP_MESSAGE
, *PLPCP_MESSAGE
;
254 typedef struct _LPCP_CONNECTION_MESSAGE
256 PORT_VIEW ClientView
;
257 PLPCP_PORT_OBJECT ClientPort
;
259 REMOTE_PORT_VIEW ServerView
;
260 } LPCP_CONNECTION_MESSAGE
, *PLPCP_CONNECTION_MESSAGE
;
265 // Client Died LPC Message
267 typedef struct _CLIENT_DIED_MSG
270 LARGE_INTEGER CreateTime
;
271 } CLIENT_DIED_MSG
, *PCLIENT_DIED_MSG
;
274 // Maximum total Kernel-Mode LPC Message Structure Size
276 #define LPCP_MAX_MESSAGE_SIZE \
277 N_ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
278 sizeof(LPCP_MESSAGE) + \
279 sizeof(LPCP_CONNECTION_MESSAGE), 16)
282 // Maximum actual LPC Message Length
284 #define LPC_MAX_MESSAGE_LENGTH \
285 (LPCP_MAX_MESSAGE_SIZE - \
286 FIELD_OFFSET(LPCP_MESSAGE, Request))
289 // Maximum actual size of LPC Message Data
291 #define LPC_MAX_DATA_LENGTH \
292 (LPC_MAX_MESSAGE_LENGTH - \
293 sizeof(PORT_MESSAGE) - \
294 sizeof(LPCP_CONNECTION_MESSAGE))
296 #endif // _LPCTYPES_H