c6d3a14d781f2ea54332594ffa24c66f9f44bd6d
[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 // Internal Port Management
68 //
69 VOID
70 NTAPI
71 LpcpClosePort(
72 IN PEPROCESS Process OPTIONAL,
73 IN PVOID Object,
74 IN ACCESS_MASK GrantedAccess,
75 IN ULONG ProcessHandleCount,
76 IN ULONG SystemHandleCount
77 );
78
79 VOID
80 NTAPI
81 LpcpDeletePort(
82 IN PVOID ObjectBody
83 );
84
85 NTSTATUS
86 NTAPI
87 LpcpInitializePortQueue(
88 IN PLPCP_PORT_OBJECT Port
89 );
90
91 VOID
92 NTAPI
93 LpcpFreeToPortZone(
94 IN PLPCP_MESSAGE Message,
95 IN ULONG LockFlags
96 );
97
98 VOID
99 NTAPI
100 LpcpMoveMessage(
101 IN PPORT_MESSAGE Destination,
102 IN PPORT_MESSAGE Origin,
103 IN PVOID Data,
104 IN ULONG MessageType,
105 IN PCLIENT_ID ClientId
106 );
107
108 VOID
109 NTAPI
110 LpcpSaveDataInfoMessage(
111 IN PLPCP_PORT_OBJECT Port,
112 IN PLPCP_MESSAGE Message,
113 IN ULONG LockFlags
114 );
115
116 //
117 // Module-external utlity functions
118 //
119 VOID
120 NTAPI
121 LpcExitThread(
122 IN PETHREAD Thread
123 );
124
125 //
126 // Initialization functions
127 //
128 BOOLEAN
129 NTAPI
130 LpcInitSystem(
131 VOID
132 );
133
134 //
135 // Global data inside the Process Manager
136 //
137 extern POBJECT_TYPE LpcPortObjectType;
138 extern ULONG LpcpNextMessageId, LpcpNextCallbackId;
139 extern KGUARDED_MUTEX LpcpLock;
140 extern PAGED_LOOKASIDE_LIST LpcpMessagesLookaside;
141 extern ULONG LpcpMaxMessageSize;
142 extern ULONG LpcpTraceLevel;
143
144 //
145 // Inlined Functions
146 //
147 #include "lpc_x.h"