New Page 1
Never allocate a dispatcher object from
PagedPool. Which means, don't even think about doing a
KSPIN_LOCK SpinLock;
within your PAGED_CODE.
If a dispatcher object is allocated
from PagedPool, the driver might work peacefully, but occasionally the system
will bugcheck saying that it tried to access paged memory from higher IRQL.
So,
- Allocate them explicitly from
NonPagedPool .
PKSPIN_LOCK
pSpinLock = ExAllocatePool(NonPagedPool, sizeof(struct KSPIN_LOCK));
- Or declare them globally. (All
global variables in a kernel mode driver are allocated from NonPagedPool).
- You can place them in the device
extension of the driver created device object. The device extension is
always allocated from NonPaged memory.
- You can also place them in the
controller extension of the driver created controller object.