ReactOS  0.4.14-dev-77-gd9e7c48
connect.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/lpc/connect.c
5  * PURPOSE: Local Procedure Call: Connection Management
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* PRIVATE FUNCTIONS *********************************************************/
16 
17 PVOID
18 NTAPI
20  IN OUT PLPCP_CONNECTION_MESSAGE *ConnectMessage,
21  IN PETHREAD CurrentThread)
22 {
23  PVOID SectionToMap;
25 
26  /* Acquire the LPC lock */
28 
29  /* Check if the reply chain is not empty */
30  if (!IsListEmpty(&CurrentThread->LpcReplyChain))
31  {
32  /* Remove this entry and re-initialize it */
33  RemoveEntryList(&CurrentThread->LpcReplyChain);
34  InitializeListHead(&CurrentThread->LpcReplyChain);
35  }
36 
37  /* Check if there's a reply message */
38  ReplyMessage = LpcpGetMessageFromThread(CurrentThread);
39  if (ReplyMessage)
40  {
41  /* Get the message */
43 
44  /* Check if it's got messages */
45  if (!IsListEmpty(&ReplyMessage->Entry))
46  {
47  /* Clear the list */
50  }
51 
52  /* Clear message data */
53  CurrentThread->LpcReceivedMessageId = 0;
54  CurrentThread->LpcReplyMessage = NULL;
55 
56  /* Get the connection message and clear the section */
57  *ConnectMessage = (PLPCP_CONNECTION_MESSAGE)(ReplyMessage + 1);
58  SectionToMap = (*ConnectMessage)->SectionToMap;
59  (*ConnectMessage)->SectionToMap = NULL;
60  }
61  else
62  {
63  /* No message to return */
64  *Message = NULL;
65  SectionToMap = NULL;
66  }
67 
68  /* Release the lock and return the section */
70  return SectionToMap;
71 }
72 
73 /* PUBLIC FUNCTIONS **********************************************************/
74 
75 /*
76  * @implemented
77  */
79 NTAPI
82  IN PSECURITY_QUALITY_OF_SERVICE SecurityQos,
83  IN OUT PPORT_VIEW ClientView OPTIONAL,
84  IN PSID ServerSid OPTIONAL,
85  IN OUT PREMOTE_PORT_VIEW ServerView OPTIONAL,
86  OUT PULONG MaxMessageLength OPTIONAL,
87  IN OUT PVOID ConnectionInformation OPTIONAL,
88  IN OUT PULONG ConnectionInformationLength OPTIONAL)
89 {
93  SECURITY_QUALITY_OF_SERVICE CapturedQos;
94  PORT_VIEW CapturedClientView;
95  PSID CapturedServerSid;
96  ULONG ConnectionInfoLength = 0;
99  PLPCP_CONNECTION_MESSAGE ConnectMessage;
100  ULONG PortMessageLength;
101  HANDLE Handle;
102  PVOID SectionToMap;
104  PTOKEN Token;
105  PTOKEN_USER TokenUserInfo;
106 
107  PAGED_CODE();
109  "Name: %wZ. SecurityQos: %p. Views: %p/%p. Sid: %p\n",
110  PortName,
111  SecurityQos,
112  ClientView,
113  ServerView,
114  ServerSid);
115 
116  /* Check if the call comes from user mode */
117  if (PreviousMode != KernelMode)
118  {
119  /* Enter SEH for probing the parameters */
120  _SEH2_TRY
121  {
122  /* Probe the PortHandle */
123  ProbeForWriteHandle(PortHandle);
124 
125  /* Probe and capture the QoS */
126  ProbeForRead(SecurityQos, sizeof(*SecurityQos), sizeof(ULONG));
127  CapturedQos = *(volatile SECURITY_QUALITY_OF_SERVICE*)SecurityQos;
128  /* NOTE: Do not care about CapturedQos.Length */
129 
130  /* The following parameters are optional */
131 
132  /* Capture the client view */
133  if (ClientView)
134  {
135  ProbeForWrite(ClientView, sizeof(*ClientView), sizeof(ULONG));
136  CapturedClientView = *(volatile PORT_VIEW*)ClientView;
137 
138  /* Validate the size of the client view */
139  if (CapturedClientView.Length != sizeof(CapturedClientView))
140  {
141  /* Invalid size */
143  }
144 
145  }
146 
147  /* Capture the server view */
148  if (ServerView)
149  {
150  ProbeForWrite(ServerView, sizeof(*ServerView), sizeof(ULONG));
151 
152  /* Validate the size of the server view */
153  if (((volatile REMOTE_PORT_VIEW*)ServerView)->Length != sizeof(*ServerView))
154  {
155  /* Invalid size */
157  }
158  }
159 
160  if (MaxMessageLength)
161  ProbeForWriteUlong(MaxMessageLength);
162 
163  /* Capture connection information length */
164  if (ConnectionInformationLength)
165  {
166  ProbeForWriteUlong(ConnectionInformationLength);
167  ConnectionInfoLength = *(volatile ULONG*)ConnectionInformationLength;
168  }
169 
170  /* Probe the ConnectionInformation */
171  if (ConnectionInformation)
172  ProbeForWrite(ConnectionInformation, ConnectionInfoLength, sizeof(ULONG));
173 
174  CapturedServerSid = ServerSid;
175  if (ServerSid != NULL)
176  {
177  /* Capture it */
178  Status = SepCaptureSid(ServerSid,
179  PreviousMode,
180  PagedPool,
181  TRUE,
182  &CapturedServerSid);
183  if (!NT_SUCCESS(Status))
184  {
185  DPRINT1("Failed to capture ServerSid!\n");
186  _SEH2_YIELD(return Status);
187  }
188  }
189  }
191  {
192  /* There was an exception, return the exception code */
194  }
195  _SEH2_END;
196  }
197  else
198  {
199  CapturedQos = *SecurityQos;
200  /* NOTE: Do not care about CapturedQos.Length */
201 
202  /* The following parameters are optional */
203 
204  /* Capture the client view */
205  if (ClientView)
206  {
207  /* Validate the size of the client view */
208  if (ClientView->Length != sizeof(*ClientView))
209  {
210  /* Invalid size */
212  }
213  CapturedClientView = *ClientView;
214  }
215 
216  /* Capture the server view */
217  if (ServerView)
218  {
219  /* Validate the size of the server view */
220  if (ServerView->Length != sizeof(*ServerView))
221  {
222  /* Invalid size */
224  }
225  }
226 
227  /* Capture connection information length */
228  if (ConnectionInformationLength)
229  ConnectionInfoLength = *ConnectionInformationLength;
230 
231  CapturedServerSid = ServerSid;
232  }
233 
234  /* Get the port */
236  0,
237  NULL,
238  PORT_CONNECT,
240  PreviousMode,
241  NULL,
242  (PVOID*)&Port);
243  if (!NT_SUCCESS(Status))
244  {
245  DPRINT1("Failed to reference port '%wZ': 0x%lx\n", PortName, Status);
246 
247  if (CapturedServerSid != ServerSid)
248  SepReleaseSid(CapturedServerSid, PreviousMode, TRUE);
249 
250  return Status;
251  }
252 
253  /* This has to be a connection port */
255  {
256  DPRINT1("Port '%wZ' is not a connection port (Flags: 0x%lx)\n", PortName, Port->Flags);
257 
258  /* It isn't, so fail */
260 
261  if (CapturedServerSid != ServerSid)
262  SepReleaseSid(CapturedServerSid, PreviousMode, TRUE);
263 
265  }
266 
267  /* Check if we have a (captured) SID */
268  if (ServerSid)
269  {
270  /* Make sure that we have a server */
271  if (Port->ServerProcess)
272  {
273  /* Get its token and query user information */
274  Token = PsReferencePrimaryToken(Port->ServerProcess);
275  Status = SeQueryInformationToken(Token, TokenUser, (PVOID*)&TokenUserInfo);
277 
278  /* Check for success */
279  if (NT_SUCCESS(Status))
280  {
281  /* Compare the SIDs */
282  if (!RtlEqualSid(CapturedServerSid, TokenUserInfo->User.Sid))
283  {
284  /* Fail */
285  DPRINT1("Port '%wZ': server SID mismatch\n", PortName);
287  }
288 
289  /* Free token information */
290  ExFreePoolWithTag(TokenUserInfo, TAG_SE);
291  }
292  }
293  else
294  {
295  /* Invalid SID */
296  DPRINT1("Port '%wZ': server SID mismatch\n", PortName);
298  }
299 
300  /* Finally release the captured SID, we don't need it anymore */
301  if (CapturedServerSid != ServerSid)
302  SepReleaseSid(CapturedServerSid, PreviousMode, TRUE);
303 
304  /* Check if SID failed */
305  if (!NT_SUCCESS(Status))
306  {
307  /* Quit */
309  return Status;
310  }
311  }
312 
313  /* Create the client port */
316  NULL,
317  PreviousMode,
318  NULL,
319  sizeof(LPCP_PORT_OBJECT),
320  0,
321  0,
322  (PVOID*)&ClientPort);
323  if (!NT_SUCCESS(Status))
324  {
325  /* Failed, dereference the server port and return */
326  DPRINT1("Failed to create Port object: 0x%lx\n", Status);
328  return Status;
329  }
330 
331  /*
332  * Setup the client port -- From now on, dereferencing the client port
333  * will automatically dereference the connection port too.
334  */
336  ClientPort->Flags = LPCP_CLIENT_PORT;
337  ClientPort->ConnectionPort = Port;
338  ClientPort->MaxMessageLength = Port->MaxMessageLength;
339  ClientPort->SecurityQos = CapturedQos;
340  InitializeListHead(&ClientPort->LpcReplyChainHead);
341  InitializeListHead(&ClientPort->LpcDataInfoChainHead);
342 
343  /* Check if we have dynamic security */
345  {
346  /* Remember that */
348  }
349  else
350  {
351  /* Create our own client security */
353  &CapturedQos,
354  FALSE,
355  &ClientPort->StaticSecurity);
356  if (!NT_SUCCESS(Status))
357  {
358  /* Security failed, dereference and return */
359  DPRINT1("SeCreateClientSecurity failed: 0x%lx\n", Status);
361  return Status;
362  }
363  }
364 
365  /* Initialize the port queue */
367  if (!NT_SUCCESS(Status))
368  {
369  /* Failed */
370  DPRINT1("LpcpInitializePortQueue failed: 0x%lx\n", Status);
372  return Status;
373  }
374 
375  /* Check if we have a client view */
376  if (ClientView)
377  {
378  /* Get the section handle */
379  Status = ObReferenceObjectByHandle(CapturedClientView.SectionHandle,
383  PreviousMode,
384  (PVOID*)&SectionToMap,
385  NULL);
386  if (!NT_SUCCESS(Status))
387  {
388  /* Fail */
389  DPRINT1("Failed to reference port section handle: 0x%lx\n", Status);
391  return Status;
392  }
393 
394  /* Set the section offset */
395  SectionOffset.QuadPart = CapturedClientView.SectionOffset;
396 
397  /* Map it */
398  Status = MmMapViewOfSection(SectionToMap,
400  &ClientPort->ClientSectionBase,
401  0,
402  0,
403  &SectionOffset,
404  &CapturedClientView.ViewSize,
405  ViewUnmap,
406  0,
408 
409  /* Update the offset */
410  CapturedClientView.SectionOffset = SectionOffset.LowPart;
411 
412  /* Check for failure */
413  if (!NT_SUCCESS(Status))
414  {
415  /* Fail */
416  DPRINT1("Failed to map port section: 0x%lx\n", Status);
417  ObDereferenceObject(SectionToMap);
419  return Status;
420  }
421 
422  /* Update the base */
423  CapturedClientView.ViewBase = ClientPort->ClientSectionBase;
424 
425  /* Reference and remember the process */
426  ClientPort->MappingProcess = PsGetCurrentProcess();
427  ObReferenceObject(ClientPort->MappingProcess);
428  }
429  else
430  {
431  /* No section */
432  SectionToMap = NULL;
433  }
434 
435  /* Normalize connection information */
436  if (ConnectionInfoLength > Port->MaxConnectionInfoLength)
437  {
438  /* Use the port's maximum allowed value */
439  ConnectionInfoLength = Port->MaxConnectionInfoLength;
440  }
441 
442  /* Allocate a message from the port zone */
444  if (!Message)
445  {
446  /* Fail if we couldn't allocate a message */
447  DPRINT1("LpcpAllocateFromPortZone failed\n");
448  if (SectionToMap) ObDereferenceObject(SectionToMap);
450  return STATUS_NO_MEMORY;
451  }
452 
453  /* Set pointer to the connection message and fill in the CID */
454  ConnectMessage = (PLPCP_CONNECTION_MESSAGE)(Message + 1);
455  Message->Request.ClientId = Thread->Cid;
456 
457  /* Check if we have a client view */
458  if (ClientView)
459  {
460  /* Set the view size */
461  Message->Request.ClientViewSize = CapturedClientView.ViewSize;
462 
463  /* Copy the client view and clear the server view */
464  RtlCopyMemory(&ConnectMessage->ClientView,
465  &CapturedClientView,
466  sizeof(CapturedClientView));
467  RtlZeroMemory(&ConnectMessage->ServerView, sizeof(REMOTE_PORT_VIEW));
468  }
469  else
470  {
471  /* Set the size to 0 and clear the connect message */
472  Message->Request.ClientViewSize = 0;
473  RtlZeroMemory(ConnectMessage, sizeof(LPCP_CONNECTION_MESSAGE));
474  }
475 
476  /* Set the section and client port. Port is NULL for now */
477  ConnectMessage->ClientPort = NULL;
478  ConnectMessage->SectionToMap = SectionToMap;
479 
480  /* Set the data for the connection request message */
481  Message->Request.u1.s1.DataLength = (CSHORT)ConnectionInfoLength +
482  sizeof(LPCP_CONNECTION_MESSAGE);
483  Message->Request.u1.s1.TotalLength = sizeof(LPCP_MESSAGE) +
484  Message->Request.u1.s1.DataLength;
485  Message->Request.u2.s2.Type = LPC_CONNECTION_REQUEST;
486 
487  /* Check if we have connection information */
488  if (ConnectionInformation)
489  {
490  _SEH2_TRY
491  {
492  /* Copy it in */
493  RtlCopyMemory(ConnectMessage + 1,
494  ConnectionInformation,
495  ConnectionInfoLength);
496  }
498  {
499  DPRINT1("Exception 0x%lx when copying connection info to user mode\n",
501 
502  /* Cleanup and return the exception code */
503 
504  /* Free the message we have */
506 
507  /* Dereference other objects */
508  if (SectionToMap) ObDereferenceObject(SectionToMap);
510 
511  /* Return status */
513  }
514  _SEH2_END;
515  }
516 
517  /* Reset the status code */
519 
520  /* Acquire the port lock */
522 
523  /* Check if someone already deleted the port name */
525  {
526  /* Fail the request */
528  }
529  else
530  {
531  /* Associate no thread yet */
532  Message->RepliedToThread = NULL;
533 
534  /* Generate the Message ID and set it */
535  Message->Request.MessageId = LpcpNextMessageId++;
537  Thread->LpcReplyMessageId = Message->Request.MessageId;
538 
539  /* Insert the message into the queue and thread chain */
540  InsertTailList(&Port->MsgQueue.ReceiveHead, &Message->Entry);
541  InsertTailList(&Port->LpcReplyChainHead, &Thread->LpcReplyChain);
542  Thread->LpcReplyMessage = Message;
543 
544  /* Now we can finally reference the client port and link it */
546  ConnectMessage->ClientPort = ClientPort;
547 
548  /* Enter a critical region */
550  }
551 
552  /* Add another reference to the port */
554 
555  /* Release the lock */
557 
558  /* Check for success */
559  if (NT_SUCCESS(Status))
560  {
562  "Messages: %p/%p. Ports: %p/%p. Status: %lx\n",
563  Message,
564  ConnectMessage,
565  Port,
566  ClientPort,
567  Status);
568 
569  /* If this is a waitable port, set the event */
571  KeSetEvent(&Port->WaitEvent, 1, FALSE);
572 
573  /* Release the queue semaphore and leave the critical region */
574  LpcpCompleteWait(Port->MsgQueue.Semaphore);
576 
577  /* Now wait for a reply and set 'Status' */
578  LpcpConnectWait(&Thread->LpcReplySemaphore, PreviousMode);
579  }
580 
581  /* Now, always free the connection message */
582  SectionToMap = LpcpFreeConMsg(&Message, &ConnectMessage, Thread);
583 
584  /* Check for failure */
585  if (!NT_SUCCESS(Status))
586  {
587  /* Check if the semaphore got signaled in the meantime */
588  if (KeReadStateSemaphore(&Thread->LpcReplySemaphore))
589  {
590  /* Wait on it */
591  KeWaitForSingleObject(&Thread->LpcReplySemaphore,
592  WrExecutive,
593  KernelMode,
594  FALSE,
595  NULL);
596  }
597 
598  goto Failure;
599  }
600 
601  /* Check if we got a message back */
602  if (Message)
603  {
604  /* Check for new return length */
605  if ((Message->Request.u1.s1.DataLength -
606  sizeof(LPCP_CONNECTION_MESSAGE)) < ConnectionInfoLength)
607  {
608  /* Set new normalized connection length */
609  ConnectionInfoLength = Message->Request.u1.s1.DataLength -
610  sizeof(LPCP_CONNECTION_MESSAGE);
611  }
612 
613  /* Check if the caller had connection information */
614  if (ConnectionInformation)
615  {
616  _SEH2_TRY
617  {
618  /* Return the connection information length if needed */
619  if (ConnectionInformationLength)
620  *ConnectionInformationLength = ConnectionInfoLength;
621 
622  /* Return the connection information */
623  RtlCopyMemory(ConnectionInformation,
624  ConnectMessage + 1,
625  ConnectionInfoLength);
626  }
628  {
629  /* Cleanup and return the exception code */
631  _SEH2_YIELD(goto Failure);
632  }
633  _SEH2_END;
634  }
635 
636  /* Make sure we had a connected port */
637  if (ClientPort->ConnectedPort)
638  {
639  /* Get the message length before the port might get killed */
640  PortMessageLength = Port->MaxMessageLength;
641 
642  /* Insert the client port */
644  NULL,
646  0,
647  NULL,
648  &Handle);
649  if (NT_SUCCESS(Status))
650  {
652  "Handle: %p. Length: %lx\n",
653  Handle,
654  PortMessageLength);
655 
656  _SEH2_TRY
657  {
658  /* Return the handle */
659  *PortHandle = Handle;
660 
661  /* Check if maximum length was requested */
662  if (MaxMessageLength)
663  *MaxMessageLength = PortMessageLength;
664 
665  /* Check if we had a client view */
666  if (ClientView)
667  {
668  /* Copy it back */
669  RtlCopyMemory(ClientView,
670  &ConnectMessage->ClientView,
671  sizeof(*ClientView));
672  }
673 
674  /* Check if we had a server view */
675  if (ServerView)
676  {
677  /* Copy it back */
678  RtlCopyMemory(ServerView,
679  &ConnectMessage->ServerView,
680  sizeof(*ServerView));
681  }
682  }
684  {
685  /* An exception happened, close the opened handle */
688  }
689  _SEH2_END;
690  }
691  }
692  else
693  {
694  /* No connection port, we failed */
695  if (SectionToMap) ObDereferenceObject(SectionToMap);
696 
697  /* Acquire the lock */
699 
700  /* Check if it's because the name got deleted */
701  if (!(ClientPort->ConnectionPort) ||
703  {
704  /* Set the correct status */
706  }
707  else
708  {
709  /* Otherwise, the caller refused us */
711  }
712 
713  /* Release the lock */
715 
716  /* Kill the port */
718  }
719 
720  /* Free the message */
722  }
723  else
724  {
725  /* No reply message, fail */
727  goto Failure;
728  }
729 
731 
732  /* Return status */
733  return Status;
734 
735 Failure:
736  /* Check if we had a message and free it */
738 
739  /* Dereference other objects */
740  if (SectionToMap) ObDereferenceObject(SectionToMap);
743 
744  /* Return status */
745  return Status;
746 }
747 
748 /*
749  * @implemented
750  */
751 NTSTATUS
752 NTAPI
755  IN PSECURITY_QUALITY_OF_SERVICE SecurityQos,
756  IN OUT PPORT_VIEW ClientView OPTIONAL,
757  IN OUT PREMOTE_PORT_VIEW ServerView OPTIONAL,
758  OUT PULONG MaxMessageLength OPTIONAL,
759  IN OUT PVOID ConnectionInformation OPTIONAL,
760  IN OUT PULONG ConnectionInformationLength OPTIONAL)
761 {
762  /* Call the newer API */
763  return NtSecureConnectPort(PortHandle,
764  PortName,
765  SecurityQos,
766  ClientView,
767  NULL,
768  ServerView,
769  MaxMessageLength,
770  ConnectionInformation,
771  ConnectionInformationLength);
772 }
773 
774 /* EOF */
#define ProbeForWriteUlong(Ptr)
Definition: probe.h:36
#define STATUS_SERVER_SID_MISMATCH
Definition: ntstatus.h:773
CPPORT Port[4]
Definition: headless.c:34
#define IN
Definition: typedefs.h:38
REMOTE_PORT_VIEW ServerView
Definition: lpctypes.h:259
struct _LPCP_CONNECTION_MESSAGE * PLPCP_CONNECTION_MESSAGE
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
KGUARDED_MUTEX LpcpLock
Definition: port.c:20
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define LpcpCompleteWait(s)
Definition: lpc_x.h:88
#define KeGetPreviousMode()
Definition: ketypes.h:1107
LONG NTSTATUS
Definition: precomp.h:26
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE Token
_Outptr_ PFLT_PORT * ClientPort
Definition: fltkernel.h:1892
ULONG SectionOffset
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define InsertTailList(ListHead, Entry)
#define LPCP_PORT_TYPE_MASK
Definition: lpctypes.h:58
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define PAGED_CODE()
Definition: video.h:57
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
_SEH2_TRY
Definition: create.c:4250
#define STATUS_INVALID_PORT_HANDLE
Definition: ntstatus.h:288
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define STATUS_PORT_CONNECTION_REFUSED
Definition: ntstatus.h:287
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
ULONG LpcpNextMessageId
Definition: port.c:22
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NTAPI NtSecureConnectPort(OUT PHANDLE PortHandle, IN PUNICODE_STRING PortName, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, IN OUT PPORT_VIEW ClientView OPTIONAL, IN PSID ServerSid OPTIONAL, IN OUT PREMOTE_PORT_VIEW ServerView OPTIONAL, OUT PULONG MaxMessageLength OPTIONAL, IN OUT PVOID ConnectionInformation OPTIONAL, IN OUT PULONG ConnectionInformationLength OPTIONAL)
Definition: connect.c:80
#define LPCP_CONNECTION_PORT
Definition: lpctypes.h:54
USHORT Flags
Definition: cportlib.h:31
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
FORCEINLINE PLPCP_MESSAGE LpcpGetMessageFromThread(IN PETHREAD Thread)
Definition: lpc_x.h:129
LIST_ENTRY LpcReplyChain
Definition: pstypes.h:1039
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI LpcpFreeConMsg(IN OUT PLPCP_MESSAGE *Message, IN OUT PLPCP_CONNECTION_MESSAGE *ConnectMessage, IN PETHREAD CurrentThread)
Definition: connect.c:19
#define LpcpConnectWait(s, w)
Definition: lpc_x.h:60
NTKERNELAPI NTSTATUS NTAPI SeCreateClientSecurity(IN PETHREAD Thread, IN PSECURITY_QUALITY_OF_SERVICE QualityOfService, IN BOOLEAN RemoteClient, OUT PSECURITY_CLIENT_CONTEXT ClientContext)
Definition: access.c:506
BOOL WINAPI ReplyMessage(_In_ LRESULT)
NTSTATUS NTAPI MmMapViewOfSection(IN PVOID SectionObject, IN PEPROCESS Process, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:4502
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:952
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:404
static __inline PLPCP_MESSAGE LpcpAllocateFromPortZone(VOID)
Definition: lpc_x.h:100
#define SECTION_MAP_WRITE
Definition: nt_native.h:1288
POBJECT_TYPE LpcPortObjectType
Definition: port.c:17
NTSTATUS NTAPI LpcpInitializePortQueue(IN PLPCP_PORT_OBJECT Port)
Definition: create.c:19
_In_ HANDLE Handle
Definition: extypes.h:390
#define TAG_SE
Definition: tag.h:173
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
#define PORT_CONNECT
Definition: lpctypes.h:46
NTSTATUS NTAPI NtConnectPort(OUT PHANDLE PortHandle, IN PUNICODE_STRING PortName, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, IN OUT PPORT_VIEW ClientView OPTIONAL, IN OUT PREMOTE_PORT_VIEW ServerView OPTIONAL, OUT PULONG MaxMessageLength OPTIONAL, IN OUT PVOID ConnectionInformation OPTIONAL, IN OUT PULONG ConnectionInformationLength OPTIONAL)
Definition: connect.c:753
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LPC_SIZE_T ViewSize
CLIENT_ID Cid
Definition: pstypes.h:1059
#define ProbeForWriteHandle(Ptr)
Definition: probe.h:43
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
POBJECT_TYPE MmSectionObjectType
Definition: section.c:136
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
CHAR Message[80]
Definition: alive.c:5
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define LPCP_NAME_DELETED
Definition: lpctypes.h:61
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define SECTION_MAP_READ
Definition: compat.h:128
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
PACCESS_TOKEN NTAPI PsReferencePrimaryToken(PEPROCESS Process)
Definition: security.c:440
#define LPCP_WAITABLE_PORT
Definition: lpctypes.h:60
Status
Definition: gdiplustypes.h:24
VOID NTAPI LpcpFreeToPortZone(IN PLPCP_MESSAGE Message, IN ULONG LockFlags)
Definition: close.c:52
PLPCP_PORT_OBJECT ClientPort
Definition: lpctypes.h:257
LPC_PVOID ViewBase
_SEH2_END
Definition: create.c:4424
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2932
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
NTSTATUS NTAPI SeQueryInformationToken(IN PACCESS_TOKEN AccessToken, IN TOKEN_INFORMATION_CLASS TokenInformationClass, OUT PVOID *TokenInformation)
Definition: token.c:1309
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LONG NTAPI KeReadStateSemaphore(IN PKSEMAPHORE Semaphore)
Definition: semphobj.c:41
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int * PULONG
Definition: retypes.h:1
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
VOID NTAPI SepReleaseSid(IN PSID CapturedSid, IN KPROCESSOR_MODE AccessMode, IN BOOLEAN CaptureIfKernel)
Definition: sid.c:342
VOID NTAPI PsDereferencePrimaryToken(IN PACCESS_TOKEN PrimaryToken)
Definition: security.c:835
#define DPRINT1
Definition: precomp.h:8
struct _LPCP_MESSAGE LPCP_MESSAGE
#define PORT_ALL_ACCESS
Definition: lpctypes.h:47
struct _LPCP_CONNECTION_MESSAGE LPCP_CONNECTION_MESSAGE
#define OUT
Definition: typedefs.h:39
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define LPCP_SECURITY_DYNAMIC
Definition: lpctypes.h:62
#define LPC_CONNECT_DEBUG
Definition: lpc.h:19
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
LPC_HANDLE SectionHandle
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
short CSHORT
Definition: umtypes.h:127
NTSTATUS NTAPI SepCaptureSid(IN PSID InputSid, IN KPROCESSOR_MODE AccessMode, IN POOL_TYPE PoolType, IN BOOLEAN CaptureIfKernel, OUT PSID *CapturedSid)
Definition: sid.c:274
NTSTATUS NTAPI ObReferenceObjectByName(IN PUNICODE_STRING ObjectPath, IN ULONG Attributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext, OUT PVOID *ObjectPtr)
Definition: obref.c:411
#define LPCTRACE(x, fmt,...)
Definition: lpc.h:49
#define LPCP_CLIENT_PORT
Definition: lpctypes.h:57
NTSYSAPI BOOLEAN NTAPI RtlEqualSid(_In_ PSID Sid1, _In_ PSID Sid2)
#define PAGE_READWRITE
Definition: nt_native.h:1304
IN PUNICODE_STRING PortName
Definition: conport.c:35
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68