Author: greatlrd Date: Sun Apr 16 20:04:28 2006 New Revision: 21611
URL: http://svn.reactos.ru/svn/reactos?rev=21611&view=rev Log: kjk_hyperion : "Breaking auditing lock for a temporary fix: allow ExEnterCriticalRegionAndAcquireFastMutexUnsafe and ExReleaseFastMutexUnsafeAndLeaveCriticalRegion to be called from any thread; fixes UserEnterShared, UserEnterExclusive and UserLeave in win32k"
Modified: trunk/reactos/ntoskrnl/ex/fmutex.c
Modified: trunk/reactos/ntoskrnl/ex/fmutex.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ex/fmutex.c?rev=216... ============================================================================== --- trunk/reactos/ntoskrnl/ex/fmutex.c (original) +++ trunk/reactos/ntoskrnl/ex/fmutex.c Sun Apr 16 20:04:28 2006 @@ -28,6 +28,122 @@
/* Enter the Critical Region */ KeEnterCriticalRegion(); + /* + ASSERT((KeGetCurrentIrql() == APC_LEVEL) || + (Thread == NULL) || + (Thread->CombinedApcDisable != 0) || + (Thread->Teb == NULL) || + (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); + */ + ASSERT((KeGetCurrentIrql() == APC_LEVEL) || + (Thread == NULL) || + (Thread->CombinedApcDisable != 0)); + + ASSERT((Thread == NULL) || (FastMutex->Owner != Thread)); + + /* Decrease the count */ + if (InterlockedDecrement(&FastMutex->Count)) + { + /* Someone is still holding it, use slow path */ + KiAcquireFastMutex(FastMutex); + } + + /* Set the owner */ + FastMutex->Owner = Thread; +} + +/* + * @implemented + */ +VOID +FASTCALL +ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(PFAST_MUTEX FastMutex) +{ + /* + ASSERT((KeGetCurrentIrql() == APC_LEVEL) || + (KeGetCurrentThread() == NULL) || + (KeGetCurrentThread()->CombinedApcDisable != 0) || + (KeGetCurrentThread()->Teb == NULL) || + (KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); + + */ + ASSERT((KeGetCurrentIrql() == APC_LEVEL) || + (Thread == NULL) || + (Thread->CombinedApcDisable != 0)); + ASSERT(FastMutex->Owner == KeGetCurrentThread()); + + /* Erase the owner */ + FastMutex->Owner = NULL; + + /* Increase the count */ + if (InterlockedIncrement(&FastMutex->Count) <= 0) + { + /* Someone was waiting for it, signal the waiter */ + KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT); + } + + /* Leave the critical region */ + KeLeaveCriticalRegion(); +} + +/* + * @implemented + */ +VOID +FASTCALL +ExAcquireFastMutex(PFAST_MUTEX FastMutex) +{ + KIRQL OldIrql; + ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); + + /* Raise IRQL to APC */ + OldIrql = KfRaiseIrql(APC_LEVEL); + + /* Decrease the count */ + if (InterlockedDecrement(&FastMutex->Count)) + { + /* Someone is still holding it, use slow path */ + KiAcquireFastMutex(FastMutex); + } + + /* Set the owner and IRQL */ + FastMutex->Owner = KeGetCurrentThread(); + FastMutex->OldIrql = OldIrql; +} + +/* + * @implemented + */ +VOID +FASTCALL +ExReleaseFastMutex (PFAST_MUTEX FastMutex) +{ + KIRQL OldIrql; + ASSERT_IRQL(APC_LEVEL); + + /* Erase the owner */ + FastMutex->Owner = NULL; + OldIrql = FastMutex->OldIrql; + + /* Increase the count */ + if (InterlockedIncrement(&FastMutex->Count) <= 0) + { + /* Someone was waiting for it, signal the waiter */ + KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT); + } + + /* Lower IRQL back */ + KfLowerIrql(OldIrql); +} + +/* + * @implemented + */ +VOID +FASTCALL +ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex) +{ + PKTHREAD Thread = KeGetCurrentThread(); ASSERT((KeGetCurrentIrql() == APC_LEVEL) || (Thread == NULL) || (Thread->CombinedApcDisable != 0) || @@ -51,7 +167,7 @@ */ VOID FASTCALL -ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(PFAST_MUTEX FastMutex) +ExReleaseFastMutexUnsafe(PFAST_MUTEX FastMutex) { ASSERT((KeGetCurrentIrql() == APC_LEVEL) || (KeGetCurrentThread() == NULL) || @@ -69,110 +185,6 @@ /* Someone was waiting for it, signal the waiter */ KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT); } - - /* Leave the critical region */ - KeLeaveCriticalRegion(); -} - -/* - * @implemented - */ -VOID -FASTCALL -ExAcquireFastMutex(PFAST_MUTEX FastMutex) -{ - KIRQL OldIrql; - ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); - - /* Raise IRQL to APC */ - OldIrql = KfRaiseIrql(APC_LEVEL); - - /* Decrease the count */ - if (InterlockedDecrement(&FastMutex->Count)) - { - /* Someone is still holding it, use slow path */ - KiAcquireFastMutex(FastMutex); - } - - /* Set the owner and IRQL */ - FastMutex->Owner = KeGetCurrentThread(); - FastMutex->OldIrql = OldIrql; -} - -/* - * @implemented - */ -VOID -FASTCALL -ExReleaseFastMutex (PFAST_MUTEX FastMutex) -{ - KIRQL OldIrql; - ASSERT_IRQL(APC_LEVEL); - - /* Erase the owner */ - FastMutex->Owner = NULL; - OldIrql = FastMutex->OldIrql; - - /* Increase the count */ - if (InterlockedIncrement(&FastMutex->Count) <= 0) - { - /* Someone was waiting for it, signal the waiter */ - KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT); - } - - /* Lower IRQL back */ - KfLowerIrql(OldIrql); -} - -/* - * @implemented - */ -VOID -FASTCALL -ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex) -{ - PKTHREAD Thread = KeGetCurrentThread(); - ASSERT((KeGetCurrentIrql() == APC_LEVEL) || - (Thread == NULL) || - (Thread->CombinedApcDisable != 0) || - (Thread->Teb == NULL) || - (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); - ASSERT((Thread == NULL) || (FastMutex->Owner != Thread)); - - /* Decrease the count */ - if (InterlockedDecrement(&FastMutex->Count)) - { - /* Someone is still holding it, use slow path */ - KiAcquireFastMutex(FastMutex); - } - - /* Set the owner */ - FastMutex->Owner = Thread; -} - -/* - * @implemented - */ -VOID -FASTCALL -ExReleaseFastMutexUnsafe(PFAST_MUTEX FastMutex) -{ - ASSERT((KeGetCurrentIrql() == APC_LEVEL) || - (KeGetCurrentThread() == NULL) || - (KeGetCurrentThread()->CombinedApcDisable != 0) || - (KeGetCurrentThread()->Teb == NULL) || - (KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); - ASSERT(FastMutex->Owner == KeGetCurrentThread()); - - /* Erase the owner */ - FastMutex->Owner = NULL; - - /* Increase the count */ - if (InterlockedIncrement(&FastMutex->Count) <= 0) - { - /* Someone was waiting for it, signal the waiter */ - KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT); - } }
/*