Best Practices for Managing Thread Context and IRQL in KMDF Drivers


To avoid problems related to thread context and IRQL, adopt these practices:

  • Unless you are certain that a driver function is called in a particular thread context, never make any assumptions about the contents of the user-mode address space.

  • Know which driver functions can be called at IRQL>=DISPATCH_LEVEL and understand the restrictions that running at this level places on driver code.

  • Store any data that can be accessed at IRQL>=DISPATCH_LEVEL in nonpaged memory.

    Possible locations are the device object context area, a driver-allocated space in nonpaged pool memory, or the kernel-mode stack.

  • Use Driver Verifier, the PAGED_CODE and PAGED_CODE_LOCKED macros, SDV, PREfast for Drivers, and debugger extensions to help find IRQL-related bugs in drivers.

  • Test drivers on as many hardware configurations as possible, including multiprocessor systems.




Developing Drivers with the Microsoft Windows Driver Foundation
Developing Drivers with the Windows Driver Foundation (Pro Developer)
ISBN: 0735623740
EAN: 2147483647
Year: 2007
Pages: 224

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net