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.

278 lines
5.6 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. );
  141. NTSTATUS
  142. SrLogWrite (
  143. IN PSR_DEVICE_EXTENSION pExtension OPTIONAL,
  144. IN PSR_LOG_CONTEXT pOptionalLogContext OPTIONAL,
  145. IN PSR_LOG_ENTRY pLogEntry
  146. );
  147. NTSTATUS
  148. SrGetAclInformation (
  149. IN PFILE_OBJECT pFileObject,
  150. IN PSR_DEVICE_EXTENSION pExtension,
  151. OUT PSECURITY_DESCRIPTOR * pSecurityDescriptorPtr,
  152. OUT PULONG pSizeNeeded
  153. );
  154. NTSTATUS
  155. SrLoggerStart (
  156. IN PDEVICE_OBJECT pDeviceObject,
  157. OUT PSR_LOGGER_CONTEXT * pLoggerInfo
  158. );
  159. NTSTATUS
  160. SrLoggerStop (
  161. IN PSR_LOGGER_CONTEXT pLoggerInfo
  162. );
  163. NTSTATUS
  164. SrLoggerSwitchLogs (
  165. IN PSR_LOGGER_CONTEXT pLogger
  166. );
  167. NTSTATUS
  168. SrGetLogFileName (
  169. IN PUNICODE_STRING pVolumeName,
  170. IN USHORT LogFileNameLength,
  171. OUT PUNICODE_STRING pLogFileName
  172. );
  173. NTSTATUS
  174. SrPackDebugInfo (
  175. IN PBYTE pBuffer,
  176. IN ULONG BufferSize
  177. );
  178. NTSTATUS
  179. SrPackLogEntry(
  180. OUT PSR_LOG_ENTRY *ppLogEntry,
  181. IN ULONG EntryType,
  182. IN ULONG Attributes,
  183. IN INT64 SequenceNum,
  184. IN PSECURITY_DESCRIPTOR pAclInfo OPTIONAL,
  185. IN ULONG AclInfoSize OPTIONAL,
  186. IN PVOID pDebugBlob OPTIONAL,
  187. IN PUNICODE_STRING pPath1,
  188. IN USHORT Path1StreamLength,
  189. IN PUNICODE_STRING pTempPath OPTIONAL,
  190. IN PUNICODE_STRING pPath2 OPTIONAL,
  191. IN USHORT Path2StreamLength OPTIONAL,
  192. IN PSR_DEVICE_EXTENSION pExtension,
  193. IN PUNICODE_STRING pShortName OPTIONAL
  194. );
  195. #endif