2 * PROJECT: Local Security Authority Server DLL
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: LSA policy change notifications
5 * COPYRIGHT: Eric Kohl 2018
10 typedef struct _LSA_NOTIFICATION_ENTRY
13 POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass
;
15 } LSA_NOTIFICATION_ENTRY
, *PLSA_NOTIFICATION_ENTRY
;
17 /* GLOBALS *****************************************************************/
19 static LIST_ENTRY NotificationListHead
;
20 static RTL_RESOURCE NotificationListLock
;
23 /* FUNCTIONS ***************************************************************/
26 LsapInitNotificationList(VOID
)
28 InitializeListHead(&NotificationListHead
);
29 RtlInitializeResource(&NotificationListLock
);
34 PLSA_NOTIFICATION_ENTRY
35 LsapGetNotificationEntry(
37 POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass
)
39 PLIST_ENTRY NotificationEntry
;
40 PLSA_NOTIFICATION_ENTRY CurrentNotification
;
42 NotificationEntry
= NotificationListHead
.Flink
;
43 while (NotificationEntry
!= &NotificationListHead
)
45 CurrentNotification
= CONTAINING_RECORD(NotificationEntry
, LSA_NOTIFICATION_ENTRY
, Entry
);
47 if ((CurrentNotification
->EventHandle
== EventHandle
) &&
48 (CurrentNotification
->InformationClass
== InformationClass
))
49 return CurrentNotification
;
51 NotificationEntry
= NotificationEntry
->Flink
;
59 LsapRegisterNotification(
60 PLSA_API_MSG pRequestMsg
)
62 PLSA_NOTIFICATION_ENTRY pEntry
;
63 NTSTATUS Status
= STATUS_SUCCESS
;
65 FIXME("LsapRegisterNotification(%p)\n", pRequestMsg
);
67 /* Acquire the notification list lock exclusively */
68 RtlAcquireResourceExclusive(&NotificationListLock
, TRUE
);
70 if (pRequestMsg
->PolicyChangeNotify
.Request
.Register
)
72 /* Register the notification event */
73 pEntry
= RtlAllocateHeap(RtlGetProcessHeap(),
75 sizeof(LSA_NOTIFICATION_ENTRY
));
78 Status
= STATUS_INSUFFICIENT_RESOURCES
;
82 pEntry
->InformationClass
= pRequestMsg
->PolicyChangeNotify
.Request
.InformationClass
;
83 pEntry
->EventHandle
= pRequestMsg
->PolicyChangeNotify
.Request
.NotificationEventHandle
;
85 InsertHeadList(&NotificationListHead
,
90 /* Unregister the notification event */
91 pEntry
= LsapGetNotificationEntry(pRequestMsg
->PolicyChangeNotify
.Request
.NotificationEventHandle
,
92 pRequestMsg
->PolicyChangeNotify
.Request
.InformationClass
);
95 Status
= STATUS_INVALID_HANDLE
;
99 RemoveEntryList(&pEntry
->Entry
);
100 RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry
);
104 /* Release the notification list lock */
105 RtlReleaseResource(&NotificationListLock
);
112 LsapNotifyPolicyChange(
113 POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass
)
115 PLIST_ENTRY NotificationEntry
;
116 PLSA_NOTIFICATION_ENTRY CurrentNotification
;
118 FIXME("LsapNotifyPolicyChange(%lu)\n", InformationClass
);
120 /* Acquire the notification list lock shared */
121 RtlAcquireResourceShared(&NotificationListLock
, TRUE
);
123 NotificationEntry
= NotificationListHead
.Flink
;
124 while (NotificationEntry
!= &NotificationListHead
)
126 CurrentNotification
= CONTAINING_RECORD(NotificationEntry
, LSA_NOTIFICATION_ENTRY
, Entry
);
128 if (CurrentNotification
->InformationClass
== InformationClass
)
130 FIXME("Notify event %p\n", CurrentNotification
->EventHandle
);
134 NotificationEntry
= NotificationEntry
->Flink
;
137 /* Release the notification list lock */
138 RtlReleaseResource(&NotificationListLock
);