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.

152 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. irptrace.cxx
  5. Abstract:
  6. This module implements an IRP tracing facility.
  7. Author:
  8. Keith Moore (keithmo) 10-Aug-1999
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #if ENABLE_IRP_TRACE
  13. /***************************************************************************++
  14. Routine Description:
  15. Creates a new (empty) IRP trace log buffer.
  16. Arguments:
  17. LogSize - Supplies the number of entries in the log.
  18. ExtraBytesInHeader - Supplies the number of extra bytes to include
  19. in the log header. This is useful for adding application-
  20. specific data to the log.
  21. Return Value:
  22. PTRACE_LOG - Pointer to the newly created log if successful,
  23. NULL otherwise.
  24. --***************************************************************************/
  25. PTRACE_LOG
  26. CreateIrpTraceLog(
  27. IN LONG LogSize,
  28. IN LONG ExtraBytesInHeader
  29. )
  30. {
  31. return CreateTraceLog(
  32. IRP_TRACE_LOG_SIGNATURE,
  33. LogSize,
  34. ExtraBytesInHeader,
  35. sizeof(IRP_TRACE_LOG_ENTRY)
  36. );
  37. } // CreateIrpTraceLog
  38. /***************************************************************************++
  39. Routine Description:
  40. Destroys an IRP trace log buffer created with CreateIrpTraceLog().
  41. Arguments:
  42. pLog - Supplies the IRP trace log buffer to destroy.
  43. --***************************************************************************/
  44. VOID
  45. DestroyIrpTraceLog(
  46. IN PTRACE_LOG pLog
  47. )
  48. {
  49. DestroyTraceLog( pLog );
  50. } // DestroyIrpTraceLog
  51. /***************************************************************************++
  52. Routine Description:
  53. Writes a new entry to the specified IRP trace log.
  54. Arguments:
  55. pLog - Supplies the log to write to.
  56. Action - Supplies an action code for the new log entry.
  57. pIrp - Supplies the IRP for the log entry.
  58. pFileName - Supplies the filename of the routine writing the log entry.
  59. LineNumber - Supplies he line number of the routine writing the log
  60. entry.
  61. --***************************************************************************/
  62. VOID
  63. WriteIrpTraceLog(
  64. IN PTRACE_LOG pLog,
  65. IN UCHAR Action,
  66. IN PIRP pIrp,
  67. IN PVOID pFileName,
  68. IN USHORT LineNumber
  69. )
  70. {
  71. IRP_TRACE_LOG_ENTRY entry;
  72. USHORT irpSize;
  73. //
  74. // Initialize the entry.
  75. //
  76. RtlGetCallersAddress( &entry.pCaller, &entry.pCallersCaller );
  77. entry.Action = Action;
  78. entry.pIrp = pIrp;
  79. entry.pFileName = pFileName;
  80. entry.LineNumber = LineNumber;
  81. entry.Processor = (UCHAR)KeGetCurrentProcessorNumber();
  82. entry.pProcess = PsGetCurrentProcess();
  83. entry.pThread = PsGetCurrentThread();
  84. #if ENABLE_IRP_CAPTURE
  85. irpSize = pIrp->Size;
  86. if (irpSize > sizeof(entry.CapturedIrp))
  87. {
  88. irpSize = sizeof(entry.CapturedIrp);
  89. }
  90. RtlCopyMemory( entry.CapturedIrp, pIrp, irpSize );
  91. #endif
  92. //
  93. // Write it to the logs.
  94. //
  95. WriteTraceLog( pLog, &entry );
  96. } // WriteIrpTraceLog
  97. #endif // ENABLE_IRP_TRACE