Windows NT 4.0 source code leak
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.

105 lines
2.2 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. nullloop.c
  5. Abstract:
  6. Session Manager Listen and API loops
  7. Author:
  8. Mark Lucovsky (markl) 04-Oct-1989
  9. Revision History:
  10. --*/
  11. #include "nullsrvp.h"
  12. PNULLAPI NullSrvApiDispatch[NullMaxApiNumber] = {
  13. NullSrvNull1,
  14. NullSrvNull4,
  15. NullSrvNull8,
  16. NullSrvNull16
  17. };
  18. #if DBG
  19. PSZ NullSrvApiName[ NullMaxApiNumber+1 ] = {
  20. "NullSrvNull1",
  21. "NullSrvNull4",
  22. "NullSrvNull8",
  23. "NullSrvNull16",
  24. "Unknown Sm Api Number"
  25. };
  26. #endif // DBG
  27. NTSTATUS
  28. NullSrvApiLoop (
  29. IN PVOID ThreadParameter
  30. )
  31. {
  32. PNULLAPIMSG ApiReplyMsg;
  33. NULLAPIMSG ApiMsg;
  34. NTSTATUS Status;
  35. HANDLE ConnectionPort,CommunicationPort;
  36. ConnectionPort = (HANDLE) ThreadParameter;
  37. ApiReplyMsg = NULL;
  38. for(;;) {
  39. Status = NtReplyWaitReceivePort(
  40. ConnectionPort,
  41. NULL,
  42. (PPORT_MESSAGE) ApiReplyMsg,
  43. (PPORT_MESSAGE) &ApiMsg
  44. );
  45. if ( !NT_SUCCESS(Status) ) {
  46. ApiReplyMsg = NULL;
  47. continue;
  48. }
  49. else if ( ApiMsg.h.u2.s2.Type == LPC_CONNECTION_REQUEST ) {
  50. Status = NtAcceptConnectPort(
  51. &CommunicationPort,
  52. NULL,
  53. &ApiMsg,
  54. TRUE,
  55. NULL,
  56. NULL
  57. );
  58. if (!NT_SUCCESS(Status)) {
  59. printf("NtAccept Failed %x\n",Status);
  60. ExitProcess(1);
  61. }
  62. Status = NtCompleteConnectPort(CommunicationPort);
  63. if (!NT_SUCCESS(Status)) {
  64. printf("NtAccept Failed %x\n",Status);
  65. ExitProcess(1);
  66. }
  67. ApiReplyMsg = NULL;
  68. }
  69. else if ( ApiMsg.h.u2.s2.Type == LPC_PORT_CLOSED ) {
  70. ApiReplyMsg = NULL;
  71. }
  72. else {
  73. Status = (NullSrvApiDispatch[ApiMsg.ApiNumber])(&ApiMsg);
  74. ApiMsg.ReturnedStatus = Status;
  75. ApiReplyMsg = &ApiMsg;
  76. }
  77. }
  78. //
  79. // Make the compiler happy
  80. //
  81. return STATUS_UNSUCCESSFUL;
  82. }