Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. lpclistn.c
  5. Abstract:
  6. Local Inter-Process Communication (LPC) connection system services.
  7. Author:
  8. Steve Wood (stevewo) 15-May-1989
  9. Revision History:
  10. --*/
  11. #include "lpcp.h"
  12. #ifdef ALLOC_PRAGMA
  13. #pragma alloc_text(PAGE,NtListenPort)
  14. #endif
  15. NTSTATUS
  16. NtListenPort (
  17. IN HANDLE PortHandle,
  18. OUT PPORT_MESSAGE ConnectionRequest
  19. )
  20. /*++
  21. Routine Description:
  22. A server thread can listen for connection requests from client threads
  23. using the NtReplyWaitReceivePort service and looking for an
  24. LPC_CONNECTION_REQUEST message type.
  25. This call will loop, calling the NtReplyWaitReceivePort service, and
  26. return when it sees a message of type LPC_CONNECTION_REQUEST
  27. Arguments:
  28. PortHandle - Specifies the connection port to listen for connection
  29. requests to.
  30. ConnectionRequest - Pointer to a structure that describes the
  31. connection request the client is making:
  32. Return Value:
  33. NTSTATUS - An appropriate status value
  34. --*/
  35. {
  36. NTSTATUS Status;
  37. PAGED_CODE();
  38. //
  39. // Keep on looping until we get a connection request on the lpc port
  40. //
  41. while (TRUE) {
  42. Status = NtReplyWaitReceivePort( PortHandle,
  43. NULL,
  44. NULL,
  45. ConnectionRequest );
  46. //
  47. // We'll return from this procedure if ever we get back non success
  48. // or the message is a connection request. We still need to protect
  49. // the testing of ConnectionRequest because it is a user supplied
  50. // buffer.
  51. //
  52. try {
  53. if ((Status != STATUS_SUCCESS) ||
  54. ((ConnectionRequest->u2.s2.Type & ~LPC_KERNELMODE_MESSAGE) == LPC_CONNECTION_REQUEST)) {
  55. break;
  56. }
  57. } except( EXCEPTION_EXECUTE_HANDLER ) {
  58. Status = GetExceptionCode();
  59. break;
  60. }
  61. }
  62. //
  63. // And return to our caller
  64. //
  65. return Status;
  66. }