Source code of Windows XP (NT5)
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.

143 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. sbreqst.c
  5. Abstract:
  6. This module contains the Server Request thread procedure for the Sb
  7. API calls exported by the POSIX Emulation SubSystem to the Session
  8. Manager SubSystem.
  9. Author:
  10. Steve Wood (stevewo) 20-Sep-1989
  11. Revision History:
  12. Ellen Aycock-Wright (ellena) 16-Jul-91 Modified for POSIX
  13. --*/
  14. #include "psxsrv.h"
  15. NTSTATUS
  16. PsxSbApiHandleConnectionRequest(
  17. IN PSBAPIMSG Message
  18. );
  19. //PSB_API_ROUTINE PsxServerSbApiDispatch[ SbMaxApiNumber+1 ] = {
  20. // PsxSbCreateSession,
  21. // PsxSbTerminateSession,
  22. // PsxSbForeignSessionComplete,
  23. // NULL
  24. //};
  25. NTSTATUS
  26. PsxSbApiRequestThread(
  27. IN PVOID Parameter
  28. )
  29. {
  30. NTSTATUS Status;
  31. SBAPIMSG ReceiveMsg;
  32. PSBAPIMSG ReplyMsg;
  33. UNREFERENCED_PARAMETER(Parameter);
  34. ReplyMsg = NULL;
  35. while (TRUE) {
  36. IF_PSX_DEBUG( LPC ) {
  37. KdPrint(("PSXSS: Sb Api Request Thread waiting...\n"));
  38. }
  39. Status = NtReplyWaitReceivePort(PsxSbApiPort, NULL,
  40. (PPORT_MESSAGE)ReplyMsg, (PPORT_MESSAGE)&ReceiveMsg);
  41. if (Status != 0) {
  42. if (NT_SUCCESS(Status)) {
  43. continue; // Try again if alerted or a failure
  44. } else {
  45. IF_PSX_DEBUG( LPC ) {
  46. KdPrint(("PSXSS: SB ReceivePort failed:Status == %X\n",
  47. Status));
  48. }
  49. break;
  50. }
  51. }
  52. //
  53. // Check to see if this is a connection request and handle
  54. //
  55. if (ReceiveMsg.h.u2.s2.Type == LPC_CONNECTION_REQUEST) {
  56. PsxSbApiHandleConnectionRequest( &ReceiveMsg );
  57. ReplyMsg = NULL;
  58. continue;
  59. }
  60. if (ReceiveMsg.ApiNumber >= SbMaxApiNumber) {
  61. IF_PSX_DEBUG(LPC) {
  62. KdPrint(("PSXSS: %lx is invalid Sb ApiNumber\n",
  63. ReceiveMsg.ApiNumber));
  64. }
  65. ReceiveMsg.ApiNumber = SbMaxApiNumber;
  66. }
  67. ReplyMsg = &ReceiveMsg;
  68. if (ReceiveMsg.ApiNumber < SbMaxApiNumber) {
  69. // if (!(*PsxServerSbApiDispatch[ ReceiveMsg.ApiNumber ])( &ReceiveMsg )) {
  70. ReplyMsg = NULL;
  71. // }
  72. // }
  73. // else {
  74. // ReplyMsg->ReturnedStatus = STATUS_NOT_IMPLEMENTED;
  75. }
  76. }
  77. NtTerminateThread( NtCurrentThread(), Status );
  78. //
  79. // This line should never be executed
  80. //
  81. return STATUS_SUCCESS;
  82. }
  83. NTSTATUS
  84. PsxSbApiHandleConnectionRequest(
  85. IN PSBAPIMSG Message
  86. )
  87. {
  88. NTSTATUS st;
  89. REMOTE_PORT_VIEW ClientView;
  90. HANDLE CommunicationPort;
  91. //
  92. // The protocol for a subsystem is to connect to the session manager,
  93. // then to listen and accept a connection from the session manager
  94. //
  95. ClientView.Length = sizeof(ClientView);
  96. st = NtAcceptConnectPort(
  97. &CommunicationPort,
  98. NULL,
  99. (PPORT_MESSAGE)Message,
  100. TRUE,
  101. NULL,
  102. &ClientView
  103. );
  104. if ( !NT_SUCCESS(st) ) {
  105. KdPrint(("PSXSS: Sb Accept Connection failed %lx\n",st));
  106. return st;
  107. }
  108. st = NtCompleteConnectPort(CommunicationPort);
  109. if ( !NT_SUCCESS(st) ) {
  110. KdPrint(("PSXSS: Sb Complete Connection failed %lx\n",st));
  111. }
  112. return st;
  113. }