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.

71 lines
2.1 KiB

  1. `**********************************************************************`
  2. `* This is an include template file for tracewpp preprocessor. *`
  3. `* *`
  4. `* Copyright 1999-2000 Microsoft Corporation. All Rights Reserved. *`
  5. `**********************************************************************`
  6. // template `TemplateFile`
  7. `* Dump defintions specified via -D on the command line to WPP *`
  8. `FORALL def IN MacroDefinitions`
  9. #define `def.Name` `def.Alias`
  10. `ENDFOR`
  11. #define WPP_THIS_FILE `SourceFile.CanonicalName`
  12. #if !defined(WPP_KERNEL_MODE)
  13. # include <windows.h>
  14. # pragma warning(disable: 4201)
  15. # include <wmistr.h>
  16. # include <evntrace.h>
  17. # define WPP_TRACE TraceMessage
  18. #else
  19. #define WPP_TRACE WmiTraceMessage
  20. #endif
  21. #if !defined(WPP_PRIVATE)
  22. # define WPP_INLINE __inline
  23. # define WPP_SELECT_ANY extern "C" __declspec(selectany)
  24. #else
  25. # define WPP_INLINE static
  26. # define WPP_SELECT_ANY static
  27. #endif
  28. __inline TRACEHANDLE WppQueryLogger(PCWSTR LoggerName)
  29. {
  30. if (!LoggerName) {LoggerName = L"stdout";}
  31. {
  32. #if defined(WPP_KERNEL_MODE)
  33. ULONG ReturnLength ;
  34. NTSTATUS Status ;
  35. TRACEHANDLE TraceHandle ;
  36. UNICODE_STRING Buffer ;
  37. RtlInitUnicodeString(&Buffer, LoggerName);
  38. if ((Status = WmiQueryTraceInformation(TraceHandleByNameClass,
  39. (PVOID)&TraceHandle,
  40. sizeof(TraceHandle),
  41. &ReturnLength,
  42. (PVOID)&Buffer)) == STATUS_SUCCESS) {
  43. return TraceHandle ;
  44. }
  45. #else
  46. ULONG status;
  47. EVENT_TRACE_PROPERTIES LoggerInfo;
  48. ZeroMemory(&LoggerInfo, sizeof(LoggerInfo));
  49. LoggerInfo.Wnode.BufferSize = sizeof(LoggerInfo);
  50. LoggerInfo.Wnode.Flags = WNODE_FLAG_TRACED_GUID;
  51. status = QueryTraceW(0, LoggerName, &LoggerInfo);
  52. if (status == ERROR_SUCCESS || status == ERROR_MORE_DATA) {
  53. return (TRACEHANDLE) LoggerInfo.Wnode.HistoricalContext;
  54. }
  55. #endif
  56. }
  57. return 0;
  58. }