ReactOS 0.4.15-dev-8219-ge8b88cf
lpc.h File Reference
#include "lpc_x.h"
Include dependency graph for lpc.h:

Go to the source code of this file.

Classes

struct  _LPCP_DATA_INFO
 

Macros

#define _LPC_DEBUG_   0x00
 
#define LPC_CREATE_DEBUG   0x01
 
#define LPC_CLOSE_DEBUG   0x02
 
#define LPC_CONNECT_DEBUG   0x04
 
#define LPC_LISTEN_DEBUG   0x08
 
#define LPC_REPLY_DEBUG   0x10
 
#define LPC_COMPLETE_DEBUG   0x20
 
#define LPC_SEND_DEBUG   0x40
 
#define LPCTRACE(x, fmt, ...)   DPRINT(fmt, ##__VA_ARGS__)
 
#define LPCP_THREAD_FLAG_IS_PORT   1
 
#define LPCP_THREAD_FLAG_NO_IMPERSONATION   2
 
#define LPCP_THREAD_FLAGS
 
#define LPCP_LOCK_HELD   1
 
#define LPCP_LOCK_RELEASE   2
 

Typedefs

typedef struct _LPCP_DATA_INFO LPCP_DATA_INFO
 
typedef struct _LPCP_DATA_INFOPLPCP_DATA_INFO
 

Functions

VOID NTAPI LpcpClosePort (IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
 
VOID NTAPI LpcpDeletePort (IN PVOID ObjectBody)
 
NTSTATUS NTAPI LpcpInitializePortQueue (IN PLPCP_PORT_OBJECT Port)
 
VOID NTAPI LpcpFreeToPortZone (IN PLPCP_MESSAGE Message, IN ULONG LockFlags)
 
VOID NTAPI LpcpMoveMessage (IN PPORT_MESSAGE Destination, IN PPORT_MESSAGE Origin, IN PVOID Data, IN ULONG MessageType, IN PCLIENT_ID ClientId)
 
VOID NTAPI LpcpSaveDataInfoMessage (IN PLPCP_PORT_OBJECT Port, IN PLPCP_MESSAGE Message, IN ULONG LockFlags)
 
VOID NTAPI LpcExitThread (IN PETHREAD Thread)
 
BOOLEAN NTAPI LpcInitSystem (VOID)
 
BOOLEAN NTAPI LpcpValidateClientPort (PETHREAD ClientThread, PLPCP_PORT_OBJECT Port)
 

Variables

POBJECT_TYPE LpcPortObjectType
 
ULONG LpcpNextMessageId
 
ULONG LpcpNextCallbackId
 
KGUARDED_MUTEX LpcpLock
 
PAGED_LOOKASIDE_LIST LpcpMessagesLookaside
 
ULONG LpcpMaxMessageSize
 
ULONG LpcpTraceLevel
 

Macro Definition Documentation

◆ _LPC_DEBUG_

#define _LPC_DEBUG_   0x00

Definition at line 12 of file lpc.h.

◆ LPC_CLOSE_DEBUG

#define LPC_CLOSE_DEBUG   0x02

Definition at line 18 of file lpc.h.

◆ LPC_COMPLETE_DEBUG

#define LPC_COMPLETE_DEBUG   0x20

Definition at line 22 of file lpc.h.

◆ LPC_CONNECT_DEBUG

#define LPC_CONNECT_DEBUG   0x04

Definition at line 19 of file lpc.h.

◆ LPC_CREATE_DEBUG

#define LPC_CREATE_DEBUG   0x01

Definition at line 17 of file lpc.h.

◆ LPC_LISTEN_DEBUG

#define LPC_LISTEN_DEBUG   0x08

Definition at line 20 of file lpc.h.

◆ LPC_REPLY_DEBUG

#define LPC_REPLY_DEBUG   0x10

Definition at line 21 of file lpc.h.

◆ LPC_SEND_DEBUG

#define LPC_SEND_DEBUG   0x40

Definition at line 23 of file lpc.h.

◆ LPCP_LOCK_HELD

#define LPCP_LOCK_HELD   1

Definition at line 63 of file lpc.h.

◆ LPCP_LOCK_RELEASE

#define LPCP_LOCK_RELEASE   2

Definition at line 64 of file lpc.h.

◆ LPCP_THREAD_FLAG_IS_PORT

#define LPCP_THREAD_FLAG_IS_PORT   1

Definition at line 55 of file lpc.h.

◆ LPCP_THREAD_FLAG_NO_IMPERSONATION

#define LPCP_THREAD_FLAG_NO_IMPERSONATION   2

Definition at line 56 of file lpc.h.

◆ LPCP_THREAD_FLAGS

#define LPCP_THREAD_FLAGS
Value:
#define LPCP_THREAD_FLAG_IS_PORT
Definition: lpc.h:55
#define LPCP_THREAD_FLAG_NO_IMPERSONATION
Definition: lpc.h:56

Definition at line 57 of file lpc.h.

◆ LPCTRACE

#define LPCTRACE (   x,
  fmt,
  ... 
)    DPRINT(fmt, ##__VA_ARGS__)

Definition at line 49 of file lpc.h.

Typedef Documentation

◆ LPCP_DATA_INFO

◆ PLPCP_DATA_INFO

Function Documentation

◆ LpcExitThread()

VOID NTAPI LpcExitThread ( IN PETHREAD  Thread)

Definition at line 19 of file close.c.

20{
23
24 /* Acquire the lock */
26
27 /* Make sure that the Reply Chain is empty */
29 {
30 /* It's not, remove the entry */
32 }
33
34 /* Set the thread in exit mode */
36 Thread->LpcReplyMessageId = 0;
37
38 /* Check if there's a reply message */
40 if (Message)
41 {
42 /* FIXME: TODO */
44 }
45
46 /* Release the lock */
48}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR Message[]
Definition: register.c:74
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
KGUARDED_MUTEX LpcpLock
Definition: port.c:20
FORCEINLINE PLPCP_MESSAGE LpcpGetMessageFromThread(IN PETHREAD Thread)
Definition: lpc_x.h:129
#define ASSERT(a)
Definition: mode.c:44
ULONG LpcExitThreadCalled
Definition: pstypes.h:1215
LIST_ENTRY LpcReplyChain
Definition: pstypes.h:1108

Referenced by PspExitThread().

◆ LpcInitSystem()

BOOLEAN NTAPI LpcInitSystem ( VOID  )

Definition at line 37 of file port.c.

38{
39 OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
41
42 /* Setup the LPC Lock */
44
45 /* Create the Port Object Type */
46 RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
48 ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
49 ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(LPCP_NONPAGED_PORT_QUEUE);
50 ObjectTypeInitializer.DefaultPagedPoolCharge = FIELD_OFFSET(LPCP_PORT_OBJECT, WaitEvent);
51 ObjectTypeInitializer.GenericMapping = LpcpPortMapping;
52 ObjectTypeInitializer.PoolType = PagedPool;
53 ObjectTypeInitializer.UseDefaultObject = TRUE;
54 ObjectTypeInitializer.CloseProcedure = LpcpClosePort;
55 ObjectTypeInitializer.DeleteProcedure = LpcpDeletePort;
56 ObjectTypeInitializer.ValidAccessMask = PORT_ALL_ACCESS;
57 ObjectTypeInitializer.InvalidAttributes = OBJ_VALID_ATTRIBUTES & ~OBJ_CASE_INSENSITIVE;
59 &ObjectTypeInitializer,
60 NULL,
62
63 /* Create the Waitable Port Object Type */
64 RtlInitUnicodeString(&Name, L"WaitablePort");
65 ObjectTypeInitializer.PoolType = NonPagedPool;
66 ObjectTypeInitializer.DefaultNonPagedPoolCharge += sizeof(LPCP_PORT_OBJECT);
67 ObjectTypeInitializer.DefaultPagedPoolCharge = 0;
68 ObjectTypeInitializer.UseDefaultObject = FALSE;
70 &ObjectTypeInitializer,
71 NULL,
73
74 /* Allocate the LPC lookaside list */
77 NULL,
78 NULL,
79 0,
81 'McpL',
82 32);
83
84 /* We're done */
85 return TRUE;
86}
struct NameRec_ * Name
Definition: cdprocs.h:460
#define NULL
Definition: types.h:112
#define NonPagedPool
Definition: env_spec_w32.h:307
#define PagedPool
Definition: env_spec_w32.h:308
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define OBJ_VALID_ATTRIBUTES
Definition: winternl.h:233
VOID NTAPI ExInitializePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:270
VOID NTAPI LpcpDeletePort(IN PVOID ObjectBody)
Definition: close.c:302
VOID NTAPI LpcpClosePort(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
Definition: close.c:244
#define PORT_ALL_ACCESS
Definition: lpctypes.h:47
struct _LPCP_NONPAGED_PORT_QUEUE LPCP_NONPAGED_PORT_QUEUE
struct _LPCP_PORT_OBJECT LPCP_PORT_OBJECT
#define LPCP_MAX_MESSAGE_SIZE
Definition: lpctypes.h:276
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
ULONG LpcpMaxMessageSize
Definition: port.c:18
KGUARDED_MUTEX LpcpLock
Definition: port.c:20
POBJECT_TYPE LpcPortObjectType
Definition: port.c:17
PAGED_LOOKASIDE_LIST LpcpMessagesLookaside
Definition: port.c:19
POBJECT_TYPE LpcWaitablePortObjectType
Definition: port.c:17
static GENERIC_MAPPING LpcpPortMapping
Definition: port.c:24
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1136
OB_CLOSE_METHOD CloseProcedure
Definition: obtypes.h:368
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by Phase1InitializationDiscard().

◆ LpcpClosePort()

VOID NTAPI LpcpClosePort ( IN PEPROCESS Process  OPTIONAL,
IN PVOID  Object,
IN ACCESS_MASK  GrantedAccess,
IN ULONG  ProcessHandleCount,
IN ULONG  SystemHandleCount 
)

Definition at line 244 of file close.c.

249{
251
252 LPCTRACE(LPC_CLOSE_DEBUG, "Port: %p. Flags: %lx\n", Port, Port->Flags);
253
254 /* Only Server-side Connection Ports need clean up*/
256 {
257 /* Check the handle count */
258 switch (SystemHandleCount)
259 {
260 /* No handles left */
261 case 0:
262
263 /* Destroy the port queue */
265 break;
266
267 /* Last handle remaining */
268 case 1:
269
270 /* Reset the queue only */
272
273 /* More handles remain, do nothing */
274 default:
275 break;
276 }
277 }
278}
CPPORT Port[4]
Definition: headless.c:35
#define LPC_CLOSE_DEBUG
Definition: lpc.h:18
#define LPCTRACE(x, fmt,...)
Definition: lpc.h:49
#define LPCP_CONNECTION_PORT
Definition: lpctypes.h:54
struct _LPCP_PORT_OBJECT * PLPCP_PORT_OBJECT
#define LPCP_PORT_TYPE_MASK
Definition: lpctypes.h:58
VOID NTAPI LpcpDestroyPortQueue(IN PLPCP_PORT_OBJECT Port, IN BOOLEAN Destroy)
Definition: close.c:111
USHORT Flags
Definition: cportlib.h:31
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

Referenced by LpcInitSystem().

◆ LpcpDeletePort()

VOID NTAPI LpcpDeletePort ( IN PVOID  ObjectBody)

Definition at line 302 of file close.c.

303{
307 PLPCP_PORT_OBJECT ConnectionPort;
309 PLIST_ENTRY ListHead, NextEntry;
310 HANDLE Pid;
311 CLIENT_DIED_MSG ClientDiedMsg;
312
313 PAGED_CODE();
314 LPCTRACE(LPC_CLOSE_DEBUG, "Port: %p. Flags: %lx\n", Port, Port->Flags);
315
316 Timeout.QuadPart = -1000000;
317
318 /* Check if this is a communication port */
320 {
321 /* Acquire the lock */
323
324 /* Get the thread */
325 Thread = Port->ClientThread;
326 if (Thread)
327 {
328 /* Clear it */
329 Port->ClientThread = NULL;
330
331 /* Release the lock and dereference */
334 }
335 else
336 {
337 /* Release the lock */
339 }
340 }
341
342 /* Check if this is a client-side port */
344 {
345 /* Setup the client died message */
346 ClientDiedMsg.h.u1.s1.TotalLength = sizeof(ClientDiedMsg);
347 ClientDiedMsg.h.u1.s1.DataLength = sizeof(ClientDiedMsg.CreateTime);
348 ClientDiedMsg.h.u2.ZeroInit = 0;
349 ClientDiedMsg.h.u2.s2.Type = LPC_PORT_CLOSED;
350 ClientDiedMsg.CreateTime = PsGetCurrentProcess()->CreateTime;
351
352 /* Send it */
353 for (;;)
354 {
355 /* Send the message */
356 if (LpcRequestPort(Port, &ClientDiedMsg.h) != STATUS_NO_MEMORY)
357 break;
358
359 /* Wait until trying again */
361 }
362 }
363
364 /* Destroy the port queue */
366
367 /* Check if we had views */
368 if ((Port->ClientSectionBase) || (Port->ServerSectionBase))
369 {
370 /* Check if we had a client view */
371 if (Port->ClientSectionBase)
372 {
373 /* Unmap it */
374 MmUnmapViewOfSection(Port->MappingProcess,
375 Port->ClientSectionBase);
376 }
377
378 /* Check for a server view */
379 if (Port->ServerSectionBase)
380 {
381 /* Unmap it */
382 MmUnmapViewOfSection(Port->MappingProcess,
383 Port->ServerSectionBase);
384 }
385
386 /* Dereference the mapping process */
387 ObDereferenceObject(Port->MappingProcess);
388 Port->MappingProcess = NULL;
389 }
390
391 /* Acquire the lock */
393
394 /* Get the connection port */
395 ConnectionPort = Port->ConnectionPort;
396 if (ConnectionPort)
397 {
398 /* Get the PID */
399 Pid = PsGetCurrentProcessId();
400
401 /* Loop the data lists */
402 ListHead = &ConnectionPort->LpcDataInfoChainHead;
403 NextEntry = ListHead->Flink;
404 while (NextEntry != ListHead)
405 {
406 /* Get the message */
408 NextEntry = NextEntry->Flink;
409
410 /* Check if this is the connection port */
411 if (Port == ConnectionPort)
412 {
413 /* Free queued messages */
414 RemoveEntryList(&Message->Entry);
417
418 /* Restart at the head */
419 NextEntry = ListHead->Flink;
420 }
421 else if ((Message->Request.ClientId.UniqueProcess == Pid) &&
422 ((Message->SenderPort == Port) ||
423 (Message->SenderPort == Port->ConnectedPort) ||
424 (Message->SenderPort == ConnectionPort)))
425 {
426 /* Remove it */
427 RemoveEntryList(&Message->Entry);
430
431 /* Restart at the head */
432 NextEntry = ListHead->Flink;
433 }
434 }
435
436 /* Release the lock */
438
439 /* Dereference the object unless it's the same port */
440 if (ConnectionPort != Port) ObDereferenceObject(ConnectionPort);
441
442 /* Check if this is a connection port with a server process */
444 (ConnectionPort->ServerProcess))
445 {
446 /* Dereference the server process */
447 ObDereferenceObject(ConnectionPort->ServerProcess);
448 ConnectionPort->ServerProcess = NULL;
449 }
450 }
451 else
452 {
453 /* Release the lock */
455 }
456
457 /* Free client security */
459 LPCTRACE(LPC_CLOSE_DEBUG, "Port: %p deleted\n", Port);
460}
NTSTATUS NTAPI MmUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress)
Definition: section.c:2750
#define PAGED_CODE()
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
#define LPCP_LOCK_HELD
Definition: lpc.h:63
#define LPCP_COMMUNICATION_PORT
Definition: lpctypes.h:56
#define LPCP_CLIENT_PORT
Definition: lpctypes.h:57
#define LPC_PORT_CLOSED
Definition: port.c:97
#define KernelMode
Definition: asm.h:34
VOID NTAPI LpcpFreeToPortZone(IN PLPCP_MESSAGE Message, IN ULONG LockFlags)
Definition: close.c:52
VOID NTAPI LpcpFreePortClientSecurity(IN PLPCP_PORT_OBJECT Port)
Definition: close.c:282
NTSTATUS NTAPI LpcRequestPort(IN PVOID PortObject, IN PPORT_MESSAGE LpcMessage)
Definition: send.c:22
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
static ULONG Timeout
Definition: ping.c:61
base of all file and directory entries
Definition: entries.h:83
PORT_MESSAGE h
Definition: lpctypes.h:269
LARGE_INTEGER CreateTime
Definition: lpctypes.h:270
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY LpcDataInfoChainHead
Definition: lpctypes.h:222
PEPROCESS ServerProcess
Definition: lpctypes.h:225
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define ObDereferenceObject
Definition: obfuncs.h:203
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by LpcInitSystem().

◆ LpcpFreeToPortZone()

VOID NTAPI LpcpFreeToPortZone ( IN PLPCP_MESSAGE  Message,
IN ULONG  LockFlags 
)

Definition at line 52 of file close.c.

54{
55 PLPCP_CONNECTION_MESSAGE ConnectMessage;
58 BOOLEAN LockHeld = (LockFlags & LPCP_LOCK_HELD);
60
61 PAGED_CODE();
62
63 LPCTRACE(LPC_CLOSE_DEBUG, "Message: %p. LockFlags: %lx\n", Message, LockFlags);
64
65 /* Acquire the lock if not already */
66 if (!LockHeld) KeAcquireGuardedMutex(&LpcpLock);
67
68 /* Check if the queue list is empty */
69 if (!IsListEmpty(&Message->Entry))
70 {
71 /* Remove and re-initialize */
72 RemoveEntryList(&Message->Entry);
74 }
75
76 /* Check if we've already replied */
77 if (Message->RepliedToThread)
78 {
79 /* Set thread to dereference and clean up */
80 Thread = Message->RepliedToThread;
81 Message->RepliedToThread = NULL;
82 }
83
84 /* Check if this is a connection request */
85 if (Message->Request.u2.s2.Type == LPC_CONNECTION_REQUEST)
86 {
87 /* Get the connection message */
88 ConnectMessage = (PLPCP_CONNECTION_MESSAGE)(Message + 1);
89
90 /* Clear the client port */
91 ClientPort = ConnectMessage->ClientPort;
92 if (ClientPort) ConnectMessage->ClientPort = NULL;
93 }
94
95 /* Release the lock */
97
98 /* Check if we had anything to dereference */
101
102 /* Free the entry */
103 ExFreeToPagedLookasideList(&LpcpMessagesLookaside, Message);
104
105 /* Reacquire the lock if needed */
106 if ((LockHeld) && !(ReleaseLock)) KeAcquireGuardedMutex(&LpcpLock);
107}
unsigned char BOOLEAN
_Outptr_ PFLT_PORT * ClientPort
Definition: fltkernel.h:1891
pPkgPnp m_DeviceInterfaceLock ReleaseLock(pFxDriverGlobals)
PAGED_LOOKASIDE_LIST LpcpMessagesLookaside
Definition: port.c:19
#define LPCP_LOCK_RELEASE
Definition: lpc.h:64
struct _LPCP_CONNECTION_MESSAGE * PLPCP_CONNECTION_MESSAGE
#define LPC_CONNECTION_REQUEST
Definition: port.c:102
PLPCP_PORT_OBJECT ClientPort
Definition: lpctypes.h:257

Referenced by LpcpDeletePort(), LpcpDestroyPortQueue(), LpcpFreeDataInfoMessage(), LpcRequestPort(), LpcRequestWaitReplyPort(), NtReplyPort(), NtReplyWaitReceivePortEx(), NtRequestPort(), NtRequestWaitReplyPort(), and NtSecureConnectPort().

◆ LpcpInitializePortQueue()

NTSTATUS NTAPI LpcpInitializePortQueue ( IN PLPCP_PORT_OBJECT  Port)

Definition at line 19 of file create.c.

20{
21 PLPCP_NONPAGED_PORT_QUEUE MessageQueue;
22
23 PAGED_CODE();
24
25 /* Allocate the queue */
27 sizeof(*MessageQueue),
28 'troP');
29 if (!MessageQueue) return STATUS_INSUFFICIENT_RESOURCES;
30
31 /* Set it up */
32 KeInitializeSemaphore(&MessageQueue->Semaphore, 0, MAXLONG);
33 MessageQueue->BackPointer = Port;
34
35 /* And link it with the Paged Pool part */
36 Port->MsgQueue.Semaphore = &MessageQueue->Semaphore;
37 InitializeListHead(&Port->MsgQueue.ReceiveHead);
38 return STATUS_SUCCESS;
39}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI KeInitializeSemaphore(IN PKSEMAPHORE Semaphore, IN LONG Count, IN LONG Limit)
Definition: semphobj.c:22
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _LPCP_PORT_OBJECT * BackPointer
Definition: lpctypes.h:196
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define MAXLONG
Definition: umtypes.h:116

Referenced by LpcpCreatePort(), and NtSecureConnectPort().

◆ LpcpMoveMessage()

VOID NTAPI LpcpMoveMessage ( IN PPORT_MESSAGE  Destination,
IN PPORT_MESSAGE  Origin,
IN PVOID  Data,
IN ULONG  MessageType,
IN PCLIENT_ID  ClientId 
)

Definition at line 139 of file reply.c.

144{
146 "Destination/Origin: %p/%p. Data: %p. Length: %lx\n",
148 Origin,
149 Data,
150 Origin->u1.Length);
151
152 /* Set the Message size */
153 Destination->u1.Length = Origin->u1.Length;
154
155 /* Set the Message Type */
156 Destination->u2.s2.Type = !MessageType ?
157 Origin->u2.s2.Type : MessageType & 0xFFFF;
158
159 /* Check if we have a Client ID */
160 if (ClientId)
161 {
162 /* Set the Client ID */
163 Destination->ClientId.UniqueProcess = ClientId->UniqueProcess;
164 Destination->ClientId.UniqueThread = ClientId->UniqueThread;
165 }
166 else
167 {
168 /* Otherwise, copy it */
169 Destination->ClientId.UniqueProcess = Origin->ClientId.UniqueProcess;
170 Destination->ClientId.UniqueThread = Origin->ClientId.UniqueThread;
171 }
172
173 /* Copy the MessageId and ClientViewSize */
174 Destination->MessageId = Origin->MessageId;
175 Destination->ClientViewSize = Origin->ClientViewSize;
176
177 /* Copy the Message Data */
179 Data,
180 ALIGN_UP_BY(Destination->u1.s1.DataLength, sizeof(ULONG)));
181}
#define ALIGN_UP_BY(size, align)
#define LPC_SEND_DEBUG
Definition: lpc.h:23
#define LPC_REPLY_DEBUG
Definition: lpc.h:21
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3004
HANDLE UniqueThread
Definition: compat.h:826
HANDLE UniqueProcess
Definition: compat.h:825
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1151

Referenced by LpcRequestPort(), LpcRequestWaitReplyPort(), NtReplyPort(), NtReplyWaitReceivePortEx(), NtRequestPort(), and NtRequestWaitReplyPort().

◆ LpcpSaveDataInfoMessage()

VOID NTAPI LpcpSaveDataInfoMessage ( IN PLPCP_PORT_OBJECT  Port,
IN PLPCP_MESSAGE  Message,
IN ULONG  LockFlags 
)

Definition at line 62 of file reply.c.

65{
66 BOOLEAN LockHeld = (LockFlags & LPCP_LOCK_HELD);
67
68 PAGED_CODE();
69
70 /* Acquire the lock */
71 if (!LockHeld) KeAcquireGuardedMutex(&LpcpLock);
72
73 /* Check if the port we want is the connection port */
75 {
76 /* Use it */
77 Port = Port->ConnectionPort;
78 if (!Port)
79 {
80 /* Release the lock and return */
81 if (!LockHeld) KeReleaseGuardedMutex(&LpcpLock);
82 return;
83 }
84 }
85
86 /* Link the message */
87 InsertTailList(&Port->LpcDataInfoChainHead, &Message->Entry);
88
89 /* Release the lock */
90 if (!LockHeld) KeReleaseGuardedMutex(&LpcpLock);
91}
#define InsertTailList(ListHead, Entry)
#define LPCP_UNCONNECTED_PORT
Definition: lpctypes.h:55

Referenced by NtReplyWaitReceivePortEx(), and NtRequestWaitReplyPort().

◆ LpcpValidateClientPort()

BOOLEAN NTAPI LpcpValidateClientPort ( PETHREAD  ClientThread,
PLPCP_PORT_OBJECT  Port 
)

Definition at line 90 of file port.c.

93{
94 PLPCP_PORT_OBJECT ThreadPort;
95
96 /* Get the thread's port */
98 if (ThreadPort == NULL)
99 {
100 return FALSE;
101 }
102
103 /* Check if the port matches directly */
104 if ((Port == ThreadPort) ||
105 (Port == ThreadPort->ConnectionPort) ||
106 (Port == ThreadPort->ConnectedPort))
107 {
108 return TRUE;
109 }
110
111 /* Check if this is a communication port and the connection port matches */
113 (Port->ConnectionPort == ThreadPort))
114 {
115 return TRUE;
116 }
117
118 return FALSE;
119}
UINT CALLBACK ClientThread(_Inout_ PVOID Parameter)
FORCEINLINE PLPCP_PORT_OBJECT LpcpGetPortFromThread(IN PETHREAD Thread)
Definition: lpc_x.h:144
struct _LPCP_PORT_OBJECT * ConnectedPort
Definition: lpctypes.h:212
struct _LPCP_PORT_OBJECT * ConnectionPort
Definition: lpctypes.h:211

Referenced by LpcpCopyRequestData(), and NtImpersonateClientOfPort().

Variable Documentation

◆ LpcpLock

◆ LpcpMaxMessageSize

ULONG LpcpMaxMessageSize
extern

Definition at line 18 of file port.c.

Referenced by LpcInitSystem(), and LpcpCreatePort().

◆ LpcpMessagesLookaside

PAGED_LOOKASIDE_LIST LpcpMessagesLookaside
extern

Definition at line 19 of file port.c.

Referenced by LpcInitSystem(), LpcpAllocateFromPortZone(), and LpcpFreeToPortZone().

◆ LpcpNextCallbackId

ULONG LpcpNextCallbackId

Definition at line 158 of file lpc.h.

◆ LpcpNextMessageId

ULONG LpcpNextMessageId
extern

◆ LpcPortObjectType

◆ LpcpTraceLevel

ULONG LpcpTraceLevel
extern

Definition at line 21 of file port.c.