annotations are used only by the static analyze
By Static Driver Verifier (SDV) and by VS Code Analysis (CA), yes.
I suppose that deep down I had to have known that. The annotation macros all expand to nothingness, so it would be unreasonable to think that they would modify the code to check things at runtime.
Can you think of no advantages to knowing if a pointer handed to you is nonpaged? What if you have a pointer and you want an mdl to describe it, but you don’t know if it is pageable? If it is nonpaged pool or locked, you can call MmBuildMdlForNonPagedPool(), if not you have to call MmProbeAndLockPages().
I don’t know what the code looks like, but “build mdl knowing it is non-paged” sounds more efficient than “probing and locking + adding a reference count that needs to be unlocked + building an mdl”. What would you do in this situation? Just call MmProbeAndLockPages() to be safe? Both functions are void, so it’s not like you can call MmBuildMdlForNonPagedPool() and check for an error code.
MmProbeAndLockPages() can be called at DISPATCH_LEVEL if the memory is nonpaged, else it has to be called at <= APC_LEVEL. Knowing if a pointer is pinned or not can therefore make the difference between having to pend until safe or not.
MmBuildMdlForNonPagedPool() only works for locked pages. The documentation doesn’t say what happens if you call it for a range that includes a non-pinned page, but I imagine it is a bugcheck. So knowing if the pointer includes paged memory can avoid a bugcheck.
If I’m way off base, just say so. I’ve got less than a year of kernel development under my belt, and most of what I know comes from you all, and the MS documentation that perpetually falls short. You are the definitive source for information, I’m just looking for something that feels satisfying.
_Ron