ReactOS  0.4.14-dev-323-g6fe6a88
gpolicy.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for gpolicy.c:

Go to the source code of this file.

Classes

struct  _GP_NOTIFY
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _GP_NOTIFY GP_NOTIFY
 
typedef struct _GP_NOTIFYPGP_NOTIFY
 

Enumerations

enum  GP_ACTION { gpaUpdate = 0, gpaTerminate }
 

Functions

VOID InitializeGPNotifications (VOID)
 
VOID UninitializeGPNotifications (VOID)
 
static VOID NotifyGPEvents (IN BOOL bMachine)
 
static DWORD WINAPI GPNotificationThreadProc (IN LPVOID lpParameter)
 
static HANDLE CreateGPEvent (IN BOOL bMachine, IN PSECURITY_DESCRIPTOR lpSecurityDescriptor)
 
BOOL WINAPI RegisterGPNotification (IN HANDLE hEvent, IN BOOL bMachine)
 
BOOL WINAPI UnregisterGPNotification (IN HANDLE hEvent)
 
BOOL WINAPI RefreshPolicy (IN BOOL bMachine)
 
BOOL WINAPI RefreshPolicyEx (IN BOOL bMachine, IN DWORD dwOptions)
 
HANDLE WINAPI EnterCriticalPolicySection (IN BOOL bMachine)
 
BOOL WINAPI LeaveCriticalPolicySection (IN HANDLE hSection)
 
BOOL WINAPI WaitForUserPolicyForegroundProcessing (VOID)
 
BOOL WINAPI WaitForMachinePolicyForegroundProcessing (VOID)
 
DWORD WINAPI GetAppliedGPOListA (_In_ DWORD dwFlags, _In_ LPCSTR pMachineName, _In_ PSID pSidUser, _In_ GUID *pGuidExtension, _Out_ PGROUP_POLICY_OBJECTA *ppGPOList)
 
DWORD WINAPI GetAppliedGPOListW (_In_ DWORD dwFlags, _In_ LPCWSTR pMachineName, _In_ PSID pSidUser, _In_ GUID *pGuidExtension, _Out_ PGROUP_POLICY_OBJECTW *ppGPOList)
 

Variables

static const WCHAR szLocalGPApplied [] = L"userenv: User Group Policy has been applied"
 
static const WCHAR szLocalGPMutex [] = L"userenv: user policy mutex"
 
static const WCHAR szLocalGPRefreshEvent [] = L"userenv: user policy refresh event"
 
static const WCHAR szLocalGPForceRefreshEvent [] = L"userenv: user policy force refresh event"
 
static const WCHAR szLocalGPDoneEvent [] = L"userenv: User Policy Foreground Done Event"
 
static const WCHAR szMachineGPApplied [] = L"Global\\userenv: Machine Group Policy has been applied"
 
static const WCHAR szMachineGPMutex [] = L"Global\\userenv: machine policy mutex"
 
static const WCHAR szMachineGPRefreshEvent [] = L"Global\\userenv: machine policy refresh event"
 
static const WCHAR szMachineGPForceRefreshEvent [] = L"Global\\userenv: machine policy force refresh event"
 
static const WCHAR szMachineGPDoneEvent [] = L"Global\\userenv: Machine Policy Foreground Done Event"
 
static CRITICAL_SECTION GPNotifyLock
 
static PGP_NOTIFY NotificationList = NULL
 
static GP_ACTION GPNotificationAction = gpaUpdate
 
static HANDLE hNotificationThread = NULL
 
static HANDLE hNotificationThreadEvent = NULL
 
static HANDLE hLocalGPAppliedEvent = NULL
 
static HANDLE hMachineGPAppliedEvent = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 29 of file gpolicy.c.

Typedef Documentation

◆ GP_NOTIFY

◆ PGP_NOTIFY

Enumeration Type Documentation

◆ GP_ACTION

Enumerator
gpaUpdate 
gpaTerminate 

Definition at line 39 of file gpolicy.c.

40 {
41  gpaUpdate = 0,
43 } GP_ACTION;
GP_ACTION
Definition: gpolicy.c:39

Function Documentation

◆ CreateGPEvent()

static HANDLE CreateGPEvent ( IN BOOL  bMachine,
IN PSECURITY_DESCRIPTOR  lpSecurityDescriptor 
)
static

Definition at line 262 of file gpolicy.c.

264 {
265  HANDLE hEvent;
266  SECURITY_ATTRIBUTES SecurityAttributes;
267 
268  SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
269  SecurityAttributes.lpSecurityDescriptor = lpSecurityDescriptor;
270  SecurityAttributes.bInheritHandle = FALSE;
271 
272  hEvent = CreateEventW(&SecurityAttributes,
273  TRUE,
274  FALSE,
276 
277  return hEvent;
278 }
static const WCHAR szMachineGPApplied[]
Definition: gpolicy.c:50
#define TRUE
Definition: types.h:120
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
static HANDLE hEvent
Definition: comm.c:54
LPVOID lpSecurityDescriptor
Definition: compat.h:181
static PCWSTR BOOL bMachine
Definition: layerapi.c:34
static const WCHAR szLocalGPApplied[]
Definition: gpolicy.c:45
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES

Referenced by RegisterGPNotification().

◆ EnterCriticalPolicySection()

HANDLE WINAPI EnterCriticalPolicySection ( IN BOOL  bMachine)

Definition at line 482 of file gpolicy.c.

483 {
484  SECURITY_ATTRIBUTES SecurityAttributes;
485  PSECURITY_DESCRIPTOR lpSecurityDescriptor;
487 
488  /* create or open the mutex */
489  lpSecurityDescriptor = CreateDefaultSecurityDescriptor();
490  if (lpSecurityDescriptor != NULL)
491  {
492  SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
493  SecurityAttributes.lpSecurityDescriptor = lpSecurityDescriptor;
494  SecurityAttributes.bInheritHandle = FALSE;
495 
496  hSection = CreateMutexW(&SecurityAttributes,
497  FALSE,
499 
500  LocalFree((HLOCAL)lpSecurityDescriptor);
501 
502  if (hSection != NULL)
503  {
504  /* wait up to 10 minutes */
506  600000) != WAIT_FAILED)
507  {
508  return hSection;
509  }
510 
512  }
513  }
514 
515  return NULL;
516 }
#define CloseHandle
Definition: compat.h:398
static const WCHAR szLocalGPMutex[]
Definition: gpolicy.c:46
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR szMachineGPMutex[]
Definition: gpolicy.c:51
#define WAIT_FAILED
Definition: winbase.h:394
PSECURITY_DESCRIPTOR CreateDefaultSecurityDescriptor(VOID)
Definition: misc.c:57
LPVOID lpSecurityDescriptor
Definition: compat.h:181
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3234
static PCWSTR BOOL bMachine
Definition: layerapi.c:34
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES

◆ GetAppliedGPOListA()

DWORD WINAPI GetAppliedGPOListA ( _In_ DWORD  dwFlags,
_In_ LPCSTR  pMachineName,
_In_ PSID  pSidUser,
_In_ GUID pGuidExtension,
_Out_ PGROUP_POLICY_OBJECTA *  ppGPOList 
)

Definition at line 578 of file gpolicy.c.

585 {
586  DPRINT1("GetAppliedGPOListA is UNIMPLEMENTED!\n");
588 }
#define DPRINT1
Definition: precomp.h:8
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ GetAppliedGPOListW()

DWORD WINAPI GetAppliedGPOListW ( _In_ DWORD  dwFlags,
_In_ LPCWSTR  pMachineName,
_In_ PSID  pSidUser,
_In_ GUID pGuidExtension,
_Out_ PGROUP_POLICY_OBJECTW *  ppGPOList 
)

Definition at line 592 of file gpolicy.c.

599 {
600  DPRINT1("GetAppliedGPOListW is UNIMPLEMENTED!\n");
602 }
#define DPRINT1
Definition: precomp.h:8
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ GPNotificationThreadProc()

static DWORD WINAPI GPNotificationThreadProc ( IN LPVOID  lpParameter)
static

Definition at line 132 of file gpolicy.c.

133 {
135  DWORD WaitResult, WaitCount;
136  HANDLE WaitHandles[3];
137 
138  /* reference the library so we don't screw up if the application
139  causes the DLL to unload while this thread is still running */
140  if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
142  &hModule))
143  {
145 
147 
149  WaitHandles[0] = hNotificationThreadEvent;
150  for (;;)
151  {
153 
154  if (NotificationList == NULL)
155  break;
156 
157  WaitCount = 2;
158  WaitHandles[1] = hMachineGPAppliedEvent;
159 
160  if (hLocalGPAppliedEvent != NULL)
161  {
162  WaitHandles[2] = hLocalGPAppliedEvent;
163  WaitCount++;
164  }
165 
167 
168  WaitResult = WaitForMultipleObjects(WaitCount,
169  WaitHandles,
170  FALSE,
171  INFINITE);
172 
174 
175  if (WaitResult != WAIT_FAILED)
176  {
177  if (WaitResult == WAIT_OBJECT_0)
178  {
180 
182  {
183  /* terminate the thread */
184  break;
185  }
186  }
187  else if (WaitResult == WAIT_OBJECT_0 + 1 || WaitResult == WAIT_OBJECT_0 + 2)
188  {
189  /* group policies have been applied */
190  if (NotificationList != NULL)
191  {
192  NotifyGPEvents((WaitResult == WAIT_OBJECT_0 + 1));
193  }
194  }
195  else if (WaitResult == WAIT_ABANDONED_0 + 2)
196  {
197  /* In case the local group policies event was abandoned, keep watching!
198  But close the handle as it's no longer of any use. */
199  if (hLocalGPAppliedEvent != NULL)
200  {
203  }
204  }
205  else if (WaitResult == WAIT_ABANDONED_0 || WaitResult == WAIT_ABANDONED_0 + 1)
206  {
207  /* terminate the thread if the machine group policies event was abandoned
208  or for some reason the rundown event got abandoned. */
209  break;
210  }
211  else
212  {
213  DPRINT("Unexpected wait result watching the group policy events: 0x%x\n", WaitResult);
214  ASSERT(FALSE);
215  break;
216  }
217 
218  if (NotificationList == NULL)
219  break;
220  }
221  else
222  break;
223 
224  }
225 
226  /* cleanup handles no longer used */
229 
234 
235  if (hLocalGPAppliedEvent != NULL)
236  {
239  }
241  {
244  }
245 
247 
248  /* dereference the library and exit */
250  0);
251  }
252  else
253  {
254  DPRINT1("Referencing the library failed!\n");
255  }
256 
257  return 1;
258 }
#define CloseHandle
Definition: compat.h:398
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
static CRITICAL_SECTION GPNotifyLock
Definition: gpolicy.c:56
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:516
static HANDLE hLocalGPAppliedEvent
Definition: gpolicy.c:61
HINSTANCE hInstance
Definition: charmap.c:20
static PGP_NOTIFY NotificationList
Definition: gpolicy.c:57
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static HANDLE hMachineGPAppliedEvent
Definition: gpolicy.c:62
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define WAIT_ABANDONED_0
Definition: winbase.h:388
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_FAILED
Definition: winbase.h:394
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static HANDLE hNotificationThreadEvent
Definition: gpolicy.c:60
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:875
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
static HANDLE hNotificationThread
Definition: gpolicy.c:59
#define DPRINT1
Definition: precomp.h:8
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static GP_ACTION GPNotificationAction
Definition: gpolicy.c:58
#define INFINITE
Definition: serial.h:102
static VOID NotifyGPEvents(IN BOOL bMachine)
Definition: gpolicy.c:114
HMODULE hModule
Definition: animate.c:44

Referenced by RegisterGPNotification().

◆ InitializeGPNotifications()

VOID InitializeGPNotifications ( VOID  )

Definition at line 65 of file gpolicy.c.

66 {
68 }
static CRITICAL_SECTION GPNotifyLock
Definition: gpolicy.c:56
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751

Referenced by DllMain().

◆ LeaveCriticalPolicySection()

BOOL WINAPI LeaveCriticalPolicySection ( IN HANDLE  hSection)

Definition at line 520 of file gpolicy.c.

521 {
522  BOOL Ret;
523 
524  if (hSection == NULL)
525  {
527  return FALSE;
528  }
529 
530  Ret = ReleaseMutex(hSection);
532 
533  return Ret;
534 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CloseHandle
Definition: compat.h:398
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3234

◆ NotifyGPEvents()

static VOID NotifyGPEvents ( IN BOOL  bMachine)
static

Definition at line 114 of file gpolicy.c.

115 {
117 
118  while (Notify != NULL)
119  {
120  if (Notify->bMachine == bMachine)
121  {
122  SetEvent(Notify->hEvent);
123  }
124 
125  Notify = Notify->Next;
126  }
127 }
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
static PGP_NOTIFY NotificationList
Definition: gpolicy.c:57
smooth NULL
Definition: ftsmooth.c:416
static PCWSTR BOOL bMachine
Definition: layerapi.c:34

Referenced by GPNotificationThreadProc().

◆ RefreshPolicy()

BOOL WINAPI RefreshPolicy ( IN BOOL  bMachine)

Definition at line 428 of file gpolicy.c.

429 {
430  HANDLE hEvent;
431  BOOL Ret = TRUE;
432 
434  FALSE,
436  if (hEvent != NULL)
437  {
438  Ret = SetEvent(hEvent);
440  }
441 
442  /* return TRUE even if the mutex doesn't exist! */
443  return Ret;
444 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
static const WCHAR szMachineGPRefreshEvent[]
Definition: gpolicy.c:52
static const WCHAR szLocalGPRefreshEvent[]
Definition: gpolicy.c:47
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
static HANDLE hEvent
Definition: comm.c:54
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define EVENT_MODIFY_STATE
Definition: winbase.h:163
static PCWSTR BOOL bMachine
Definition: layerapi.c:34

Referenced by RefreshPolicyEx().

◆ RefreshPolicyEx()

BOOL WINAPI RefreshPolicyEx ( IN BOOL  bMachine,
IN DWORD  dwOptions 
)

Definition at line 448 of file gpolicy.c.

450 {
451  if (dwOptions & ~RP_FORCE)
452  {
454  return FALSE;
455  }
456 
457  if (dwOptions & RP_FORCE)
458  {
459  HANDLE hEvent;
460  BOOL Ret = TRUE;
461 
463  FALSE,
465  if (hEvent != NULL)
466  {
467  Ret = SetEvent(hEvent);
469  }
470 
471  /* return TRUE even if the mutex doesn't exist! */
472  return Ret;
473  }
474  else
475  {
476  return RefreshPolicy(bMachine);
477  }
478 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD dwOptions
Definition: solitaire.cpp:23
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
static HANDLE hEvent
Definition: comm.c:54
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI RefreshPolicy(IN BOOL bMachine)
Definition: gpolicy.c:428
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR szMachineGPForceRefreshEvent[]
Definition: gpolicy.c:53
static const WCHAR szLocalGPForceRefreshEvent[]
Definition: gpolicy.c:48
#define EVENT_MODIFY_STATE
Definition: winbase.h:163
static PCWSTR BOOL bMachine
Definition: layerapi.c:34

◆ RegisterGPNotification()

BOOL WINAPI RegisterGPNotification ( IN HANDLE  hEvent,
IN BOOL  bMachine 
)

Definition at line 282 of file gpolicy.c.

284 {
286  PSECURITY_DESCRIPTOR lpSecurityDescriptor = NULL;
287  BOOL Ret = FALSE;
288 
290 
291  /* create the thread notification event */
293  {
295  TRUE,
296  FALSE,
297  NULL);
299  {
300  goto Cleanup;
301  }
302  }
303 
304  /* create or open the machine group policy event */
306  {
307  lpSecurityDescriptor = CreateDefaultSecurityDescriptor();
308  if (lpSecurityDescriptor == NULL)
309  {
310  goto Cleanup;
311  }
312 
314  lpSecurityDescriptor);
316  {
317  goto Cleanup;
318  }
319  }
320 
321  /* create or open the local group policy event only if necessary */
323  {
324  if (lpSecurityDescriptor == NULL)
325  {
326  lpSecurityDescriptor = CreateDefaultSecurityDescriptor();
327  if (lpSecurityDescriptor == NULL)
328  {
329  goto Cleanup;
330  }
331  }
332 
334  lpSecurityDescriptor);
335  if (hLocalGPAppliedEvent == NULL)
336  {
337  goto Cleanup;
338  }
339  }
340 
341  if (hNotificationThread == NULL)
342  {
344  0,
346  NULL,
347  0,
348  NULL);
349  }
350 
351  if (hNotificationThread != NULL)
352  {
354  sizeof(GP_NOTIFY));
355  if (Notify != NULL)
356  {
357  /* add the item to the beginning of the list */
358  Notify->Next = NotificationList;
359  Notify->hEvent = hEvent;
360  Notify->bMachine = bMachine;
361 
363 
364  /* notify the thread */
367 
368  Ret = TRUE;
369  }
370  }
371 
372 Cleanup:
374 
375  if (lpSecurityDescriptor != NULL)
376  {
377  LocalFree((HLOCAL)lpSecurityDescriptor);
378  }
379 
380  /* NOTE: don't delete the events or close the handles created */
381 
382  return Ret;
383 }
#define CreateEvent
Definition: winbase.h:3572
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)
#define TRUE
Definition: types.h:120
struct _GP_NOTIFY * PGP_NOTIFY
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static CRITICAL_SECTION GPNotifyLock
Definition: gpolicy.c:56
static HANDLE hEvent
Definition: comm.c:54
static HANDLE hLocalGPAppliedEvent
Definition: gpolicy.c:61
unsigned int BOOL
Definition: ntddk_ex.h:94
static PGP_NOTIFY NotificationList
Definition: gpolicy.c:57
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
static HANDLE hMachineGPAppliedEvent
Definition: gpolicy.c:62
#define LMEM_FIXED
Definition: winbase.h:349
static DWORD WINAPI GPNotificationThreadProc(IN LPVOID lpParameter)
Definition: gpolicy.c:132
static HANDLE hNotificationThreadEvent
Definition: gpolicy.c:60
static const WCHAR Cleanup[]
Definition: register.c:80
PSECURITY_DESCRIPTOR CreateDefaultSecurityDescriptor(VOID)
Definition: misc.c:57
static HANDLE CreateGPEvent(IN BOOL bMachine, IN PSECURITY_DESCRIPTOR lpSecurityDescriptor)
Definition: gpolicy.c:262
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static HANDLE hNotificationThread
Definition: gpolicy.c:59
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static GP_ACTION GPNotificationAction
Definition: gpolicy.c:58
static PCWSTR BOOL bMachine
Definition: layerapi.c:34

◆ UninitializeGPNotifications()

VOID UninitializeGPNotifications ( VOID  )

Definition at line 71 of file gpolicy.c.

72 {
74 
75  /* rundown the notification thread */
77  {
79 
80  /* notify the thread */
83 
85 
86  /* wait for the thread to terminate itself */
88  INFINITE);
89 
91 
93  {
94  /* the handle should be closed by the thread,
95  just in case that didn't happen for an unknown reason */
98  }
99  }
100 
102  {
105  }
106 
108 
110 }
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static CRITICAL_SECTION GPNotifyLock
Definition: gpolicy.c:56
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static HANDLE hNotificationThreadEvent
Definition: gpolicy.c:60
static HANDLE hNotificationThread
Definition: gpolicy.c:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static GP_ACTION GPNotificationAction
Definition: gpolicy.c:58
#define INFINITE
Definition: serial.h:102

Referenced by DllMain().

◆ UnregisterGPNotification()

BOOL WINAPI UnregisterGPNotification ( IN HANDLE  hEvent)

Definition at line 387 of file gpolicy.c.

388 {
389  PGP_NOTIFY Notify = NULL, *NotifyLink;
390  BOOL Ret = FALSE;
391 
393 
395  NotifyLink = &NotificationList;
396 
397  while (Notify != NULL)
398  {
399  if (Notify->hEvent == hEvent)
400  {
401  /* remove and free the item */
402  *NotifyLink = Notify->Next;
404 
405  /* notify the thread */
406  if (hNotificationThread != NULL &&
408  {
411  }
412 
413  Ret = TRUE;
414  break;
415  }
416 
417  NotifyLink = &Notify->Next;
418  Notify = Notify->Next;
419  }
420 
422 
423  return Ret;
424 }
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)
#define TRUE
Definition: types.h:120
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static CRITICAL_SECTION GPNotifyLock
Definition: gpolicy.c:56
static HANDLE hEvent
Definition: comm.c:54
unsigned int BOOL
Definition: ntddk_ex.h:94
static PGP_NOTIFY NotificationList
Definition: gpolicy.c:57
smooth NULL
Definition: ftsmooth.c:416
static HANDLE hNotificationThreadEvent
Definition: gpolicy.c:60
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static HANDLE hNotificationThread
Definition: gpolicy.c:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static GP_ACTION GPNotificationAction
Definition: gpolicy.c:58

◆ WaitForMachinePolicyForegroundProcessing()

BOOL WINAPI WaitForMachinePolicyForegroundProcessing ( VOID  )

Definition at line 558 of file gpolicy.c.

559 {
560  HANDLE hEvent;
561  BOOL Ret = FALSE;
562 
564  FALSE,
566  if (hEvent != NULL)
567  {
569  INFINITE) != WAIT_FAILED;
571  }
572 
573  return Ret;
574 }
static const WCHAR szMachineGPDoneEvent[]
Definition: gpolicy.c:54
#define CloseHandle
Definition: compat.h:398
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
static HANDLE hEvent
Definition: comm.c:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_FAILED
Definition: winbase.h:394
#define SYNCHRONIZE
Definition: nt_native.h:61
#define INFINITE
Definition: serial.h:102

◆ WaitForUserPolicyForegroundProcessing()

BOOL WINAPI WaitForUserPolicyForegroundProcessing ( VOID  )

Definition at line 538 of file gpolicy.c.

539 {
540  HANDLE hEvent;
541  BOOL Ret = FALSE;
542 
544  FALSE,
546  if (hEvent != NULL)
547  {
549  INFINITE) != WAIT_FAILED;
551  }
552 
553  return Ret;
554 }
#define CloseHandle
Definition: compat.h:398
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
static HANDLE hEvent
Definition: comm.c:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR szLocalGPDoneEvent[]
Definition: gpolicy.c:49
#define WAIT_FAILED
Definition: winbase.h:394
#define SYNCHRONIZE
Definition: nt_native.h:61
#define INFINITE
Definition: serial.h:102

Variable Documentation

◆ GPNotificationAction

◆ GPNotifyLock

◆ hLocalGPAppliedEvent

HANDLE hLocalGPAppliedEvent = NULL
static

Definition at line 61 of file gpolicy.c.

Referenced by GPNotificationThreadProc(), and RegisterGPNotification().

◆ hMachineGPAppliedEvent

HANDLE hMachineGPAppliedEvent = NULL
static

Definition at line 62 of file gpolicy.c.

Referenced by GPNotificationThreadProc(), and RegisterGPNotification().

◆ hNotificationThread

HANDLE hNotificationThread = NULL
static

◆ hNotificationThreadEvent

HANDLE hNotificationThreadEvent = NULL
static

◆ NotificationList

PGP_NOTIFY NotificationList = NULL
static

◆ szLocalGPApplied

const WCHAR szLocalGPApplied[] = L"userenv: User Group Policy has been applied"
static

Definition at line 45 of file gpolicy.c.

Referenced by CreateGPEvent().

◆ szLocalGPDoneEvent

const WCHAR szLocalGPDoneEvent[] = L"userenv: User Policy Foreground Done Event"
static

Definition at line 49 of file gpolicy.c.

Referenced by WaitForUserPolicyForegroundProcessing().

◆ szLocalGPForceRefreshEvent

const WCHAR szLocalGPForceRefreshEvent[] = L"userenv: user policy force refresh event"
static

Definition at line 48 of file gpolicy.c.

Referenced by RefreshPolicyEx().

◆ szLocalGPMutex

const WCHAR szLocalGPMutex[] = L"userenv: user policy mutex"
static

Definition at line 46 of file gpolicy.c.

Referenced by EnterCriticalPolicySection().

◆ szLocalGPRefreshEvent

const WCHAR szLocalGPRefreshEvent[] = L"userenv: user policy refresh event"
static

Definition at line 47 of file gpolicy.c.

Referenced by RefreshPolicy().

◆ szMachineGPApplied

const WCHAR szMachineGPApplied[] = L"Global\\userenv: Machine Group Policy has been applied"
static

Definition at line 50 of file gpolicy.c.

Referenced by CreateGPEvent().

◆ szMachineGPDoneEvent

const WCHAR szMachineGPDoneEvent[] = L"Global\\userenv: Machine Policy Foreground Done Event"
static

Definition at line 54 of file gpolicy.c.

Referenced by WaitForMachinePolicyForegroundProcessing().

◆ szMachineGPForceRefreshEvent

const WCHAR szMachineGPForceRefreshEvent[] = L"Global\\userenv: machine policy force refresh event"
static

Definition at line 53 of file gpolicy.c.

Referenced by RefreshPolicyEx().

◆ szMachineGPMutex

const WCHAR szMachineGPMutex[] = L"Global\\userenv: machine policy mutex"
static

Definition at line 51 of file gpolicy.c.

Referenced by EnterCriticalPolicySection().

◆ szMachineGPRefreshEvent

const WCHAR szMachineGPRefreshEvent[] = L"Global\\userenv: machine policy refresh event"
static

Definition at line 52 of file gpolicy.c.

Referenced by RefreshPolicy().