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.

147 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. irptrace.h
  5. Abstract:
  6. This module contains public declarations and definitions for tracing
  7. and debugging IRP problems. This module uses the generic TRACE_LOG
  8. facility in tracelog.h.
  9. Author:
  10. Keith Moore (keithmo) 10-Aug-1999
  11. Revision History:
  12. --*/
  13. #ifndef _IRPTRACE_H_
  14. #define _IRPTRACE_H_
  15. #if defined(__cplusplus)
  16. extern "C" {
  17. #endif // __cplusplus
  18. //
  19. // This defines the entry written to the trace log.
  20. //
  21. #define ENABLE_IRP_CAPTURE 1
  22. #define MAX_CAPTURED_IRP_SIZE \
  23. (sizeof(IRP) + (DEFAULT_IRP_STACK_SIZE * sizeof(IO_STACK_LOCATION)))
  24. typedef struct _IRP_TRACE_LOG_ENTRY
  25. {
  26. PIRP pIrp;
  27. PVOID pFileName;
  28. PEPROCESS pProcess;
  29. PETHREAD pThread;
  30. PVOID pCaller;
  31. PVOID pCallersCaller;
  32. USHORT LineNumber;
  33. UCHAR Action;
  34. UCHAR Processor;
  35. #if ENABLE_IRP_CAPTURE
  36. ULONG CapturedIrp[MAX_CAPTURED_IRP_SIZE / sizeof(ULONG)];
  37. #endif
  38. } IRP_TRACE_LOG_ENTRY, *PIRP_TRACE_LOG_ENTRY;
  39. //
  40. // Action codes.
  41. //
  42. // N.B. These codes must be contiguous, starting at zero. If you update
  43. // this list, you must also update the corresponding array in
  44. // ul\ulkd\irp.c.
  45. //
  46. #define IRP_ACTION_INCOMING_IRP 0
  47. #define IRP_ACTION_ALLOCATE_IRP 1
  48. #define IRP_ACTION_FREE_IRP 2
  49. #define IRP_ACTION_CALL_DRIVER 3
  50. #define IRP_ACTION_COMPLETE_IRP 4
  51. #define IRP_ACTION_COUNT 5
  52. #define IRP_TRACE_LOG_SIGNATURE ((LONG)'gLrI')
  53. //
  54. // Manipulators.
  55. //
  56. PTRACE_LOG
  57. CreateIrpTraceLog(
  58. IN LONG LogSize,
  59. IN LONG ExtraBytesInHeader
  60. );
  61. VOID
  62. DestroyIrpTraceLog(
  63. IN PTRACE_LOG pLog
  64. );
  65. VOID
  66. WriteIrpTraceLog(
  67. IN PTRACE_LOG pLog,
  68. IN UCHAR Action,
  69. IN PIRP pIrp,
  70. IN PVOID pFileName,
  71. IN USHORT LineNumber
  72. );
  73. #if ENABLE_IRP_TRACE
  74. #define CREATE_IRP_TRACE_LOG( ptr, size, extra ) \
  75. (ptr) = CreateIrpTraceLog( (size), (extra) )
  76. #define DESTROY_IRP_TRACE_LOG( ptr ) \
  77. do \
  78. { \
  79. DestroyIrpTraceLog( ptr ); \
  80. (ptr) = NULL; \
  81. } while (FALSE)
  82. #define WRITE_IRP_TRACE_LOG( plog, act, pirp, pfile, line ) \
  83. WriteIrpTraceLog( \
  84. (plog), \
  85. (act), \
  86. (pirp), \
  87. (pfile), \
  88. (line) \
  89. )
  90. #else // !ENABLE_IRP_TRACE
  91. #define CREATE_IRP_TRACE_LOG( ptr, size, extra )
  92. #define DESTROY_IRP_TRACE_LOG( ptr )
  93. #define WRITE_IRP_TRACE_LOG( plog, act, ref, pfile, line )
  94. #endif // ENABLE_IRP_TRACE
  95. #define TRACE_IRP( act, pirp ) \
  96. WRITE_IRP_TRACE_LOG( \
  97. g_pIrpTraceLog, \
  98. (act), \
  99. (pirp), \
  100. (PVOID)__FILE__, \
  101. (USHORT)__LINE__ \
  102. )
  103. #if defined(__cplusplus)
  104. } // extern "C"
  105. #endif // __cplusplus
  106. #endif // _IRPTRACE_H_