[NTOSKRNL:CC] Add Lock Guard for DPC Level SPinlock
This commit is contained in:
parent
2472e39635
commit
377ff4fb9b
@ -105,6 +105,31 @@ private:
|
||||
KIRQL m_OldIrql;
|
||||
};
|
||||
|
||||
class QueuedSpinlockAtDPC {
|
||||
public:
|
||||
// Constructor to acquire the lock
|
||||
explicit QueuedSpinlockAtDPC(KSPIN_LOCK_QUEUE_NUMBER lockNumber)
|
||||
: m_lockNumber(lockNumber) {
|
||||
// Acquire the lock at DPC level
|
||||
m_lockHandle = KeAcquireQueuedSpinLockAtDpcLevel(&KeGetCurrentPrcb()->LockQueue[m_lockNumber]);
|
||||
}
|
||||
|
||||
// Destructor to release the lock automatically
|
||||
~QueuedSpinlockAtDPC() {
|
||||
// Release the lock at DPC level
|
||||
KeReleaseQueuedSpinLockFromDpcLevel(&KeGetCurrentPrcb()->LockQueue[m_lockNumber], m_lockHandle);
|
||||
}
|
||||
|
||||
// Deleting copy and move constructors to prevent unintended copying
|
||||
QueuedSpinlockAtDPC(const QueuedSpinlockAtDPC&) = delete;
|
||||
QueuedSpinlockAtDPC& operator=(const QueuedSpinlockAtDPC&) = delete;
|
||||
|
||||
private:
|
||||
KSPIN_LOCK_QUEUE_NUMBER m_lockNumber; // Spinlock queue number
|
||||
KIRQL m_lockHandle; // Lock handle returned by KeAcquireQueuedSpinLockAtDpcLevel
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
class Array {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user