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.

153 lines
3.7 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. }
  93. else {
  94. Process->ServerDllPerProcessData[i] = NULL;
  95. }
  96. }
  97. CsrInsertProcess( NULL, NULL, Process );
  98. Msg->ReturnedStatus = NtResumeThread( a->ProcessInformation.Thread,
  99. NULL
  100. );
  101. ReleaseProcessStructureLock();
  102. return( TRUE );
  103. }
  104. BOOLEAN
  105. CsrSbTerminateSession(
  106. IN PSBAPIMSG Msg
  107. )
  108. {
  109. PSBTERMINATESESSION a = &Msg->u.TerminateSession;
  110. Msg->ReturnedStatus = STATUS_NOT_IMPLEMENTED;
  111. return( TRUE );
  112. }
  113. BOOLEAN
  114. CsrSbForeignSessionComplete(
  115. IN PSBAPIMSG Msg
  116. )
  117. {
  118. PSBFOREIGNSESSIONCOMPLETE a = &Msg->u.ForeignSessionComplete;
  119. Msg->ReturnedStatus = STATUS_NOT_IMPLEMENTED;
  120. return( TRUE );
  121. }