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.

298 lines
7.7 KiB

  1. /*************************************************************************
  2. *
  3. * server.c
  4. *
  5. * Client side APIs for server-level administration
  6. *
  7. * Copyright Microsoft Corporation, 1999
  8. *
  9. *************************************************************************/
  10. /*
  11. * Includes
  12. */
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <ntddkbd.h>
  17. #include <ntddmou.h>
  18. #include <windows.h>
  19. #include <winbase.h>
  20. #include <winerror.h>
  21. #include <allproc.h>
  22. #include <winsta.h>
  23. /*
  24. * Include the RPC generated common header
  25. */
  26. #include "tsrpc.h"
  27. #include "rpcwire.h"
  28. #ifdef NTSDDEBUG
  29. #define NTSDDBGPRINT(x) DbgPrint x
  30. #else
  31. #define NTSDDBGPRINT(x)
  32. #endif
  33. #if DBG
  34. ULONG
  35. DbgPrint(
  36. PCH Format,
  37. ...
  38. );
  39. #define DBGPRINT(x) DbgPrint x
  40. #if DBGTRACE
  41. #define TRACE0(x) DbgPrint x
  42. #define TRACE1(x) DbgPrint x
  43. #else
  44. #define TRACE0(x)
  45. #define TRACE1(x)
  46. #endif
  47. #else
  48. #define DBGPRINT(x)
  49. #define TRACE0(x)
  50. #define TRACE1(x)
  51. #endif
  52. /*
  53. * This handle is returned when there is no terminal
  54. * server present on the system. (Non-Hydra)
  55. */
  56. #define RPC_HANDLE_NO_SERVER (HANDLE)IntToPtr( 0xFFFFFFFD )
  57. /*
  58. * Private Procedures defined here
  59. */
  60. /*
  61. * Global data
  62. */
  63. /*
  64. * other internal Procedures used (not defined here)
  65. */
  66. VOID WinStationConfigU2A( PWINSTATIONCONFIGA, PWINSTATIONCONFIGW );
  67. ULONG CheckUserBuffer(WINSTATIONINFOCLASS,
  68. PVOID,
  69. ULONG,
  70. PVOID *,
  71. PULONG,
  72. BOOLEAN *);
  73. BOOLEAN
  74. RpcLocalAutoBind(
  75. VOID
  76. );
  77. /*
  78. * Check to see that caller does not hold the loader critsec.
  79. * WinStation APIs must NOT be called while holding the loader critsec
  80. * since deadlock may occur.
  81. */
  82. #define CheckLoaderLock() \
  83. ASSERT( NtCurrentTeb()->ClientId.UniqueThread != \
  84. ((PRTL_CRITICAL_SECTION)(NtCurrentPeb()->LoaderLock))->OwningThread );
  85. /*
  86. * Handle the SERVERNAME_CURRENT for auto local binding.
  87. */
  88. #define HANDLE_CURRENT_BINDING( hServer ) \
  89. CheckLoaderLock(); \
  90. if( hServer == SERVERNAME_CURRENT ) { \
  91. if( IcaApi_IfHandle == NULL ) { \
  92. if( !RpcLocalAutoBind() ) { \
  93. return FALSE; \
  94. } \
  95. } \
  96. hServer = IcaApi_IfHandle; \
  97. } \
  98. if( hServer == RPC_HANDLE_NO_SERVER ) { \
  99. *pResult = ERROR_APP_WRONG_OS; \
  100. return FALSE; \
  101. }
  102. /******************************************************************************
  103. *
  104. * ServerGetInternetConnectorStatus
  105. *
  106. * Returns whether Internet Connector licensing is being used
  107. *
  108. * ENTRY:
  109. *
  110. * EXIT:
  111. *
  112. * TRUE -- The query succeeded, and pfEnabled contains the requested data.
  113. *
  114. * FALSE -- The operation failed. Extended error status is in pResult
  115. *
  116. ******************************************************************************/
  117. BOOLEAN
  118. ServerGetInternetConnectorStatus(
  119. HANDLE hServer,
  120. DWORD *pResult,
  121. PBOOLEAN pfEnabled
  122. )
  123. {
  124. BOOLEAN rc = FALSE;
  125. if (pResult == NULL)
  126. {
  127. goto Done;
  128. }
  129. HANDLE_CURRENT_BINDING( hServer );
  130. RpcTryExcept {
  131. rc = RpcServerGetInternetConnectorStatus(hServer,
  132. pResult,
  133. pfEnabled
  134. );
  135. *pResult = RtlNtStatusToDosError( *pResult );
  136. }
  137. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode())) {
  138. *pResult = RpcExceptionCode();
  139. }
  140. RpcEndExcept
  141. Done:
  142. return rc;
  143. }
  144. /******************************************************************************
  145. *
  146. * ServerSetInternetConnectorStatus
  147. *
  148. * This function will (if fEnabled has changed from its previous setting):
  149. * Check that the caller has administrative privileges,
  150. * Modify the corresponding value in the registry,
  151. * Change licensing mode (between normal per-seat and Internet Connector.
  152. *
  153. * ENTRY:
  154. *
  155. * EXIT:
  156. *
  157. * TRUE -- The operation succeeded.
  158. *
  159. * FALSE -- The operation failed. Extended error status is in pResult
  160. *
  161. ******************************************************************************/
  162. BOOLEAN
  163. ServerSetInternetConnectorStatus(
  164. HANDLE hServer,
  165. DWORD *pResult,
  166. BOOLEAN fEnabled
  167. )
  168. {
  169. BOOLEAN rc = FALSE;
  170. if (pResult == NULL)
  171. {
  172. goto Done;
  173. }
  174. HANDLE_CURRENT_BINDING( hServer );
  175. RpcTryExcept {
  176. rc = RpcServerSetInternetConnectorStatus(hServer,
  177. pResult,
  178. fEnabled
  179. );
  180. // STATUS_LICENSE_VIOLATION has no DOS error to map to
  181. if (*pResult != STATUS_LICENSE_VIOLATION)
  182. *pResult = RtlNtStatusToDosError( *pResult );
  183. }
  184. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode())) {
  185. *pResult = RpcExceptionCode();
  186. }
  187. RpcEndExcept
  188. Done:
  189. return rc;
  190. }
  191. /*******************************************************************************
  192. *
  193. * ServerQueryInetConnectorInformationA (ANSI stub)
  194. *
  195. * Queries the server for internet connector configuration information.
  196. *
  197. * ENTRY:
  198. *
  199. * see ServerQueryInetConnectorInformationW
  200. *
  201. * EXIT:
  202. *
  203. * see ServerQueryInetConnectorInformationW
  204. *
  205. ******************************************************************************/
  206. BOOLEAN
  207. ServerQueryInetConnectorInformationA(
  208. HANDLE hServer,
  209. PVOID pWinStationInformation,
  210. ULONG WinStationInformationLength,
  211. PULONG pReturnLength
  212. )
  213. {
  214. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  215. return(FALSE);
  216. }
  217. /*******************************************************************************
  218. *
  219. * ServerQueryInetConnectorInformationW (UNICODE)
  220. *
  221. * Queries the server for internet connector configuration information.
  222. *
  223. * ENTRY:
  224. *
  225. * WinStationHandle (input)
  226. * Identifies the window station object. The handle must have
  227. * WINSTATION_QUERY access.
  228. *
  229. * pWinStationInformation (output)
  230. * A pointer to a buffer that will receive information about the
  231. * specified window station. The format and contents of the buffer
  232. * depend on the specified information class being queried.
  233. *
  234. * WinStationInformationLength (input)
  235. * Specifies the length in bytes of the window station information
  236. * buffer.
  237. *
  238. * pReturnLength (output)
  239. * An optional parameter that if specified, receives the number of
  240. * bytes placed in the window station information buffer.
  241. *
  242. * EXIT:
  243. *
  244. * TRUE -- The query succeeded, and the buffer contains the requested data.
  245. *
  246. * FALSE -- The operation failed. Extended error status is available
  247. * using GetLastError.
  248. *
  249. ******************************************************************************/
  250. BOOLEAN
  251. ServerQueryInetConnectorInformationW(
  252. HANDLE hServer,
  253. PVOID pWinStationInformation,
  254. ULONG WinStationInformationLength,
  255. PULONG pReturnLength
  256. )
  257. {
  258. SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  259. return(FALSE);
  260. }