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.

160 lines
3.3 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. Needs to be moved to wmilib\inc when DCR is approved
  12. --*/
  13. #ifndef WMLUM_H
  14. #define WMLUM_H 1
  15. #pragma warning(disable: 4201) // error C4201: nonstandard extension used : nameless struct/union
  16. #include <wmistr.h>
  17. #include <evntrace.h>
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. typedef struct _WMILIB_REG_STRUCT
  22. {
  23. TRACEHANDLE LoggerHandle;
  24. ULONG EnableFlags;
  25. ULONG EnableLevel;
  26. struct _WMILIB_REG_STRUCT* Next;
  27. TRACEHANDLE RegistrationHandle;
  28. } WMILIB_REG_STRUCT, *PWMILIB_REG_STRUCT;
  29. typedef PWMILIB_REG_STRUCT WMILIB_REG_HANDLE;
  30. typedef void (*WMILIBPRINTFUNC)(UINT Level, PCHAR String);
  31. ULONG
  32. WmlInitialize(
  33. IN LPWSTR ProductName,
  34. IN WMILIBPRINTFUNC PrintFunc,
  35. OUT WMILIB_REG_HANDLE*,
  36. ... // Pairs: LPWSTR CtrlGuidName, Corresponding WMILIB_REG_STRUCT
  37. );
  38. VOID
  39. WmlUninitialize(
  40. IN WMILIB_REG_HANDLE
  41. );
  42. ULONG
  43. WmlTrace(
  44. IN UINT Type,
  45. IN LPCGUID TraceGuid,
  46. IN TRACEHANDLE LoggerHandle,
  47. ... // Pairs: Address, Length
  48. );
  49. typedef
  50. ULONG
  51. (*PWML_INITIALIZE)(
  52. IN LPWSTR ProductName,
  53. IN WMILIBPRINTFUNC PrintFunc,
  54. OUT WMILIB_REG_HANDLE*,
  55. ...
  56. );
  57. typedef
  58. VOID
  59. (*PWML_UNINITIALIZE)(
  60. IN WMILIB_REG_HANDLE);
  61. typedef
  62. ULONG
  63. (*PWML_TRACE)(
  64. IN UINT Type,
  65. IN LPCGUID TraceGuid,
  66. IN TRACEHANDLE LoggerHandle,
  67. ...
  68. );
  69. typedef
  70. struct _WML_DATA {
  71. PWML_TRACE Trace;
  72. PWML_INITIALIZE Initialize;
  73. PWML_UNINITIALIZE Uninitialize;
  74. WMILIB_REG_HANDLE WmiRegHandle;
  75. HINSTANCE WmlDllInstance;
  76. } WML_DATA;
  77. #define LOADWML(status, wml) \
  78. do \
  79. { \
  80. (wml).Trace = (PWML_TRACE) WmlTrace; \
  81. (wml).Initialize = (PWML_INITIALIZE) WmlInitialize; \
  82. (wml).Uninitialize = (PWML_UNINITIALIZE) WmlUninitialize; \
  83. \
  84. if (!(wml).Trace || !(wml).Initialize || !(wml).Uninitialize) { \
  85. status = GetLastError(); \
  86. } else { \
  87. status = ERROR_SUCCESS; \
  88. } \
  89. } \
  90. while(0)
  91. /*
  92. #define LOADWML(status, wml) \
  93. do \
  94. { \
  95. HINSTANCE hInst = LoadLibraryW(L"wmlum.dll"); \
  96. (wml).WmlDllInstance = hInst; \
  97. if (!hInst) { \
  98. status = GetLastError(); \
  99. } else { \
  100. (wml).Trace = (PWML_TRACE) GetProcAddress(hInst, "WmlTrace"); \
  101. (wml).Initialize = (PWML_INITIALIZE) GetProcAddress(hInst, "WmlInitialize"); \
  102. (wml).Uninitialize = (PWML_UNINITIALIZE) GetProcAddress(hInst, "WmlUninitialize"); \
  103. \
  104. if (!(wml).Trace || !(wml).Initialize || !(wml).Uninitialize) { \
  105. status = GetLastError(); \
  106. } else { \
  107. status = ERROR_SUCCESS; \
  108. } \
  109. } \
  110. } \
  111. while(0)
  112. */
  113. #define UNLOADWML(wml) \
  114. do \
  115. { \
  116. if ( (wml).Uninitialize ) { \
  117. (wml).Uninitialize( (wml).WmiRegHandle ); \
  118. } \
  119. if ( (wml).WmlDllInstance ) { \
  120. FreeLibrary( (wml).WmlDllInstance ); \
  121. } \
  122. RtlZeroMemory( &(wml) , sizeof(WML_DATA) ); \
  123. } \
  124. while(0)
  125. #ifdef __cplusplus
  126. };
  127. #endif
  128. #endif // WMLUM_H