2

How can the IRQL Level of a piece of driver code be determined. PAGED_CODE() macro specifies that the piece of code can be run in an IRQL level less than DISPATCH_LEVEL.But haw can the exact IRQL Level be determined.

1 Answer 1

5

KeGetCurrentIrql function returns the current IRQL:

KIRQL KeGetCurrentIrql(void);

PAGED_CODE macro uses this function by the following way:

#define PAGED_CODE() \
    if (KeGetCurrentIrql() > APC_LEVEL) { \
        KdPrint(( "EX: Pageable code called at IRQL %d\n", KeGetCurrentIrql() )); \
        ASSERT(FALSE); \
    }

This macro should be placed to any pageable function, it crashes the driver in the case when the function is called at IRQL that doesn't allow paging.

4
  • Thanks for the answer. Is there any way to set the Irql Level for a function? Mar 11, 2015 at 8:58
  • IRQL is not a function attribute. Every function starts on the same IRQL as its caller. There are many ways to change current IRQL, like KeRaiseIrql and different synchronization functions.
    – Alex F
    Mar 11, 2015 at 9:09
  • Thanks Alex. Ive got the info I was looking for. Mar 11, 2015 at 9:11
  • Note, this macro is useful on checked builds only. On a release build it's a NOP Mar 13, 2015 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.