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