implemented EnterCriticalPolicySection() and LeaveCriticalPolicySection()
Modified: trunk/reactos/lib/userenv/gpolicy.c
Modified: trunk/reactos/lib/userenv/userenv.def

Modified: trunk/reactos/lib/userenv/gpolicy.c
--- trunk/reactos/lib/userenv/gpolicy.c	2006-01-12 17:52:51 UTC (rev 20807)
+++ trunk/reactos/lib/userenv/gpolicy.c	2006-01-12 18:05:35 UTC (rev 20808)
@@ -44,7 +44,9 @@
 } GP_ACTION;
 
 static const WCHAR szLocalGPApplied[] = L"userenv: User Group Policy has been applied";
+static const WCHAR szLocalGPMutex[] = L"userenv: user policy mutex";
 static const WCHAR szMachineGPApplied[] = L"Global\\userenv: Machine Group Policy has been applied";
+static const WCHAR szMachineGPMutex[] = L"Global\\userenv: machine policy mutex";
 
 static CRITICAL_SECTION GPNotifyLock;
 static PGP_NOTIFY NotificationList = NULL;
@@ -409,3 +411,57 @@
 
     return Ret;
 }
+
+HANDLE WINAPI
+EnterCriticalPolicySection(IN BOOL bMachine)
+{
+    SECURITY_ATTRIBUTES SecurityAttributes;
+    PSECURITY_DESCRIPTOR lpSecurityDescriptor;
+    HANDLE hSection;
+
+    /* create or open the mutex */
+    lpSecurityDescriptor = CreateDefaultSecurityDescriptor();
+    if (lpSecurityDescriptor == NULL)
+    {
+        return NULL;
+    }
+
+    SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
+    SecurityAttributes.lpSecurityDescriptor = lpSecurityDescriptor;
+    SecurityAttributes.bInheritHandle = FALSE;
+
+    hSection = CreateMutexW(&SecurityAttributes,
+                            FALSE,
+                            (bMachine ? szMachineGPMutex : szLocalGPMutex));
+
+    if (hSection != NULL)
+    {
+        /* wait up to 10 seconds */
+        if (WaitForSingleObject(hSection,
+                                60000) != WAIT_FAILED)
+        {
+            return hSection;
+        }
+
+        CloseHandle(hSection);
+    }
+
+    return NULL;
+}
+
+BOOL WINAPI
+LeaveCriticalPolicySection(IN HANDLE hSection)
+{
+    BOOL Ret;
+
+    if (hSection == NULL)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    Ret = ReleaseMutex(hSection);
+    CloseHandle(hSection);
+
+    return Ret;
+}

Modified: trunk/reactos/lib/userenv/userenv.def
--- trunk/reactos/lib/userenv/userenv.def	2006-01-12 17:52:51 UTC (rev 20807)
+++ trunk/reactos/lib/userenv/userenv.def	2006-01-12 18:05:35 UTC (rev 20808)
@@ -19,6 +19,7 @@
 DeleteDesktopItemW@8 @116 NONAME
 CreateEnvironmentBlock@12
 DestroyEnvironmentBlock@4
+EnterCriticalPolicySection@4
 ExpandEnvironmentStringsForUserA@16
 ExpandEnvironmentStringsForUserW@16
 GetAllUsersProfileDirectoryA@8
@@ -29,6 +30,7 @@
 GetProfilesDirectoryW@8
 GetUserProfileDirectoryA@12
 GetUserProfileDirectoryW@12
+LeaveCriticalPolicySection@4
 LoadUserProfileA@8
 LoadUserProfileW@8
 RegisterGPNotification@8