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.

129 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. notify.c
  5. Abstract:
  6. Manages KM to UM notification queue
  7. Author:
  8. AlanWar
  9. Environment:
  10. Kernel Mode
  11. Revision History:
  12. --*/
  13. #include "wmikmp.h"
  14. void WmipInitializeNotifications(
  15. void
  16. );
  17. void WmipEventNotification(
  18. IN PVOID Context
  19. );
  20. #ifdef ALLOC_PRAGMA
  21. #pragma alloc_text(INIT,WmipInitializeNotifications)
  22. #pragma alloc_text(PAGE,WmipEventNotification)
  23. #endif
  24. WORK_QUEUE_ITEM WmipEventWorkQueueItem;
  25. LIST_ENTRY WmipNPEvent = {&WmipNPEvent, &WmipNPEvent};
  26. KSPIN_LOCK WmipNPNotificationSpinlock;
  27. LONG WmipEventWorkItems;
  28. #if DBG
  29. ULONG WmipNPAllocFail;
  30. #endif
  31. void WmipInitializeNotifications(
  32. void
  33. )
  34. {
  35. PAGED_CODE();
  36. ExInitializeWorkItem( &WmipEventWorkQueueItem,
  37. WmipEventNotification,
  38. NULL );
  39. KeInitializeSpinLock(&WmipNPNotificationSpinlock);
  40. }
  41. void WmipEventNotification(
  42. IN PVOID Context
  43. )
  44. /*++
  45. Routine Description:
  46. Work item routine to call WmipNotifyUserMode on behalf of an event fired
  47. by a driver
  48. Arguments:
  49. Context is not used
  50. Return Value:
  51. --*/
  52. {
  53. PWNODE_HEADER WnodeEventItem;
  54. PLIST_ENTRY NotificationPacketList;
  55. PEVENTWORKCONTEXT EventContext;
  56. PAGED_CODE();
  57. UNREFERENCED_PARAMETER (Context);
  58. do
  59. {
  60. NotificationPacketList = ExInterlockedRemoveHeadList(
  61. &WmipNPEvent,
  62. &WmipNPNotificationSpinlock);
  63. WmipAssert(NotificationPacketList != NULL);
  64. EventContext = (PEVENTWORKCONTEXT)
  65. CONTAINING_RECORD(NotificationPacketList,
  66. EVENTWORKCONTEXT,
  67. ListEntry);
  68. WnodeEventItem = EventContext->Wnode;
  69. //
  70. // Restore the Wnode->Version from ->ClientContext
  71. //
  72. WnodeEventItem->Version = WnodeEventItem->ClientContext;
  73. WnodeEventItem->ClientContext = 0;
  74. WnodeEventItem->Linkage = 0;
  75. WmipProcessEvent(WnodeEventItem,
  76. FALSE,
  77. TRUE);
  78. if (EventContext->RegEntry != NULL)
  79. {
  80. //
  81. // Unref for the ref count taken in IoWMIWriteEvent
  82. //
  83. WmipUnreferenceRegEntry(EventContext->RegEntry);
  84. }
  85. ExFreePool(EventContext);
  86. } while (InterlockedDecrement(&WmipEventWorkItems));
  87. }