ReactOS 0.4.15-dev-7924-g5949c20
notify.c File Reference
#include "lsasrv.h"
Include dependency graph for notify.c:

Go to the source code of this file.

Classes

struct  _LSA_NOTIFICATION_ENTRY
 

Typedefs

typedef struct _LSA_NOTIFICATION_ENTRY LSA_NOTIFICATION_ENTRY
 
typedef struct _LSA_NOTIFICATION_ENTRYPLSA_NOTIFICATION_ENTRY
 

Functions

VOID LsapInitNotificationList (VOID)
 
static PLSA_NOTIFICATION_ENTRY LsapGetNotificationEntry (PLSA_API_MSG pRequestMsg)
 
static NTSTATUS LsapAddNotification (PLSA_API_MSG pRequestMsg)
 
static NTSTATUS LsapRemoveNotification (PLSA_API_MSG pRequestMsg)
 
NTSTATUS LsapRegisterNotification (PLSA_API_MSG pRequestMsg)
 
VOID LsapNotifyPolicyChange (POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass)
 

Variables

static LIST_ENTRY NotificationListHead
 
static RTL_RESOURCE NotificationListLock
 

Typedef Documentation

◆ LSA_NOTIFICATION_ENTRY

◆ PLSA_NOTIFICATION_ENTRY

Function Documentation

◆ LsapAddNotification()

static NTSTATUS LsapAddNotification ( PLSA_API_MSG  pRequestMsg)
static

Definition at line 63 of file notify.c.

65{
69
70 TRACE("LsapAddNotification(%p)\n", pRequestMsg);
71
72 /* Allocate a new notification list entry */
73 pEntry = RtlAllocateHeap(RtlGetProcessHeap(),
76 if (pEntry == NULL)
77 {
79 goto done;
80 }
81
82 /* Copy the notification data */
83 pEntry->InformationClass = pRequestMsg->PolicyChangeNotify.Request.InformationClass;
84 pEntry->EventHandle = pRequestMsg->PolicyChangeNotify.Request.NotificationEventHandle;
85 pEntry->ClientId = pRequestMsg->h.ClientId;
86
87 /* Open the client process */
90 NULL,
91 pEntry->ClientId.UniqueProcess);
92 if (!NT_SUCCESS(Status))
93 {
94 ERR("NtOpenProcess() failed (Status 0x%08lx)\n", Status);
95 goto done;
96 }
97
98 /* Duplicate the event handle into the current process */
100 pEntry->EventHandle,
102 &pEntry->MappedEventHandle,
103 0,
104 0,
106 if (!NT_SUCCESS(Status))
107 {
108 ERR("NtDuplicateObject() failed (Status 0x%08lx)\n", Status);
109 goto done;
110 }
111
112 /* Insert the new entry into the notification list */
114 &pEntry->Entry);
115
116done:
117 if (hProcess != NULL)
119
120 if (!NT_SUCCESS(Status))
121 {
122 if (pEntry != NULL)
123 RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry);
124 }
125
126 return Status;
127}
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: debug.h:110
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static LIST_ENTRY NotificationListHead
Definition: notify.c:21
#define InsertHeadList(ListHead, Entry)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
Status
Definition: gdiplustypes.h:25
#define PROCESS_DUP_HANDLE
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSTATUS NTAPI NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId)
Definition: process.c:1440
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3410
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE(s)
Definition: solgame.cpp:4
PORT_MESSAGE h
Definition: lsass.h:177
LSA_POLICY_CHANGE_NOTIFY_MSG PolicyChangeNotify
Definition: lsass.h:193
Definition: notify.c:11
struct _LSA_POLICY_CHANGE_NOTIFY_MSG::@3515::@3517 Request
CLIENT_ID ClientId
Definition: winternl.h:1751
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define DUPLICATE_SAME_ACCESS

Referenced by LsapRegisterNotification().

◆ LsapGetNotificationEntry()

static PLSA_NOTIFICATION_ENTRY LsapGetNotificationEntry ( PLSA_API_MSG  pRequestMsg)
static

Definition at line 37 of file notify.c.

39{
41 PLSA_NOTIFICATION_ENTRY CurrentNotification;
42
45 {
47
48 if ((CurrentNotification->ClientId.UniqueProcess == pRequestMsg->h.ClientId.UniqueProcess) &&
49 (CurrentNotification->ClientId.UniqueThread == pRequestMsg->h.ClientId.UniqueThread) &&
50 (CurrentNotification->InformationClass == pRequestMsg->PolicyChangeNotify.Request.InformationClass) &&
51 (CurrentNotification->EventHandle == pRequestMsg->PolicyChangeNotify.Request.NotificationEventHandle))
52 return CurrentNotification;
53
55 }
56
57 return NULL;
58}
base of all file and directory entries
Definition: entries.h:83
HANDLE UniqueThread
Definition: compat.h:826
HANDLE UniqueProcess
Definition: compat.h:825
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass
Definition: notify.c:13
HANDLE EventHandle
Definition: notify.c:15
CLIENT_ID ClientId
Definition: notify.c:14
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ ULONG _In_opt_ PVOID _In_ PDRIVER_OBJECT _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE _Inout_opt_ __drv_aliasesMem PVOID _Outptr_result_nullonfailure_ _At_ * NotificationEntry(return==0, __drv_allocatesMem(Mem))) PVOID *NotificationEntry

Referenced by LsapRemoveNotification().

◆ LsapInitNotificationList()

VOID LsapInitNotificationList ( VOID  )

Definition at line 28 of file notify.c.

29{
32}
static RTL_RESOURCE NotificationListLock
Definition: notify.c:22
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSYSAPI VOID NTAPI RtlInitializeResource(_In_ PRTL_RESOURCE Resource)

Referenced by LsapInitLsa().

◆ LsapNotifyPolicyChange()

VOID LsapNotifyPolicyChange ( POLICY_NOTIFICATION_INFORMATION_CLASS  InformationClass)

Definition at line 188 of file notify.c.

190{
192 PLSA_NOTIFICATION_ENTRY CurrentNotification;
193
194 TRACE("LsapNotifyPolicyChange(%lu)\n", InformationClass);
195
196 /* Acquire the notification list lock shared */
198
201 {
203
204 if (CurrentNotification->InformationClass == InformationClass)
205 {
206 TRACE("Notify event %p\n", CurrentNotification->MappedEventHandle);
207 NtSetEvent(CurrentNotification->MappedEventHandle, NULL);
208 }
209
211 }
212
213 /* Release the notification list lock */
215}
#define TRUE
Definition: types.h:120
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1713
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
HANDLE MappedEventHandle
Definition: notify.c:16

Referenced by LsarSetInformationPolicy().

◆ LsapRegisterNotification()

NTSTATUS LsapRegisterNotification ( PLSA_API_MSG  pRequestMsg)

Definition at line 159 of file notify.c.

161{
163
164 TRACE("LsapRegisterNotification(%p)\n", pRequestMsg);
165
166 /* Acquire the notification list lock exclusively */
168
169 if (pRequestMsg->PolicyChangeNotify.Request.Register)
170 {
171 /* Register the notification event */
172 Status = LsapAddNotification(pRequestMsg);
173 }
174 else
175 {
176 /* Unregister the notification event */
177 Status = LsapRemoveNotification(pRequestMsg);
178 }
179
180 /* Release the notification list lock */
182
183 return Status;
184}
static NTSTATUS LsapAddNotification(PLSA_API_MSG pRequestMsg)
Definition: notify.c:63
static NTSTATUS LsapRemoveNotification(PLSA_API_MSG pRequestMsg)
Definition: notify.c:132
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceExclusive(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)

Referenced by AuthPortThreadRoutine().

◆ LsapRemoveNotification()

static NTSTATUS LsapRemoveNotification ( PLSA_API_MSG  pRequestMsg)
static

Definition at line 132 of file notify.c.

134{
136
137 TRACE("LsapRemoveNotification(%p)\n", pRequestMsg);
138
139 pEntry = LsapGetNotificationEntry(pRequestMsg);
140 if (pEntry == NULL)
141 {
143 }
144
145 /* Remove the notification entry from the notification list */
146 RemoveEntryList(&pEntry->Entry);
147
148 /* Close the mapped event handle */
149 NtClose(pEntry->MappedEventHandle);
150
151 /* Release the notification entry */
152 RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry);
153
154 return STATUS_SUCCESS;
155}
static PLSA_NOTIFICATION_ENTRY LsapGetNotificationEntry(PLSA_API_MSG pRequestMsg)
Definition: notify.c:37
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245

Referenced by LsapRegisterNotification().

Variable Documentation

◆ NotificationListHead

LIST_ENTRY NotificationListHead
static

◆ NotificationListLock

RTL_RESOURCE NotificationListLock
static