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.

193 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. dcapi.c
  5. Abstract:
  6. WMI data consumer api set
  7. Author:
  8. 16-Jan-1997 AlanWar
  9. Revision History:
  10. --*/
  11. #include "wmiump.h"
  12. #ifndef MEMPHIS
  13. #include <aclapi.h>
  14. #endif
  15. ULONG
  16. WMIAPI
  17. EtwNotificationRegistrationA(
  18. IN LPGUID Guid,
  19. IN BOOLEAN Enable,
  20. IN PVOID DeliveryInfo,
  21. IN ULONG_PTR DeliveryContext,
  22. IN ULONG Flags
  23. )
  24. /*+++
  25. Routine Description:
  26. ANSI thunk to NotificationRegistration
  27. Return Value:
  28. Returns ERROR_SUCCESS or an error code
  29. ---*/
  30. {
  31. return(EtwpNotificationRegistration(Guid,
  32. Enable,
  33. DeliveryInfo,
  34. DeliveryContext,
  35. 0,
  36. Flags,
  37. TRUE));
  38. }
  39. ULONG
  40. WMIAPI
  41. EtwNotificationRegistrationW(
  42. IN LPGUID Guid,
  43. IN BOOLEAN Enable,
  44. IN PVOID DeliveryInfo,
  45. IN ULONG_PTR DeliveryContext,
  46. IN ULONG Flags
  47. )
  48. /*+++
  49. Routine Description:
  50. This routine allows a data consumer to register or unregister for
  51. notification of events fired by WMI data providers. Notifications are
  52. delivered via callbackor via a posted meesage to a window.
  53. Arguments:
  54. Guid is pointer to the guid whose events are being registered for
  55. Enable is TRUE if enabling notifications else FALSE. If FALSE the
  56. Destination and DestinationInformation parameters are ignored.
  57. DeliveryInfo has the callback function pointer or window handle to which
  58. to deliver the notifications for the guid.
  59. DeliveryContext has a context value or additional information to use
  60. when delivering the notification.
  61. Flags are a set of flags that define how the notification is delivered.
  62. DeliveryInfo and DeliveryContext have different meanings depending
  63. upon the value in Flags:
  64. NOTIFICATION_WINDOW_HANDLE is set when notifications for the guid
  65. are to be delivered by posting a message to the window handle
  66. passed in DeliveryInfo. The message posted is the value that
  67. is returned from the call to
  68. RegisterWindowMessage(WMINOTIFICATIONWINDOWMESSAGE) with the
  69. wParam set to the pointer to the Wnode containing the notification
  70. and lParam set to the context value passed in DeliveryContext.
  71. The caller MUST free the Wnode passed in wParam by calling
  72. WMIFreeBuffer.
  73. NOTIFICATION_CALLBACK_DIRECT is set when notifications for the
  74. guid are to be delivered by direct callback. Whenever a
  75. notification arrives WMI creates a new thread dedicated to
  76. calling the callback function with the notification. This
  77. mechanism provides the shortest latency from notification firing
  78. to notification delivery, although it is the most expensive
  79. mechanism. The callback function pointer is passed in DeliveryInfo
  80. and must conform to the prototype described by the type
  81. NOTIFICATIONCALLBACK. The context value passed in the callback
  82. is specified by the DeliveryContext parameter. WMI does not
  83. serialize calling the callback function so it must be reentrant.
  84. NOTIFICATION_CALLBACK_QUEUED is set when notifications for the
  85. guid are to be delivered by a queued callback. Whenever a
  86. notification arrives WMI places it at the end of an internal
  87. queue. A single thread monitors this queue and calls the callback
  88. function serially for each notification in the queue. This
  89. mechanism provides low overhead for event delivery, however
  90. notification delivery can be delayed if the callback function
  91. for an earlier notification does not complete quickly.
  92. The callback function pointer is passed in DeliveryInfo
  93. and must conform to the prototype described by the type
  94. NOTIFICATIONCALLBACK. The context value passed in the callback
  95. is specified by the DeliveryContext parameter. WMI does
  96. serialize calling the callback function so it need not be
  97. reentrant provided it is not also used for
  98. NOTIFICATION_CALLBACK_DIRECT notififications. NOTE THAT THIS
  99. IS NOT YET IMPLEMENTED.
  100. NOTIFICATION_TRACE_FLAG is set when the caller wishes to enable
  101. trace logging in the data provider for the guid. DeliveryInfo
  102. specifies the trace logger handle to be passed to the data
  103. provider. DeliveryContext is not used. No notifications are
  104. generated to the caller when this flag is set.
  105. Note that all of the above flags are mutually exclusive.
  106. Return Value:
  107. Returns ERROR_SUCCESS or an error code
  108. ---*/
  109. {
  110. return(EtwpNotificationRegistration(Guid,
  111. Enable,
  112. DeliveryInfo,
  113. DeliveryContext,
  114. 0,
  115. Flags,
  116. FALSE));
  117. }
  118. ULONG
  119. WMIAPI
  120. EtwReceiveNotificationsW(
  121. IN ULONG HandleCount,
  122. IN HANDLE *HandleList,
  123. IN NOTIFICATIONCALLBACK Callback,
  124. IN ULONG_PTR DeliveryContext
  125. )
  126. {
  127. return(EtwpReceiveNotifications(HandleCount,
  128. HandleList,
  129. Callback,
  130. DeliveryContext,
  131. FALSE,
  132. RECEIVE_ACTION_NONE,
  133. NULL,
  134. NULL));
  135. }
  136. ULONG
  137. WMIAPI
  138. EtwReceiveNotificationsA(
  139. IN ULONG HandleCount,
  140. IN HANDLE *HandleList,
  141. IN NOTIFICATIONCALLBACK Callback,
  142. IN ULONG_PTR DeliveryContext
  143. )
  144. {
  145. return(EtwpReceiveNotifications(HandleCount,
  146. HandleList,
  147. Callback,
  148. DeliveryContext,
  149. TRUE,
  150. RECEIVE_ACTION_NONE,
  151. NULL,
  152. NULL));
  153. }