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.

134 lines
4.1 KiB

  1. `**********************************************************************`
  2. `* This is a template file for tracewpp preprocessor *`
  3. `* If you need to use a custom version of this file in your project *`
  4. `* Please clone it from this one and point WPP to it by specifying *`
  5. `* -gen:{yourfile} option on RUN_WPP line in your sources file *`
  6. `* *`
  7. `* This specific header is um-w2k.tpl and is used to define tracing *`
  8. `* applications which must also run under Windows 2000 *`
  9. `* *`
  10. `* Copyright 1999-2001 Microsoft Corporation. All Rights Reserved. *`
  11. `**********************************************************************`
  12. //`Compiler.Checksum` Generated File. Do not edit.
  13. // File created by `Compiler.Name` compiler version `Compiler.Version`-`Compiler.Timestamp`
  14. // on `System.Date` at `System.Time` UTC from a template `TemplateFile`
  15. #define WPP_TRACE_W2K_COMPATABILITY
  16. #define WPP_TRACE TraceMessageW2k
  17. #ifdef WPP_TRACE_W2K_COMPATABILITY
  18. #include <windows.h>
  19. #pragma warning(disable: 4201)
  20. #include <wmistr.h>
  21. #include <evntrace.h>
  22. #if defined(__cplusplus)
  23. extern "C" {
  24. #endif
  25. void TraceMessageW2k(IN TRACEHANDLE LoggerHandle, IN DWORD TraceOptions, IN LPGUID MessageGuid, IN USHORT MessageNumber, ...) ;
  26. #if defined(__cplusplus)
  27. };
  28. #endif
  29. `IF FOUND WPP_INIT_TRACING`
  30. #include "stdlib.h"
  31. void TraceMessageW2k(IN TRACEHANDLE LoggerHandle, IN DWORD TraceOptions, IN LPGUID MessageGuid, IN USHORT MessageNumber, ...)
  32. {
  33. size_t uiBytes, uiArgCount ;
  34. va_list ap ;
  35. PVOID source ;
  36. size_t uiElemBytes = 0, uiTotSize, uiOffset ;
  37. PEVENT_TRACE_HEADER pHeaderData ;
  38. unsigned long ulResult ;
  39. TraceOptions; // unused
  40. // Determine the number bytes to follow header
  41. uiBytes = 0 ; // For Count of Bytes
  42. uiArgCount = 0 ; // For Count of Arguments
  43. va_start(ap, MessageNumber) ;
  44. while ((source = va_arg (ap, PVOID)) != NULL)
  45. {
  46. uiElemBytes = va_arg (ap, size_t) ;
  47. uiBytes += uiElemBytes ;
  48. uiArgCount++ ;
  49. }
  50. va_end(ap) ;
  51. uiTotSize = sizeof(EVENT_TRACE_HEADER) + sizeof(USHORT) + uiBytes ;
  52. pHeaderData = (PEVENT_TRACE_HEADER) malloc(uiTotSize) ;
  53. if(pHeaderData != NULL)
  54. {
  55. // Set allocated memory to zero
  56. // memset(pHeaderData, 0, uiTotSize) ;
  57. pHeaderData->Size = (USHORT)uiTotSize ;
  58. pHeaderData->GuidPtr = (ULONGLONG)MessageGuid ;
  59. pHeaderData->Flags = WNODE_FLAG_TRACED_GUID | WNODE_FLAG_USE_GUID_PTR ;
  60. pHeaderData->Class.Type = 0xFF ;
  61. memcpy((char*)pHeaderData + sizeof(EVENT_TRACE_HEADER), &MessageNumber, sizeof(USHORT)) ;
  62. uiOffset = 0 ;
  63. uiElemBytes = 0 ;
  64. va_start(ap, MessageNumber) ;
  65. while ((source = va_arg (ap, PVOID)) != NULL)
  66. {
  67. uiElemBytes = va_arg (ap, size_t) ;
  68. memcpy((char*)pHeaderData + sizeof(EVENT_TRACE_HEADER) + sizeof(USHORT) + uiOffset, source, uiElemBytes) ;
  69. uiOffset += uiElemBytes ;
  70. }
  71. va_end(ap) ;
  72. ulResult = TraceEvent(LoggerHandle, pHeaderData) ;
  73. free(pHeaderData) ;
  74. if(ERROR_SUCCESS != ulResult)
  75. {
  76. // Silently ignored error
  77. }
  78. }
  79. }
  80. `ENDIF`
  81. __inline TRACEHANDLE WppQueryLogger(LPTSTR LoggerName)
  82. {
  83. #ifndef UNICODE
  84. if (!LoggerName) {LoggerName = "stdout";}
  85. #else
  86. if (!LoggerName) {LoggerName = L"stdout";}
  87. #endif
  88. {
  89. ULONG status;
  90. EVENT_TRACE_PROPERTIES LoggerInfo;
  91. ZeroMemory(&LoggerInfo, sizeof(LoggerInfo));
  92. LoggerInfo.Wnode.BufferSize = sizeof(LoggerInfo);
  93. LoggerInfo.Wnode.Flags = WNODE_FLAG_TRACED_GUID;
  94. status = QueryTrace(0, LoggerName, &LoggerInfo);
  95. if (status == ERROR_SUCCESS) {
  96. return (TRACEHANDLE) LoggerInfo.Wnode.HistoricalContext;
  97. }
  98. }
  99. return 0;
  100. }
  101. #endif // #ifdef WPP_TRACE_W2K_COMPATABIlITY
  102. `INCLUDE um-header.tpl`
  103. `INCLUDE control.tpl`
  104. `INCLUDE trmacro.tpl`
  105. `IF FOUND WPP_INIT_TRACING`
  106. #define WPPINIT_EXPORT
  107. `INCLUDE um-init.tpl`
  108. `ENDIF`