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.

125 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. smcsup.c
  5. Abstract:
  6. Session Manager Client Support APIs
  7. Author:
  8. Mark Lucovsky (markl) 05-Oct-1989
  9. Revision History:
  10. --*/
  11. #include "smdllp.h"
  12. #include <string.h>
  13. NTSTATUS
  14. SmConnectToSm(
  15. IN PUNICODE_STRING SbApiPortName OPTIONAL,
  16. IN HANDLE SbApiPort OPTIONAL,
  17. IN ULONG SbImageType OPTIONAL,
  18. OUT PHANDLE SmApiPort
  19. )
  20. /*++
  21. Routine Description:
  22. This function is used to connect to the NT Session Manager
  23. Arguments:
  24. SbApiPortName - Supplies the name of the sub system's session management
  25. API port (for Sb APIs). That the session manager is to connect with.
  26. SbApiPort - Supplies a port handle to the connection port where the
  27. subsystem's session management (Sb) APIs are exported.
  28. SbImageType - Supplies the image type that the connecting subsystem
  29. serves.
  30. SmApiPort - Returns the communication port which is connected to the
  31. session manager and over which Sm APIs may be made.
  32. Return Value:
  33. TBD.
  34. --*/
  35. {
  36. NTSTATUS st;
  37. UNICODE_STRING PortName;
  38. ULONG ConnectInfoLength;
  39. PSBCONNECTINFO ConnectInfo;
  40. SBAPIMSG Message;
  41. SECURITY_QUALITY_OF_SERVICE DynamicQos;
  42. //
  43. // Set up the security quality of service parameters to use over the
  44. // port. Use the most efficient (least overhead) - which is dynamic
  45. // rather than static tracking.
  46. //
  47. DynamicQos.ImpersonationLevel = SecurityImpersonation;
  48. DynamicQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
  49. DynamicQos.EffectiveOnly = TRUE;
  50. RtlInitUnicodeString(&PortName,L"\\SmApiPort");
  51. ConnectInfoLength = sizeof(SBCONNECTINFO);
  52. ConnectInfo = &Message.ConnectionRequest;
  53. //
  54. // Subsystems must specify an SbApiPortName
  55. //
  56. if ( ARGUMENT_PRESENT(SbApiPortName) ) {
  57. if ( !ARGUMENT_PRESENT(SbApiPort) ) {
  58. return STATUS_INVALID_PARAMETER_MIX;
  59. }
  60. if ( !SbImageType ) {
  61. return STATUS_INVALID_PARAMETER_MIX;
  62. }
  63. RtlCopyMemory(
  64. ConnectInfo->EmulationSubSystemPortName,
  65. SbApiPortName->Buffer,
  66. SbApiPortName->Length
  67. );
  68. ConnectInfo->EmulationSubSystemPortName[SbApiPortName->Length>>1] = UNICODE_NULL;
  69. ConnectInfo->SubsystemImageType = SbImageType;
  70. } else {
  71. ConnectInfo->EmulationSubSystemPortName[0] = UNICODE_NULL;
  72. ConnectInfo->SubsystemImageType = 0;
  73. }
  74. st = NtConnectPort(
  75. SmApiPort,
  76. &PortName,
  77. &DynamicQos,
  78. NULL,
  79. NULL,
  80. NULL,
  81. ConnectInfo,
  82. &ConnectInfoLength
  83. );
  84. if ( !NT_SUCCESS(st) ) {
  85. KdPrint(("SmConnectToSm: Connect to Sm failed %lx\n",st));
  86. return st;
  87. }
  88. return STATUS_SUCCESS;
  89. }