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.

180 lines
5.6 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. #define WPP_TRACE_OPTIONS 0
  19. #include <windows.h>
  20. #pragma warning(disable: 4201)
  21. #include <wmistr.h>
  22. #include <evntrace.h>
  23. #if defined(__cplusplus)
  24. extern "C" {
  25. #endif
  26. #ifndef WPP_MAX_MOF_FIELDS
  27. #define WPP_MAX_MOF_FIELDS 8
  28. #endif
  29. typedef struct _TRACE_BUFFER {
  30. EVENT_TRACE_HEADER Header;
  31. MOF_FIELD MofField[WPP_MAX_MOF_FIELDS+1];
  32. } TRACE_BUFFER;
  33. #ifndef TRACE_MESSAGE_MAXIMUM_SIZE
  34. #define TRACE_MESSAGE_MAXIMUM_SIZE 8*1024
  35. #endif
  36. void TraceMessageW2k(IN TRACEHANDLE LoggerHandle, IN DWORD TraceOptions, IN LPGUID MessageGuid, IN USHORT MessageNumber, ...) ;
  37. #if defined(__cplusplus)
  38. };
  39. #endif
  40. `IF FOUND WPP_INIT_TRACING`
  41. #include "stdlib.h"
  42. void TraceMessageW2k(IN TRACEHANDLE LoggerHandle, IN DWORD TraceOptions, IN LPGUID MessageGuid, IN USHORT MessageNumber, ...)
  43. {
  44. size_t uiBytes, uiArgCount ;
  45. va_list ap ;
  46. PVOID source ;
  47. size_t uiElemBytes = 0, uiOffset ;
  48. unsigned long ulResult ;
  49. TRACE_BUFFER TraceBuf;
  50. void *pData=NULL;
  51. TraceOptions; // unused
  52. //Fill in header fields
  53. //Type is 0xFF to indicate that the first data is the MessageNumber
  54. TraceBuf.Header.GuidPtr = (ULONGLONG)MessageGuid ;
  55. TraceBuf.Header.Flags = WNODE_FLAG_TRACED_GUID |WNODE_FLAG_USE_GUID_PTR|WNODE_FLAG_USE_MOF_PTR ;
  56. TraceBuf.Header.Class.Type = 0xFF ;
  57. //The first Mof data is the Message Number
  58. TraceBuf.MofField[0].DataPtr = (ULONGLONG)&MessageNumber;
  59. TraceBuf.MofField[0].Length = sizeof(USHORT);
  60. //Determine the number bytes to follow header
  61. uiBytes = 0 ; // For Count of Bytes
  62. uiArgCount = 0 ; // For Count of Arguments
  63. va_start(ap, MessageNumber);
  64. while ((source = va_arg (ap, PVOID)) != NULL)
  65. {
  66. uiElemBytes = va_arg (ap, size_t) ;
  67. uiBytes += uiElemBytes ;
  68. uiArgCount++ ;
  69. if (uiArgCount <= WPP_MAX_MOF_FIELDS)
  70. {
  71. TraceBuf.MofField[uiArgCount].DataPtr = (ULONGLONG)source;
  72. TraceBuf.MofField[uiArgCount].Length = (ULONG)uiElemBytes;
  73. }
  74. }
  75. va_end(ap);
  76. if (uiBytes > TRACE_MESSAGE_MAXIMUM_SIZE)
  77. return;
  78. //This occurs infrequently
  79. if (uiArgCount > WPP_MAX_MOF_FIELDS)
  80. {
  81. //Allocate the blob to hold the data
  82. pData = LocalAlloc(0,uiBytes);
  83. if (pData == NULL)
  84. {
  85. return;
  86. }
  87. TraceBuf.MofField[1].DataPtr = (ULONGLONG)pData;
  88. TraceBuf.MofField[1].Length = uiBytes;
  89. uiOffset = 0 ;
  90. uiElemBytes = 0 ;
  91. va_start(ap, MessageNumber) ;
  92. while ((source = va_arg (ap, PVOID)) != NULL)
  93. {
  94. uiElemBytes = va_arg (ap, size_t) ;
  95. memcpy((char*)pData + uiOffset, source, uiElemBytes) ;
  96. uiOffset += uiElemBytes ;
  97. }
  98. va_end(ap) ;
  99. //Fill in the total size (header + 2 mof fields)
  100. TraceBuf.Header.Size = (USHORT)(sizeof(EVENT_TRACE_HEADER) + 2*sizeof(MOF_FIELD));
  101. }
  102. else
  103. {
  104. //Fill in the total size (header + mof fields)
  105. TraceBuf.Header.Size = (USHORT)(sizeof(EVENT_TRACE_HEADER) + (uiArgCount+1)*sizeof(MOF_FIELD));
  106. }
  107. ulResult = TraceEvent(LoggerHandle, &TraceBuf.Header) ;
  108. if (pData)
  109. {
  110. LocalFree(pData);
  111. }
  112. if(ERROR_SUCCESS != ulResult)
  113. {
  114. // Silently ignored error
  115. }
  116. }
  117. `ENDIF`
  118. __inline TRACEHANDLE WppQueryLogger(LPTSTR LoggerName)
  119. {
  120. #ifndef UNICODE
  121. if (!LoggerName) {LoggerName = "stdout";}
  122. #else
  123. if (!LoggerName) {LoggerName = L"stdout";}
  124. #endif
  125. {
  126. ULONG status;
  127. EVENT_TRACE_PROPERTIES LoggerInfo;
  128. ZeroMemory(&LoggerInfo, sizeof(LoggerInfo));
  129. LoggerInfo.Wnode.BufferSize = sizeof(LoggerInfo);
  130. LoggerInfo.Wnode.Flags = WNODE_FLAG_TRACED_GUID;
  131. status = QueryTrace(0, LoggerName, &LoggerInfo);
  132. if (status == ERROR_SUCCESS) {
  133. return (TRACEHANDLE) LoggerInfo.Wnode.HistoricalContext;
  134. }
  135. }
  136. return 0;
  137. }
  138. #endif // #ifdef WPP_TRACE_W2K_COMPATABIlITY
  139. `INCLUDE um-header.tpl`
  140. `INCLUDE control.tpl`
  141. `INCLUDE trmacro.tpl`
  142. `IF FOUND WPP_INIT_TRACING`
  143. #define WPPINIT_EXPORT
  144. `INCLUDE um-init.tpl`
  145. `ENDIF`