[ros-diffs] [weiden] 20808: implemented
EnterCriticalPolicySection() and LeaveCriticalPolicySection()
weiden at svn.reactos.org
weiden at svn.reactos.org
Thu Jan 12 19:05:47 CET 2006
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 at 8 @116 NONAME
CreateEnvironmentBlock at 12
DestroyEnvironmentBlock at 4
+EnterCriticalPolicySection at 4
ExpandEnvironmentStringsForUserA at 16
ExpandEnvironmentStringsForUserW at 16
GetAllUsersProfileDirectoryA at 8
@@ -29,6 +30,7 @@
GetProfilesDirectoryW at 8
GetUserProfileDirectoryA at 12
GetUserProfileDirectoryW at 12
+LeaveCriticalPolicySection at 4
LoadUserProfileA at 8
LoadUserProfileW at 8
RegisterGPNotification at 8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20060112/32c3bfb8/attachment.html
More information about the Ros-diffs
mailing list