- Implement RtlInitializeUnicodePrefix and RtlNextUnicodePrefix. The UnicodePrefix...
[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 typedef enum _PORT_INFORMATION_CLASS
36 {
37 PortNoInformation
38 } PORT_INFORMATION_CLASS;
39
40 /* TYPES *********************************************************************/
41
42 #ifdef NTOS_MODE_USER
43
44 #if defined(USE_LPC6432)
45 #define LPC_CLIENT_ID CLIENT_ID64
46 #define LPC_SIZE_T ULONGLONG
47 #define LPC_PVOID ULONGLONG
48 #define LPC_HANDLE ULONGLONG
49 #else
50 #define LPC_CLIENT_ID CLIENT_ID
51 #define LPC_SIZE_T SIZE_T
52 #define LPC_PVOID PVOID
53 #define LPC_HANDLE HANDLE
54 #endif
55
56 typedef struct _PORT_MESSAGE
57 {
58 union
59 {
60 struct
61 {
62 CSHORT DataLength;
63 CSHORT TotalLength;
64 } s1;
65 ULONG Length;
66 } u1;
67 union
68 {
69 struct
70 {
71 CSHORT Type;
72 CSHORT DataInfoOffset;
73 } s2;
74 ULONG ZeroInit;
75 } u2;
76 union
77 {
78 LPC_CLIENT_ID ClientId;
79 double DoNotUseThisField;
80 };
81 ULONG MessageId;
82 union
83 {
84 LPC_SIZE_T ClientViewSize;
85 ULONG CallbackId;
86 };
87 } PORT_MESSAGE, *PPORT_MESSAGE;
88
89 typedef struct _PORT_VIEW
90 {
91 ULONG Length;
92 LPC_HANDLE SectionHandle;
93 ULONG SectionOffset;
94 LPC_SIZE_T ViewSize;
95 LPC_PVOID ViewBase;
96 LPC_PVOID ViewRemoteBase;
97 } PORT_VIEW, *PPORT_VIEW;
98
99 typedef struct _REMOTE_PORT_VIEW
100 {
101 ULONG Length;
102 LPC_SIZE_T ViewSize;
103 LPC_PVOID ViewBase;
104 } REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW;
105
106 typedef struct _LPCP_MESSAGE
107 {
108 UCHAR Data[0x14];
109 PORT_MESSAGE Request;
110 } LPCP_MESSAGE;
111
112 typedef struct _LPCP_CONNECTION_MESSAGE
113 {
114 UCHAR Data[0x2C];
115 } LPCP_CONNECTION_MESSAGE;
116
117 /* Kernel-Mode Structures */
118 #else
119
120 typedef struct _LPCP_NONPAGED_PORT_QUEUE
121 {
122 KSEMAPHORE Semaphore;
123 struct _LPCP_PORT_OBJECT *BackPointer;
124 } LPCP_NONPAGED_PORT_QUEUE, *PLPCP_NONPAGED_PORT_QUEUE;
125
126 typedef struct _LPCP_PORT_QUEUE
127 {
128 PLPCP_NONPAGED_PORT_QUEUE NonPagedPortQueue;
129 KSEMAPHORE Semaphore;
130 LIST_ENTRY ReceiveHead;
131 } LPCP_PORT_QUEUE, *PLPCP_PORT_QUEUE;
132
133 typedef struct _LPCP_PORT_OBJECT
134 {
135 ULONG Length;
136 ULONG Flags;
137 struct _LPCP_PORT_OBJECT *ConnectionPort;
138 struct _LPCP_PORT_OBJECT *ConnectedPort;
139 LPCP_PORT_QUEUE MsgQueue;
140 CLIENT_ID Creator;
141 PVOID ClientSectionBase;
142 PVOID ServerSectionBase;
143 PVOID PortContext;
144 ULONG MaxMessageLength;
145 ULONG MaxConnectionInfoLength;
146 PETHREAD ClientThread;
147 SECURITY_QUALITY_OF_SERVICE SecurityQos;
148 SECURITY_CLIENT_CONTEXT StaticSecurity;
149 LIST_ENTRY LpcReplyChainHead;
150 LIST_ENTRY LpcDataInfoChainHead;
151 } LPCP_PORT_OBJECT, *PLPCP_PORT_OBJECT;
152
153 typedef struct _LPCP_MESSAGE
154 {
155 union
156 {
157 LIST_ENTRY Entry;
158 struct
159 {
160 SINGLE_LIST_ENTRY FreeEntry;
161 ULONG Reserved0;
162 };
163 };
164 PLPCP_PORT_OBJECT SenderPort;
165 PETHREAD RepliedToThread;
166 PVOID PortContext;
167 PORT_MESSAGE Request;
168 } LPCP_MESSAGE, *PLPCP_MESSAGE;
169
170 typedef struct _LPCP_CONNECTION_MESSAGE
171 {
172 PORT_VIEW ClientView;
173 PLPCP_PORT_OBJECT ClientPort;
174 PVOID SectionToMap;
175 REMOTE_PORT_VIEW ServerView;
176 } LPCP_CONNECTION_MESSAGE, *PLPCP_CONNECTION_MESSAGE;
177 #endif
178
179 typedef struct _HARDERROR_MSG
180 {
181 PORT_MESSAGE h;
182 NTSTATUS Status;
183 LARGE_INTEGER ErrorTime;
184 ULONG ValidResponseOptions;
185 ULONG Response;
186 ULONG NumberOfParameters;
187 ULONG UnicodeStringParameterMask;
188 ULONG Parameters[MAXIMUM_HARDERROR_PARAMETERS];
189 } HARDERROR_MSG, *PHARDERROR_MSG;
190
191 typedef struct _CLIENT_DIED_MSG
192 {
193 PORT_MESSAGE h;
194 LARGE_INTEGER CreateTime;
195 } CLIENT_DIED_MSG, *PCLIENT_DIED_MSG;
196
197 /* CONSTANTS *****************************************************************/
198
199 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
200
201 #define LPCP_MAX_MESSAGE_SIZE \
202 ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
203 sizeof(LPCP_MESSAGE) + \
204 sizeof(LPCP_CONNECTION_MESSAGE), 16)
205
206 #define LPC_MAX_MESSAGE_LENGTH \
207 (LPCP_MAX_MESSAGE_SIZE - \
208 FIELD_OFFSET(LPCP_MESSAGE, Request))
209
210 #define LPC_MAX_DATA_LENGTH \
211 (LPC_MAX_MESSAGE_LENGTH - \
212 sizeof(PORT_MESSAGE) - \
213 sizeof(LPCP_CONNECTION_MESSAGE))
214
215 #endif