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.

143 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. wmlum.h
  5. Abstract:
  6. User mode definitions for an easy wmi tracing.
  7. Author:
  8. gorn
  9. Revision History:
  10. Comments:
  11. --*/
  12. #ifndef WMLUM_H
  13. #define WMLUM_H 1
  14. #pragma warning(disable: 4201) // error C4201: nonstandard extension used : nameless struct/union
  15. #include <wmistr.h>
  16. #include <evntrace.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. typedef struct _WML_REG_STRUCT
  21. {
  22. TRACEHANDLE LoggerHandle;
  23. ULONG EnableFlags;
  24. ULONG EnableLevel;
  25. struct _WML_REG_STRUCT* Next;
  26. TRACEHANDLE RegistrationHandle;
  27. } WML_REG_STRUCT, *PWML_REG_STRUCT;
  28. typedef PWML_REG_STRUCT WML_REG_HANDLE;
  29. typedef void (*WMLPRINTFUNC)(UINT Level, LPCSTR String);
  30. ULONG
  31. WmlInitialize(
  32. IN LPCWSTR ProductName,
  33. IN WMLPRINTFUNC PrintFunc,
  34. OUT WML_REG_HANDLE*,
  35. ... // Pairs: LPWSTR CtrlGuidName, Corresponding WML_REG_STRUCT
  36. );
  37. VOID
  38. WmlUninitialize(
  39. IN WML_REG_HANDLE
  40. );
  41. ULONG
  42. WmlTrace(
  43. IN UINT Type,
  44. IN LPCGUID TraceGuid,
  45. IN TRACEHANDLE LoggerHandle,
  46. ... // Pairs: Address, Length
  47. );
  48. typedef
  49. ULONG
  50. (*PWML_INITIALIZE)(
  51. IN LPCWSTR ProductName,
  52. IN WMLPRINTFUNC PrintFunc,
  53. OUT WML_REG_HANDLE*,
  54. ...
  55. );
  56. typedef
  57. VOID
  58. (*PWML_UNINITIALIZE)(
  59. IN WML_REG_HANDLE);
  60. typedef
  61. ULONG
  62. (*PWML_TRACE)(
  63. IN UINT Type,
  64. IN LPCGUID TraceGuid,
  65. IN TRACEHANDLE LoggerHandle,
  66. ...
  67. );
  68. typedef
  69. struct _WML_DATA {
  70. PWML_TRACE Trace;
  71. PWML_INITIALIZE Initialize;
  72. PWML_UNINITIALIZE Uninitialize;
  73. WML_REG_HANDLE WmiRegHandle;
  74. HINSTANCE WmlDllInstance;
  75. } WML_DATA;
  76. #define LOADWML(status, wml) \
  77. do \
  78. { \
  79. HINSTANCE hInst = LoadLibraryW(L"wmlum.dll"); \
  80. (wml).WmlDllInstance = hInst; \
  81. if (!hInst) { \
  82. status = GetLastError(); \
  83. } else { \
  84. (wml).Trace = (PWML_TRACE) GetProcAddress(hInst, "WmlTrace"); \
  85. (wml).Initialize = (PWML_INITIALIZE) GetProcAddress(hInst, "WmlInitialize"); \
  86. (wml).Uninitialize = (PWML_UNINITIALIZE) GetProcAddress(hInst, "WmlUninitialize"); \
  87. \
  88. if (!(wml).Trace || !(wml).Initialize || !(wml).Uninitialize) { \
  89. status = GetLastError(); \
  90. } else { \
  91. status = ERROR_SUCCESS; \
  92. } \
  93. } \
  94. } \
  95. while(0)
  96. #define UNLOADWML(wml) \
  97. do \
  98. { \
  99. if ( (wml).Uninitialize ) { \
  100. (wml).Uninitialize( (wml).WmiRegHandle ); \
  101. } \
  102. if ( (wml).WmlDllInstance ) { \
  103. FreeLibrary( (wml).WmlDllInstance ); \
  104. } \
  105. RtlZeroMemory( &(wml) , sizeof(WML_DATA) ); \
  106. } \
  107. while(0)
  108. #ifdef __cplusplus
  109. };
  110. #endif
  111. #endif // WMLUM_H