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.

407 lines
10 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. apppool.c
  5. Abstract:
  6. User-mode interface to UL.SYS.
  7. Author:
  8. Keith Moore (keithmo) 15-Dec-1998
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. //
  13. // Private macros.
  14. //
  15. //
  16. // Private prototypes.
  17. //
  18. //
  19. // Public functions.
  20. //
  21. /***************************************************************************++
  22. Routine Description:
  23. Creates a new Application Pool.
  24. Arguments:
  25. pAppPoolHandle - Receives a handle to the new application pool.
  26. object.
  27. pAppPoolName - Supplies the name of the new application pool.
  28. pSecurityAttributes - Optionally supplies security attributes for
  29. the new application pool.
  30. Options - Supplies creation options.
  31. Return Value:
  32. ULONG - Completion status.
  33. --***************************************************************************/
  34. ULONG
  35. WINAPI
  36. HttpCreateAppPool(
  37. OUT PHANDLE pAppPoolHandle,
  38. IN PCWSTR pAppPoolName,
  39. IN PSECURITY_ATTRIBUTES pSecurityAttributes OPTIONAL,
  40. IN ULONG Options
  41. )
  42. {
  43. NTSTATUS status;
  44. //
  45. // Make the request.
  46. //
  47. status = HttpApiOpenDriverHelper(
  48. pAppPoolHandle, // pHandle
  49. GENERIC_READ | // DesiredAccess
  50. GENERIC_WRITE |
  51. SYNCHRONIZE |
  52. WRITE_DAC, // WAS needs WRITE DAC permissions
  53. // to support different worker process permissions.
  54. HttpApiAppPoolHandleType, // HandleType
  55. pAppPoolName, // pObjectName
  56. Options, // Options
  57. FILE_CREATE, // CreateDisposition
  58. pSecurityAttributes // pSecurityAttributes
  59. );
  60. //
  61. // If we couldn't open the driver because it's not running, then try
  62. // to start the driver & retry the open.
  63. //
  64. if (status == STATUS_OBJECT_NAME_NOT_FOUND ||
  65. status == STATUS_OBJECT_PATH_NOT_FOUND)
  66. {
  67. if (HttpApiTryToStartDriver())
  68. {
  69. status = HttpApiOpenDriverHelper(
  70. pAppPoolHandle, // pHandle
  71. GENERIC_READ | // DesiredAccess
  72. GENERIC_WRITE |
  73. SYNCHRONIZE,
  74. HttpApiAppPoolHandleType, // HandleType
  75. pAppPoolName, // pObjectName
  76. Options, // Options
  77. FILE_CREATE, // CreateDisposition
  78. pSecurityAttributes // pSecurityAttributes
  79. );
  80. }
  81. }
  82. return HttpApiNtStatusToWin32Status( status );
  83. } // HttpCreateAppPool
  84. /***************************************************************************++
  85. Routine Description:
  86. Opens an existing application pool.
  87. Arguments:
  88. pAppPoolHandle - Receives a handle to the existing application pool object.
  89. pAppPoolName - Supplies the name of the existing application pool.
  90. Options - Supplies open options.
  91. Return Value:
  92. ULONG - Completion status.
  93. --***************************************************************************/
  94. ULONG
  95. WINAPI
  96. HttpOpenAppPool(
  97. OUT PHANDLE pAppPoolHandle,
  98. IN PCWSTR pAppPoolName,
  99. IN ULONG Options
  100. )
  101. {
  102. NTSTATUS status;
  103. //
  104. // Make the request.
  105. //
  106. status = HttpApiOpenDriverHelper(
  107. pAppPoolHandle, // pHandle
  108. GENERIC_READ | // DesiredAccess
  109. SYNCHRONIZE,
  110. HttpApiAppPoolHandleType, // HandleType
  111. pAppPoolName, // pObjectName
  112. Options, // Options
  113. FILE_OPEN, // CreateDisposition
  114. NULL // pSecurityAttributes
  115. );
  116. return HttpApiNtStatusToWin32Status( status );
  117. } // HttpOpenAppPool
  118. /***************************************************************************++
  119. Routine Description:
  120. Queries information from a application pool.
  121. Arguments:
  122. AppPoolHandle - Supplies a handle to a UL.SYS application pool
  123. as returned from either HttpCreateAppPool() or
  124. HttpOpenAppPool().
  125. InformationClass - Supplies the type of information to query.
  126. pAppPoolInformation - Supplies a buffer for the query.
  127. Length - Supplies the length of pAppPoolInformation.
  128. pReturnLength - Receives the length of data written to the buffer.
  129. Return Value:
  130. ULONG - Completion status.
  131. --***************************************************************************/
  132. ULONG
  133. WINAPI
  134. HttpQueryAppPoolInformation(
  135. IN HANDLE AppPoolHandle,
  136. IN HTTP_APP_POOL_INFORMATION_CLASS InformationClass,
  137. OUT PVOID pAppPoolInformation,
  138. IN ULONG Length,
  139. OUT PULONG pReturnLength OPTIONAL
  140. )
  141. {
  142. NTSTATUS status;
  143. HTTP_APP_POOL_INFO appPoolInfo;
  144. //
  145. // Initialize the input structure.
  146. //
  147. appPoolInfo.InformationClass = InformationClass;
  148. //
  149. // Make the request.
  150. //
  151. status = HttpApiSynchronousDeviceControl(
  152. AppPoolHandle, // FileHandle
  153. IOCTL_HTTP_QUERY_APP_POOL_INFORMATION, // IoControlCode
  154. &appPoolInfo, // pInputBuffer
  155. sizeof(appPoolInfo), // InputBufferLength
  156. pAppPoolInformation, // pOutputBuffer
  157. Length, // OutputBufferLength
  158. pReturnLength // pBytesTransferred
  159. );
  160. return HttpApiNtStatusToWin32Status( status );
  161. } // HttpQueryAppPoolInformation
  162. /***************************************************************************++
  163. Routine Description:
  164. Sets information in an admin container.
  165. Arguments:
  166. AppPoolHandle - Supplies a handle to a UL.SYS application pool
  167. as returned from either HttpCreateAppPool() or
  168. HttpOpenAppPool().
  169. InformationClass - Supplies the type of information to set.
  170. pAppPoolInformation - Supplies the data to set.
  171. Length - Supplies the length of pAppPoolInformation.
  172. Return Value:
  173. ULONG - Completion status.
  174. --***************************************************************************/
  175. ULONG
  176. WINAPI
  177. HttpSetAppPoolInformation(
  178. IN HANDLE AppPoolHandle,
  179. IN HTTP_APP_POOL_INFORMATION_CLASS InformationClass,
  180. IN PVOID pAppPoolInformation,
  181. IN ULONG Length
  182. )
  183. {
  184. NTSTATUS status;
  185. HTTP_APP_POOL_INFO appPoolInfo;
  186. //
  187. // Initialize the input structure.
  188. //
  189. appPoolInfo.InformationClass = InformationClass;
  190. //
  191. // Make the request.
  192. //
  193. status = HttpApiSynchronousDeviceControl(
  194. AppPoolHandle, // FileHandle
  195. IOCTL_HTTP_SET_APP_POOL_INFORMATION, // IoControlCode
  196. &appPoolInfo, // pInputBuffer
  197. sizeof(appPoolInfo), // InputBufferLength
  198. pAppPoolInformation, // pOutputBuffer
  199. Length, // OutputBufferLength
  200. NULL // pBytesTransferred
  201. );
  202. return HttpApiNtStatusToWin32Status( status );
  203. } // HttpSetAppPoolInformation
  204. /***************************************************************************++
  205. Routine Description:
  206. Adds a transient URL prefix.
  207. Arguments:
  208. AppPoolHandle - Supplies a handle to a UL.SYS application pool
  209. as returned from either HttpCreateAppPool() or
  210. HttpOpenAppPool().
  211. pFullyQualifiedUrl - the URL prefix to add
  212. Return Value:
  213. Completion status.
  214. --***************************************************************************/
  215. ULONG
  216. WINAPI
  217. HttpAddTransientUrl(
  218. IN HANDLE AppPoolHandle,
  219. IN PCWSTR pFullyQualifiedUrl
  220. )
  221. {
  222. NTSTATUS status;
  223. HTTP_TRANSIENT_URL_INFO transientUrlInfo;
  224. //
  225. // Initialize the input structure.
  226. //
  227. RtlInitUnicodeString(
  228. &transientUrlInfo.FullyQualifiedUrl,
  229. pFullyQualifiedUrl
  230. );
  231. //
  232. // Make the request.
  233. //
  234. status = HttpApiSynchronousDeviceControl(
  235. AppPoolHandle, // FileHandle
  236. IOCTL_HTTP_ADD_TRANSIENT_URL, // IoControlCode
  237. &transientUrlInfo, // pInputBuffer
  238. sizeof(transientUrlInfo), // InputBufferLength
  239. NULL, // pOutputBuffer
  240. 0, // OutputBufferLength
  241. NULL // pBytesTransferred
  242. );
  243. return HttpApiNtStatusToWin32Status( status );
  244. } // HttpAddTransientUrl
  245. /***************************************************************************++
  246. Routine Description:
  247. Removes a transient URL prefix.
  248. Arguments:
  249. AppPoolHandle - Supplies a handle to a UL.SYS application pool
  250. as returned from either HttpCreateAppPool() or
  251. HttpOpenAppPool().
  252. pFullyQualifiedUrl - the URL prefix to add
  253. Return Value:
  254. Completion status.
  255. --***************************************************************************/
  256. ULONG
  257. WINAPI
  258. HttpRemoveTransientUrl(
  259. IN HANDLE AppPoolHandle,
  260. IN PCWSTR pFullyQualifiedUrl
  261. )
  262. {
  263. NTSTATUS status;
  264. HTTP_TRANSIENT_URL_INFO transientUrlInfo;
  265. //
  266. // Initialize the input structure.
  267. //
  268. RtlInitUnicodeString(
  269. &transientUrlInfo.FullyQualifiedUrl,
  270. pFullyQualifiedUrl
  271. );
  272. //
  273. // Make the request.
  274. //
  275. status = HttpApiSynchronousDeviceControl(
  276. AppPoolHandle, // FileHandle
  277. IOCTL_HTTP_REMOVE_TRANSIENT_URL, // IoControlCode
  278. &transientUrlInfo, // pInputBuffer
  279. sizeof(transientUrlInfo), // InputBufferLength
  280. NULL, // pOutputBuffer
  281. 0, // OutputBufferLength
  282. NULL // pBytesTransferred
  283. );
  284. return HttpApiNtStatusToWin32Status( status );
  285. } // HttpRemoveTransientUrl
  286. //
  287. // Private functions.
  288. //