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.

83 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. sbinit.c
  5. Abstract:
  6. This module contains code to initialize the SbApiPort of the
  7. POSIX Subsystem.
  8. Author:
  9. Steve Wood (stevewo) 22-Aug-1989
  10. Revision History:
  11. Ellen Aycock-Wright (ellena) 10-Jul-1991 Modified for POSIX
  12. --*/
  13. #include "psxsrv.h"
  14. #include "sesport.h"
  15. #include <windef.h>
  16. #include <winbase.h>
  17. NTSTATUS
  18. PsxSbApiPortInitialize( VOID )
  19. {
  20. NTSTATUS Status;
  21. OBJECT_ATTRIBUTES ObjectAttributes;
  22. PSX_GET_SESSION_OBJECT_NAME(&PsxSbApiPortName_U, PSX_SS_SBAPI_PORT_NAME);
  23. IF_PSX_DEBUG( LPC ) {
  24. KdPrint(("PSXSS: Creating %wZ port and associated thread\n",
  25. &PsxSbApiPortName_U));
  26. }
  27. InitializeObjectAttributes(&ObjectAttributes, &PsxSbApiPortName_U, 0, NULL,
  28. NULL);
  29. Status = NtCreatePort(&PsxSbApiPort, &ObjectAttributes,
  30. sizeof(SBCONNECTINFO), sizeof(SBAPIMSG),
  31. sizeof(SBAPIMSG) * 32);
  32. ASSERT(NT_SUCCESS(Status));
  33. if (!NT_SUCCESS(Status)) {
  34. NtTerminateProcess(NtCurrentProcess(), 1);
  35. }
  36. PsxServerThreadHandles[PSX_SS_SBAPI_REQUEST_THREAD] = CreateThread(NULL, 0,
  37. (LPTHREAD_START_ROUTINE)PsxSbApiRequestThread, NULL,
  38. CREATE_SUSPENDED,
  39. (LPDWORD)&PsxServerThreadClientIds[PSX_SS_SBAPI_REQUEST_THREAD]);
  40. ASSERT(NULL != PsxServerThreadHandles[PSX_SS_SBAPI_REQUEST_THREAD]);
  41. if (NULL == PsxServerThreadHandles[PSX_SS_SBAPI_REQUEST_THREAD]) {
  42. NtTerminateProcess(NtCurrentProcess(), 1);
  43. }
  44. Status = ResumeThread(PsxServerThreadHandles[PSX_SS_SBAPI_REQUEST_THREAD]);
  45. ASSERT(-1 != Status);
  46. return Status;
  47. }
  48. VOID
  49. PsxSbApiPortTerminate(
  50. NTSTATUS Status
  51. )
  52. {
  53. IF_PSX_DEBUG(LPC) {
  54. KdPrint(("PSXSS: Closing %Z port and associated thread\n",
  55. &PsxSbApiPortName));
  56. }
  57. NtTerminateThread(PsxServerThreadHandles[PSX_SS_SBAPI_REQUEST_THREAD],
  58. Status);
  59. NtClose(PsxSbApiPort);
  60. NtClose(PsxSmApiPort);
  61. }