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.

150 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. sbapi.c
  5. Abstract:
  6. This module contains the implementations of the Sb API calls exported
  7. by the Server side of the Client-Server Runtime Subsystem to the
  8. Session Manager SubSystem.
  9. Author:
  10. Steve Wood (stevewo) 8-Oct-1990
  11. Revision History:
  12. --*/
  13. #include "csrsrv.h"
  14. BOOLEAN
  15. CsrSbCreateSession(
  16. IN PSBAPIMSG Msg
  17. )
  18. {
  19. PSBCREATESESSION a = &Msg->u.CreateSession;
  20. PCSR_PROCESS Process;
  21. PCSR_THREAD Thread;
  22. PVOID ProcessDataPtr;
  23. ULONG i;
  24. NTSTATUS Status;
  25. HANDLE ProcessHandle;
  26. HANDLE ThreadHandle;
  27. KERNEL_USER_TIMES TimeInfo;
  28. ProcessHandle = a->ProcessInformation.Process;
  29. ThreadHandle = a->ProcessInformation.Thread;
  30. AcquireProcessStructureLock();
  31. Process = CsrAllocateProcess();
  32. if (Process == NULL) {
  33. Msg->ReturnedStatus = STATUS_NO_MEMORY;
  34. ReleaseProcessStructureLock();
  35. return( TRUE );
  36. }
  37. Status = NtSetInformationProcess(
  38. ProcessHandle,
  39. ProcessExceptionPort,
  40. &CsrApiPort,
  41. sizeof(HANDLE)
  42. );
  43. if ( !NT_SUCCESS(Status) ) {
  44. CsrDeallocateProcess( Process );
  45. ReleaseProcessStructureLock();
  46. return( (BOOLEAN)STATUS_NO_MEMORY );
  47. }
  48. //
  49. // capture the thread's createtime so that we can use
  50. // this as a sequence number
  51. //
  52. Status = NtQueryInformationThread(
  53. ThreadHandle,
  54. ThreadTimes,
  55. (PVOID)&TimeInfo,
  56. sizeof(TimeInfo),
  57. NULL
  58. );
  59. if ( !NT_SUCCESS(Status) ) {
  60. CsrDeallocateProcess( Process );
  61. ReleaseProcessStructureLock();
  62. return( (BOOLEAN)Status );
  63. }
  64. Thread = CsrAllocateThread( Process );
  65. if (Thread == NULL) {
  66. CsrDeallocateProcess( Process );
  67. Msg->ReturnedStatus = STATUS_NO_MEMORY;
  68. ReleaseProcessStructureLock();
  69. return( TRUE );
  70. }
  71. Thread->CreateTime = TimeInfo.CreateTime;
  72. Thread->ClientId = a->ProcessInformation.ClientId;
  73. Thread->ThreadHandle = a->ProcessInformation.Thread;
  74. ProtectHandle(Thread->ThreadHandle);
  75. Thread->Flags = 0;
  76. CsrInsertThread( Process, Thread );
  77. //
  78. // this needs a little more thought
  79. //
  80. Process->NtSession = CsrAllocateNtSession( a->SessionId );
  81. Process->ClientId = a->ProcessInformation.ClientId;
  82. Process->ProcessHandle = a->ProcessInformation.Process;
  83. CsrSetBackgroundPriority(Process);
  84. //
  85. // initialize each DLL's per process data area.
  86. //
  87. ProcessDataPtr = (PVOID)QUAD_ALIGN(&Process->ServerDllPerProcessData[CSR_MAX_SERVER_DLL]);
  88. for (i = 0; i < CSR_MAX_SERVER_DLL; i++) {
  89. if (CsrLoadedServerDll[i] != NULL && CsrLoadedServerDll[i]->PerProcessDataLength) {
  90. Process->ServerDllPerProcessData[i] = ProcessDataPtr;
  91. ProcessDataPtr = (PVOID)QUAD_ALIGN((PCHAR)ProcessDataPtr + CsrLoadedServerDll[i]->PerProcessDataLength);
  92. } else {
  93. Process->ServerDllPerProcessData[i] = NULL;
  94. }
  95. }
  96. CsrInsertProcess(NULL, Process);
  97. Msg->ReturnedStatus = NtResumeThread(a->ProcessInformation.Thread, NULL);
  98. ReleaseProcessStructureLock();
  99. return( TRUE );
  100. }
  101. BOOLEAN
  102. CsrSbTerminateSession(
  103. IN PSBAPIMSG Msg
  104. )
  105. {
  106. PSBTERMINATESESSION a = &Msg->u.TerminateSession;
  107. Msg->ReturnedStatus = STATUS_NOT_IMPLEMENTED;
  108. return( TRUE );
  109. }
  110. BOOLEAN
  111. CsrSbForeignSessionComplete(
  112. IN PSBAPIMSG Msg
  113. )
  114. {
  115. PSBFOREIGNSESSIONCOMPLETE a = &Msg->u.ForeignSessionComplete;
  116. Msg->ReturnedStatus = STATUS_NOT_IMPLEMENTED;
  117. return( TRUE );
  118. }