[NTOSKRNL]
[reactos.git] / reactos / ntoskrnl / include / internal / lpc.h
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/internal/lpc.h
5 * PURPOSE: Internal header for the Local Procedure Call
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 //
10 // Define this if you want debugging support
11 //
12 #define _LPC_DEBUG_ 0x00
13
14 //
15 // These define the Debug Masks Supported
16 //
17 #define LPC_CREATE_DEBUG 0x01
18 #define LPC_CLOSE_DEBUG 0x02
19 #define LPC_CONNECT_DEBUG 0x04
20 #define LPC_LISTEN_DEBUG 0x08
21 #define LPC_REPLY_DEBUG 0x10
22 #define LPC_COMPLETE_DEBUG 0x20
23 #define LPC_SEND_DEBUG 0x40
24
25 //
26 // Debug/Tracing support
27 //
28 #if _LPC_DEBUG_
29 #ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
30 #define LPCTRACE(x, ...) \
31 { \
32 DbgPrintEx("%s [%.16s] - ", \
33 __FUNCTION__, \
34 PsGetCurrentProcess()->ImageFileName); \
35 DbgPrintEx(__VA_ARGS__); \
36 }
37 #else
38 #define LPCTRACE(x, ...) \
39 if (x & LpcpTraceLevel) \
40 { \
41 DbgPrint("%s [%.16s:%lx] - ", \
42 __FUNCTION__, \
43 PsGetCurrentProcess()->ImageFileName, \
44 PsGetCurrentThreadId()); \
45 DbgPrint(__VA_ARGS__); \
46 }
47 #endif
48 #else
49 #define LPCTRACE(x, fmt, ...) DPRINT(fmt, ##__VA_ARGS__)
50 #endif
51
52 //
53 // LPC Port/Message Flags
54 //
55 #define LPCP_THREAD_FLAG_IS_PORT 1
56 #define LPCP_THREAD_FLAG_NO_IMPERSONATION 2
57 #define LPCP_THREAD_FLAGS (LPCP_THREAD_FLAG_IS_PORT | \
58 LPCP_THREAD_FLAG_NO_IMPERSONATION)
59
60 //
61 // LPC Locking Flags
62 //
63 #define LPCP_LOCK_HELD 1
64 #define LPCP_LOCK_RELEASE 2
65
66
67 typedef struct _LPCP_DATA_INFO
68 {
69 ULONG NumberOfEntries;
70 struct
71 {
72 PVOID BaseAddress;
73 ULONG DataLength;
74 } Entries[1];
75 } LPCP_DATA_INFO, *PLPCP_DATA_INFO;
76
77
78 //
79 // Internal Port Management
80 //
81 VOID
82 NTAPI
83 LpcpClosePort(
84 IN PEPROCESS Process OPTIONAL,
85 IN PVOID Object,
86 IN ACCESS_MASK GrantedAccess,
87 IN ULONG ProcessHandleCount,
88 IN ULONG SystemHandleCount
89 );
90
91 VOID
92 NTAPI
93 LpcpDeletePort(
94 IN PVOID ObjectBody
95 );
96
97 NTSTATUS
98 NTAPI
99 LpcpInitializePortQueue(
100 IN PLPCP_PORT_OBJECT Port
101 );
102
103 VOID
104 NTAPI
105 LpcpFreeToPortZone(
106 IN PLPCP_MESSAGE Message,
107 IN ULONG LockFlags
108 );
109
110 VOID
111 NTAPI
112 LpcpMoveMessage(
113 IN PPORT_MESSAGE Destination,
114 IN PPORT_MESSAGE Origin,
115 IN PVOID Data,
116 IN ULONG MessageType,
117 IN PCLIENT_ID ClientId
118 );
119
120 VOID
121 NTAPI
122 LpcpSaveDataInfoMessage(
123 IN PLPCP_PORT_OBJECT Port,
124 IN PLPCP_MESSAGE Message,
125 IN ULONG LockFlags
126 );
127
128 //
129 // Module-external utlity functions
130 //
131 VOID
132 NTAPI
133 LpcExitThread(
134 IN PETHREAD Thread
135 );
136
137 //
138 // Initialization functions
139 //
140 BOOLEAN
141 NTAPI
142 LpcInitSystem(
143 VOID
144 );
145
146 BOOLEAN
147 NTAPI
148 LpcpValidateClientPort(
149 PETHREAD ClientThread,
150 PLPCP_PORT_OBJECT Port);
151
152
153 //
154 // Global data inside the Process Manager
155 //
156 extern POBJECT_TYPE LpcPortObjectType;
157 extern ULONG LpcpNextMessageId, LpcpNextCallbackId;
158 extern KGUARDED_MUTEX LpcpLock;
159 extern PAGED_LOOKASIDE_LIST LpcpMessagesLookaside;
160 extern ULONG LpcpMaxMessageSize;
161 extern ULONG LpcpTraceLevel;
162
163 //
164 // Inlined Functions
165 //
166 #include "lpc_x.h"