f27ed12bb8f90e04ad66d25fa1eb7b54f2f99ed3
[reactos.git] / reactos / include / ndk / lpctypes.h
1 /*
2 * PROJECT: ReactOS Native Headers
3 * FILE: include/ndk/lpctypes.h
4 * PURPOSE: Definitions for Local Procedure Call Types not defined in DDK/IFS
5 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
6 * UPDATE HISTORY:
7 * Created 06/10/04
8 */
9 #ifndef _LPCTYPES_H
10 #define _LPCTYPES_H
11
12 /* DEPENDENCIES **************************************************************/
13
14 /* EXPORTED DATA *************************************************************/
15
16 /* ENUMERATIONS **************************************************************/
17
18 typedef enum _LPC_TYPE
19 {
20 LPC_NEW_MESSAGE,
21 LPC_REQUEST,
22 LPC_REPLY,
23 LPC_DATAGRAM,
24 LPC_LOST_REPLY,
25 LPC_PORT_CLOSED,
26 LPC_CLIENT_DIED,
27 LPC_EXCEPTION,
28 LPC_DEBUG_EVENT,
29 LPC_ERROR_EVENT,
30 LPC_CONNECTION_REQUEST,
31 LPC_CONNECTION_REFUSED,
32 LPC_MAXIMUM
33 } LPC_TYPE;
34
35 /* TYPES *********************************************************************/
36
37 #ifdef NTOS_MODE_USER
38
39 #if defined(USE_LPC6432)
40 #define LPC_CLIENT_ID CLIENT_ID64
41 #define LPC_SIZE_T ULONGLONG
42 #define LPC_PVOID ULONGLONG
43 #define LPC_HANDLE ULONGLONG
44 #else
45 #define LPC_CLIENT_ID CLIENT_ID
46 #define LPC_SIZE_T SIZE_T
47 #define LPC_PVOID PVOID
48 #define LPC_HANDLE HANDLE
49 #endif
50
51 typedef struct _PORT_MESSAGE
52 {
53 union
54 {
55 struct
56 {
57 CSHORT DataLength;
58 CSHORT TotalLength;
59 } s1;
60 ULONG Length;
61 } u1;
62 union
63 {
64 struct
65 {
66 CSHORT Type;
67 CSHORT DataInfoOffset;
68 } s2;
69 ULONG ZeroInit;
70 } u2;
71 union
72 {
73 LPC_CLIENT_ID ClientId;
74 double DoNotUseThisField;
75 };
76 ULONG MessageId;
77 union
78 {
79 LPC_SIZE_T ClientViewSize;
80 ULONG CallbackId;
81 };
82 } PORT_MESSAGE, *PPORT_MESSAGE;
83
84 typedef struct _PORT_VIEW
85 {
86 ULONG Length;
87 LPC_HANDLE SectionHandle;
88 ULONG SectionOffset;
89 LPC_SIZE_T ViewSize;
90 LPC_PVOID ViewBase;
91 LPC_PVOID ViewRemoteBase;
92 } PORT_VIEW, *PPORT_VIEW;
93
94 typedef struct _REMOTE_PORT_VIEW
95 {
96 ULONG Length;
97 LPC_SIZE_T ViewSize;
98 LPC_PVOID ViewBase;
99 } REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW;
100
101 typedef struct _LPCP_MESSAGE
102 {
103 UCHAR Data[0x14];
104 PORT_MESSAGE Request;
105 } LPCP_MESSAGE;
106
107 typedef struct _LPCP_CONNECTION_MESSAGE
108 {
109 UCHAR Data[0x2C];
110 } LPCP_CONNECTION_MESSAGE;
111
112 /* Kernel-Mode Structures */
113 #else
114
115 typedef struct _LPCP_NONPAGED_PORT_QUEUE
116 {
117 KSEMAPHORE Semaphore;
118 struct _LPCP_PORT_OBJECT *BackPointer;
119 } LPCP_NONPAGED_PORT_QUEUE, *PLPCP_NONPAGED_PORT_QUEUE;
120
121 typedef struct _LPCP_PORT_QUEUE
122 {
123 PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue;
124 KSEMAPHORE Semaphore;
125 LIST_ENTRY ReceiveHead;
126 } LPCP_PORT_QUEUE, *PLPCP_PORT_QUEUE;
127
128 typedef struct _LPCP_PORT_OBJECT
129 {
130 ULONG Length;
131 ULONG Flags;
132 struct _LPCP_PORT_OBJECT *ConnectionPort;
133 struct _LPCP_PORT_OBJECT *ConnectedPort;
134 LPCP_PORT_QUEUE MsgQueue;
135 CLIENT_ID Creator;
136 PVOID ClientSectionBase;
137 PVOID ServerSectionBase;
138 PVOID PortContext;
139 ULONG MaxMessageLength;
140 ULONG MaxConnectionInfoLength;
141 PETHREAD ClientThread;
142 SECURITY_QUALITY_OF_SERVICE SecurityQos;
143 SECURITY_CLIENT_CONTEXT StaticSecurity;
144 LIST_ENTRY LpcReplyChainHead;
145 LIST_ENTRY LpcDataInfoChainHead;
146 } LPCP_PORT_OBJECT, *PLPCP_PORT_OBJECT;
147
148 typedef struct _LPCP_MESSAGE
149 {
150 union
151 {
152 LIST_ENTRY Entry;
153 struct
154 {
155 SINGLE_LIST_ENTRY FreeEntry;
156 ULONG Reserved0;
157 };
158 };
159 PLPCP_PORT_OBJECT SenderPort;
160 PETHREAD RepliedToThread;
161 PVOID PortContext;
162 PORT_MESSAGE Request;
163 } LPCP_MESSAGE, *PLPCP_MESSAGE;
164
165 typedef struct _LPCP_CONNECTION_MESSAGE
166 {
167 PORT_VIEW ClientView;
168 PLPCP_PORT_OBJECT ClientPort;
169 PVOID SectionToMap;
170 REMOTE_PORT_VIEW ServerView;
171 } LPCP_CONNECTION_MESSAGE, *PLPCP_CONNECTION_MESSAGE;
172 #endif
173
174 /* CONSTANTS *****************************************************************/
175
176 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
177
178 #define LPCP_MAX_MESSAGE_SIZE \
179 ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
180 sizeof(LPCP_MESSAGE) + \
181 sizeof(LPCP_CONNECTION_MESSAGE), 16)
182
183 #define LPC_MAX_MESSAGE_LENGTH \
184 (LPCP_MAX_MESSAGE_SIZE - \
185 FIELD_OFFSET(LPCP_MESSAGE, Request))
186
187 #define LPC_MAX_DATA_LENGTH \
188 (LPC_MAX_MESSAGE_LENGTH - \
189 sizeof(PORT_MESSAGE) - \
190 sizeof(LPCP_CONNECTION_MESSAGE))
191
192 #endif