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.

145 lines
2.9 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. HINSTANCE hInst = LoadLibrary(L"wmlum.dll"); \
  81. (wml).WmlDllInstance = hInst; \
  82. if (!hInst) { \
  83. status = GetLastError(); \
  84. } else { \
  85. (wml).Trace = (PWML_TRACE) GetProcAddress(hInst, "WmlTrace"); \
  86. (wml).Initialize = (PWML_INITIALIZE) GetProcAddress(hInst, "WmlInitialize"); \
  87. (wml).Uninitialize = (PWML_UNINITIALIZE) GetProcAddress(hInst, "WmlUninitialize"); \
  88. \
  89. if (!(wml).Trace || !(wml).Initialize || !(wml).Uninitialize) { \
  90. status = GetLastError(); \
  91. } else { \
  92. status = ERROR_SUCCESS; \
  93. } \
  94. } \
  95. } \
  96. while(0)
  97. #define UNLOADWML(wml) \
  98. do \
  99. { \
  100. if ( (wml).Uninitialize ) { \
  101. (wml).Uninitialize( (wml).WmiRegHandle ); \
  102. } \
  103. if ( (wml).WmlDllInstance ) { \
  104. FreeLibrary( (wml).WmlDllInstance ); \
  105. } \
  106. RtlZeroMemory( &(wml) , sizeof(WML_DATA) ); \
  107. } \
  108. while(0)
  109. #ifdef __cplusplus
  110. };
  111. #endif
  112. #endif // WMLUM_H