void spin_lock::lock() { // This function raises IRQL to DISPATCH_LEVEL KeAcquireInStackQueuedSpinLock(&m_Lock, &m_LockHandle); }
The m_LockHandle lock variable needed for KeAcquireInStackQueuedSpinLock must be on the stack. Each thread must have its own instance of the variable. It cannot be a member of a class, that doesn't work.