xref: /reactos/ntoskrnl/lpc/listen.c (revision 40462c92)
1 /*
2  * PROJECT:         ReactOS Kernel
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * FILE:            ntoskrnl/lpc/listen.c
5  * PURPOSE:         Local Procedure Call: Listening
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 /* PUBLIC FUNCTIONS **********************************************************/
16 
17 /*
18  * @implemented
19  */
20 NTSTATUS
21 NTAPI
22 NtListenPort(IN HANDLE PortHandle,
23              OUT PPORT_MESSAGE ConnectMessage)
24 {
25     NTSTATUS Status;
26 
27     PAGED_CODE();
28     LPCTRACE(LPC_LISTEN_DEBUG, "Handle: %p\n", PortHandle);
29 
30     /* Wait forever for a connection request */
31     for (;;)
32     {
33         /* Do the wait */
34         Status = NtReplyWaitReceivePort(PortHandle,
35                                         NULL,
36                                         NULL,
37                                         ConnectMessage);
38 
39         _SEH2_TRY
40         {
41             /* Accept only LPC_CONNECTION_REQUEST requests */
42             if ((Status != STATUS_SUCCESS) ||
43                 (LpcpGetMessageType(ConnectMessage) == LPC_CONNECTION_REQUEST))
44             {
45                 /* Break out */
46                 _SEH2_YIELD(break);
47             }
48         }
49         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
50         {
51             Status = _SEH2_GetExceptionCode();
52             _SEH2_YIELD(break);
53         }
54         _SEH2_END;
55     }
56 
57     /* Return status */
58     return Status;
59 }
60 
61 /* EOF */
62