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.

284 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. srlog.h
  5. Abstract:
  6. contains prototypes/macros for functions SR logging functionality
  7. Author:
  8. Kanwaljit Marok (kmarok) 01-March-2000
  9. Revision History:
  10. --*/
  11. #ifndef _SR_LOG_H_
  12. #define _SR_LOG_H_
  13. #include "logfmt.h"
  14. //
  15. // This structure contains all the relevant context information
  16. // regarding the current SRlog
  17. //
  18. #define IS_VALID_LOG_CONTEXT(pObject) \
  19. (((pObject) != NULL) && \
  20. ((pObject)->Signature == SR_LOG_CONTEXT_TAG) && \
  21. ((pObject)->pExtension != NULL) && \
  22. ((pObject)->pExtension->pLogContext == (pObject)))
  23. typedef struct _SR_LOG_CONTEXT
  24. {
  25. //
  26. // PagedPool
  27. //
  28. //
  29. // = SR_LOG_CONTEXT_TAG
  30. //
  31. ULONG Signature;
  32. //
  33. // Log file handle
  34. //
  35. HANDLE LogHandle;
  36. //
  37. // File object represented by LogHandle.
  38. //
  39. PFILE_OBJECT pLogFileObject;
  40. //
  41. // Pointer to log buffer (NonPagedPool)
  42. //
  43. PBYTE pLogBuffer;
  44. //
  45. // Current log file allocation size.
  46. //
  47. ULONG AllocationSize;
  48. //
  49. // Offset for next buffer write in the file
  50. //
  51. ULONG FileOffset;
  52. //
  53. // Offset for next to log entry write in the buffer
  54. //
  55. ULONG BufferOffset;
  56. //
  57. // indicates the offset of a previous entry
  58. //
  59. ULONG LastBufferOffset;
  60. //
  61. // Log file path - required for suspend / resume
  62. //
  63. PUNICODE_STRING pLogFilePath;
  64. //
  65. // Logging flags , enabled, dirty, etc.
  66. //
  67. ULONG LoggingFlags;
  68. //
  69. // Keep a backpointer to the DeviceExtension associated with this
  70. // log context.
  71. //
  72. PSR_DEVICE_EXTENSION pExtension;
  73. } SR_LOG_CONTEXT, *PSR_LOG_CONTEXT;
  74. //
  75. // This stucture contains context information for the logger
  76. //
  77. #define IS_VALID_LOGGER_CONTEXT(pObject) \
  78. (((pObject) != NULL) && ((pObject)->Signature == SR_LOGGER_CONTEXT_TAG))
  79. typedef struct _SR_LOGGER_CONTEXT
  80. {
  81. //
  82. // NonPagedPool
  83. //
  84. //
  85. // = SR_LOGGER_CONTEXT_TAG
  86. //
  87. ULONG Signature;
  88. //
  89. // Number of active log contexts
  90. //
  91. LONG ActiveContexts;
  92. //
  93. // Timer object for flushing logs evry 5 Secs
  94. //
  95. KTIMER Timer;
  96. //
  97. // Dpc routine used along with the timer object
  98. //
  99. KDPC Dpc;
  100. #ifdef USE_LOOKASIDE
  101. //
  102. // lookaside lists for speedy allocations
  103. //
  104. PAGED_LOOKASIDE_LIST LogEntryLookaside;
  105. //
  106. // lookaside lists for speedy log allocations
  107. //
  108. NPAGED_LOOKASIDE_LIST LogBufferLookaside;
  109. #endif
  110. } SR_LOGGER_CONTEXT, * PSR_LOGGER_CONTEXT;
  111. #define SR_MAX_INLINE_ACL_SIZE 8192
  112. #define SR_LOG_DEBUG_INFO_SIZE sizeof( SR_LOG_DEBUG_INFO )
  113. #ifdef USE_LOOKASIDE
  114. #define SrAllocateLogBuffer() \
  115. ExAllocateFromNPagedLookasideList(&global->pLogger->LogBufferLookaside)
  116. #define SrFreeLogBuffer( pBuffer ) \
  117. ExFreeToNPagedLookasideList( \
  118. &global->pLogger->LogBufferLookaside, \
  119. (pBuffer) )
  120. #else
  121. #define SrAllocateLogBuffer( _bufferSize ) \
  122. SR_ALLOCATE_POOL(NonPagedPool, (_bufferSize) , SR_LOG_BUFFER_TAG)
  123. #define SrFreeLogBuffer( pBuffer ) \
  124. SR_FREE_POOL(pBuffer, SR_LOG_BUFFER_TAG)
  125. #endif
  126. #define SrAllocateLogEntry( EntrySize ) \
  127. SR_ALLOCATE_POOL(PagedPool, (EntrySize), SR_LOG_ENTRY_TAG)
  128. #define SrFreeLogEntry( pBuffer ) \
  129. SR_FREE_POOL(pBuffer, SR_LOG_ENTRY_TAG)
  130. NTSTATUS
  131. SrLogStart (
  132. IN PUNICODE_STRING pLogPath,
  133. IN PSR_DEVICE_EXTENSION pExtension,
  134. OUT PSR_LOG_CONTEXT * ppLogContext
  135. );
  136. NTSTATUS
  137. SrLogStop(
  138. IN PSR_DEVICE_EXTENSION pExtension,
  139. IN BOOLEAN PurgeContexts,
  140. IN BOOLEAN CheckLog
  141. );
  142. NTSTATUS
  143. SrLogWrite (
  144. IN PSR_DEVICE_EXTENSION pExtension OPTIONAL,
  145. IN PSR_LOG_CONTEXT pOptionalLogContext OPTIONAL,
  146. IN PSR_LOG_ENTRY pLogEntry
  147. );
  148. NTSTATUS
  149. SrLogNormalize (
  150. IN PSR_DEVICE_EXTENSION pExtension
  151. );
  152. NTSTATUS
  153. SrGetAclInformation (
  154. IN PFILE_OBJECT pFileObject,
  155. IN PSR_DEVICE_EXTENSION pExtension,
  156. OUT PSECURITY_DESCRIPTOR * pSecurityDescriptorPtr,
  157. OUT PULONG pSizeNeeded
  158. );
  159. NTSTATUS
  160. SrLoggerStart (
  161. IN PDEVICE_OBJECT pDeviceObject,
  162. OUT PSR_LOGGER_CONTEXT * pLoggerInfo
  163. );
  164. NTSTATUS
  165. SrLoggerStop (
  166. IN PSR_LOGGER_CONTEXT pLoggerInfo
  167. );
  168. NTSTATUS
  169. SrLoggerSwitchLogs (
  170. IN PSR_LOGGER_CONTEXT pLogger
  171. );
  172. NTSTATUS
  173. SrGetLogFileName (
  174. IN PUNICODE_STRING pVolumeName,
  175. IN USHORT LogFileNameLength,
  176. OUT PUNICODE_STRING pLogFileName
  177. );
  178. NTSTATUS
  179. SrPackDebugInfo (
  180. IN PBYTE pBuffer,
  181. IN ULONG BufferSize
  182. );
  183. NTSTATUS
  184. SrPackLogEntry(
  185. OUT PSR_LOG_ENTRY *ppLogEntry,
  186. IN ULONG EntryType,
  187. IN ULONG Attributes,
  188. IN INT64 SequenceNum,
  189. IN PSECURITY_DESCRIPTOR pAclInfo OPTIONAL,
  190. IN ULONG AclInfoSize OPTIONAL,
  191. IN PVOID pDebugBlob OPTIONAL,
  192. IN PUNICODE_STRING pPath1,
  193. IN USHORT Path1StreamLength,
  194. IN PUNICODE_STRING pTempPath OPTIONAL,
  195. IN PUNICODE_STRING pPath2 OPTIONAL,
  196. IN USHORT Path2StreamLength OPTIONAL,
  197. IN PSR_DEVICE_EXTENSION pExtension,
  198. IN PUNICODE_STRING pShortName OPTIONAL
  199. );
  200. #endif