Signed-off-by: Derek Lesho dereklesho52@Gmail.com --- dlls/hal/hal.c | 9 ++++++++- dlls/ntoskrnl.exe/sync.c | 14 ++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/hal/hal.c b/dlls/hal/hal.c index 269a551f17..d8452952f1 100644 --- a/dlls/hal/hal.c +++ b/dlls/hal/hal.c @@ -89,9 +89,16 @@ void WINAPI ExReleaseFastMutex( FAST_MUTEX *mutex ) DEFINE_FASTCALL1_WRAPPER( ExTryToAcquireFastMutex ) BOOLEAN WINAPI ExTryToAcquireFastMutex( FAST_MUTEX *mutex ) { + BOOLEAN ret; + TRACE("mutex %p.\n", mutex);
- return (InterlockedCompareExchange( &mutex->Count, 0, 1 ) == 1); + ret = (InterlockedCompareExchange( &mutex->Count, 0, 1 ) == 1); + + if (ret) + mutex->Owner = KeGetCurrentThread(); + + return ret; }
DEFINE_FASTCALL1_WRAPPER( KfAcquireSpinLock ) diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index 3085543727..bb2d318e56 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -668,13 +668,12 @@ PSLIST_ENTRY WINAPI NTOSKRNL_ExInterlockedPushEntrySList( PSLIST_HEADER list, PS DEFINE_FASTCALL1_WRAPPER(ExAcquireFastMutexUnsafe) void WINAPI ExAcquireFastMutexUnsafe( FAST_MUTEX *mutex ) { - LONG count; - TRACE("mutex %p.\n", mutex);
- count = InterlockedDecrement( &mutex->Count ); - if (count < 0) + if (InterlockedDecrement(&mutex->Count) < 0) KeWaitForSingleObject( &mutex->Event, Executive, KernelMode, FALSE, NULL ); + + mutex->Owner = KeGetCurrentThread(); }
/*********************************************************************** @@ -683,11 +682,10 @@ void WINAPI ExAcquireFastMutexUnsafe( FAST_MUTEX *mutex ) DEFINE_FASTCALL1_WRAPPER(ExReleaseFastMutexUnsafe) void WINAPI ExReleaseFastMutexUnsafe( FAST_MUTEX *mutex ) { - LONG count; - TRACE("mutex %p.\n", mutex);
- count = InterlockedIncrement( &mutex->Count ); - if (count < 1) + mutex->Owner = NULL; + + if (InterlockedIncrement(&mutex->Count) < 1) KeSetEvent( &mutex->Event, IO_NO_INCREMENT, FALSE ); }