test: lpclistn.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# lpclistn.c File Reference

`#include "lpcp.h"`

Go to the source code of this file.

## Functions

NTSTATUS | NtListenPort (IN HANDLE PortHandle, OUT PPORT_MESSAGE ConnectionRequest)

## Function Documentation

NTSTATUS NtListenPort | ( | IN HANDLE | PortHandle,
|  | OUT PPORT_MESSAGE | ConnectionRequest
| ) |

Definition at line 29 of file lpclistn.c.

References EXCEPTION_EXECUTE_HANDLER, NtReplyWaitReceivePort(), NTSTATUS(), NULL, PAGED_CODE, PortHandle, Status, and TRUE.

    00036                    :
    00037
    00038     A server thread can listen for connection requests from client threads
    00039     using the NtReplyWaitReceivePort service and looking for an
    00040     LPC_CONNECTION_REQUEST message type.
    00041
    00042     This call will loop, calling the NtReplyWaitReceivePort service, and
    00043     return when it sees a message of type LPC_CONNECTION_REQUEST
    00044
    00045 Arguments:
    00046
    00047     PortHandle - Specifies the connection port to listen for connection
    00048         requests to.
    00049
    00050     ConnectionRequest - Pointer to a structure that describes the
    00051         connection request the client is making:
    00052
    00053 Return Value:
    00054
    00055     NTSTATUS - An appropriate status value
    00056
    00057 --*/
    00058
    00059 {
    00060     NTSTATUS Status;
    00061
    00062     PAGED_CODE();
    00063
    00064     //
    00065     //  Keep on looping until we get a connection request on the lpc port
    00066     //
    00067
    00068     while (TRUE) {
    00069
    00070         Status = NtReplyWaitReceivePort( PortHandle,
    00071                                          NULL,
    00072                                          NULL,
    00073                                          ConnectionRequest );
    00074
    00075         //
    00076         //  We'll return from this procedure if ever we get back non success
    00077         //  or the message is a connection request.  We still need to protect
    00078         //  the testing of ConnectionRequest because it is a user supplied
    00079         //  buffer.
    00080         //
    00081
    00082         try {
    00083
    00084             if ((Status != STATUS_SUCCESS) ||
    00085                 ((ConnectionRequest->u2.s2.Type & ~LPC_KERNELMODE_MESSAGE) == LPC_CONNECTION_REQUEST)) {
    00086
    00087                 break;
    00088             }
    00089
    00090         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00091
    00092             Status = GetExceptionCode();
    00093
    00094             break;
    00095         }
    00096     }
    00097
    00098     //
    00099     //  And return to our caller
    00100     //
    00101
    00102     return Status;
    00103 }
    }