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.

856 lines
17 KiB

  1. /*++
  2. Copyright (c) 1998-2002 Microsoft Corporation
  3. Module Name:
  4. proc.h
  5. Abstract:
  6. This module contains routine prototypes for UL.
  7. Author:
  8. Keith Moore (keithmo) 10-Jun-1998
  9. Revision History:
  10. --*/
  11. #ifndef _PROC_H_
  12. #define _PROC_H_
  13. //
  14. // Device driver entry routine from INIT.C.
  15. //
  16. EXTERN_C
  17. NTSTATUS
  18. DriverEntry(
  19. IN PDRIVER_OBJECT DriverObject,
  20. IN PUNICODE_STRING RegistryPath
  21. );
  22. //
  23. // IRP handlers from various modules.
  24. //
  25. NTSTATUS
  26. UlCleanup(
  27. IN PDEVICE_OBJECT DeviceObject,
  28. IN PIRP Irp
  29. );
  30. NTSTATUS
  31. UlClose(
  32. IN PDEVICE_OBJECT DeviceObject,
  33. IN PIRP Irp
  34. );
  35. NTSTATUS
  36. UlCreate(
  37. IN PDEVICE_OBJECT DeviceObject,
  38. IN PIRP Irp
  39. );
  40. NTSTATUS
  41. UlDeviceControl (
  42. IN PDEVICE_OBJECT DeviceObject,
  43. IN PIRP Irp
  44. );
  45. NTSTATUS
  46. UlEtwDispatch(
  47. IN PDEVICE_OBJECT DeviceObject,
  48. IN PIRP Irp
  49. );
  50. //
  51. // Fast IO handler from DEVCTRL.C.
  52. //
  53. BOOLEAN
  54. UlFastDeviceControl(
  55. IN PFILE_OBJECT FileObject,
  56. IN BOOLEAN Wait,
  57. IN PVOID InputBuffer OPTIONAL,
  58. IN ULONG InputBufferLength,
  59. OUT PVOID OutputBuffer OPTIONAL,
  60. IN ULONG OutputBufferLength,
  61. IN ULONG IoControlCode,
  62. OUT PIO_STATUS_BLOCK IoStatus,
  63. IN PDEVICE_OBJECT DeviceObject
  64. );
  65. //
  66. // Global data initialization/termination from DATA.C.
  67. //
  68. NTSTATUS
  69. UlInitializeData(
  70. PUL_CONFIG pConfig
  71. );
  72. VOID
  73. UlTerminateData(
  74. VOID
  75. );
  76. //
  77. // Utility functions from MISC.C.
  78. //
  79. NTSTATUS
  80. UlOpenRegistry(
  81. IN PUNICODE_STRING BaseName,
  82. OUT PHANDLE ParametersHandle,
  83. IN PWSTR OptionalParameterString
  84. );
  85. LONG
  86. UlReadLongParameter(
  87. IN HANDLE ParametersHandle,
  88. IN PWCHAR ValueName,
  89. IN LONG DefaultValue
  90. );
  91. LONGLONG
  92. UlReadLongLongParameter(
  93. IN HANDLE ParametersHandle,
  94. IN PWCHAR ValueName,
  95. IN LONGLONG DefaultValue
  96. );
  97. NTSTATUS
  98. UlReadGenericParameter(
  99. IN HANDLE ParametersHandle,
  100. IN PWCHAR ValueName,
  101. OUT PKEY_VALUE_PARTIAL_INFORMATION * Value
  102. );
  103. VOID
  104. UlBuildDeviceControlIrp(
  105. IN OUT PIRP Irp,
  106. IN ULONG IoControlCode,
  107. IN PVOID InputBuffer OPTIONAL,
  108. IN ULONG InputBufferLength,
  109. IN PVOID OutputBuffer OPTIONAL,
  110. IN ULONG OutputBufferLength,
  111. IN PMDL MdlAddress,
  112. IN PFILE_OBJECT FileObject,
  113. IN PDEVICE_OBJECT DeviceObject,
  114. IN PIO_STATUS_BLOCK IoStatusBlock,
  115. IN PIO_COMPLETION_ROUTINE CompletionRoutine,
  116. IN PVOID CompletionContext,
  117. IN PETHREAD TargetThread OPTIONAL
  118. );
  119. PSTR
  120. UlULongLongToAscii(
  121. IN PSTR String,
  122. IN ULONGLONG Value
  123. );
  124. NTSTATUS
  125. _RtlIntegerToUnicode(
  126. IN ULONG Integer,
  127. IN ULONG Base OPTIONAL,
  128. IN LONG BufferLength,
  129. OUT PWSTR pBuffer
  130. );
  131. __inline
  132. NTSTATUS
  133. UlAnsiToULongLong(
  134. PUCHAR pString,
  135. USHORT StringLength,
  136. ULONG Base,
  137. PULONGLONG pValue
  138. )
  139. {
  140. ASSERT(StringLength > 0);
  141. return HttpAnsiStringToULongLong(
  142. pString,
  143. StringLength,
  144. TRUE, // LeadingZerosAllowed
  145. Base,
  146. NULL, // ppTerminator
  147. pValue
  148. );
  149. }
  150. __inline
  151. NTSTATUS
  152. UlUnicodeToULongLong(
  153. PWCHAR pString,
  154. USHORT StringLength,
  155. ULONG Base,
  156. PULONGLONG pValue
  157. )
  158. {
  159. ASSERT(StringLength > 0);
  160. return HttpWideStringToULongLong(
  161. pString,
  162. StringLength,
  163. TRUE, // LeadingZerosAllowed
  164. Base,
  165. NULL, // ppTerminator
  166. pValue
  167. );
  168. }
  169. NTSTATUS
  170. UlIssueDeviceControl(
  171. IN PUX_TDI_OBJECT pTdiObject,
  172. IN PVOID pIrpParameters,
  173. IN ULONG IrpParametersLength,
  174. IN PVOID pMdlBuffer OPTIONAL,
  175. IN ULONG MdlBufferLength OPTIONAL,
  176. IN UCHAR MinorFunction
  177. );
  178. /***************************************************************************++
  179. Routine Description:
  180. Invokes the completion routine (if specified) and determines the
  181. appropriate return code. This routine ensures that, if the completion
  182. routine is invoked, the caller always returns STATUS_PENDING.
  183. Arguments:
  184. Status - Supplies the completion status.
  185. Information - Optionally supplies additional information about
  186. the completed operation, such as the number of bytes
  187. transferred.
  188. pCompletionRoutine - Supplies a pointer to a completion routine to
  189. invoke after the listening endpoint is fully closed.
  190. pCompletionContext - Supplies an uninterpreted context value for the
  191. completion routine.
  192. Return Value:
  193. NTSTATUS - Completion status. Will always be STATUS_PENDING if the
  194. completion routine is invoked.
  195. --***************************************************************************/
  196. __inline
  197. NTSTATUS
  198. UlInvokeCompletionRoutine(
  199. IN NTSTATUS Status,
  200. IN ULONG_PTR Information,
  201. IN PUL_COMPLETION_ROUTINE pCompletionRoutine,
  202. IN PVOID pCompletionContext
  203. )
  204. {
  205. if (pCompletionRoutine != NULL)
  206. {
  207. (pCompletionRoutine)(
  208. pCompletionContext,
  209. Status,
  210. Information
  211. );
  212. Status = STATUS_PENDING;
  213. }
  214. return Status;
  215. } // UlInvokeCompletionRoutine
  216. //
  217. // Initialize a TA_IP_ADDRESS[6] structure.
  218. //
  219. #define UlInitializeIpTransportAddress( ta, inaddr, port ) \
  220. do { \
  221. RtlZeroMemory( (ta), sizeof(*(ta)) ); \
  222. (ta)->TAAddressCount = 1; \
  223. (ta)->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP; \
  224. (ta)->Address[0].AddressType = TDI_ADDRESS_TYPE_IP; \
  225. (ta)->Address[0].Address[0].in_addr = (inaddr); \
  226. (ta)->Address[0].Address[0].sin_port = (USHORT) (port); \
  227. } while (0, 0)
  228. #define UlInitializeIp6TransportAddress( ta, in6addr, port, scope_id) \
  229. do { \
  230. RtlZeroMemory( (ta), sizeof(*(ta)) ); \
  231. (ta)->TAAddressCount = 1; \
  232. (ta)->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP6; \
  233. (ta)->Address[0].AddressType = TDI_ADDRESS_TYPE_IP6; \
  234. RtlCopyMemory((ta)->Address[0].Address[0].sin6_addr, \
  235. (in6addr), \
  236. sizeof(in6addr)); \
  237. (ta)->Address[0].Address[0].sin6_port = (USHORT) (port); \
  238. (ta)->Address[0].Address[0].sin6_flowinfo = 0; \
  239. (ta)->Address[0].Address[0].sin6_scope_id = (scope_id); \
  240. } while (0, 0)
  241. //
  242. // IRP context manipulators.
  243. //
  244. __inline
  245. PUL_IRP_CONTEXT
  246. UlPplAllocateIrpContext(
  247. VOID
  248. )
  249. {
  250. PUL_IRP_CONTEXT pContext;
  251. pContext = (PUL_IRP_CONTEXT)
  252. PplAllocate(g_pUlNonpagedData->IrpContextLookaside);
  253. if (pContext)
  254. {
  255. ASSERT(pContext->Signature == UL_IRP_CONTEXT_SIGNATURE_X);
  256. pContext->Signature = UL_IRP_CONTEXT_SIGNATURE;
  257. }
  258. return pContext;
  259. }
  260. __inline
  261. VOID
  262. UlPplFreeIrpContext(
  263. PUL_IRP_CONTEXT pContext
  264. )
  265. {
  266. ASSERT(HAS_VALID_SIGNATURE(pContext, UL_IRP_CONTEXT_SIGNATURE));
  267. pContext->Signature = UL_IRP_CONTEXT_SIGNATURE_X;
  268. PplFree(g_pUlNonpagedData->IrpContextLookaside, pContext);
  269. }
  270. PVOID
  271. UlAllocateIrpContextPool(
  272. IN POOL_TYPE PoolType,
  273. IN SIZE_T ByteLength,
  274. IN ULONG Tag
  275. );
  276. VOID
  277. UlFreeIrpContextPool(
  278. IN PVOID pBuffer
  279. );
  280. //
  281. // Buffer allocators.
  282. //
  283. __inline
  284. PUL_RECEIVE_BUFFER
  285. UlPplAllocateReceiveBuffer(
  286. VOID
  287. )
  288. {
  289. PUL_RECEIVE_BUFFER pBuffer;
  290. pBuffer = (PUL_RECEIVE_BUFFER)
  291. PplAllocate(g_pUlNonpagedData->ReceiveBufferLookaside);
  292. if (pBuffer)
  293. {
  294. ASSERT(pBuffer->Signature == UL_RECEIVE_BUFFER_SIGNATURE_X);
  295. pBuffer->Signature = UL_RECEIVE_BUFFER_SIGNATURE;
  296. }
  297. return pBuffer;
  298. }
  299. __inline
  300. VOID
  301. UlPplFreeReceiveBuffer(
  302. PUL_RECEIVE_BUFFER pBuffer
  303. )
  304. {
  305. ASSERT(HAS_VALID_SIGNATURE(pBuffer, UL_RECEIVE_BUFFER_SIGNATURE));
  306. pBuffer->Signature = UL_RECEIVE_BUFFER_SIGNATURE_X;
  307. PplFree(g_pUlNonpagedData->ReceiveBufferLookaside, pBuffer);
  308. }
  309. PVOID
  310. UlAllocateReceiveBuffer(
  311. IN CCHAR IrpStackSize
  312. );
  313. PVOID
  314. UlAllocateReceiveBufferPool(
  315. IN POOL_TYPE PoolType,
  316. IN SIZE_T ByteLength,
  317. IN ULONG Tag
  318. );
  319. VOID
  320. UlFreeReceiveBufferPool(
  321. IN PVOID pBuffer
  322. );
  323. //
  324. // Request buffer allocators.
  325. //
  326. __inline
  327. PUL_REQUEST_BUFFER
  328. UlPplAllocateRequestBuffer(
  329. VOID
  330. )
  331. {
  332. PUL_REQUEST_BUFFER pBuffer;
  333. pBuffer = (PUL_REQUEST_BUFFER)
  334. PplAllocate(g_pUlNonpagedData->RequestBufferLookaside);
  335. if (pBuffer)
  336. {
  337. ASSERT(pBuffer->Signature == MAKE_FREE_TAG(UL_REQUEST_BUFFER_POOL_TAG));
  338. pBuffer->Signature = UL_REQUEST_BUFFER_POOL_TAG;
  339. }
  340. return pBuffer;
  341. }
  342. __inline
  343. VOID
  344. UlPplFreeRequestBuffer(
  345. PUL_REQUEST_BUFFER pBuffer
  346. )
  347. {
  348. ASSERT(HAS_VALID_SIGNATURE(pBuffer, UL_REQUEST_BUFFER_POOL_TAG));
  349. pBuffer->Signature = MAKE_FREE_TAG(UL_REQUEST_BUFFER_POOL_TAG);
  350. PplFree(g_pUlNonpagedData->RequestBufferLookaside, pBuffer);
  351. }
  352. PVOID
  353. UlAllocateRequestBufferPool(
  354. IN POOL_TYPE PoolType,
  355. IN SIZE_T ByteLength,
  356. IN ULONG Tag
  357. );
  358. VOID
  359. UlFreeRequestBufferPool(
  360. IN PVOID pBuffer
  361. );
  362. //
  363. // Internal request buffer allocators.
  364. //
  365. __inline
  366. PUL_INTERNAL_REQUEST
  367. UlPplAllocateInternalRequest(
  368. VOID
  369. )
  370. {
  371. PUL_INTERNAL_REQUEST pRequest;
  372. pRequest = (PUL_INTERNAL_REQUEST)
  373. PplAllocate(g_pUlNonpagedData->InternalRequestLookaside);
  374. if (pRequest)
  375. {
  376. ASSERT(pRequest->Signature ==
  377. MAKE_FREE_TAG(UL_INTERNAL_REQUEST_POOL_TAG));
  378. pRequest->Signature = UL_INTERNAL_REQUEST_POOL_TAG;
  379. }
  380. return pRequest;
  381. }
  382. __inline
  383. VOID
  384. UlPplFreeInternalRequest(
  385. PUL_INTERNAL_REQUEST pRequest
  386. )
  387. {
  388. ASSERT(HAS_VALID_SIGNATURE(pRequest, UL_INTERNAL_REQUEST_POOL_TAG));
  389. pRequest->Signature = MAKE_FREE_TAG(UL_INTERNAL_REQUEST_POOL_TAG);
  390. PplFree(g_pUlNonpagedData->InternalRequestLookaside, pRequest);
  391. }
  392. PVOID
  393. UlAllocateInternalRequestPool(
  394. IN POOL_TYPE PoolType,
  395. IN SIZE_T ByteLength,
  396. IN ULONG Tag
  397. );
  398. VOID
  399. UlFreeInternalRequestPool(
  400. IN PVOID pBuffer
  401. );
  402. //
  403. // Chunk tracker allocators.
  404. //
  405. __inline
  406. PUL_CHUNK_TRACKER
  407. UlPplAllocateChunkTracker(
  408. VOID
  409. )
  410. {
  411. PUL_CHUNK_TRACKER pTracker;
  412. pTracker = (PUL_CHUNK_TRACKER)
  413. PplAllocate(g_pUlNonpagedData->ChunkTrackerLookaside);
  414. if (pTracker)
  415. {
  416. ASSERT(pTracker->Signature == MAKE_FREE_TAG(UL_CHUNK_TRACKER_POOL_TAG));
  417. pTracker->Signature = UL_CHUNK_TRACKER_POOL_TAG;
  418. }
  419. return pTracker;
  420. }
  421. __inline
  422. VOID
  423. UlPplFreeChunkTracker(
  424. PUL_CHUNK_TRACKER pTracker
  425. )
  426. {
  427. ASSERT(HAS_VALID_SIGNATURE(pTracker, UL_CHUNK_TRACKER_POOL_TAG));
  428. pTracker->Signature = MAKE_FREE_TAG(UL_CHUNK_TRACKER_POOL_TAG);
  429. PplFree(g_pUlNonpagedData->ChunkTrackerLookaside, pTracker);
  430. }
  431. PVOID
  432. UlAllocateChunkTrackerPool(
  433. IN POOL_TYPE PoolType,
  434. IN SIZE_T ByteLength,
  435. IN ULONG Tag
  436. );
  437. VOID
  438. UlFreeChunkTrackerPool(
  439. IN PVOID pBuffer
  440. );
  441. //
  442. // Full tracker allocators.
  443. //
  444. __inline
  445. PUL_FULL_TRACKER
  446. UlPplAllocateFullTracker(
  447. VOID
  448. )
  449. {
  450. PUL_FULL_TRACKER pTracker;
  451. pTracker = (PUL_FULL_TRACKER)
  452. PplAllocate(g_pUlNonpagedData->FullTrackerLookaside);
  453. if (pTracker)
  454. {
  455. ASSERT(pTracker->Signature == MAKE_FREE_TAG(UL_FULL_TRACKER_POOL_TAG));
  456. pTracker->Signature = UL_FULL_TRACKER_POOL_TAG;
  457. }
  458. return pTracker;
  459. }
  460. __inline
  461. VOID
  462. UlPplFreeFullTracker(
  463. PUL_FULL_TRACKER pTracker
  464. )
  465. {
  466. ASSERT(HAS_VALID_SIGNATURE(pTracker, UL_FULL_TRACKER_POOL_TAG));
  467. pTracker->Signature = MAKE_FREE_TAG(UL_FULL_TRACKER_POOL_TAG);
  468. PplFree(g_pUlNonpagedData->FullTrackerLookaside, pTracker);
  469. }
  470. PVOID
  471. UlAllocateFullTrackerPool(
  472. IN POOL_TYPE PoolType,
  473. IN SIZE_T ByteLength,
  474. IN ULONG Tag
  475. );
  476. VOID
  477. UlFreeFullTrackerPool(
  478. IN PVOID pBuffer
  479. );
  480. //
  481. // Internal response buffer allocators.
  482. //
  483. __inline
  484. PUL_INTERNAL_RESPONSE
  485. UlPplAllocateResponseBuffer(
  486. VOID
  487. )
  488. {
  489. PUL_INTERNAL_RESPONSE pResponse;
  490. pResponse = (PUL_INTERNAL_RESPONSE)
  491. PplAllocate(g_pUlNonpagedData->ResponseBufferLookaside);
  492. if (pResponse)
  493. {
  494. ASSERT(pResponse->Signature ==
  495. MAKE_FREE_TAG(UL_INTERNAL_RESPONSE_POOL_TAG));
  496. pResponse->Signature = UL_INTERNAL_RESPONSE_POOL_TAG;
  497. }
  498. return pResponse;
  499. }
  500. __inline
  501. VOID
  502. UlPplFreeResponseBuffer(
  503. PUL_INTERNAL_RESPONSE pResponse
  504. )
  505. {
  506. ASSERT(HAS_VALID_SIGNATURE(pResponse, UL_INTERNAL_RESPONSE_POOL_TAG));
  507. pResponse->Signature = MAKE_FREE_TAG(UL_INTERNAL_RESPONSE_POOL_TAG);
  508. PplFree(g_pUlNonpagedData->ResponseBufferLookaside, pResponse);
  509. }
  510. PVOID
  511. UlAllocateResponseBufferPool(
  512. IN POOL_TYPE PoolType,
  513. IN SIZE_T ByteLength,
  514. IN ULONG Tag
  515. );
  516. VOID
  517. UlFreeResponseBufferPool(
  518. IN PVOID pBuffer
  519. );
  520. //
  521. // Log file buffer allocators.
  522. //
  523. __inline
  524. PUL_LOG_FILE_BUFFER
  525. UlPplAllocateLogFileBuffer(
  526. VOID
  527. )
  528. {
  529. PUL_LOG_FILE_BUFFER pBuffer;
  530. PAGED_CODE();
  531. pBuffer = (PUL_LOG_FILE_BUFFER)
  532. PplAllocate(g_pUlNonpagedData->LogFileBufferLookaside);
  533. if (pBuffer)
  534. {
  535. ASSERT(pBuffer->Signature ==
  536. MAKE_FREE_TAG(UL_LOG_FILE_BUFFER_POOL_TAG));
  537. pBuffer->Signature = UL_LOG_FILE_BUFFER_POOL_TAG;
  538. }
  539. return pBuffer;
  540. }
  541. __inline
  542. VOID
  543. UlPplFreeLogFileBuffer(
  544. IN PUL_LOG_FILE_BUFFER pBuffer
  545. )
  546. {
  547. PAGED_CODE();
  548. ASSERT(IS_VALID_LOG_FILE_BUFFER(pBuffer));
  549. pBuffer->BufferUsed = 0;
  550. pBuffer->Signature = MAKE_FREE_TAG(UL_LOG_FILE_BUFFER_POOL_TAG);
  551. PplFree(g_pUlNonpagedData->LogFileBufferLookaside, pBuffer);
  552. }
  553. PVOID
  554. UlAllocateLogFileBufferPool(
  555. IN POOL_TYPE PoolType,
  556. IN SIZE_T ByteLength,
  557. IN ULONG Tag
  558. );
  559. VOID
  560. UlFreeLogFileBufferPool(
  561. IN PVOID pBuffer
  562. );
  563. //
  564. // Log data buffer allocators
  565. //
  566. __inline
  567. PUL_LOG_DATA_BUFFER
  568. UlPplAllocateLogDataBuffer(
  569. BOOLEAN Binary
  570. )
  571. {
  572. PUL_LOG_DATA_BUFFER pBuffer;
  573. HANDLE Lookaside;
  574. ULONG Tag;
  575. PAGED_CODE();
  576. if (Binary)
  577. {
  578. Tag = UL_BINARY_LOG_DATA_BUFFER_POOL_TAG;
  579. Lookaside = g_pUlNonpagedData->BinaryLogDataBufferLookaside;
  580. }
  581. else
  582. {
  583. Tag = UL_ANSI_LOG_DATA_BUFFER_POOL_TAG;
  584. Lookaside = g_pUlNonpagedData->AnsiLogDataBufferLookaside;
  585. }
  586. pBuffer = (PUL_LOG_DATA_BUFFER) PplAllocate(Lookaside);
  587. if (pBuffer)
  588. {
  589. ASSERT(pBuffer->Signature == MAKE_FREE_TAG(Tag));
  590. pBuffer->Signature = Tag;
  591. pBuffer->Used = 0;
  592. }
  593. return pBuffer;
  594. }
  595. __inline
  596. VOID
  597. UlPplFreeLogDataBuffer(
  598. IN PUL_LOG_DATA_BUFFER pBuffer
  599. )
  600. {
  601. HANDLE Lookaside;
  602. ULONG Tag;
  603. PAGED_CODE();
  604. ASSERT(IS_VALID_LOG_DATA_BUFFER(pBuffer));
  605. if (pBuffer->Flags.Binary)
  606. {
  607. Tag = UL_BINARY_LOG_DATA_BUFFER_POOL_TAG;
  608. Lookaside = g_pUlNonpagedData->BinaryLogDataBufferLookaside;
  609. }
  610. else
  611. {
  612. Tag = UL_ANSI_LOG_DATA_BUFFER_POOL_TAG;
  613. Lookaside = g_pUlNonpagedData->AnsiLogDataBufferLookaside;
  614. }
  615. pBuffer->Used = 0;
  616. pBuffer->Signature = MAKE_FREE_TAG(Tag);
  617. PplFree(Lookaside, pBuffer);
  618. }
  619. PVOID
  620. UlAllocateLogDataBufferPool(
  621. IN POOL_TYPE PoolType,
  622. IN SIZE_T ByteLength,
  623. IN ULONG Tag
  624. );
  625. VOID
  626. UlFreeLogDataBufferPool(
  627. IN PVOID pBuffer
  628. );
  629. //
  630. // Error logging buffer allocaters and de-allocators
  631. //
  632. __inline
  633. PUL_ERROR_LOG_BUFFER
  634. UlPplAllocateErrorLogBuffer(
  635. VOID
  636. )
  637. {
  638. PUL_ERROR_LOG_BUFFER pBuffer;
  639. HANDLE Lookaside = g_pUlNonpagedData->ErrorLogBufferLookaside;
  640. PAGED_CODE();
  641. UlTrace(ERROR_LOGGING,("Http!UlPplAllocateErrorLogBuffer: <LOOKASIDE>\n"));
  642. pBuffer = (PUL_ERROR_LOG_BUFFER) PplAllocate(Lookaside);
  643. if (pBuffer)
  644. {
  645. ASSERT(pBuffer->Signature ==
  646. MAKE_FREE_TAG(UL_ERROR_LOG_BUFFER_POOL_TAG));
  647. pBuffer->Signature = UL_ERROR_LOG_BUFFER_POOL_TAG;
  648. pBuffer->Used = 0;
  649. }
  650. return pBuffer;
  651. }
  652. __inline
  653. VOID
  654. UlPplFreeErrorLogBuffer(
  655. IN PUL_ERROR_LOG_BUFFER pBuffer
  656. )
  657. {
  658. HANDLE Lookaside = g_pUlNonpagedData->ErrorLogBufferLookaside;
  659. PAGED_CODE();
  660. ASSERT(IS_VALID_ERROR_LOG_BUFFER(pBuffer));
  661. pBuffer->Used = 0;
  662. pBuffer->Signature = MAKE_FREE_TAG(UL_ERROR_LOG_BUFFER_POOL_TAG);
  663. PplFree(Lookaside, pBuffer);
  664. }
  665. PVOID
  666. UlAllocateErrorLogBufferPool(
  667. IN POOL_TYPE PoolType,
  668. IN SIZE_T ByteLength,
  669. IN ULONG Tag
  670. );
  671. VOID
  672. UlFreeErrorLogBufferPool(
  673. IN PVOID pBuffer
  674. );
  675. //
  676. // Trivial macro that should probably be in ntos\inc\io.h.
  677. //
  678. #define UlUnmarkIrpPending( Irp ) ( \
  679. IoGetCurrentIrpStackLocation( (Irp) )->Control &= ~SL_PENDING_RETURNED )
  680. #endif // _PROC_H_