From da4291dfc535052a6d802ca6a374198104b1426c Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sun, 27 Jan 2019 20:45:32 -0600 Subject: [PATCH] ntoskrnl.exe: Implement KeAcquireSpinLockAtDpcLevel(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +- dlls/ntoskrnl.exe/sync.c | 10 ++++++++++ include/ddk/wdm.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index 47ce683a243..52ffc3de6b4 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -510,7 +510,7 @@ @ stub Ke386QueryIoAccessMap @ stdcall Ke386SetIoAccessMap(long ptr) @ stub KeAcquireInterruptSpinLock -@ stub KeAcquireSpinLockAtDpcLevel +@ stdcall KeAcquireSpinLockAtDpcLevel(ptr) @ stdcall -arch=arm,arm64,x86_64 KeAcquireSpinLockRaiseToDpc(ptr) @ stub KeAddSystemServiceTable @ stub KeAreApcsDisabled diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index b439695fd7b..31a3ad72095 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -395,6 +395,16 @@ static inline void small_pause(void) #endif } +/*********************************************************************** + * KeAcquireSpinLockAtDpcLevel (NTOSKRNL.EXE.@) + */ +void WINAPI KeAcquireSpinLockAtDpcLevel( KSPIN_LOCK *lock ) +{ + TRACE("lock %p.\n", lock); + while (!InterlockedCompareExchangePointer( (void **)lock, (void *)1, (void *)0 )) + small_pause(); +} + /*********************************************************************** * KeReleaseSpinLockFromDpcLevel (NTOSKRNL.EXE.@) */ diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index 25d7da8c5c9..ca2aa9da9d6 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1427,6 +1427,7 @@ void WINAPI KeAcquireSpinLock(KSPIN_LOCK*,KIRQL*); #define KeAcquireSpinLock( lock, irql ) *(irql) = KeAcquireSpinLockRaiseToDpc( lock ) KIRQL WINAPI KeAcquireSpinLockRaiseToDpc(KSPIN_LOCK*); #endif +void WINAPI KeAcquireSpinLockAtDpcLevel(KSPIN_LOCK*); BOOLEAN WINAPI KeCancelTimer(KTIMER*); void WINAPI KeClearEvent(PRKEVENT); NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);