Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining IRQL level

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.

like image 532
Reena Cyril Avatar asked Feb 20 '26 02:02

Reena Cyril


1 Answers

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.

like image 64
Alex F Avatar answered Feb 21 '26 20:02

Alex F