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.

159 lines
3.4 KiB

  1. #include "termsrvpch.h"
  2. #pragma hdrstop
  3. #include <wtsapi32.h>
  4. //
  5. // Caution! Many of these functions must perform a SetLastError() because
  6. // the callers will call GetLastError() and try to recover based on the
  7. // error code. Even more interesting, Taskmgr will sometimes pass the
  8. // error code to FormatMessage and display it to the end user. So
  9. // we can't use ERROR_PROC_NOT_FOUND = "The specified procedure could not be
  10. // found", because it is meaningless to the end user.
  11. //
  12. // I have chosen to use ERROR_FUNCTION_NOT_CALLED = "Function could not be
  13. // executed".
  14. //
  15. static
  16. VOID
  17. WINAPI
  18. WTSCloseServer(
  19. IN HANDLE hServer
  20. )
  21. {
  22. // Not much can be done here.
  23. // We will probably never hit this code anyway,
  24. // since you'd need to obtain a handle first
  25. }
  26. static
  27. BOOL
  28. WINAPI
  29. WTSDisconnectSession(
  30. IN HANDLE hServer,
  31. IN DWORD SessionId,
  32. IN BOOL bWait
  33. )
  34. {
  35. // Taskmgr needs an error code here
  36. SetLastError(ERROR_FUNCTION_NOT_CALLED);
  37. return FALSE;
  38. }
  39. BOOL
  40. WINAPI
  41. WTSEnumerateSessionsW(
  42. IN HANDLE hServer,
  43. IN DWORD Reserved,
  44. IN DWORD Version,
  45. OUT PWTS_SESSION_INFOW * ppSessionInfo,
  46. OUT DWORD * pCount
  47. )
  48. {
  49. // Windows Update needs an error code here
  50. SetLastError(ERROR_FUNCTION_NOT_CALLED);
  51. return FALSE;
  52. }
  53. VOID
  54. WINAPI
  55. WTSFreeMemory(
  56. IN PVOID pMemory
  57. )
  58. {
  59. // May as well just implement it directly since we're in kernel32 already.
  60. // Though theoretically nobody should call us since the only time you
  61. // WTSFreeMemory is after a successful WTSQuerySessionInformation.
  62. LocalFree( pMemory );
  63. }
  64. BOOL
  65. WINAPI
  66. WTSLogoffSession(
  67. IN HANDLE hServer,
  68. IN DWORD SessionId,
  69. IN BOOL bWait
  70. )
  71. {
  72. // Taskmgr needs an error code here
  73. SetLastError(ERROR_FUNCTION_NOT_CALLED);
  74. return FALSE;
  75. }
  76. HANDLE
  77. WINAPI
  78. WTSOpenServerW(
  79. IN LPWSTR pServerName
  80. )
  81. {
  82. // This function is doc'd to set the LE
  83. SetLastError(ERROR_FUNCTION_NOT_CALLED);
  84. return NULL;
  85. }
  86. BOOL
  87. WINAPI
  88. WTSQuerySessionInformationW(
  89. IN HANDLE hServer,
  90. IN DWORD SessionId,
  91. IN WTS_INFO_CLASS WTSInfoClass,
  92. OUT LPWSTR * ppBuffer,
  93. OUT DWORD * pBytesReturned
  94. )
  95. {
  96. // SessMgr.exe needs an error code here
  97. SetLastError(ERROR_FUNCTION_NOT_CALLED);
  98. return FALSE;
  99. }
  100. BOOL
  101. WINAPI
  102. WTSQueryUserToken(
  103. IN ULONG SessionId,
  104. IN PHANDLE phToken
  105. )
  106. {
  107. // Somebody might need an error code here
  108. SetLastError(ERROR_FUNCTION_NOT_CALLED);
  109. return FALSE;
  110. }
  111. BOOL
  112. WINAPI
  113. WTSSendMessageW(
  114. IN HANDLE hServer,
  115. IN DWORD SessionId,
  116. IN LPWSTR pTitle,
  117. IN DWORD TitleLength,
  118. IN LPWSTR pMessage,
  119. IN DWORD MessageLength,
  120. IN DWORD Style,
  121. IN DWORD Timeout,
  122. OUT DWORD * pResponse,
  123. IN BOOL bWait
  124. )
  125. {
  126. // Taskmgr needs an error code here
  127. SetLastError(ERROR_FUNCTION_NOT_CALLED);
  128. return FALSE;
  129. }
  130. //
  131. // !! WARNING !! The entries below must be in alphabetical order, and are CASE SENSITIVE (eg lower case comes last!)
  132. //
  133. DEFINE_PROCNAME_ENTRIES(wtsapi32)
  134. {
  135. DLPENTRY(WTSCloseServer)
  136. DLPENTRY(WTSDisconnectSession)
  137. DLPENTRY(WTSEnumerateSessionsW)
  138. DLPENTRY(WTSFreeMemory)
  139. DLPENTRY(WTSLogoffSession)
  140. DLPENTRY(WTSOpenServerW)
  141. DLPENTRY(WTSQuerySessionInformationW)
  142. DLPENTRY(WTSQueryUserToken)
  143. DLPENTRY(WTSSendMessageW)
  144. };
  145. DEFINE_PROCNAME_MAP(wtsapi32)